攻防世界 逆向高手进阶区

新手练习区完结,高手进阶区有些也做过了。如果在这里找不到笔记,请到小凉的CSDN博客去找,如果没有那就真没有了。

1. secret-string-400

下载下来是个.gz文件,拖进kali解压,发现又是一个压缩文件,继续解压。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
                    
┌──(v5le0n9㉿kali)-[~/Desktop]
└─$ gzip -d secret.gz

┌──(v5le0n9㉿kali)-[~/Desktop]
└─$ file secret
secret: POSIX tar archive

┌──(v5le0n9㉿kali)-[~/Desktop]
└─$ tar -xvf secret
./._Task.html
Task.html
./._Machine.js
Machine.js

解压出来一个html文件和一个js文件。打开html文件输入字符串试试,啥都没有。要我们输入一个无效字符串才可以得到flag。

打开js分析check()函数。

loadcode()用来加载aardio代码,或一个aardio代码文件,并创建一个函数对象。函数原型:

1
函数对象,错误信息 = loadcode(codeString | filepath)

参数可以是包含aardio代码的字符串值,也可以是aardio代码文件的路径。路径可以用斜杠作为首字符表示应用程序根目录。该函数并不立即执行代码,而是返回一个函数对象。如果加载代码失败,则返回的函数对象为null值,并在第二个返回值中返回错误信息。

所以那些数字其实是aardio代码。先去到run函数看看。

救…js我实在不会啊!看了牛牛们的wp,通过修改js文件将命令参数打印在Console中。在run函数中加入代码:

1
console.log('new Opcode' + command.args)

运行一下,在Console中就可以看到被解析出来的代码了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var f=window.machine.registers[1].userinput//
var i = f.length//
var nonce = 'groke';//
var j = 0;//
var out = [];//
var eq = true;//
while(j < i){//
out.push(f.charCodeAt(j) ^ nonce.charCodeAt(j%5))//
j++;//
}//
var ex = [1, 30, 14, 12, 69, 14, 1, 85, 75, 50, 40, 37, 48, 24, 10, 56, 55, 46, 56, 60];//
if (ex.length == out.length) {//
j = 0;//
while(j < ex.length){//
if(ex[j] != out[j])//
eq = false;//
j += 1;//
}//
if(eq){//
alert('YOU WIN!');//
}else{
alert('NOPE!');
}
}else{alert('NOPE!');}//

这些代码我就看懂了。输入的长度与ex长度要相等,经过异或算法最终要与ex中的元素相等。马上编写逆向脚本:

1
2
3
4
5
6
7
8
9
ex =  [1, 30, 14, 12, 69, 14, 1, 85, 75, 50, 40, 37, 48, 24, 10, 56, 55, 46, 56, 60]
nonce = list('groke')
flag = ""
for i in range(len(ex)):
flag += chr(ex[i] ^ ord(nonce[i%5]))
print(flag)
'''
flag is: WOW_so_EASY
'''
1
WOW_so_EASY

原来这就是Web逆向嘛,呜呜呜呜js硬伤啊

2. Newbie_calculations

运行一下,发现输入不了任何东西。载入OD,发现每隔一段时间暂停一下它会停在不同的地址,说明这个程序一直在运行,而不是等待我们输入。

载入IDA查看伪代码,发现它在不停地调用这几个函数。

一个个进去看,反编译乱死了…

