Crack 小实验
工具
Dev C++(书上使用的VS)IDA_Pro_v7.0OllydbgLordPE010 editor
使用IDA打开文件
找到程序分支点空格跳转到汇编界面得到VA:0x40156d
使用OD打开文件
Ctrl+G跳转到IDA得到的VA加断点,运行,此时输入任意密码,回车后程序在此中断。我们只要把je改成jne就能实现输入错误密码返回正确结果。
使用LordPE打开文件
OD修改只是修改了内存中的值利用公式计算:文件偏移地址 = 虚拟内存地址(VA) - 装载基址 - 节偏移= 0x0040156D - 0x00400000 - (0x1000 - 0x400)= 0x96D
使用十六进制编辑器修改文件
010Editor打开文件Ctrl + G 跳转到0x96D修改740e为750e保存运行输入正确密码显示密码错误,错误密码会返回正确的提示
实验 2.2.2 突破密码验证程序
知识点
缓冲区溢出C语言strcpy函数:https://www.runoob.com/cprogramming/c-function-strcpy.html
实验环境与工具
Win10 64bitDev-C++IDA-ProOD
实验记录
代码:
1 #include <stdio.h>
2 #include <
string.h>
3
4 #define PASSWORD "1234567"
5
6 int verify_password(
char *
password)
7 {
8 int authenticated;
9 char buffer[
8];
10 authenticated=
strcmp(password,PASSWORD);
11 strcpy(buffer,password);
12 return authenticated;
13 }
14
15 int main()
16 {
17 int valid_flag =
0;
18 char password[
1024];
19 while(
1)
20 {
21 printf(
"Please input password: ");
22 scanf(
"%s", password);
23 valid_flag =
verify_password(password);
24 if(valid_flag)
25 {
26 printf(
"incorrect password!\n\n");
27 }
28 else
29 {
30 printf(
"Congratulation! You have passed the verification!\n");
31 break;
32 }
33 }
34 return 0;
35 }
实验步骤
运行测试:静态反汇编:
strcpy后一句地址为0x401532动态调试
输入"qqqqqq",authenticated的值为1输入"qqqqqqqq"尝试使用字符串末尾的'\0'把authenticated的低字节覆盖从而变成0成功绕过了验证
实验 2.3.2 更改返回地址
实验工具
010 EditorDev C++IDA-ProOD
实验知识点
缓冲区溢出覆盖栈内函数的返回地址
实验源码
1 #include <stdio.h>
2 #define PASSWORD "1234567"
3 int verify_password(
char *
password)
4 {
5 int authenticated;
6 char buffer[
8];
7 authenticated =
strcmp(password,PASSWORD);
8 strcpy(buffer,password);
9 return authenticated;
10 }
11
12 main()
13 {
14 int valid_flag=
0;
15 char password[
1024];
16 FILE *
fp;
17 if(!(fp=fopen(
"password.txt",
"rw+")))
18 {
19 exit(
0);
20 }
21 fscanf(fp,
"%s",password);
22 valid_flag =
verify_password(password);
23 if(valid_flag)
24 {
25 printf(
"incorrect password!\n");
26 }
27 else
28 {
29 printf(
"Congratulation!You Have passed the verification!\n");
30 }
31 fclose(fp);
32 }
实验步骤
运行测试静态反编译,strcpy下一句为0x40152e,密码正确的分支是0x4015ca动态调试
当前栈帧的EBP是0x61fa78查看栈的内容尝试直接修改返回地址,成功跳转到正确密码的分支使用二进制编辑器构造payload运行,虽然会闪退,但是通过捕捉,可以发现确实跳转到了正确的分支
实验 2.4 代码植入
实验工具
Windows XP SP3Visual C++ 6.0DependsOD
源码
1 #include <stdio.h>
2 #include <
string.h>
3 #include <windows.h>
4 #define PASSWORD "1234567"
5 int verify_password(
char *
password)
6 {
7 int authenticated;
8 char buffer[
44];
9 authenticated =
strcmp(password,PASSWORD);
10 strcpy(buffer,password);
11 return authenticated;
12 }
13
14 main()
15 {
16 int valid_flag=
0;
17 char password[
1024];
18 FILE *
fp;
19 LoadLibrary(
"user32.dll");
20 if(!(fp=fopen(
"password.txt",
"rw+")))
21 {
22 exit(
0);
23 }
24 fscanf(fp,
"%s",password);
25 valid_flag =
verify_password(password);
26 if(valid_flag)
27 {
28 printf(
"incorrect password!\n");
29 }
30 else
31 {
32 printf(
"Congratulation!You Have passed the verification!\n");
33 }
34 fclose(fp);
35 }
实验步骤
编译程序并且拖入Depends,发现并没有user32.dll从编辑器里面打开dll文件,发现也可以看到库的基地址,user32.dll的库基地址为0x77D10000,MessageBoxA的偏移地址为0x407EA,地址为0x77D5 07EA先用123422343234423452346234来找到栈中buffer的位置,buffer的起始地址是0x12FAF0构造password.txt代码植入成功运行测试
遇到的问题
Depends的结果与实验指导上的不一样,没有显示出user32.dll的库基地址
从编辑器打开user32.dll:
转载于:https://www.cnblogs.com/tiumo/p/11280543.html
相关资源:0daydown资源列表大全(附0daydown解压密码).rar