forked from 0xHossam/Killer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reverse-shellcode.cpp
45 lines (39 loc) · 2.81 KB
/
reverse-shellcode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
// Function to reverse a shellcode array in 0x format
void reverseShellcode(unsigned char *shellcode, int size) {
int i;
unsigned char temp;
for (i = 0; i < size/2; i++) {
temp = shellcode[size-i-1];
shellcode[size-i-1] = shellcode[i];
shellcode[i] = temp;
}
if (size % 2 != 0) {
shellcode[size/2] = shellcode[size/2];
}
}
int main() {
// Example shellcode array in 0x format
unsigned char shellcode[] = {0xb4, 0x27, 0xb4, 0x97, 0xb1, 0xa5, 0xf3, 0x45, 0x68, 0x30, 0x3, 0x10, 0x74, 0x3c, 0x2, 0x0, 0x21, 0x7a, 0x4b, 0x8a, 0x12, 0x7b, 0xc5, 0x1a, 0xf, 0x7f, 0xf8, 0x13, 0x55, 0x7b, 0xce, 0x3a, 0x10, 0xa, 0xca, 0x47, 0x3c, 0x18, 0x5e, 0xc0, 0x78, 0x30, 0x15, 0x46, 0xfa, 0x6, 0x79, 0xaf, 0x9b, 0x4f, 0x20, 0x31, 0x31, 0x69, 0x48, 0x71, 0x83, 0x88, 0x38, 0x2d, 0x51, 0x90, 0x95, 0xdf, 0x28, 0x19, 0x26, 0x7b, 0xc5, 0x1a, 0x4f, 0xbc, 0x31, 0x7d, 0x5, 0x32, 0x95, 0xe3, 0xb0, 0xca, 0x41, 0x35, 0x6c, 0x18, 0xd4, 0xb7, 0x46, 0x1d, 0x10, 0x76, 0xe3, 0x1e, 0xc3, 0x27, 0x2f, 0x37, 0xca, 0xd, 0x13, 0xc, 0x69, 0xe0, 0xa1, 0x17, 0x7d, 0x93, 0x99, 0x10, 0xfc, 0x6, 0xf2, 0x10, 0x76, 0xe5, 0x3, 0x79, 0xa6, 0x7f, 0x42, 0x81, 0xe1, 0x72, 0x84, 0xa1, 0x3d, 0x3, 0x40, 0xf4, 0x54, 0xb0, 0x24, 0x86, 0x7e, 0x79, 0x14, 0x53, 0x3b, 0xb, 0x71, 0xbe, 0x42, 0xab, 0x19, 0x9, 0xb8, 0x5, 0x4c, 0x79, 0x43, 0x91, 0x53, 0x2d, 0xdb, 0x5d, 0x3f, 0x76, 0xf1, 0x18, 0x6b, 0x7a, 0x4f, 0x98, 0x2e, 0xbc, 0x77, 0xc9, 0x5, 0x32, 0x95, 0x29, 0x68, 0x3, 0x19, 0x6b, 0x35, 0xa, 0x10, 0x2f, 0x73, 0x23, 0x19, 0x2d, 0x7b, 0xcd, 0xa4, 0x4f, 0x76, 0x21, 0xbe, 0xad, 0x6b, 0x4, 0x31, 0x6a, 0xa, 0xca, 0x27, 0x85, 0x7, 0xae, 0x88, 0xcd, 0x27, 0x10, 0xcd, 0x32, 0x4e, 0x48, 0x6f, 0x37, 0x73, 0x41, 0x4d, 0x7b, 0xc8, 0xe5, 0x31, 0x43, 0x41, 0x35, 0x2d, 0xea, 0x60, 0xfc, 0x5d, 0xfd, 0xa7, 0xa2, 0x88, 0xbe, 0xfd, 0xcd, 0x61, 0x32, 0xfb, 0xeb, 0xa6, 0xf8, 0xf5, 0xcf, 0x97, 0x9, 0xb6, 0xa8, 0x78, 0x6d, 0x71, 0x4e, 0x70, 0xd8, 0x8c, 0xd3, 0x3b, 0x4d, 0xd4, 0x70, 0x60, 0x33, 0x22, 0x59, 0x45, 0x31, 0x71, 0xcb, 0x9b, 0xca, 0xb9, 0x33, 0x30, 0x1b, 0x51, 0x54, 0x3d, 0xf, 0x56, 0x4e};
int size = sizeof(shellcode)/sizeof(shellcode[0]);
printf("Original shellcode in hex format:\n");
for (int i = 0; i < size; i++) {
//printf("\\x%02x", (unsigned char)shellcode[i]);
printf("0x%02x", (unsigned char)shellcode[i]);
// puting the comma after the byte then when go to last byte delete the comma
if (i != size-1) {
printf(", ");
}
}
printf("\n");
// Reverse the shellcode
reverseShellcode(shellcode, size);
printf("\nReversed shellcode:\n");
for (int i = 0; i < size; i++) {
printf("0x%02x", shellcode[i]);
if (i != size-1) {
printf(", ");
}
}
return 0;
}