#include #include int main(void) { unsigned char jigsaw[42] = { 0x00, 0x00, 0x74, 0x6f, 0x73, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x6e, 0xff, 0x74, 0x6e, 0x32, 0x00, 0x00, 0x69, 0x00, 0x6f, 0x00, 0x00, 0x32, 0x00, 0x77, 0x00, 0x73, 0x00, 0x00, 0x65, 0x73, 0x00, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x77, 0x65, 0xfe, 0x00, 0x69 }; int positions[42] = { 17, 3, 8, 22, 30, 19, 32, 33, 37, 13, 14, 0, 2, 28, 38, 15, 7, 12, 5, 36, 41, 25, 40, 9, 20, 11, 16, 29, 23, 24, 6, 31, 18, 10, 39, 27, 21, 34, 4, 1, 35, 26 }; unsigned char shellcode[42] = { 0x00 }; int position; // Reconstruct the payload for (int idx = 0; idx < sizeof(positions) / sizeof(positions[0]); idx++) { position = positions[idx]; shellcode[position] = jigsaw[idx]; } int idx = 0; while ( idx < sizeof(shellcode)) { if (idx == (sizeof(shellcode) - 1) ) { printf("0x%02x ", (unsigned char)shellcode[idx]); } else { printf("0x%02x, ", (unsigned char)shellcode[idx]); } idx++; } }