LJP Reverse1 list Writeup

kazma 成大資安社 創辦人/社長

list

先來 main 逛逛吧~

main

看到題目給我們的提示:

“TODO: Xor node->value1 and node->value2”

所以這題的目標應該是找到 node 的 value1 和 value2 兩者 xor,應該就結束了。
我們可以看到 main call 了一個 function 叫 sub_1168+1,這通常應該是因為 IDA 解爛了,我們來重新定義一下他。

1168

先對 sub_1168 按 u 取消定義。

undefine

按完應該會長這樣,再來我們對 sub_1169 按 p 定義為函式。

1169

完成,那我們來看看 sub_1169 裡面在做些什麼,看一下反編譯。

1169c

首先我們看到他 malloc 了兩個空間,那就先來定義兩個 structs,分別是 0x18 和 0x10 的大小。

structs

再來稍微整理一下 sub_1169 的邏輯,變成下面這樣:

guess

有逆出邏輯基本上就簡單了,可以看到他把 array1 xor 0x5A 存到 value1,然後把 array2 xor 0xA5 存到 value2 裡,再根據題目的提示,我們把 value1 和 value2 xor,就可以拿到 flag 了,寫一個 exploit 來幫我們完成這些計算:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Given two arrays of hexadecimal values, we will perform the following operations:
# 1. XOR each value of array1 with 0x5A
# 2. XOR each value of array2 with 0xA5
# 3. XOR the results of the above two operations with each other

array1 = [0x16, 0x68, 0x13, 0x58, 0x7B, 0x4B, 0x43, 0x1B, 0x00, 0x4F, 0x68,
0x10, 0x11, 0x14, 0x39, 0x4C, 0x6B, 0x11, 0x04, 0x1A, 0x17, 0x6D,
0x6E, 0x47, 0x6D, 0x54, 0x1D, 0x16, 0x55, 0x1B, 0x05, 0x5E]

array2 = [0x0AF, 0x0DB, 0x0AD, 0x0E0, 0x0FF, 0x0D5, 0x0D0, 0x97, 0x8F,
0x0D4, 0x0FB, 0x9F, 0x0DF, 0x0D9, 0x0AA, 0x0D5, 0x0F8, 0x8F,
0x88, 0x95, 0x84, 0x0F9, 0x0E7, 0x88, 0x0AB, 0x99, 0x0D1, 0x82,
0x0CC, 0x0D4, 0x0CB, 0x0DC]

# XOR with 0x5A and 0xA5 respectively
array1_xor_5A = [value ^ 0x5A for value in array1]
array2_xor_A5 = [value ^ 0xA5 for value in array2]

# Element-wise XOR between the two new arrays
final_xor = [a ^ b for a, b in zip(array1_xor_5A, array2_xor_A5)]

# Convert the final XOR results to ASCII characters
final_ascii_string = ''.join(chr(value) for value in final_xor)
print(final_ascii_string)

最後執行可以得到:FLAG{...}

  • Title: LJP Reverse1 list Writeup
  • Author: kazma
  • Created at : 2023-12-09 00:37:00
  • Updated at : 2023-12-10 14:22:11
  • Link: https://kazma.tw/2023/12/09/LJP-Reverse1-list-Writeup/
  • License: This work is licensed under CC BY-NC-SA 4.0.
 Comments
On this page
LJP Reverse1 list Writeup