I try to write a file uploader but I have troubles with HttpSendRequest
format PE GUI 4.0
entry start
include 'win32a.inc'
section '.data' data readable writeable
hInternet dd ?
hConnect dd ?
hRequest dd ?
INTERNET_OPEN_TYPE_PRECONFIG = 0
INTERNET_SERVICE_HTTP = 3
INTERNET_FLAG_KEEP_CONNECTION = 400000
lpszFile db 'C:\file.txt',0
lpszAgent db 'Mozilla/4.0 (compatible; MSIE 6.0b; Windows NT 5.0; .NET CLR 1.0.2914)',0
lpszServerName db 'localhost',0
lpszVerb db 'POST',0
lpszObjectName db 'index.php',0
lpszHeaders db 'Content-Type: application/x-www-form-urlencoded',13,10,0
lpnoopenfile db 'Unable to open local file!',0
lpnosession db 'Unable to create new remote session!',0
lpnoconnect db 'There are no connection with remote host!',0Dh,'Please check is connection alive?',0
lpnorequest db 'Unable to open request!',0
lpnosendrequest db 'Unable to send request!',0
lpuploadok db 'Upload complete!',0
lpinfo db 'File upload',0
section '.code' code readable executable
start:
invoke InternetOpen,lpszAgent,INTERNET_OPEN_TYPE_PRECONFIG,0,0,0
test eax,eax
jnz @F
mov eax,lpnosession
call ShowError
jmp _exit
@@:
mov [hInternet],eax
invoke InternetConnect,eax,lpszServerName,80,0,0,INTERNET_SERVICE_HTTP,0,0
test eax,eax
jnz @F
mov eax,lpnoconnect
call ShowError
jmp _close_inet
@@:
mov [hConnect],eax
invoke HttpOpenRequest,eax,lpszVerb,0,0,INTERNET_FLAG_KEEP_CONNECTION,0
test eax,eax
jnz @F
mov eax,lpnorequest
call ShowError
jmp _close_inet
@@:
mov [hRequest],eax
invoke HttpSendRequest,eax,lpszHeaders,dwHeadersLength,lpOptional,dwOptionalLength
test eax,eax
jnz @F
mov eax,lpnosendrequest
call ShowError
jmp _close_inet
@@:
invoke MessageBox,0,lpuploadok,lpinfo,MB_ICONINFORMATION+MB_TOPMOST
_close_inet:
invoke InternetCloseHandle,[hInternet]
_exit:
invoke ExitProcess,0
proc ShowError
invoke MessageBox,0,eax,0,MB_ICONERROR+MB_TOPMOST
ret
endp
section '.idata' import data readable
library kernel,'KERNEL32.DLL',\
wininet,'WININET.DLL',\
user32,'USER32.DLL'
import kernel,\
ExitProcess,'ExitProcess',\
CloseHandle,'CloseHandle'
import wininet,\
InternetOpen,'InternetOpenA',\
InternetConnect,'InternetConnectA',\
HttpOpenRequest,'HttpOpenRequestA',\
HttpSendRequest,'HttpSendRequestA',\
InternetCloseHandle,'InternetCloseHandle'