我試圖通過改變它的EIP來破解另一個程序。有兩個程序正在運行,一個是目標,它告訴「核心函數」函數(例如接收密碼字符串作爲參數並返回true或false)的函數在內存中。 然後現在我知道核心函數在哪裏,我想用其他程序修改EIP,以便目標程序可以調用我的函數,並簡單地從它中獲得一個真實值,並打印出一個美麗的「訪問許可」。如何在不同的流程中更改EIP?
我的代碼是現在這個樣子:
目標計劃:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int checkPwd(char *pwd)
{
printf("\nstill in the function\n");
if(strcmp(pwd, "patrick") == 0) return true;
else return false;
}
int main()
{
char pwd[16];
printf("%d", checkPwd);
scanf("%s", &pwd);
system("pause");
if(checkPwd(pwd)) printf("Granted!\n");
else printf("Not granted\n");
system("pause");
}
攻擊計劃:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
int returnTrue()
{
return true;
}
int main()
{
int hex;
scanf("%d", &hex);
memcpy((void*)hex, (void*)returnTrue, sizeof(char)*8);
system("pause");
}
我想補充一點,我想直接把十六進制代碼(不scanf部分)在攻擊者程序中,並沒有工作,它墜毀。
所以我想我在這裏錯過了理論的一部分。我很高興知道它是什麼。
在此先感謝。
對於這樣的事情,你應該包含目標程序的程序集轉儲。 – Mysticial 2012-07-13 03:06:55
通過與堆棧上的返回地址混合來覆蓋EIP。 – user7116 2012-07-13 03:21:03
@sixlettervariables你是什麼意思? – 2012-07-13 03:25:48