无壳, 拖进IDA
, F5
查看伪代码,
主函数里面主要就func()
函数, 跟到func()
里
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
| int func() { int result; int v1[4]; unsigned __int8 v2; unsigned __int8 v3; unsigned __int8 v4; unsigned __int8 v5; unsigned __int8 v6; int v7; int v8; int v9; int v10; unsigned __int8 v11; char v12[29];
strcpy(v12, "Qsw3sj_lz4_Ujw@l"); printf("Please input:"); scanf("%s", &v2); result = v2; if ( v2 == 'A' ) { result = v3; if ( v3 == 'C' ) { result = v4; if ( v4 == 'T' ) { result = v5; if ( v5 == 'F' ) { result = v6; if ( v6 == '{' ) { result = v11; if ( v11 == '}' ) { v1[0] = v7; v1[1] = v8; v1[2] = v9; v1[3] = v10; *(_DWORD *)&v12[17] = 0; while ( *(int *)&v12[17] <= 15 ) { if ( *((char *)v1 + *(_DWORD *)&v12[17]) > 64 && *((char *)v1 + *(_DWORD *)&v12[17]) <= 90 ) *((_BYTE *)v1 + *(_DWORD *)&v12[17]) = (*((char *)v1 + *(_DWORD *)&v12[17]) - 51) % 26 + 65; if ( *((char *)v1 + *(_DWORD *)&v12[17]) > 96 && *((char *)v1 + *(_DWORD *)&v12[17]) <= 122 ) *((_BYTE *)v1 + *(_DWORD *)&v12[17]) = (*((char *)v1 + *(_DWORD *)&v12[17]) - 79) % 26 + 97; ++*(_DWORD *)&v12[17]; } *(_DWORD *)&v12[17] = 0; while ( *(int *)&v12[17] <= 15 ) { result = (unsigned __int8)v12[*(_DWORD *)&v12[17]]; if ( *((_BYTE *)v1 + *(_DWORD *)&v12[17]) != (_BYTE)result ) return result; ++*(_DWORD *)&v12[17]; } result = printf("You are correct!"); } } } } } } 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
| #include <cstdio>
using namespace std;
int main() {
char ciphertext[32] = "Qsw3sj_lz4_Ujw@l"; char plaintext[32] = { 0 }; for (int i = 0; i < 16; i++) { for (char c = 32; c < 127; c++) { char temp = c; if (c > 64 && c <= 90) temp = (c - 51) % 26 + 65; else if (c > 96 && c <= 122) temp = (c - 79) % 26 + 97; if (temp == ciphertext[i]) plaintext[i] = c; } } printf("ACTF{%s}", plaintext); }
|