日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
如何編寫一段內(nèi)存蠕蟲?

我們怎么寫一段代碼,能夠在程序內(nèi)存里面不停移動?就是讓shellcode代碼能在內(nèi)存中不停的復(fù)制自己,并且一直執(zhí)行下去,也就是內(nèi)存蠕蟲。我們要把shellcode代碼偏移出蠕蟲長度再復(fù)制到蠕蟲后面的內(nèi)存中,然后執(zhí)行。

創(chuàng)新互聯(lián)是網(wǎng)站建設(shè)技術(shù)企業(yè),為成都企業(yè)提供專業(yè)的成都網(wǎng)站設(shè)計、成都做網(wǎng)站,網(wǎng)站設(shè)計,網(wǎng)站制作,網(wǎng)站改版等技術(shù)服務(wù)。擁有10余年豐富建站經(jīng)驗和眾多成功案例,為您定制適合企業(yè)的網(wǎng)站。10余年品質(zhì),值得信賴!

我們在實現(xiàn)過程中同時把前面同長度代碼變成\x90,那個就是蟲子走過的路,最終吃掉所有的內(nèi)存。實現(xiàn)這個我們要知道shellcode長度,并且計算好shellcode每次移動的位置是多少。我們的shllcode以調(diào)用printf函數(shù)為例。

1. 寫出printf程序

 
 
 
 
  1. #include "stdio.h" 
  2. int main() 
  3.     printf("begin\n"); 
  4.     char *str="a=%d\n"; 
  5.      
  6.     __asm{ 
  7.         mov eax,5 
  8.         push eax 
  9.         push str 
  10.         mov eax,0x00401070   
  11.         call eax 
  12.         add esp,8 
  13.         ret 
  14.     } 
  15.         return 0; 

0×00401070 是我機(jī)子上printf的地址,將自己機(jī)子上的printf地址更換一下就行,還要在最后加一個ret,因為執(zhí)行完shellcode還要回到復(fù)制shellcode的代碼執(zhí)行。

上面匯編轉(zhuǎn)成shellcode形式,shellcode為:

 
 
 
 
  1. char shellcode[]="\xB8\x05\x00\x00\x00\x50\xFF\x75\xFC\xB8\x70\x10\x40\x00\xFF\xD0\x83\x**\x08\xc3"; 

2. 編寫蠕蟲代碼

 
 
 
 
  1. insect:mov bl,byte ptr ds:[eax+edx] 
  2.        mov byte ptr ds:[eax+edx+20],bl 
  3.        mov byte ptr ds:[eax+edx],0x90 
  4.        inc edx 
  5.        cmp edx,20 
  6.        je ee 
  7.        jmp insect 
  8.         
  9. ee:     add eax,20 
  10.         push eax 
  11.         call eax 
  12.         pop eax 
  13.         xor edx,edx 
  14.         jmp insect 

shellcode長度是20,假設(shè)數(shù)據(jù)的地址是s,我們把數(shù)據(jù)復(fù)制到地址為s+20處,原來的數(shù)據(jù)變?yōu)?×90,表示數(shù)據(jù)曾經(jīng)來過這里,insect段是用來復(fù)制數(shù)據(jù)用到,復(fù)制了20次,剛剛好把shellcode復(fù)制完。

因為shellcode相當(dāng)于向下移動20位,所以我們要把eax加上20,還要把edx恢復(fù)成0,方便下次接著復(fù)制,然后去執(zhí)行我們的shellcode,接著跳轉(zhuǎn)到insect段繼續(xù)執(zhí)行,這是ee段干的事。

inscet和ee段加起來是復(fù)制我們的shellcode到其他地方,然后去執(zhí)行shellcode,然后再復(fù)制,循環(huán)下去。

3. 最終程序

 
 
 
 
  1. #include "stdio.h" 
  2.  
  3. char shellcode[]="\xB8\x05\x00\x00\x00\x50\xFF\x75\xFC\xB8\x70\x10\x40\x00\xFF\xD0\x83\x**\x08\xc3"; 
  4. int main() 
  5.     printf("begin\n"); 
  6.     char *str="a=%d\n"; 
  7.      
  8.      
  9.     __asm{ 
  10.          
  11.         lea eax,shellcode 
  12.         push eax 
  13.         call eax 
  14.         pop eax 
  15.         xor edx,edx 
  16.              
  17. insect:mov bl,byte ptr ds:[eax+edx] 
  18.        mov byte ptr ds:[eax+edx+20],bl 
  19.        mov byte ptr ds:[eax+edx],0x90 
  20.        inc edx 
  21.        cmp edx,20 
  22.        je ee 
  23.        jmp insect 
  24.         
  25. ee:     add eax,20 
  26.         push eax 
  27.         call eax 
  28.         pop eax 
  29.         xor edx,edx 
  30.         jmp insect 
  31.  
  32.  
  33.          
  34.     } 
  35.      
  36.      
  37.     return 0; 

調(diào)試的時候找到shellcode位置,一步步調(diào)試能看見shellcode被復(fù)制,原來的轉(zhuǎn)成0×90,并且printf還被執(zhí)行

沒有復(fù)制前:

復(fù)制后:

4. 總結(jié)

我們要先計算出shellcode的長度,計算好shellcode每次移動的位置是多少,然后寫出復(fù)制程序,并且還要有調(diào)轉(zhuǎn)到復(fù)制后的shellcode首地址程序,執(zhí)行復(fù)制后的shellcode,接著在復(fù)制再執(zhí)行,循環(huán)下去,當(dāng)然在一段內(nèi)存里循環(huán)執(zhí)行也可以,只要找到位置,跳轉(zhuǎn)過去就行


分享文章:如何編寫一段內(nèi)存蠕蟲?
文章鏈接:http://m.5511xx.com/article/dphidej.html