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
| // search js
__int64 __fastcall w2c_check(unsigned int flag_arr, unsigned int key_arr, unsigned int enc_arr)
{
......
if ( ++wasm_rt_call_stack_depth > 0x1F4u )
wasm_rt_trap(7LL);
w2c___stack_pointer -= 112; // new vm stack frame
check_sp = w2c___stack_pointer;
i32_store(&w2c_memory, (unsigned int)w2c___stack_pointer + 104LL, flag_arr);// push parameters to stack
i32_store(&w2c_memory, check_sp + 100LL, key_arr);
i32_store(&w2c_memory, check_sp + 96LL, enc_arr);
v14 = i64_load(&w2c_memory, 1032LL); // xref to find memory initialization
i64_store(&w2c_memory, check_sp + 88, v14); // 8-byte table
v5 = i64_load(&w2c_memory, 1024LL);
i64_store(&w2c_memory, check_sp + 80, v5); // another 8-byte table
v55 = i32_load(&w2c_memory, check_sp + 104LL);
v54 = w2c_strlen(v55);
i32_store(&w2c_memory, check_sp + 76LL, v54); // length of flag_arr
v53 = i32_load(&w2c_memory, check_sp + 100LL);
v52 = w2c_strlen(v53);
i32_store(&w2c_memory, check_sp + 72LL, v52); // length of key_arr
v51 = i32_load(&w2c_memory, check_sp + 96LL);
v50 = w2c_strlen(v51);
i32_store(&w2c_memory, check_sp + 68LL, v50); // length of enc_arr
if ( (int)i32_load(&w2c_memory, check_sp + 72LL) >= 8// len(key) >= 8
&& (v49 = 4 * i32_load(&w2c_memory, check_sp + 76LL), v49 > (int)(i32_load(&w2c_memory, check_sp + 68LL) - 32))// len(enc) - 32 < 4 * len(flag) <= len(enc)
&& (v48 = 4 * i32_load(&w2c_memory, check_sp + 76LL), v48 <= (int)i32_load(&w2c_memory, check_sp + 68LL)) )
{
v47 = (i32_load(&w2c_memory, check_sp + 76LL) + 15) & 0xFFFFFFF0;// mapping the elements of each group to the largest element of that group
i32_store(&w2c_memory, check_sp + 64LL, v47);
v46 = i32_load(&w2c_memory, check_sp + 64LL);// padding length
v45 = w2c_dlmalloc(v46); // malloc
i32_store(&w2c_memory, check_sp + 60LL, v45);
v44 = i32_load(&w2c_memory, check_sp + 60LL);
v43 = i32_load(&w2c_memory, check_sp + 64LL);
w2c_memset(v44, 0LL, v43); // memset(ptr, 0, padlen)
v42 = i32_load(&w2c_memory, check_sp + 60LL);
v41 = i32_load(&w2c_memory, check_sp + 104LL);
v6 = i32_load(&w2c_memory, check_sp + 76LL);
w2c___memcpy(v42, v41, v6);
i32_store(&w2c_memory, check_sp + 28LL, 0LL);// var i = 0
while ( (int)i32_load(&w2c_memory, check_sp + 28LL) < 8 )
{
v40 = i32_load(&w2c_memory, check_sp + 100LL);
v39 = v40 + i32_load(&w2c_memory, check_sp + 28LL);// &key_arr[i]
v38 = i32_load8_u(&w2c_memory, v39);
v37 = check_sp + 32 + i32_load(&w2c_memory, check_sp + 28LL);// new_space
i32_store8(&w2c_memory, v37, v38);
v7 = i32_load(&w2c_memory, check_sp + 28LL) + 1;
i32_store(&w2c_memory, check_sp + 28LL, v7);// i += 1
}
i32_store(&w2c_memory, check_sp + 24LL, 0LL);// isok = 0
i32_store(&w2c_memory, check_sp + 20LL, 0LL);// var i = 0
while ( 1 )
{
v36 = i32_load(&w2c_memory, check_sp + 20LL);
if ( v36 >= (int)i32_load(&w2c_memory, check_sp + 76LL) )// i < len(flag_arr)
break;
i32_store(&w2c_memory, check_sp + 16LL, 0LL);// var j = 0
while ( (int)i32_load(&w2c_memory, check_sp + 16LL) < 8 )
{
v35 = i32_load(&w2c_memory, check_sp + 60LL);
v34 = i32_load(&w2c_memory, check_sp + 20LL);
v33 = v35 + v34 + i32_load(&w2c_memory, check_sp + 16LL);// pad_flag + i + j
v32 = i32_load8_u(&w2c_memory, v33);
v31 = check_sp + 32 + i32_load(&w2c_memory, check_sp + 16LL) + 8;// new_space + 8 + j
i32_store8(&w2c_memory, v31, v32);
v8 = i32_load(&w2c_memory, check_sp + 16LL) + 1;// j += 1
i32_store(&w2c_memory, check_sp + 16LL, v8);
}
i32_store(&w2c_memory, check_sp + 12LL, 0LL);
while ( (int)i32_load(&w2c_memory, check_sp + 12LL) < 42 )// 42 rounds encryption
{
w2c_qua_rou(check_sp + 32, 12LL, 8LL, 4LL, 0LL);
w2c_qua_rou(check_sp + 32, 13LL, 9LL, 5LL, 1LL);
w2c_qua_rou(check_sp + 32, 14LL, 10LL, 6LL, 2LL);
w2c_qua_rou(check_sp + 32, 15LL, 11LL, 7LL, 3LL);
w2c_qua_rou(check_sp + 32, 15LL, 10LL, 5LL, 0LL);
w2c_qua_rou(check_sp + 32, 12LL, 11LL, 6LL, 1LL);
w2c_qua_rou(check_sp + 32, 13LL, 8LL, 7LL, 2LL);
w2c_qua_rou(check_sp + 32, 14LL, 9LL, 4LL, 3LL);
v9 = i32_load(&w2c_memory, check_sp + 12LL) + 1;
i32_store(&w2c_memory, check_sp + 12LL, v9);
}
i32_store(&w2c_memory, check_sp + 8LL, 0LL);
while ( (int)i32_load(&w2c_memory, check_sp + 8LL) < 16 )// verify hex
{
v30 = i32_load(&w2c_memory, check_sp + 96LL);
v29 = 4 * i32_load(&w2c_memory, check_sp + 20LL);
v28 = v30 + v29 + 2 * i32_load(&w2c_memory, check_sp + 8LL);
v27 = i32_load8_u(&w2c_memory, v28); // enc[4 * i + 2 * j]
v26 = check_sp + 32 + i32_load(&w2c_memory, check_sp + 8LL);
v13 = (unsigned __int8)i32_load8_u(&w2c_memory, v26);// new_space[j]
v25 = i32_load8_u(&w2c_memory, check_sp + 80 + v13 / 16);// table[new_space[j] / 16]
v24 = i32_load(&w2c_memory, check_sp + 24LL) | (v27 != v25);
i32_store(&w2c_memory, check_sp + 24LL, v24);
v23 = i32_load(&w2c_memory, check_sp + 96LL);
v22 = 4 * i32_load(&w2c_memory, check_sp + 20LL);
v21 = v22 + 2 * i32_load(&w2c_memory, check_sp + 8LL);
v20 = i32_load8_u(&w2c_memory, (unsigned int)(v23 + v21 + 1));// enc[4 * i + 2 * j + 1]
v19 = check_sp + 32 + i32_load(&w2c_memory, check_sp + 8LL);
v4 = (unsigned __int8)i32_load8_u(&w2c_memory, v19) % 16;
v18 = i32_load8_u(&w2c_memory, check_sp + 80 + v4);// table[new_space[j] % 16]
v17 = i32_load(&w2c_memory, check_sp + 24LL) | (v20 != v18);
i32_store(&w2c_memory, check_sp + 24LL, v17);
v10 = i32_load(&w2c_memory, check_sp + 8LL) + 1;
i32_store(&w2c_memory, check_sp + 8LL, v10);
}
v11 = i32_load(&w2c_memory, check_sp + 20LL) + 8;// i += 8
i32_store(&w2c_memory, check_sp + 20LL, v11);
}
v16 = i32_load(&w2c_memory, check_sp + 60LL);
w2c_dlfree(v16);
v12 = i32_load(&w2c_memory, check_sp + 24LL);
i32_store(&w2c_memory, check_sp + 108LL, v12);
}
else // -1
{
i32_store(&w2c_memory, check_sp + 108LL, 0xFFFFFFFFLL);
}
v15 = i32_load(&w2c_memory, check_sp + 108LL);
w2c___stack_pointer = check_sp + 112; // pop stack frame
--wasm_rt_call_stack_depth;
return v15;
}
|