我有一個工作嗅探器程序,用Delphi編寫。它在局域網中很好。但是當我的電腦在WLAN上時,它不會記錄任何東西。初始化:德爾福,我的嗅探器不會在WLAN工作
if (WSAStartup(MAKEWORD(2,2), Wsa) <> 0) then ErrorMsg ('WSAStartup');
//Create a RAW Socket
sniffer:= socket(AF_INET, SOCK_RAW, IPPROTO_IP);
if (sniffer = INVALID_SOCKET) then ErrorMsg ('Socket');
//Retrive the local hostname
getmem (hostname, 100);
if (gethostname(hostname, 100) = SOCKET_ERROR) then ErrorMsg ('Gethostname');
//Retrive the available IPs of the local host
local:= gethostbyname(hostname);
if (local = nil) then ErrorMsg ('Gethostbyname');
i:= 0;
repeat
i:= i + 1;
Move (local^.h_addr^[i-1], Addr, sizeof(Tinaddr));
until (local^.h_addr^[i-1] <> #0);
Players.MyIP:= inet_ntoa(Addr);
if Players.MyIP = '0.0.0.0' then
begin
Showmessage ('No IP!?'); halt;
end;
_in:= 0;
FillChar (Dest, SizeOf(Dest), 0);
Move (local^.h_addr^[_in], dest.sin_addr.s_addr, sizeof(dest.sin_addr.s_addr));
dest.sin_family:= AF_INET;
dest.sin_port := 0;
if (bind(sniffer, @dest, sizeof(dest))) = SOCKET_ERROR then ErrorMsg ('Bind');
j:= 1;
if (WSAIoctl(sniffer, SIO_RCVALL, @j,4, nil, 0, LPDWORD(@_in),nil, nil)) = SOCKET_ERROR then ErrorMsg ('WSAIoctl');
捕捉線程
while not Terminated do
begin
mangobyte:= recvfrom (sniffer,Buffer^,65536,0,nil,nil); //Eat as much as u can
if (mangobyte > 0) then
begin
adsasdasd
end
所以它不會記錄任何東西。我錯過了什麼嗎?