-
-
Save akkartik/3e6669576f4a23b2b33e43fabc423829 to your computer and use it in GitHub Desktop.
attempt to read argc
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
; attempt to read argc | |
; | |
; Build and run on 32-bit Linux: | |
; $ nasm -f elf x.s | |
; $ gcc -Wall -s -nostdlib x.o -o x | |
; $ ./x; echo $? | |
; 77 # expected: 1 | |
; $ ./x abc; echo $? | |
; 73 # expected: 2 | |
; $ ./x abc def; echo $? | |
; 69 # expected: 3 | |
; | |
; The return values change from binary to binary (ASLR). But the difference is | |
; always the total size of argv (in bytes, including nulls) | |
BITS 32 | |
GLOBAL _start | |
SECTION .text | |
_start: | |
mov ebx, [esp+4] | |
mov eax, 1 | |
int 0x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment