mirror of
https://github.com/dobin/ShellcodeObfuscationLab
synced 2026-06-08 13:53:31 +00:00
refactor: fix directory case...
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
{{ANTI_EMULATION}}
|
||||
|
||||
{{SHELLCODE}}
|
||||
|
||||
char shellcode[PAYLOAD_SIZE] = { 0x00 };
|
||||
int twoArrIdx = 0;
|
||||
int idx = 0;
|
||||
|
||||
while (idx < PAYLOAD_SIZE)
|
||||
{
|
||||
// read from the even array
|
||||
shellcode[idx] = evens[twoArrIdx];
|
||||
|
||||
// odds will be one byte less than evens if PAYLOAD_SIZE is odd
|
||||
if ( twoArrIdx == (int)sizeof(odds) )
|
||||
{
|
||||
// do nothing, otherwise we'll read past the end of our array
|
||||
}
|
||||
else
|
||||
{
|
||||
// read from odd array
|
||||
shellcode[idx+1] = odds[twoArrIdx];
|
||||
|
||||
// increment twoArrIdx to move to the next position in the evens and odds arrays
|
||||
twoArrIdx++;
|
||||
}
|
||||
|
||||
// we've just added two bytes, so we need to shift two positions instead of one
|
||||
idx = idx + 2;
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
while ( idx < PAYLOAD_SIZE)
|
||||
{
|
||||
if (idx == (PAYLOAD_SIZE - 1))
|
||||
{
|
||||
printf("0x%02x ", (unsigned char)shellcode[idx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("0x%02x, ", (unsigned char)shellcode[idx]);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import sys
|
||||
|
||||
|
||||
def get_raw_sc(input_file):
|
||||
input_file = input_file
|
||||
file_shellcode = b''
|
||||
try:
|
||||
with open(input_file, 'rb') as shellcode_file:
|
||||
file_shellcode = shellcode_file.read()
|
||||
return(file_shellcode)
|
||||
except FileNotFoundError:
|
||||
sys.exit("Supplied input file not found!")
|
||||
|
||||
|
||||
def split_list(input_list):
|
||||
even_list = []
|
||||
odd_list = []
|
||||
|
||||
idx = 0
|
||||
for val in input_list:
|
||||
if (idx % 2) == 0:
|
||||
even_list.append(val)
|
||||
else:
|
||||
odd_list.append(val)
|
||||
idx = idx + 1
|
||||
|
||||
return even_list, odd_list
|
||||
|
||||
|
||||
def twoarray(input_file):
|
||||
shellcode = get_raw_sc(input_file)
|
||||
shellcode = list(shellcode)
|
||||
|
||||
evenArray = []
|
||||
oddArray = []
|
||||
evenArray,oddArray = split_list(shellcode)
|
||||
|
||||
ret = ""
|
||||
ret += '#define PAYLOAD_SIZE {0}\n'.format(str(len(shellcode)))
|
||||
ret += 'char evens[{0}] = {{{1}}};\n'.format(str(len(evenArray)),', '.join(hex(x) for x in evenArray))
|
||||
ret += 'char odds[{0}] = {{{1}}};\n'.format(str(len(oddArray)),', '.join(hex(x) for x in oddArray))
|
||||
return ret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user