diff --git a/ShellcodeObfuscator/Obfuscator.cpp b/ShellcodeObfuscator/Obfuscator.cpp index 28b51b0..063755e 100644 --- a/ShellcodeObfuscator/Obfuscator.cpp +++ b/ShellcodeObfuscator/Obfuscator.cpp @@ -148,6 +148,8 @@ bool obf_create_groups(pobfuscator_t obf, int32_t group_size) abs_addr->raw_data_size = 8; abs_addr->group = i; + cur_group->size_in_bytes += END_OF_GROUP_GAGT_SIZE; + pcode_link_t real_next = cur_group->end->next; cur_group->end->next = gadget; gadget->next = abs_addr; @@ -273,17 +275,6 @@ bool obf_resolve_abs_addresses(pobfuscator_t obf) return true; } -size_t obf_get_group_size(pobfuscator_t obf, int group_id) -{ - if (group_id < obf->groups.size()) - return obf->groups[group_id].size_in_bytes; -} - -void obf_copy_group_to_buffer(pobfuscator_t obf, void* buffer, int group_id) -{ - -} - bool obf_gen_all_labels(pobfuscator_t obf) { for (pcode_link_t t = obf->code_start->next; t; t = t->next) @@ -354,6 +345,16 @@ bool obf_gen_label(pobfuscator_t obf, pcode_link_t jmp, int32_t delta) return true; } +bool obf_allocate_group_buffers(pobfuscator_t obf, FnAllocateMem AllocMem) +{ + +} + +bool obf_copy_groups_into_buffers(pobfuscator_t obf, FnMemCopy MemCopy) +{ + +} + #include void obf_dbg_print_code(pobfuscator_t obf) @@ -362,8 +363,6 @@ void obf_dbg_print_code(pobfuscator_t obf) if (!StdHandle) return; - - for (pcode_link_t t = obf->code_start->next; t; t = t->next) { if (t->group % 2) diff --git a/ShellcodeObfuscator/Obfuscator.h b/ShellcodeObfuscator/Obfuscator.h index 93f67fc..78a6b5f 100644 --- a/ShellcodeObfuscator/Obfuscator.h +++ b/ShellcodeObfuscator/Obfuscator.h @@ -52,7 +52,9 @@ typedef struct _obfuscator_t xed_address_width_enum_t addr_width; }obfuscator_t, *pobfuscator_t; -typedef void* (*FnAllocateMem)(unsigned long size); +typedef void* (*FnAllocateMem)(uint32_t size); + +typedef void (*FnMemCopy)(void* dest, void* src, uint32_t size); //snickers void obf_one_time_please(); @@ -69,18 +71,17 @@ void obf_replace_rel_jmps(pobfuscator_t obf); //replaces address in the abs jmp stub with the right address of the given label. bool obf_resolve_abs_addresses(pobfuscator_t obf); -//return number of bytes needed to store given group -size_t obf_get_group_size(pobfuscator_t obf, int group_id); - -//copy group to whever u want it to go -void obf_copy_group_to_buffer(pobfuscator_t obf, void* buffer, int group_id); - //generate all the labels after loaded from buffa bool obf_gen_all_labels(pobfuscator_t obf); //walk backwards or forwards until placing label bool obf_gen_label(pobfuscator_t obf, pcode_link_t start, int32_t delta); +//allocate buffers for all groups +bool obf_allocate_group_buffers(pobfuscator_t obf, FnAllocateMem AllocMem); + +//copy all instructions from each group into allocated buffers +bool obf_copy_groups_into_buffers(pobfuscator_t obf, FnMemCopy MemCopy); void obf_dbg_print_code(pobfuscator_t obf);