-
-
[原创]看雪CTF.TSRC 2018 团队赛 第六题 追凶者也 WP
-
发表于: 2018-12-19 15:01 1902
-
看雪CTF.TSRC 2018 团队赛 第六题 追凶者也 在TlsCallback的线程中hook了GetDlgItemTextA: int sub_401C10() { void *v0; // edx signed int j; // [esp+0h] [ebp-Ch] signed int i; // [esp+8h] [ebp-4h] sub_4018D0(0xCCCCCCCC, 0xCCCCCCCC, -858993460); lpAddress = v0; sub_4019B0(v0); for ( i = 0; i < 5; ++i ) byte_4147DC[i] = *((_BYTE *)lpAddress + i + 32); *(_DWORD *)&byte_414028[1] = (char *)hook_GetDlgItemTextA - (char *)((_BYTE *)lpAddress + 32) - 5; for ( j = 0; j < 5; ++j ) *((_BYTE *)lpAddress + j + 32) = byte_414028[j]; return sub_4019E0(lpAddress); } 然后在读取输入框的时候,在被hook的GetDlgItemTextA内部完成了check: bool __cdecl sub_401290(int a1, int a2) { byte_4147D0[0] = 4; byte_4147D0[1] = 1; byte_4147D0[2] = 3; byte_4147D0[3] = 7; byte_4147D0[4] = 2; byte_4147D0[5] = 5; byte_4147D0[6] = 8; byte_4147D0[7] = 6; byte_4147D0[8] = 0; return sub_4015B0(a1, a2); } bool __cdecl sub_4015B0(int a1, int a2) { int i; // [esp+0h] [ebp-Ch] int v4; // [esp+8h] [ebp-4h] v4 = 0xCCCCCCCC; if ( a2 % 2 ) return 0; for ( i = 0; i < a2; i += 2 ) { if ( *(_BYTE *)(i + a1) == 'w' ) v4 = 0; if ( *(_BYTE *)(i + a1) == 'd' ) v4 = 1; if ( *(_BYTE *)(i + a1) == 's' ) v4 = 2; if ( *(_BYTE *)(i + a1) == 'a' ) v4 = 3; if ( !sub_401380(v4, *(char *)(i + a1 + 1) - '0') ) return 0; } return byte_4147D0[0] == 1 && byte_4147D0[1] == 2 && byte_4147D0[2] == 3 && byte_4147D0[3] == 4 && byte_4147D0[4] == 5 && byte_4147D0[5] == 6 && byte_4147D0[6] == 7 && byte_4147D0[7] == 8 && !byte_4147D0[8]; } F5后的流程很清晰,初始化了一个3x3的二维图案,同过wsad上下左右的操作,使最后图案排列有序 3x3的小规模,写个递归程序解决就行了: #include <windows.h> #include <stdio.h> DWORD step(BYTE k[3][3],BYTE *q,DWORD n) { DWORD i,j; DWORD s; BYTE p[3][3]; memcpy(p,k,9); if (n > 10) { return -1; } if ((p[0][0] == 1) && (p[0][1] == 2) && (p[0][2] == 3) &&(p[1][0] == 4) && (p[1][1] == 5) && (p[1][2] == 6) &&(p[2][0] == 7) && (p[2][1] == 8) && (p[2][2] == 0)) { for (i=0;i<n*2;i++) { printf("%c",q[i]); } printf("\n"); return 2; } for (i=0;i<3;i++) { for (j=0;j<3;j++) { if (p[i][j] == 0) { if (i>0) //s { memcpy(p,k,9); q[2*n] = 's'; q[2*n+1] = p[i-1][j] + '0'; p[i][j] = p[i-1][j]; p[i-1][j] = 0; s = step(p,q,n+1); if (s == 1) { return 1; } } if (i<2) //w { memcpy(p,k,9); q[2*n] = 'w'; q[2*n+1] = p[i+1][j] + '0'; p[i][j] = p[i+1][j]; p[i+1][j] = 0; s = step(p,q,n+1); if (s == 1) { return 1; } } if (j<2) //a { memcpy(p,k,9); q[2*n] = 'a'; q[2*n+1] = p[i][j+1] + '0'; p[i][j] = p[i][j+1]; p[i][j+1] = 0; s = step(p,q,n+1); if (s == 1) { return 1; } } if (j>0) //d { memcpy(p,k,9); q[2*n] = 'd'; q[2*n+1] = p[i][j-1] + '0'; p[i][j] = p[i][j-1]; p[i][j-1] = 0; s = step(p,q,n+1); if (s == 1) { return 1; } } return 0; } } } return 0; } void test06() { BYTE d[3][3] = {{4,1,3},{7,2,5},{8,6,0}}; BYTE q[0x100]; DWORD n = 0; step(d,q,n); } 最后得到结果: d6d8s7s4a1w2a5w6
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)
赞赏
他的文章
看原图
赞赏
雪币:
留言: