do
{
printf("\nSelect the number of the adapter to open: ");
scanf("%d",&open);
if(open>=1 && open<=adapternum)
break;
}while(open<1 || open>adapternum);
void usage()
{
printf("\nUsage: T-ARP [-m|-a|-s|-r] firstip secondip \n\n");
printf("Option:\n");
printf(" -m mac Get the mac address from firstip to secondip\n");
printf(" -a antisniff Get the sniffing host from firstip to secondip\n");
printf(" -s spoof 1> Spoof the host between firstip and secondip\n");
printf(" sniff 2> Sniff if firstip == secondip == your own ip\n");
printf(" shock 3> Shock if firstip == secondip != your own ip\n");
printf(" -r reset Reset the spoofed host work normally\n\n");
printf("Attention:\n");
printf(" 1> You must have installed the winpcap_2.3 or winpcap_3.0_alpha\n");
printf(" 2> HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\IPEnableRouter==0x1\n\n");
return ;
}
int getmine()
{
char sendbuf[1024];
int k;
ETHDR eth;
ARPHDR arp;
-a 以本地主机的名义(本地主机的ip和mac)向指定ip网段内的所有主机发送31位伪广播地址(ff:ff:ff:ff:ff:fe)的ARP Request数据报,只有正在嗅探的主机才会发送ARP Reply数据报,这样就可以获得当前存活主机的列表。嗅探中的win2000系统还会对16位伪广播地址(ff:ff:00:00:00:00)做出回应;而嗅探中的win95/98/me不仅会回应16位伪广播地址,而且也会回应8位伪广播地址(ff:00:00:00:00:00),而*NIX系统对各种广播地址所做出的反应却有些不同。在此我们选择31位伪广播地址,是因为绝大多数的系统在嗅探时都会对它做出回应。而正常状况下的各种系统,都不会对31位伪广播地址做出回应。
-s (ARP欺骗spoof) 需要强调的是在某些局域网(如以太网)内,数据报的发送与接收是基于硬件地址的,这是我们实现欺骗的基础。首先获得指定的两台主机(假设为 A 和 B)的mac地址,然后向A发送ARP Reply数据报,其中的源ip地址为B的ip地址,但是源mac地址却是本地主机的mac地址,这样主机A就会认为主机B的mac地址是本地主机的mac地址,所以主机A发送到主机B的数据报都发送到本地主机了。同理向主机B发送ARP Reply数据报,通知它主机A的mac地址为本地主机的mac地址。这样主机A和主机B就会把目的主机的mac地址理解为本地主机的mac地址,于是他们之间相互发送的数据报都首先到达了本地主机,而先前我们已经将本地主机设置了ip路由功能,系统会自动将数据报转发到真正的目的主机。其间,你就可以监听它们通信的各种数据报了。