WEEK1 ezasm 简单分析是一个xor 后的 sub
1 2 3 4 5 6 7 8 9 code = "nhuo[M`7mc7uhc$7midgbTf`7`$7%#ubf7 ci5Y" flag = "" for i in str (code): temp = ord (i) temp += 0xA temp ^= 0x1E flag += chr (temp) print (flag)
easy_re 打开是一个简单的高四位和第四位的转换
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 def swap_high_low_nibble (num ): high_nibble = (num >> 4 ) & 0x0F low_nibble = num & 0x0F swapped_num = (low_nibble << 4 ) | high_nibble return swapped_num input_list = [102 , 198 , 22 , 118 , 183 , 69 , 39 , 151 , 245 , 71 , 3 , 245 , 55 , 3 , 198 , 103 , 51 , 245 , 71 , 134 , 86 , 245 , 38 , 150 , 230 , 22 , 39 , 151 , 245 , 7 , 39 , 3 , 38 , 198 , 51 , 214 , 215 ] result_list = [swap_high_low_nibble(num) for num in input_list] print ("原始列表:" , input_list)print ("交换高4位和低4位后的列表:" , result_list)flag = "" for i in result_list: flag += chr (i) print (flag)
Seed 首先动态调试出来10个随机数【v5】的值:[0x26,0x45,0x49,0x8e,0x0b9,0x43,0x0cd,0x9b,0x0fa,0x0c]。
然后经过简单的xor得到flag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 lalal = [0x26 ,0x45 ,0x49 ,0x8e ,0x0b9 ,0x43 ,0x0cd ,0x9b ,0x0fa ,0x0c ] code = [64 , 41 , 40 , 233 , 194 , 4 , 164 , 237 , 159 , 83 , 95 , 117 , 60 , 209 , 205 , 43 , 168 , 196 , 137 , 105 , 21 , 33 , 22 , 239 , 215 , 39 , 146 , 223 , 202 , 83 , 95 , 42 , 60 , 209 , 206 , 3 , 163 , 239 , 165 , 120 , 22 , 26 , 45 , 225 , 196 ] flag = "" print (len (code))for i in range (45 ): temp = code[i] ^ lalal[i % 10 ] flag += chr (temp) print (flag)
easy_math 通过z3求解器解开后转成16进制再转车字符即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 from z3 import *l = [Int('l%d' % i) for i in range (6 )] solver = Solver() solver.add((593 *l[0 ] + 997 *l[1 ] + 811 *l[2 ] + 258 *l[3 ] + 829 *l[4 ] + 532 *l[5 ])== 0x5b8e0aef71d34ff43 ) solver.add((605 *l[0 ] + 686 *l[1 ] + 328 *l[2 ] + 602 *l[3 ] + 695 *l[4 ] + 576 *l[5 ])== 0x551a262360964ef7f ) solver.add((373 *l[0 ] + 512 *l[1 ] + 449 *l[2 ] + 756 *l[3 ] + 448 *l[4 ] + 580 *l[5 ])== 0x49d158a5657d6931c ) solver.add((560 *l[0 ] + 635 *l[1 ] + 422 *l[2 ] + 971 *l[3 ] + 855 *l[4 ] + 597 *l[5 ])== 0x625568d5abbabf4f3 ) solver.add((717 *l[0 ] + 507 *l[1 ] + 388 *l[2 ] + 925 *l[3 ] + 324 *l[4 ] + 524 *l[5 ])== 0x50ee0c025e70e3c23 ) solver.add((312 *l[0 ] + 368 *l[1 ] + 884 *l[2 ] + 518 *l[3 ] + 495 *l[4 ] + 414 *l[5 ])== 0x40e735f8aa2815f65 ) if solver.check() == sat: print ("结果:" , solver.model()) code = [0x66 , 0x6C ,0x61 ,0x67 ,0x7B ,0x4E ,0x30 ,0x5f ,0x4f ,0x6e ,0x65 ,0x5f ,0x6b ,0x6e ,0x30 ,0x77 , 0x73 ,0x5f ,0x6d ,0x40 ,0x74 ,0x68 ,0x5f ,0x42 ,0x33 ,0x74 ,0x74 ,0x65 ,0x72 ,0x5f ,0x54 ,0x68 ,0x40 ,0x6e ,0x5f ,0x6d ,0x65 ,0x21 ,0x21 ,0x21 ,0x21 ,0x7d ] flag = "" for i in code: flag += chr (i) print (flag)
ea_apk 这个题对我来说真的是坎坷。走了好多好多的弯路。。不过最后解出来的时候发现好简单…
这个题可不能用jadx,它编译出来有问题,要用gda
用dga打开后看到主函数是一个经过编码后对比。
看到加密过程是一个base58换表的操作。
这里看到表:
然后用工具就解开了
#flag{Jue_1_ju3_Y0ung_and_G0at_1s_go0d_for_yOuR_body}
WEEK2 pycode 1 2 3 4 5 6 7 for i in range (len (flag)): temp = chr (ord (flag[i]) ^ 8 ) value += temp for i in range (len (value)): temp = chr (ord (value[i]) + 3 ) output += temp
先是base64,然后倒叙,然后字符串替换。
==AeAF3M-tzO-giQ-AUQosDQ9tGK7MDPuhC47tDNB5Tb8Yn4sdW4
【这个题,好像有时候在线网站解出来就是有点问题】
exp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import base64key = '==AeAF3M-tzO-giQ-AUQosDQ9tGK7MDPuhC47tDNB5Tb8Yn4sdW4' flag = '' key = key.replace('-' , '+' ) key = key.replace('4' , 'c' ) key = key.replace('t' , '0' ) key = key[::-1 ] print (key)key = base64.b64decode(key.encode()).decode() print (key)for i in key: flag += chr ((ord (i) - 3 ) ^ 8 ) print (flag)
签到题? not gcc 我将文件名字改成了1.bc
clang 1.bc -o 1
得到了1
这个ELF文件。发现是数独
:
得到:
497513268 538426917 612987354 759164823 261839475 843275196 986351742 125748639 374692581
如果map[]里面是数据!=0时候,v2就需要==0。v2 就是输入的数据。
1 2 3 4 5 6 7 8 9 10 key = '497513268538426917612987354759164823261839475843275196986351742125748639374692581' num = '407003208500020900012980004709104800061000470003270006086300040020740630304002000' flag = '' for i in range (len (key)): if (key[i] == num[i]): flag += '0' else : flag += key[i] print (flag)
然后再md5
flag{afb5d3a138821e30d6e1e6ccce4e5554}
WEEK3 EaseRE
>python pyinstxtractor.py easyre.exe
uncompyle6 main.pyc
然后我们看懂它的代码:就是有一个key,然后将data中的数据和它xor后,满足条件后就将它base64解码后转成二进制来执行。
就可以去执行了。
然后我们就把它给弄出来:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import base64import marshalimport sympy as spencoded_data = b'#`VVVVVVVVVVVVVVVVVVVVVSVVVVFVVVV_YZVVVVMVU|VNFV@pU|V{xUMVYvVzBSMVDSVFRVMFDSV\\VQMV@\x7fVAxPMFU{V@BPp`]vU%B_MF]eVy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^ xor_key for byte in encoded_data]) decoded_data = base64.b64decode(xor_decoded_data) open ("new.pyc" ,"wb" ).write(decoded_data) exit()
因为这个代码是可以直接执行的,所以是new.pyc而不是new.py
补头然后再次反编译就可以了。。。
因为不会010,所以:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 hex_content = "550D0D0A000000000000000000000000" with open ('a.pyc' , 'wb' ) as file: file.write(bytes .fromhex(hex_content)) with open ('new.pyc' , 'rb' ) as source_file: with open ('a.pyc' , 'ab' ) as destination_file: destination_file.write(source_file.read()) print ("内容已写入a.pyc文件" )
uncompyle6 a.pyc
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 def rc4_encrypt (key, plaintext ): S = list (range (256 )) j = 0 for i in range (256 ): j = (j + S[i] + key[i % len (key)]) % 256 S[i], S[j] = S[j], S[i] else : i = j = 0 ciphertext = bytearray () for char in plaintext: i = (i + 1 ) % 256 j = (j + S[i]) % 256 S[i], S[j] = S[j], S[i] k = S[(S[i] + S[j]) % 256 ] ciphertext.append(char ^ k) else : return ciphertext key = b'example_key' check = b'\xd8\x94\x1e\xab\x9bft\xeb]@\x1b\xba\xe6\xe8\x133W\xdd\x0e\xe6\x924\xf1\x80mh\xeb=\x08a\x02\t.\xb5\x05B\xb0\xb0/D\x8cY' print ('Plz input your flag:' )flag = input ().encode('utf-8' ) encrypted = rc4_encrypt(key, flag) if encrypted == check: print ('yes' ) else : print ('no' )
ok 发现是rc4
解密就好了
ststst 这个是首先是一个SMC
进来首先是看到mprotect
看到地址是40696这个位置。我们动态调试运行这个函数后,找到这个地址的首地址。“u”后“c”后“p”
然后这个地址就被解密出来了,是一个tea加密
加密:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 __int64 __fastcall main (int a1, char **a2, char **a3) { int i; _QWORD input[6 ]; input[5 ] = __readfsqword(0x28 u); puts ("plz input u fl4g:" ); __isoc99_scanf("%32s" , input); sub_400763(); for ( i = 0 ; i <= 3 ; ++i ) sub_400696(&input[i], &dword_601080); if ( !memcmp (input, &dword_6010A0, 0x20 uLL) ) puts ("yeh~" ); else puts ("oh,no" ); return 0LL ; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 __int64 __fastcall sub_400696 (unsigned int *a1, _DWORD *k) { __int64 result; unsigned int v3; unsigned int v4; int v5; unsigned int i; v3 = *a1; v4 = a1[1 ]; v5 = 0 ; for ( i = 0 ; i <= 0x1F ; ++i ) { v5 -= 1640531527 ; v3 += (v4 + v5) ^ (16 * v4 + *k) ^ ((v4 >> 5 ) + k[1 ]); v4 += (v3 + v5) ^ (16 * v3 + k[2 ]) ^ ((v3 >> 5 ) + k[3 ]); } *a1 = v3; result = v4; a1[1 ] = v4; return result; }
解密:
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 #include <cstdio> #include <stdint.h> #include <stdlib.h> void decrypt (unsigned int * v, const unsigned int * k) { uint32_t v3 = v[0 ]; uint32_t v4 = v[1 ]; uint32_t v5 = ((-1640531527 ) * 32 ) & 0xFFFFFFFF ; for (int i = 0 ; i <= 31 ; ++i) { v4 -= (v3 + v5) ^ (16 * v3 + k[2 ]) ^ ((v3 >> 5 ) + k[3 ]); v3 -= (v4 + v5) ^ (16 * v4 + k[0 ]) ^ ((v4 >> 5 ) + k[1 ]); v5 += 1640531527 ; } v[0 ] = v3; v[1 ] = v4; } int main () { unsigned int v[8 ] = { 0x0DB8F2569 ,0x40CD83E3 ,0xA033E680 ,0xFFF7A644 , 0x690C3A17 ,0x0B621B866 ,0x34E7E2A7 ,0xAD10A692 }; unsigned int k[4 ] = { 0x01234567 , 0x89ABCDEF , 0xFEDCBA98 , 0x76543210 }; for (int i = 0 ; i < 8 ; i += 2 ) { decrypt(v + i, k); } for (int i = 0 ; i < 8 ; i++) { printf ("%xh\n" , v[i]); } unsigned char flag[32 ]; for (int i = 0 ; i < 8 ; i++) { for (int j = 0 ; j < 4 ; j++) { flag[i * 4 + j] = (v[i] >> (j * 8 )) & 0xFF ; } } printf ("flag[32] = {" ); for (int i = 0 ; i < 32 ; i++) { printf ("0x%02X" , flag[i]); if (i < 31 ) { printf (", " ); } } printf ("}\n" ); for (int i = 0 ; i < 32 ; i++) { printf ("%c" , flag[i]); } } #5 ef846656801c9b9714388d2ccd98cdd
得到:5ef846656801c9b9714388d2ccd98cdd