Advertisement
Xylitol

POST request MASM32

Aug 23rd, 2014
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; post.php: <?php echo htmlspecialchars($_POST['computername']); ?><br /><?php echo htmlspecialchars($_POST['username']); ?>
  2. .486
  3. .model flat, stdcall
  4. option casemap :none
  5. include \masm32\include\windows.inc
  6. include \masm32\include\user32.inc
  7. include \masm32\include\kernel32.inc
  8. include \masm32\include\masm32.inc
  9. include \masm32\include\wininet.inc
  10. include \masm32\include\advapi32.inc
  11. include \masm32\macros\macros.asm
  12. includelib \masm32\lib\user32.lib
  13. includelib \masm32\lib\kernel32.lib
  14. includelib \masm32\lib\masm32.lib
  15. includelib \masm32\lib\wininet.lib
  16. includelib \masm32\lib\advapi32.lib
  17. bufSize=MAX_COMPUTERNAME_LENGTH + 1
  18. .data
  19. format1 db 'computername=%s&username=%s',0
  20. postdata db 100 dup(0)
  21. bSize dd bufSize
  22. computer_name db bufSize dup(?)
  23. user_name db bufSize dup(?)
  24. szData db 1024 dup(0)
  25. host db "localhost",0
  26. headers db 13,10,"Keep-Alive: 115",
  27. 13,10,"Connection: keep-alive",
  28. 13,10,"Content-Type: application/x-www-form-urlencoded",0
  29. .data?
  30. hInternet dd ?
  31. hConnect dd ?
  32. hRequest dd ?
  33. dwBytesRead dd ?
  34. postdatalen dd ?
  35. .code
  36. main PROC
  37. invoke GetComputerName,addr computer_name,addr bSize
  38. invoke GetUserName,addr user_name,addr bSize
  39. invoke wsprintf,ADDR postdata,ADDR format1,ADDR computer_name,addr user_name
  40. invoke lstrlen,addr postdata
  41. mov postdatalen,eax
  42. call SendReq
  43. invoke ExitProcess,0
  44. main ENDP
  45. SendReq PROC
  46. mov hInternet,FUNC(InternetOpen,chr$("WinInet Test"),INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0)
  47. .if hInternet==NULL
  48. invoke MessageBox,0,chr$("InternetOpen error"),0,0
  49. exit
  50. .endif
  51. invoke InternetConnect,hInternet,offset host,INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,0,0
  52. mov hConnect,eax
  53. .if hConnect == NULL
  54. invoke MessageBox,0,chr$("InternetConnect error"),0,0
  55. exit
  56. .endif
  57. mov hRequest,FUNC(HttpOpenRequest,hConnect,chr$("POST"),chr$("/post.php"),NULL,chr$("localhost/post.php"),0,INTERNET_FLAG_KEEP_CONNECTION,1)
  58. .if hRequest == NULL
  59. invoke MessageBox,0,chr$("HttpOpenRequest error"),0,0
  60. exit
  61. .endif
  62. invoke HttpSendRequest,hRequest,offset headers,sizeof headers-1,offset postdata,postdatalen
  63. .if eax == 0
  64. invoke MessageBox,0,chr$("HttpSendRequest error"),0,0
  65. exit
  66. .endif
  67. invoke InternetReadFile,hRequest,offset szData,sizeof szData-1,offset dwBytesRead
  68. test eax,eax ;if (bRead == FALSE)
  69. jz @exit
  70. .if dwBytesRead==0
  71. jmp @exit
  72. .endif
  73. invoke OutputDebugString,chr$("Ok")
  74. @exit:
  75. invoke InternetCloseHandle,hRequest
  76. invoke InternetCloseHandle,hConnect
  77. invoke InternetCloseHandle,hInternet
  78. ret
  79. SendReq ENDP
  80. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement