资源简介
基于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协议获取局域网内活动主机物理地址
评论
共有 条评论