Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion donut.c
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,9 @@ static int validate_format(opt_arg *arg, void *args) {
} else
if(!strcasecmp("hex", str)) {
arg->u32 = DONUT_FORMAT_HEX;
} else
if(!strcasecmp("uuid", str)) {
arg->u32 = DONUT_FORMAT_UUID;
}
}
// validate
Expand All @@ -2097,6 +2100,7 @@ static int validate_format(opt_arg *arg, void *args) {
case DONUT_FORMAT_POWERSHELL:
case DONUT_FORMAT_CSHARP:
case DONUT_FORMAT_HEX:
case DONUT_FORMAT_UUID:
break;
default: {
printf("WARNING: Invalid format specified: %"PRId32" -- setting to binary.\n", arg->u32);
Expand Down Expand Up @@ -2150,7 +2154,7 @@ static void usage (void) {
printf(" -PIC/SHELLCODE OPTIONS-\n\n");
printf(" -a,--arch: <arch>,--cpu: <arch> Target architecture : 1=x86, 2=amd64, 3=x86+amd64(default).\n");
printf(" -o,--output: <path> Output file to save loader. Default is \"loader.bin\"\n");
printf(" -f,--format: <format> Output format. 1=Binary (default), 2=Base64, 3=C, 4=Ruby, 5=Python, 6=Powershell, 7=C#, 8=Hex\n");
printf(" -f,--format: <format> Output format. 1=Binary (default), 2=Base64, 3=C, 4=Ruby, 5=Python, 6=Powershell, 7=C#, 8=Hex, 9=UUID\n");
printf(" -y,--fork: <offset> Create a new thread for the loader and continue execution at <offset> relative to the host process's executable.\n");
printf(" -x,--exit: <action> Exit behaviour. 1=Exit thread (default), 2=Exit process, 3=Do not exit or cleanup and block indefinitely\n\n");

Expand Down
24 changes: 13 additions & 11 deletions format.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,25 +243,27 @@ int hex_template(void * pic, uint32_t pic_len, FILE* fd){
return DONUT_ERROR_OK;
}

static int uuid_null[16] = { 0 };

int uuid_template(void * pic, uint32_t pic_len, FILE* fd){
uint32_t rem;
uint32_t j;
uint32_t base;
uint8_t *p = (uint8_t*)pic;
uint32_t len = pic_len;
uint32_t chunks = (len + 15) / 16;
uint8_t last_chunk[16];

//Ensure there are enough bytes
rem = len % 16;
if(rem != 0){
pic = realloc(pic, len+rem);
memcpy(p + len, uuid_null, rem);
len+=rem;
}

for(j=0; j < len/16; j++){
for(j=0; j < chunks; j++){
base = j*16;

// last chunk have less than 16bytes
if (base+16 >= pic_len) {
rem = len % 16;
memcpy(last_chunk, p+base, rem);
memset(last_chunk+rem, 0xcc, 16-rem);
p = last_chunk;
base = 0;
}

fprintf(fd, "%02x%02x%02x%02x-", p[base+3], p[base+2], p[base+1], p[base]);
fprintf(fd, "%02x%02x-", p[base+5], p[base+4]);
fprintf(fd, "%02x%02x-", p[base+7], p[base+6]);
Expand Down