Shellcoding ... again.

From: deepcode . (pondermate_at_hotmail.com)
Date: 07/24/03

  • Next message: Patrick Strawderman: "RE: Shellcoding ... again."
    To: vuln-dev@securityfocus.com
    Date: Thu, 24 Jul 2003 12:57:27 -0300
    
    

    Here I am again with shellcoding questions ... bear with me, its hard to
    find info on this subject other than txts with 2 pages of assembly codes
    that constitutes a remote, http-trojan downloading, all portable, optimized
    shellcodes that I can't even begin to assimilate.

    I'm just trying a simple ExitProcess shellcode, hardcoded address.
    (By the way, this is on win32.)

    kernel32.dll

    imagebase= 0x77E80000
    ExitProcess RVA = 0x0000F32D

    Got these from DUMPPE, added them together to get 0x77E8F32D for ExitProcess
    address. Pretty
    sure thats the right way to get address.

    To test it out, I wrote a program that used inline assembly with that
    address.
    -----------------------------------------------------
    #include <windows.h>

    int main()
    {
    HINSTANCE h;

    h = LoadLibrary("kernel32.dll");

    __asm("
    xor %edi, %edi
    push %edi
    call 0x77E8F32D
    ");

    FreeLibrary(h);
    }
    ----------------------------------------------------

    The program runs fine. No errors, no problems at all, so i'm assuming it
    worked just fine.

    When disassembled in Gdb(win32 port), I followed from xor edi, edi with x/bx
    to get the
    opcodes

    0x31, 0xFF, 0x57 for the xor and push; which doesn't seem right.
    0xE8 for call, and and then 0xF9, 0xE0, 0xA8 and 0x77. I assume it loaded
    into memory
    at diferent addresses and got addresses changed, no biggy.

    I put the codes into a char array shellcode, and put my original address in
    after the 0xE8
    backwards (I think thats how to do it.) and it errors out.

    I've tried rearranging the address all possible combinations, so I don't
    think thats the
    problem.

    --------------------------------------------------------
    #include <windows.h>

    char shellcode[] =
    "\x31\xFF\x57\xE8" // opcodes gotten from gdb
    "\x2D\xF3\xE8\x77"; // address backwards.

    int main(void)
    {
         HINSTANCE h;

         h = LoadLibrary("kernel32.dll");

        ((void (*)(void)) &shellcode)();

        FreeLibrary(h);
    }
    -----------------------------------------------------

    I'm getting lost now ... this was so much easier on unix.

    if anyone would like to help me out, i'd appreciate it.

    deepcode

    _________________________________________________________________
    The new MSN 8: advanced junk mail protection and 2 months FREE*
    http://join.msn.com/?page=features/junkmail


  • Next message: Patrick Strawderman: "RE: Shellcoding ... again."

    Relevant Pages

    • Thanks much!
      ... everyone for helping out, I plan to do more on the subject .. ... \x31\xFF\x57 as xor edi, edi and push edi. ... The proper shellcode was ...
      (Vuln-Dev)
    • RE: Shellcoding ... again.
      ... I've been working on writing shellcode for win32 as well. ... I'm just trying a simple ExitProcess shellcode, ... xor %edi, %edi ...
      (Vuln-Dev)
    • Re: xor encoding / decoding of shellcode
      ... xor encoding / decoding of shellcode ... this is based off of x86 ideas, but asm is asm is asm, and everyone is ... then just make your decoder point past your decoder to the start of your ...
      (Vuln-Dev)
    • xor encoding / decoding of shellcode
      ... xor encoding / decoding of shellcode ... I have been working alot with asm lately on the ppc platform... ... encode / decode my shellcode. ...
      (Vuln-Dev)
    • Re: xor encoding / decoding of shellcode
      ... xor encoding / decoding of shellcode ... > to figure out how the stack needs to be layed out in order for me to xor ... > In essence I need to learn how to write a xor decoder does anyone have ...
      (Vuln-Dev)