Hello everyone! Recently I noticed that Windows lacks a http downloader for it's cmd. Here is a small download utitlity I made in FASM that parses the command line into two parts(URL, output). It also has some error catching capabilities. To make it native, just place it inside the system32 folder.
format PE console 4.0
include 'win32a.inc'
entry start
start:
invoke GetCommandLine
mov ebx, eax
mov edi, buff1
mov esi, ebx
xor ecx, ecx
next:
lodsb
cmp al, ' '
jz pf1
inc ecx
cmp ecx, 11
jae error1
jmp next
pf1:
inc esi
xor ecx, ecx
@@:
lodsb
cmp al, 20h
jz pf2
stosb
inc ecx
cmp ecx, 11d
jae error2
jmp @b
pf2:
mov edi, buff2
@@:
lodsb
cmp al, 0
jz pdone
stosb
jmp @b
pdone:
invoke URLDownloadToFileA, 0, buff1, buff2, 0, 0
exit:
invoke ExitProcess, NULL
error1:
invoke printf, emsg1
pop ecx
jmp exit
error2:
invoke printf, emsg2
pop ecx
jmp exit
;section '.data' data readable writeable
emsg1 db "ERROR: Invalid or no URL", 0
emsg2 db "ERROR: Invalid or no output file name", 0
buff1 db 300 dup (0)
buff2 db 50 dup (0)
section '.idata' import data readable writeable
library kernel32, "KERNEL32.DLL",\
urlmon, "URLMON.DLL",\
msvcrt, "MSVCRT.DLL"
include 'api\kernel32.inc'
import urlmon, URLDownloadToFileA, "URLDownloadToFileA"
import msvcrt, printf, "printf"