Unlimited~Hack > Coding/Scripting > Assembler

 
Themen-Optionen
14.08.2010, 12:46   #1
fuckinghot19
*Newbie*
 
Registriert seit: 30.07.2010
Beiträge: 4
Using WinInet in MASM

Hab hier mal ein kleines Beispiel gemacht wie ihr entweder mit GET oder POST einer Webseite Daten entlocken könnt.
Also ein Beispiel wie man die WinInet verwendet.

Bei Fragen stehe ich gern zur Verfügung.

Code:
.486
.model flat, stdcall      
option casemap :none 
include windows.inc
include kernel32.inc
includelib kernel32.lib
include wininet.inc
includelib wininet.lib
include user32.inc
includelib user32.lib
include C:\masm32\macros\macros.asm
.data
szUserAgent        db    "Internet Explorer",0
;for GET
szHost            db    "http://localhost/scan4you/index.php?country=DE&hwid=xyz",0
;for POST
szHostn            db    "localhost",0
szObject        db    "/index.php",0
szHeader        db    "user=user&pass=pass&action=login",0
POST            db    "POST",0
;programm vars
szRec            db    1024 dup(0)
temp            dd    0
.data?
hInet            HANDLE    ?
hIOpen            HANDLE    ?
hRequest        HANDLE    ?
hIConnect        HANDLE    ?
.code
start:
;GET
invoke InternetOpen,addr szUserAgent,0,0,0,0
mov hInet,eax
.if hInet == NULL
    invoke MessageBox,NULL,CTXT("Error InternetOpen"),CTXT("ERROR"),MB_ICONERROR
    invoke ExitProcess,0
.endif
invoke InternetOpenUrl,hInet,addr szHost,0,0,0,0
mov hIOpen,eax
.if hIOpen == NULL
    invoke MessageBox,NULL,CTXT("Error InternetOpenUrl"),CTXT("ERROR"),MB_ICONERROR
    invoke ExitProcess,0
.endif
invoke InternetReadFile,hIOpen,addr szRec,1024,addr temp
.if eax == 0
    invoke MessageBox,NULL,CTXT("Error InternetReadFile"),CTXT("ERROR"),MB_ICONERROR
    invoke ExitProcess,0
.endif
invoke InternetCloseHandle,hInet
invoke InternetCloseHandle,hIOpen
;POST
invoke InternetOpen,addr szUserAgent,0,0,0,0
mov hInet,eax
.if hInet == NULL
    invoke MessageBox,NULL,CTXT("Error InternetOpen"),CTXT("ERROR"),MB_ICONERROR
    invoke ExitProcess,0
.endif
invoke InternetConnect,hInet,addr szHostn,INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,NULL,NULL
mov hIConnect,eax
.if hIConnect == NULL
    invoke MessageBox,NULL,CTXT("Error InternetConnect"),CTXT("ERROR"),MB_ICONERROR
    invoke ExitProcess,0
.endif
invoke HttpOpenRequest,hIConnect,addr POST,addr szObject,0,0,0,0,0
mov hRequest,eax
.if hRequest == NULL
    invoke MessageBox,NULL,CTXT("Error HttpOpenRequest"),CTXT("ERROR"),MB_ICONERROR
    invoke ExitProcess,0
.endif
invoke HttpSendRequest,hRequest,CTXT("Content-Type: application/x-www-form-urlencoded"),47,addr szHeader,sizeof szHeader
.if eax == FALSE
    invoke MessageBox,NULL,CTXT("Error HttpSendRequest"),CTXT("ERROR"),MB_ICONERROR
    invoke ExitProcess,0
.endif
invoke InternetReadFile,hRequest,addr szRec,sizeof szRec,addr temp
.if eax == 0
    invoke MessageBox,NULL,CTXT("Error InternetReadFile"),CTXT("ERROR"),MB_ICONERROR
    invoke ExitProcess,0
.endif
invoke InternetCloseHandle,hInet
invoke InternetCloseHandle,hRequest
;Content saved in szRec
;End
invoke ExitProcess,0
end start
Ist zwar nicht der schönste Code ,aber zur Erklährung reicht es sicher
 

Themen-Optionen

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 02:16 Uhr.

Design Developed by CompleteGFX
Powered by vBulletin®