//while True do
//my_arp_packet.DLC_HDR.Source:=setMacStr(Edit1.Text);
while True do
begin
for i:=low_ip to high_ip do
begin
ip_str:='192.168.'+inttostr(strtoip(edit3.Text)[2])+'.'+inttostr(i);
//不断切换我的ip,效果就是让他发现多了n台机子,mac都是aa-bb-cc
my_arp_packet.ARP_FRAM.SenderIP:=StrToIP(ip_str);
if pcap_sendpacket(my_ppcap_t,@my_arp_packet,SizeOf(my_arp_packet))=0 then
Form1.Caption:='发送成功'+inttostr(i);
Sleep(100);
end;
end;
{以上为arp发包的过程,可以用一个CreateThread 创建线程}
procedure sniff;
var
netmaste:u_int;
fcode:Tbpf_program;
packet_filter:array[1..10]of Char;
begin
d:=@alldevs;
d:=d.next;
d:=d.next;
if d.address<>nil then// netmaste:=
netmaste:=d.address.netmask.sin_addr.S_addr
else
netmaste:=$FFFFFF;
//compile the filter ip and tcp and
if pcap_compile(my_ppcap_t,@fcode,PChar('arp'),1,netmaste)<0 then ShowMessage('compile the filter fall');
//set the filter
if pcap_setfilter(my_ppcap_t,@fcode)<0 then ShowMessage('Error setting the filter');
pcap_loop(my_ppcap_t,0,@packet_handle,nil);//
end;
{此处为嗅探的过程,如果先创建一个线程开始嗅探,并将上面发包的mac目的地址,就是以太网头部的前6个字节换成ff-ff-ff-ff-ff-ff,pcap_loop的回调函数处理mac_ip列表的对应关系,则此程序即是一个内网存活机子扫描的程序,}
评论