Author Topic: opCodePrint  (Read 2536 times)

0 Members and 1 Guest are viewing this topic.

Offline ca0s

  • VIP
  • Sir
  • *
  • Posts: 432
  • Cookies: 53
    • View Profile
    • ka0labs #
opCodePrint
« on: May 21, 2011, 12:21:29 pm »
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.

Code: [Select]
// 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;
}

Z3R0

  • Guest
Re: opCodePrint
« Reply #1 on: May 22, 2011, 06:32:05 pm »
saved my life dude! thank you! you are a fricken awesome coder I swear to God, high quality shit

Offline Tsar

  • Peasant
  • *
  • Posts: 126
  • Cookies: 10
  • turing-recognizable
    • View Profile
Re: opCodePrint
« Reply #2 on: May 22, 2011, 07:38:02 pm »
So basically this converts a given ASM instruction (or multiple) into what it would be in hexidecimal (if it were to be compiled or whatever)?

Offline ca0s

  • VIP
  • Sir
  • *
  • Posts: 432
  • Cookies: 53
    • View Profile
    • ka0labs #
Re: opCodePrint
« Reply #3 on: May 22, 2011, 10:11:30 pm »
So basically this converts a given ASM instruction (or multiple) into what it would be in hexidecimal (if it were to be compiled or whatever)?
Yes, that's it. You give ASM code, it gives you its hexa assembled code.

Offline Tsar

  • Peasant
  • *
  • Posts: 126
  • Cookies: 10
  • turing-recognizable
    • View Profile
Re: opCodePrint
« Reply #4 on: May 22, 2011, 10:29:43 pm »
Yes, that's it. You give ASM code, it gives you its hexa assembled code.

Nice, very cool, this should probably go on "Code Library" though.