Results 1 to 4 of 4

Thread: converting asm(hex) into a char array '\xXX'

  1. #1

    converting asm(hex) into a char array '\xXX'

    Hey,

    I am writing some shellcode to exploit a service running on my machine. My goal is to spawn a shell, with system privlieges, and start a telnet service via commandline.

    I have the C++/ASM code to acomplish this, my question is how to take the pertianit ASM code and convert it into a char array in C++.

    IE:
    0e 05 0a ff....blah blah blah

    into:
    Code:
    char payload[] = "\x0e\x05\x0a\xff";
    My ASM code comes from MSVC++'s debugger...

    Thanks for any input

  2. #2
    Just Another Geek
    Join Date
    Jul 2002
    Location
    Rotterdam, Netherlands
    Posts
    3,401
    You are writing shellcode and you don't know how to convert a bunch of bytes to a char array?

    How come you know how to write something as complex as shellcode but have no idea how to do this?

    Oh oh.
    Oliver's Law:
    Experience is something you don't get until just after you need it.

  3. #3
    hey,

    sorry for my unclear question. I know how to convert hex bytes into a char array, i was just wanting to hear other peoples ideas

    Code:
    char *hexArray = new char[32768];
    char *outputArray = new char[3*strlen(hexArray)];
    memset(&hexArray,'\x00',strlen(hexArray));
    long int iPos = 0;
    
    for(int i = 0; i < strlen(hexArray);i++)
    {
           outputArray[iPos] =  '\\';
           iPos++;
           outputArray[iPos] =  'x';
           iPos++;
           outputArray[iPos] =  hexArray[i]l
           iPos++;
    }
    
    delete []hexArray;
    delete []outputArray;

  4. #4
    Junior Member
    Join Date
    Apr 2003
    Posts
    1
    come cool shell coding tute,
    it converts decimal to asm to hex so um i think gdb can convert back, if i find out a shell code ot do it ill post it for u,
    right now i just reading have **** to do but ill work on a asm to hex and asm to decimal convertor maybe even a hex to dic :P
    cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •