91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2.27MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2023-08-17
  • 語言: C/C++
  • 標簽: C++)??

資源簡介

開發平臺: Windows XP SP2 Visual Studio 6.0 程序使用命令行運行:IPMonitor.exe duration_time。duration_time為監控時間,單位為秒。 程序的運行效果如下圖所示:

資源截圖

代碼片段和文件信息

#include?“IPMonitor.h“

#define?BURRER_SIZE?65535

void?main()
{
//?判斷輸入的命令行格式是否正確
int?argc=2;
char?*?argv[2];
argv[1]=new?char[10];
strcpy(argv[1]“30“);
if?(argc?!=?2)
{
cout?< < return;
}

//這個結構被用來存儲?被WSAStartup函數調用后返回的?Windows?Sockets?數據
WSADATA?wsData;

//?WSAStarup,是Windows?SocKNDs?Asynchronous的啟動命令
if?(WSAStartup(MAKEWORD(22)&wsData)?!=?0)
{
cout?< return;
}

//?創建Raw?Socket
SOCKET?sock;
//地址族描述新套接口的類型描述套接口使用的特定協議套接口的特性套接口組的描述字套接口屬性描述
if?(?(sock?=?WSASocket(AF_INET?SOCK_RAW?IPPROTO_IP?NULL?0?WSA_FLAG_OVERLAPPED))==?INVALID_SOCKET?)
{
cout?< return;
}

//?設置IP頭操作選項,表示用戶可以親自對IP頭進行處理
BOOL?bFlag?=?TRUE;
//設置套接口的選項
if?(setsockopt(sock?IPPROTO_IP?IP_HDRINCL?(char?*)&bFlag?sizeof(bFlag))?==?SOCKET_ERROR)
{
cout?< return;
}

//?獲取本地主機名
char?pHostName[128];
if?(gethostname(pHostName?100)?==?SOCKET_ERROR)
{
cout?< return;
}

//?通過本地主機名獲取本地IP地址
hostent?*?pHostIP;
if((pHostIP?=?gethostbyname(pHostName))?==?NULL)
{
cout<<“Gethostbyname?failed!“< return;
}

//?填充sockaddr_in結構
sockaddr_in?addr_in;
addr_in.sin_addr?=?*(in_addr?*)pHostIP->h_addr_list[0]; ?//?設定IP地址
addr_in.sin_family?=?AF_INET; //?設定地址類型
addr_in.sin_port?=?htons(8000); //?設定端口

//?把原始套接字綁定到本機地址上
if(bind(sock(PSOCKADDR)&addr_insizeof(addr_in))?==?SOCKET_ERROR)
{
cout?< return;
}

//?把網卡設置為混雜模式,以便接收所有的IP包
#define??IO_RCVALL?_WSAIOW(IOC_VENDOR1)
unsigned?long?pBufferLen[10];
unsigned?long?dwBufferInLen?=?1;
unsigned?long?dwBytesReturned?=?0;
if?((WSAIoctl(sock?IO_RCVALL?&dwBufferInLen?sizeof(dwBufferInLen)?&pBufferLen
sizeof(pBufferLen)?&dwBytesReturned?NULL?NULL))?==?SOCKET_ERROR)
{
cout<<“Ioctlsocket?failed!“< return;
}

//?把socket設置為非阻塞模式
unsigned?long?dwTemp?=?1;
????ioctlsocket(sock?FIONBIO?&dwTemp);

//?設置接收緩沖區
char?pBuffer[BURRER_SIZE];

//?定義存放IP數據包的鏈表
CNodeList?IpList;

double?dwDuration?=?atof(argv[1]); //?輸入參數為捕獲時間
time_t?beg;
time_t?end;
time(&beg); //?獲得當前系統時間

//?輸出本地IP地址
cout?< cout?< ?< cout?<
while?(1)
{
time(&end); //?獲得當前系統時間
//如果捕獲時間到,就結束捕獲
if?(end-beg?>=?dwDuration)
{
break;
}

//?捕獲經過網卡的IP數據包
int?nPacketSize?=?recv(sockpBufferBURRER_SIZE0);
if?(nPacketSize?>?0)
{
IPHEADER?*?pIpHdr;
//?通過指針把緩沖區中的內容強制轉換為IPHEADER數據結構
pIpHdr?=?(IPHEADER?*)pBuffer;

//?判斷IP包的源IP地址或目的IP地址是否為本地主機的IP地址
// if?(pIpHdr->SourceAddress?==?addr_in.sin_addr.S_un.S_addr?||?pIpHdr->DestAddress?==?addr_in.s

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????4244480??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\Debug\IPMonitor.bsc

?????文件?????213128??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\Debug\IPMonitor.exe

?????文件?????307260??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\Debug\IPMonitor.ilk

?????文件??????22882??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\Debug\IPMonitor.obj

?????文件????4844656??2012-03-10?16:32??IP包流量分析程序\IPMonitor\Code\Debug\IPMonitor.pch

?????文件?????607232??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\Debug\IPMonitor.pdb

?????文件??????????0??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\Debug\IPMonitor.sbr

?????文件??????10549??2012-03-09?10:46??IP包流量分析程序\IPMonitor\Code\Debug\IPNode.obj

?????文件??????????0??2012-03-09?10:46??IP包流量分析程序\IPMonitor\Code\Debug\IPNode.sbr

?????文件??????33549??2012-03-09?10:46??IP包流量分析程序\IPMonitor\Code\Debug\NodeList.obj

?????文件??????????0??2012-03-09?10:46??IP包流量分析程序\IPMonitor\Code\Debug\NodeList.sbr

?????文件?????287744??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\Debug\vc60.idb

?????文件?????102400??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\Debug\vc60.pdb

?????文件???????3675??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\IPMonitor.cpp

?????文件???????4634??2007-06-15?17:15??IP包流量分析程序\IPMonitor\Code\IPMonitor.dsp

?????文件????????541??2006-10-30?16:00??IP包流量分析程序\IPMonitor\Code\IPMonitor.dsw

?????文件????????797??2007-06-15?16:54??IP包流量分析程序\IPMonitor\Code\IPMonitor.h

?????文件?????156672??2012-03-16?17:04??IP包流量分析程序\IPMonitor\Code\IPMonitor.ncb

?????文件??????50688??2012-03-16?17:04??IP包流量分析程序\IPMonitor\Code\IPMonitor.opt

?????文件???????1616??2012-03-16?17:00??IP包流量分析程序\IPMonitor\Code\IPMonitor.plg

?????文件???????1373??2007-06-15?17:06??IP包流量分析程序\IPMonitor\Code\IPNode.cpp

?????文件???????1140??2007-06-15?17:14??IP包流量分析程序\IPMonitor\Code\IPNode.h

?????文件???????2022??2007-06-15?17:14??IP包流量分析程序\IPMonitor\Code\NodeList.cpp

?????文件????????902??2007-06-15?17:10??IP包流量分析程序\IPMonitor\Code\NodeList.h

?????文件?????254090??2007-06-28?00:22??IP包流量分析程序\IPMonitor\Exe\IPMonitor.exe

?????文件??????45568??2007-06-30?20:20??IP包流量分析程序\IPMonitor\使用說明.doc

?????目錄??????????0??2012-06-02?19:17??IP包流量分析程序\IPMonitor\Code\Debug

?????目錄??????????0??2012-06-02?19:17??IP包流量分析程序\IPMonitor\Code

?????目錄??????????0??2012-06-02?19:17??IP包流量分析程序\IPMonitor\Exe

?????目錄??????????0??2012-06-02?19:17??IP包流量分析程序\IPMonitor

............此處省略4個文件信息

評論

共有 條評論

相關資源