#include <stdio.h> #include <windows.h> #define PASSWORD "1234567" int verify_password(char *password) { int authenticated; char buffer[8]; authenticated = strcmp(password,PASSWORD); strcpy(buffer,password); //溢出就在这里 return authenticated; } void main() { int valid_flag =0; char password[1024]; FILE *fp; if (!(fp=fopen("password.txt","rw+"))) { exit(0); } fscanf(fp,"%s",password); valid_flag = verify_password(password); if (valid_flag !=0) { printf("incorrect password! "); } else { printf("Congratulation! You have passed the verification! "); } fclose(fp); getchar(); }
利用XDbg 当密码验证函数返回 此时的堆栈时
71717171 为qqqq 即PassWord.txt中的内容 现在只需要构建数据 将0029FA8C 出的地址淹没成我们需要跳转的地址即可
查看0029FA8C 所包含的地址 0040158A 可以得知这是调用完密码验证函数后 main函数下一步要执行的 将此处替换为验证成功即可
用16进制编辑器