Last active
April 27, 2024 21:54
-
-
Save michaelnewton/e17e58919a2fa7b375c4197e1d5d8d80 to your computer and use it in GitHub Desktop.
Passing parameters to execve call in assembly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;Simple assembly execve call to execute /bin/ls -la | |
global _start | |
section .text | |
_start: | |
xor eax, eax ;create null eax register | |
push eax ;push null eax register to the stack | |
push 0x736c2f2f ;push command to the stack | |
push 0x6e69622f ;"/bin//ls" | |
mov ebx, esp ;move pointer to command into ebx | |
push eax ;push null eax register to the stack | |
push 0x61616c2d ;push argument to the stack "-laa" | |
mov esi, esp ;move stack pointer to esi | |
push eax ;push null eax register to the stack | |
push esi ;push address of the argument to the stack | |
push ebx ;push address of the command to the stack | |
mov ecx, esp ;move pointer to start of the command to ecx | |
mov al, 11 ;define execve | |
int 0x80 ;execute command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, great example, one of the few I've found working, but the parameter seems to be limited to just 4 bytes of the push instruction. How can the number of parameters or the length of a single parameter be increased?
For example "ls -la /usr" or "ls /home/myuser"!
Thank you for your answer.