Hacker Reverse Engineering Protectpassword define legalpsw my good

  • Slides: 30
Download presentation
破解和混合编程实例 Hacker Reverse Engineering

破解和混合编程实例 Hacker Reverse Engineering

黑客反向 程热身 Protect_password #define legal_psw "my. good. password" int main() { char user_psw[666]; cout

黑客反向 程热身 Protect_password #define legal_psw "my. good. password" int main() { char user_psw[666]; cout << “crackme 00 hn enter password: “; cin >> user_psw; if (strcmp(legal_psw, user_psw)) cout<<“wrong passwordn”; // “标记"密码不匹配 2021/9/24 chenkm@ustc. edu. cn 3602824 05514

黑客反向 程�身 else cout<< “password oknhello , legal user|n “; //“标记”密码匹配 // "申斥"密码不匹配 return

黑客反向 程�身 else cout<< “password oknhello , legal user|n “; //“标记”密码匹配 // "申斥"密码不匹配 return 0; } 2021/9/24 chenkm@ustc. edu. cn 3602824 05515

自动过滤上述程序二进制内容结果 00007 d 11: 00007 d 1 f: 0000805 c: 0000806 a: 0000807 d:

自动过滤上述程序二进制内容结果 00007 d 11: 00007 d 1 f: 0000805 c: 0000806 a: 0000807 d: 0000808 f: 0000809 c: 000080 af: 000080 c 2: 000080 de: ………… 2021/9/24 LCMap. String. W kernel 32. dll crackme 00 h enter passwd: my. good. password wrong password ok hello, legal user!. ? Avios@@. ? Avistream@@ chenkm@ustc. edu. cn 3602824 05516

�果分析 2021/9/24 chenkm@ustc. edu. cn 3602824 05517

�果分析 2021/9/24 chenkm@ustc. edu. cn 3602824 05517

黑客反向 程热身 改写动机:隐藏密码字符串,增加一点分析难度。 int count = 0 // 从现在开始, 所有初始化变量都放置在. kpnc中. #pragma data_seg(“kpnc”) char

黑客反向 程热身 改写动机:隐藏密码字符串,增加一点分析难度。 int count = 0 // 从现在开始, 所有初始化变量都放置在. kpnc中. #pragma data_seg(“kpnc”) char passwd[]=PASSWORD; #pragma data_seg() // 现在所有初始变量又将放到默认段rdata中了. char buff[PASSWORD_SIZE]=“ “; 2021/9/24 chenkm@ustc. edu. cn 3602824 055113

黑客反向 程热身 改写后的源代码清单---list 1_p 9. cpp idag list 1_p 9. exe 目标代码中出现了如下段落: text rdata

黑客反向 程热身 改写后的源代码清单---list 1_p 9. cpp idag list 1_p 9. exe 目标代码中出现了如下段落: text rdata idata kpnc 只有在kpnc 段中才能看到密码字符串信息. "my. GOODpasswordn“ 2021/9/24 chenkm@ustc. edu. cn 3602824 055114

黑客反向 程---Ida ---list 1_7. exe 分析过程: . rdata: 00420000 00 00 24 79 F

黑客反向 程---Ida ---list 1_7. exe 分析过程: . rdata: 00420000 00 00 24 79 F 0 46 00 00 02 00 00 00. . $y餏. . �. . . rdata: 00420010 35 00 00 60 02 00 50 61 73 73 5. . . . `�. Pass rdata: 00420020 77 6 F 72 64 20 4 F 4 B 0 A 00 00 57 72 6 F 6 E word OK. . Wron rdata: 00420030 67 20 70 61 73 73 77 6 F 72 64 0 A 00 00 00 g password. . . rdata: 00420040 6 D 79 47 4 F 4 F 44 70 61 73 73 77 6 F 72 64 0 A 00 my. GOODpassword. rdata: 00420050 00 00 45 6 E 74 65 72 20 70 61 73 73 77 6 F. . Enter passwo rdata: 00420060 72 64 3 A 20 20 20 00 00 00 73 74 72 20 rd: . . . str rdata: 00420070 21 3 D 20 4 E 55 4 C 4 C 00 66 67 65 74 73 2 E 63 00 != NULL. fgets. c 2021/9/24 chenkm@ustc. edu. cn 3602824 055116

使用密码串进行比较的程序块. text: 0040104 D. text: 00401052 add esp, 0 Ch. text: 00401055 push offset

使用密码串进行比较的程序块. text: 0040104 D. text: 00401052 add esp, 0 Ch. text: 00401055 push offset s_Mygoodpasswor (00420040 h)"my. GOODpasswordn". text: 0040105 A lea ecx, [ebp+var_68]. text: 0040105 D push ecx. text: 0040105 E call strcmp. text: 0040105 E. text: 00401063 add esp, 8. text: 00401066 test eax, eax. text: 00401068 jz short loc_401079 2021/9/24 chenkm@ustc. edu. cn 3602824 055117

黑客反向 程---C规范的知识 ■ strcmp传递两个参数 : push offset s_Mygoodpasswor ;参考密码 lea ecx, [ebp+var_68]; 用户输入密码区 push

黑客反向 程---C规范的知识 ■ strcmp传递两个参数 : push offset s_Mygoodpasswor ;参考密码 lea ecx, [ebp+var_68]; 用户输入密码区 push ecx call strcmp ■ C 规范:从右到左的顺序将参数压入堆栈。 ■恢复的结果为: strcmp(var_68, "my. GOODpasswordn") 2021/9/24 chenkm@ustc. edu. cn 3602824 055118

黑客反向 程---分析修改的程序 text: 00401063. text: 00401066. text: 00401068. text: 0040106 A add esp, 8

黑客反向 程---分析修改的程序 text: 00401063. text: 00401066. text: 00401068. text: 0040106 A add esp, 8 test eax, eax jz short loc_401079 push offset_Wrong. Password ;"Wrong passwordn". text: 0040106 F call printf 检查函数返回值是否等于零,若为 0,表示密码正确, 进行相应提示;否则转错误处理程序。 修改: JNZ--》JZ, test eax, eax xor eax, eax等 JZ: 74 --》JNZ: 75 XOR: 31 2021/9/24 chenkm@ustc. edu. cn 3602824 055120

黑客反向 程��知� 反汇编器介绍 ■ IDA------常用功能介绍 ■ W 32 DASM ■ SR(Source) ■ Hex 2

黑客反向 程��知� 反汇编器介绍 ■ IDA------常用功能介绍 ■ W 32 DASM ■ SR(Source) ■ Hex 2 ASM chenkm@ustc. edu. cn 0551 -3602824 26

黑客反向 程��知� 十六进制编辑器: ■ Hiew---常用功能介绍 ■ Flex. Hex ■ Hedit ■ Win. Hex ■

黑客反向 程��知� 十六进制编辑器: ■ Hiew---常用功能介绍 ■ Flex. Hex ■ Hedit ■ Win. Hex ■ Editor chenkm@ustc. edu. cn 0551 -3602824 27