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

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

新聞中心

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

我們?cè)趺磳?xiě)一段代碼,能夠在程序內(nèi)存里面不停移動(dòng)?就是讓shellcode代碼能在內(nèi)存中不停的復(fù)制自己,并且一直執(zhí)行下去,也就是內(nèi)存蠕蟲(chóng)。我們要把shellcode代碼偏移出蠕蟲(chóng)長(zhǎng)度再?gòu)?fù)制到蠕蟲(chóng)后面的內(nèi)存中,然后執(zhí)行。

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

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

1. 寫(xiě)出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地址更換一下就行,還要在最后加一個(gè)ret,因?yàn)閳?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. 編寫(xiě)蠕蟲(chóng)代碼

 
 
 
 
  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長(zhǎng)度是20,假設(shè)數(shù)據(jù)的地址是s,我們把數(shù)據(jù)復(fù)制到地址為s+20處,原來(lái)的數(shù)據(jù)變?yōu)?×90,表示數(shù)據(jù)曾經(jīng)來(lái)過(guò)這里,insect段是用來(lái)復(fù)制數(shù)據(jù)用到,復(fù)制了20次,剛剛好把shellcode復(fù)制完。

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

inscet和ee段加起來(lái)是復(fù)制我們的shellcode到其他地方,然后去執(zhí)行shellcode,然后再?gòu)?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)試的時(shí)候找到shellcode位置,一步步調(diào)試能看見(jiàn)shellcode被復(fù)制,原來(lái)的轉(zhuǎn)成0×90,并且printf還被執(zhí)行

沒(méi)有復(fù)制前:

復(fù)制后:

4. 總結(jié)

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


文章名稱(chēng):如何編寫(xiě)一段內(nèi)存蠕蟲(chóng)?
瀏覽地址:http://www.5511xx.com/article/dphidej.html