知道每个函数的作用后,抄一遍代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
def mul_401100(a,b):
return a*b
def sub_401220(a,b):
return a-b
def add_401000(a,b):
return a+b
flag=[1 for i in range(32)]
v121 = 0
print("Your flag is:")
v3 = mul_401100(flag[0], 0x3B9ACA00)
v4 = sub_401220(v3, 0x3B9AC9CE)
flag[0]=mul_401100(v4, 2)
v5 = add_401000(flag[1], 0x4C4B40)
v6 = sub_401220(v5, 0x65B9AA)
v7 = add_401000(v6, 1666666)
v8 = add_401000(v7, 45)
v9 = mul_401100(v8, 2)
flag[1]=add_401000(v9, 5)
v10 = mul_401100(flag[2], 0x3B9ACA00)
v11 = sub_401220(v10, 999999950)
v12 = mul_401100(v11, 2)
flag[2]=add_401000(v12, 2)
v13 = add_401000(flag[3], 55)
v14 = sub_401220(v13, 3)
v15 = add_401000(v14, 4)
flag[3]=sub_401220(v15, 1)
v16 = mul_401100(flag[4], 100000000)
v17 = sub_401220(v16, 99999950)
v18 = mul_401100(v17, 2)
flag[4]=add_401000(v18, 2)
v19 = sub_401220(flag[5], 1)
v20 = mul_401100(v19, 1000000000)
v21 = add_401000(v20, 55)
flag[5]=sub_401220(v21, 3)
v22 = mul_401100(flag[6], 1000000)
v23 = sub_401220(v22, 999975)
flag[6]=mul_401100(v23, 4)
v24 = add_401000(flag[7], 55)
v25 = sub_401220(v24, 33)
v26 = add_401000(v25, 44)
flag[7]=sub_401220(v26, 11)
v27 = mul_401100(flag[8], 10)
v28 = sub_401220(v27, 5)
v29 = mul_401100(v28, 8)
flag[8]=add_401000(v29, 9)
v30 = add_401000(flag[9], 0)
v31 = sub_401220(v30, 0)
v32 = add_401000(v31, 11)
v33 = sub_401220(v32, 11)
flag[9]=add_401000(v33, 53)
v34 = add_401000(flag[10], 49)
v35 = sub_401220(v34, 2)
v36 = add_401000(v35, 4)
flag[10]=sub_401220(v36, 2)
v37 = mul_401100(flag[11], 1000000)
v38 = sub_401220(v37, 999999)
v39 = mul_401100(v38, 4)
flag[11]=add_401000(v39, 50)
v40 = add_401000(flag[12], 1)
v41 = add_401000(v40, 1)
v42 = add_401000(v41, 1)
v43 = add_401000(v42, 1)
v44 = add_401000(v43, 1)
v45 = add_401000(v44, 1)
v46 = add_401000(v45, 10)
flag[12]=add_401000(v46, 32)
v47 = mul_401100(flag[13], 10)
v48 = sub_401220(v47, 5)
v49 = mul_401100(v48, 8)
v50 = add_401000(v49, 9)
flag[13]=add_401000(v50, 48)
v51 = sub_401220(flag[14], 1)
v52 = mul_401100(v51, -294967296)
v53 = add_401000(v52, 55)
flag[14]=sub_401220(v53, 3)
v54 = add_401000(flag[15], 1)
v55 = add_401000(v54, 2)
v56 = add_401000(v55, 3)
v57 = add_401000(v56, 4)
v58 = add_401000(v57, 5)
v59 = add_401000(v58, 6)
v60 = add_401000(v59, 7)
flag[15]=add_401000(v60, 20)
v61 = mul_401100(flag[16], 10)
v62 = sub_401220(v61, 5)
v63 = mul_401100(v62, 8)
v64 = add_401000(v63, 9)
flag[16]=add_401000(v64, 48)
v65 = add_401000(flag[17], 7)
v66 = add_401000(v65, 6)
v67 = add_401000(v66, 5)
v68 = add_401000(v67, 4)
v69 = add_401000(v68, 3)
v70 = add_401000(v69, 2)
v71 = add_401000(v70, 1)
flag[17]=add_401000(v71, 20)
v72 = add_401000(flag[18], 7)
v73 = add_401000(v72, 2)
v74 = add_401000(v73, 4)
v75 = add_401000(v74, 3)
v76 = add_401000(v75, 6)
v77 = add_401000(v76, 5)
v78 = add_401000(v77, 1)
flag[18]=add_401000(v78, 20)
v79 = mul_401100(flag[19], 1000000)
v80 = sub_401220(v79, 999999)
v81 = mul_401100(v80, 4)
v82 = add_401000(v81, 50)
flag[19]=sub_401220(v82, 1)
v83 = sub_401220(flag[20], 1)
v84 = mul_401100(v83, -294967296)
v85 = add_401000(v84, 49)
flag[20]=sub_401220(v85, 1)
v86 = sub_401220(flag[21], 1)
v87 = mul_401100(v86, 1000000000)
v88 = add_401000(v87, 54)
v89 = sub_401220(v88, 1)
v90 = add_401000(v89, 1000000000)
flag[21]=sub_401220(v90, 1000000000)
v91 = add_401000(flag[22], 49)
v92 = sub_401220(v91, 1)
v93 = add_401000(v92, 2)
flag[22]=sub_401220(v93, 1)
v94 = mul_401100(flag[23], 10)
v95 = sub_401220(v94, 5)
v96 = mul_401100(v95, 8)
v97 = add_401000(v96, 9)
flag[23]=add_401000(v97, 48)
v98 = add_401000(flag[24], 1)
v99 = add_401000(v98, 3)
v100 = add_401000(v99, 3)
v101 = add_401000(v100, 3)
v102 = add_401000(v101, 6)
v103 = add_401000(v102, 6)
v104 = add_401000(v103, 6)
flag[24]=add_401000(v104, 20)
v105 = add_401000(flag[25], 55)
v106 = sub_401220(v105, 33)
v107 = add_401000(v106, 44)
v108 = sub_401220(v107, 11)
flag[25]=add_401000(v108, 42)
flag[26]=add_401000(flag[26], flag[25])
flag[27]=add_401000(flag[27], flag[12])
v109 = flag[27]
v110 = sub_401220(flag[28], 1)
v111 = add_401000(v110, v109)
flag[28]=sub_401220(v111, 1)
v112 = flag[23]
v113 = sub_401220(flag[29], 1)
v114 = mul_401100(v113, 1000000)
flag[29]=add_401000(v114, v112)
v115 = flag[27]
v116 = add_401000(flag[30], 1)
flag[30]=mul_401100(v116, v115)
flag[31]=add_401000(flag[31], flag[30])
print("CTF{"+''.join(map(chr,flag))+"}")
'''
Your flag is:
CTF{daf8f4d816261a41a115052a1bc21ade}
'''

3. easyre-153

查壳,UPX壳,拖进Ubuntu输入脱壳命令直接脱掉。

https://blog.csdn.net/xiao__1bai/article/details/120360202