資源簡介
基于MFC對話框和Winpcap實現的接收TCP數據包、偽造包頭并轉發給目的主機的程序 并附帶過程文檔

代碼片段和文件信息
//?Connection.cpp:?implementation?of?the?CConnection?class.
//
//////////////////////////////////////////////////////////////////////
#include?“stdafx.h“
#include?“Hopping?Client.h“
#include?“Connection.h“
#ifdef?_DEBUG
#undef?THIS_FILE
static?char?THIS_FILE[]=__FILE__;
#define?new?DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
CConnection::CConnection()
{
}
CConnection::~CConnection()
{
}
void?CConnection::CreateConnection()
{
}
void?CConnection::RecvHandle()
{
}
void?CConnection::SendSYNPacket(u_char?*SourceMac?u_char*DestMac?unsigned?long?SourceIp?unsigned?long?DestIp?
int?Sourceport?int?Destport)
{
TcpPacket_t?*theTcpPacket?=?new?TcpPacket_t;
/*初始化物理頭*/
theTcpPacket->theIpPacket.theEthHead.eth_type?=?htons(0x0800);
memcpy(theTcpPacket->theIpPacket.theEthHead.source_mac?SourceMac?6);
memcpy(theTcpPacket->theIpPacket.theEthHead.dest_mac?DestMac?6);
/*初始化IP包頭*/
theTcpPacket->theIpPacket.theIpHead.dwDestAddr?=?htonl(DestIp);
theTcpPacket->theIpPacket.theIpHead.dwSourceAddr?=?htonl(SourceIp);
theTcpPacket->theIpPacket.theIpHead.ucProtocol?=?6;
theTcpPacket->theIpPacket.theIpHead.ucTos?=?0;
theTcpPacket->theIpPacket.theIpHead.ucTtl?=?119;
theTcpPacket->theIpPacket.theIpHead.ucVersionAndHeadLength?=?0x45;
theTcpPacket->theIpPacket.theIpHead.usCheckSum?=?0;
theTcpPacket->theIpPacket.theIpHead.usFlagsAndFragmentOffset?=?0;
theTcpPacket->theIpPacket.theIpHead.usIdentification?=?1234;
theTcpPacket->theIpPacket.theIpHead.usTotalLength?=?60;
theTcpPacket->theIpPacket.theIpHead.usCheckSum?=?CheckSum((u_short*)(&(theTcpPacket->theIpPacket.theIpHead))?sizeof(IpHead_t));
/*初始化TCP包頭*/
theTcpPacket->theTcpHead.dwAck?=?0;
theTcpPacket->theTcpHead.dwSeq?=?0;
theTcpPacket->theTcpHead.ucFlag?=?0x0002; //SYN置1
theTcpPacket->theTcpHead.ucLength?=?0x0070;
theTcpPacket->theTcpHead.usCheckSum?=?0;
theTcpPacket->theTcpHead.usDestPort?=?htons(Destport);
theTcpPacket->theTcpHead.usSourcePort?=?htons(Sourceport);
theTcpPacket->theTcpHead.usUrgent?=?0;
theTcpPacket->theTcpHead.usWindow?=?0xFFFF;
theTcpPacket->theTcpHead.usNopOpt?=?0x0101;
theTcpPacket->theTcpHead.usSackOpt?=?0x0204;
theTcpPacket->theTcpHead.unMssOpt?=?htonl(0x020405B4);
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2472??2009-10-22?14:35??Ip?Hopping?System客戶端\Code\Connection.cpp
?????文件????????763??2009-10-22?14:35??Ip?Hopping?System客戶端\Code\Connection.h
?????文件??????22852??2009-10-21?09:08??Ip?Hopping?System客戶端\Code\Hopping?Client.aps
?????文件???????1743??2009-10-23?16:42??Ip?Hopping?System客戶端\Code\Hopping?Client.clw
?????文件???????2164??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\Hopping?Client.cpp
?????文件???????4466??2009-10-22?15:45??Ip?Hopping?System客戶端\Code\Hopping?Client.dsp
?????文件????????553??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\Hopping?Client.dsw
?????文件???????1404??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\Hopping?Client.h
?????文件???11004928??2009-10-26?16:19??Ip?Hopping?System客戶端\Code\Hopping?Client.ncb
?????文件??????57856??2009-10-23?16:46??Ip?Hopping?System客戶端\Code\Hopping?Client.opt
?????文件???????1385??2009-10-23?16:42??Ip?Hopping?System客戶端\Code\Hopping?Client.plg
?????文件???????6233??2009-10-19?17:31??Ip?Hopping?System客戶端\Code\Hopping?Client.rc
?????文件????????892??2009-10-25?09:47??Ip?Hopping?System客戶端\Code\Hopping?Client.sln
????..A..H.?????28672??2009-10-26?16:19??Ip?Hopping?System客戶端\Code\Hopping?Client.suo
?????文件???????7512??2009-10-25?09:47??Ip?Hopping?System客戶端\Code\Hopping?Client.vcproj
?????文件???????1415??2009-10-26?16:19??Ip?Hopping?System客戶端\Code\Hopping?Client.vcproj.李經緯-PC.李經緯.user
?????文件??????18026??2009-10-25?13:22??Ip?Hopping?System客戶端\Code\Hopping?ClientDlg.cpp
?????文件???????2540??2009-10-23?21:54??Ip?Hopping?System客戶端\Code\Hopping?ClientDlg.h
?????文件???????3720??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\ReadMe.txt
?????文件???????1078??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\res\Hopping?Client.ico
?????文件????????406??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\res\Hopping?Client.rc2
?????文件???????1014??2009-10-19?17:31??Ip?Hopping?System客戶端\Code\resource.h
?????文件????????216??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\StdAfx.cpp
?????文件???????1054??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\StdAfx.h
?????文件???????1028??2009-10-21?10:03??Ip?Hopping?System客戶端\Code\targetver.h
?????文件???????1344??2009-10-23?15:21??Ip?Hopping?System客戶端\Code\TCPPacket.h
?????文件?????176128??2009-10-25?13:22??Ip?Hopping?System客戶端\Exe\Hopping?Client.exe
?????文件??????64078??2009-10-25?13:25??Ip?Hopping?System客戶端\程序文檔\程序過程文檔.docx
?????目錄??????????0??2009-10-19?09:54??Ip?Hopping?System客戶端\Code\res
?????目錄??????????0??2009-10-26?11:19??Ip?Hopping?System客戶端\Code
............此處省略6個文件信息
- 上一篇:C++家族管理系統設計
- 下一篇:使用ARP協議獲取局域網內活動主機物理地址
評論
共有 條評論