---
# System prepended metadata

title: '[CH] LoTuX Vault'
tags: [Chinese, Reverse, Writeup]

---

> [name=Curious]

## 思路和解法
把 `chal` 放到 IDA 中看看

![](https://hackmd.io/_uploads/rJVW2E7j2.png)

可以發現 `chal` 會讀取 24 個數字，然後做一系列的檢查。所以我們可以用 angr 把 `call scanf` 的 instruction hook 掉，然後把原本 24 個數字寫成 24 個 symbolic variable，之後就做原本 angr 要做的事就可以解完這題了。

Solve Script : 
```python=
import angr
import claripy
import time

proj = angr.Project('./chal')

num_list = [claripy.BVS(f'num_list[{i}]', 32) for i in range(24)]

@proj.hook(0x4014b3, length=58)
def scanf_hook(state):
    for i in range(24):
        state.mem[state.regs.rbp - 0x70 + 4 * i].unsigned = num_list[i]

simgr = proj.factory.simgr()

print('====== START ======')
start_time = time.time()
simgr.explore(find=0x4011c9, avoid=0x401460)
print(f'> FINISH TIME : {int(time.time() - start_time)}s')

print('\n====== ANSWER ======')
found_state = simgr.found[0]
for i in range(24):
    print(found_state.solver.eval(num_list[i]))
```

{%hackmd M1bgOPoiQbmM0JRHWaYA1g %}
