利用GET命令提交一个HTTP数据包:
.386
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include wsock32.inc
include Ws2_32.inc
includelib user32.lib
includelib kernel32.lib
includelib wsock32.lib
includelib Ws2_32.lib
TCP_PORT equ 80 ;常量定义
.data
@wsaData WSADATA <>
@stAddr sockaddr_in <>
szHostName db "http://www.wolfexp.net/",0
sz3 db 156 dup(0)
sz1 db "GET /forum/index.php HTTP/1.1",13,10
db "Host: http://www.wolfexp.net/",0
.data?
hSocket SOCKET ?
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke WSAStartup,202h,addr @wsaData ;初始化WSAStartup库
invoke WSASocket,PF_INET,SOCK_STREAM,IPPROTO_TCP,NULL,0,0 ;加载套接字
mov hSocket,eax ;保存句柄
invoke htons,TCP_PORT ;设置端口
mov @stAddr.sin_port,ax ;保存
invoke gethostbyname,addr szHostName
.if eax
mov eax,[eax + hostent.h_list] ;取h_list指针
.while dword ptr [eax]
mov ecx,[eax] ;取一个IP地址的指针
mov ecx,[ecx] ;用指针取出IP地址
invoke inet_addr,ecx
mov @stAddr.sin_addr,eax
.endw
.endif
mov @stAddr.sin_family,AF_INET ;设置IP格式
invoke bind,hSocket,addr @stAddr,sizeof @stAddr
invoke connect,hSocket,addr @stAddr,sizeof @stAddr
invoke lstrlen,addr sz1
invoke send,hSocket,addr sz1,eax,0
invoke recv,hSocket,addr sz3,sizeof sz3,0
invoke MessageBox,NULL,addr sz3,NULL,MB_OK
invoke closesocket,hSocket
invoke ExitProcess,NULL
end start
服务器返回是空白,为虾米?大家帮我看看
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课