mirror of
https://github.com/dobin/ShellcodeObfuscationLab
synced 2026-06-08 13:53:31 +00:00
data: add random_shellcode source files too
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int main(void) {
|
||||
|
||||
|
||||
char reversed_hex_string[] = "0x0,23x0,0x0,23x0,0x0,f6x0,0x0,77x0,0x0,a7x0,0x0,37x0,0x0,e6x0,0x0,96x0,0x0,56x0,0x0,f6x0,0x0,77x0,0x0,a7x0,0x0,37x0,0x0,e6x0,0x0,96x0,0x0,56x0,0x0,47x0,0x0,37x0,0x0,56x0,0x0,47x0,efx0,ffx0";
|
||||
unsigned int shellcode_len = 42;
|
||||
|
||||
|
||||
// reverse the string
|
||||
char* hex_string = _strrev(reversed_hex_string);
|
||||
printf("Reversed hex string: %s\n", hex_string);
|
||||
|
||||
// declare a new shellcode byte array
|
||||
char shellcode[sizeof(reversed_hex_string)] = { 0 };
|
||||
|
||||
// define an index to keep track of where we're at
|
||||
int idx = 0;
|
||||
int count = 0;
|
||||
const int MAX_TOKENS = sizeof(reversed_hex_string);
|
||||
char* next_token = NULL;
|
||||
char* token = strtok_s(hex_string, ",", &next_token);
|
||||
while (token != NULL && count < MAX_TOKENS) {
|
||||
shellcode[count++] = strtol(token, NULL, 16);
|
||||
token = strtok_s(NULL, ",", &next_token);
|
||||
}
|
||||
|
||||
idx = 0;
|
||||
while ( idx < shellcode_len)
|
||||
{
|
||||
if (idx == (shellcode_len - 1) )
|
||||
{
|
||||
printf("0x%02x ", (unsigned char)shellcode[idx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("0x%02x, ", (unsigned char)shellcode[idx]);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user