资源简介
配置方法和上个版本一样,要安装winPcap。这个版本新家了写入日志,查看具体某个端口,查看发出去多少数据包和解析数据包的功能。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Net;
using System.Net.NetworkInformation;
using System.IO;
using PacketDotNet;
using SharpPcap;
using SharpPcap.AirPcap;
using SharpPcap.LibPcap;
using SharpPcap.WinPcap;
//自动侦测局域网网络数据流
//按ip数据包的源地址统计出该源地址在该时间段内发出的ip包的个数
//对数据包进行分析
//存储日志文件
namespace yuShenAnalysis
{
public partial class Form1 : Form
{
public static Thread awaker;//启动线程
public static Thread sleeper;//关闭线程
public string selectedAdp;
public string nowTime;
public Boolean chooseAll = false;
public Boolean flag = false;
System.Collections.ArrayList srcHw = new System.Collections.ArrayList(); //源硬件地址
System.Collections.ArrayList destHw = new System.Collections.ArrayList(); //目标硬件地址
System.Collections.ArrayList type = new System.Collections.ArrayList();
System.Collections.ArrayList headerLength = new System.Collections.ArrayList();//头字段长
System.Collections.ArrayList protocol = new System.Collections.ArrayList(); //协议
System.Collections.ArrayList timeToLive = new System.Collections.ArrayList();//生存时间
System.Collections.ArrayList srcIP = new System.Collections.ArrayList(); //ip
System.Collections.ArrayList destIP = new System.Collections.ArrayList(); //用了太多数组了不是件好事,下不为例
HashSet hs = new HashSet();
System.Collections.ArrayList srcAndCount = new System.Collections.ArrayList(); //源下标对应的数据包个数
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender EventArgs e)
{
if (checkWrite.Checked)
writeLog(“启动程序“);
getAdapter();
}
private void monitor()//监听
{
flag = true;
var devices = LibPcapLiveDeviceList.Instance;
//var devices = CaptureDeviceList.Instance;
foreach (PcapDevice dev in devices)
{
if (dev.Interface.FriendlyName.ToString() == selectedAdp)
{
//MessageBox.Show(“pair“);
PcapDevice device = dev;
device.OnPacketArrival += new PacketArrivalEventHandler(device_OnPackArrival);
device.Open(DeviceMode.Promiscuous 1000);
//device.Capture(20);
device.StartCapture();
}
}
}
private void device_OnPackArrival(object sender CaptureEventArgs e)//接收到包的处理
{
var packet = PacketDotNet.Packet.ParsePacket(e.Packet.linklayerType e.Packet.Data);//解析出基本包
var dlpacket = PacketDotNet.DatalinkPacket.ParsePacket(e.Packe
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 187 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\App.config
文件 196608 2013-01-14 19:59 yuShenAnalysis\yuShenAnalysis\bin\Debug\PacketDotNet.dll
文件 476563 2013-01-14 19:59 yuShenAnalysis\yuShenAnalysis\bin\Debug\PacketDotNet.xm
文件 72704 2013-01-14 19:59 yuShenAnalysis\yuShenAnalysis\bin\Debug\SharpPcap.dll
文件 186728 2013-01-14 19:59 yuShenAnalysis\yuShenAnalysis\bin\Debug\SharpPcap.xm
文件 20480 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\bin\Debug\yuShenAnalysis.exe
文件 187 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\bin\Debug\yuShenAnalysis.exe.config
文件 36352 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\bin\Debug\yuShenAnalysis.pdb
文件 24224 2015-06-21 14:11 yuShenAnalysis\yuShenAnalysis\bin\Debug\yuShenAnalysis.vshost.exe
文件 187 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\bin\Debug\yuShenAnalysis.vshost.exe.config
文件 490 2013-06-18 20:28 yuShenAnalysis\yuShenAnalysis\bin\Debug\yuShenAnalysis.vshost.exe.manifest
文件 12529 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\Form1.cs
文件 15474 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\Form1.Designer.cs
文件 6014 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\Form1.resx
文件 1453 2015-06-18 18:57 yuShenAnalysis\yuShenAnalysis\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7363 2015-06-21 10:52 yuShenAnalysis\yuShenAnalysis\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 0 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
文件 0 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
文件 0 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
文件 1638 2015-06-21 14:11 yuShenAnalysis\yuShenAnalysis\obj\Debug\yuShenAnalysis.csproj.FileListAbsolute.txt
文件 977 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\obj\Debug\yuShenAnalysis.csproj.GenerateResource.Cache
文件 9308 2015-06-18 19:16 yuShenAnalysis\yuShenAnalysis\obj\Debug\yuShenAnalysis.csprojResolveAssemblyReference.cache
文件 20480 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\obj\Debug\yuShenAnalysis.exe
文件 180 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\obj\Debug\yuShenAnalysis.Form1.resources
文件 36352 2015-06-21 14:10 yuShenAnalysis\yuShenAnalysis\obj\Debug\yuShenAnalysis.pdb
文件 180 2015-06-21 11:02 yuShenAnalysis\yuShenAnalysis\obj\Debug\yuShenAnalysis.Properties.Resources.resources
文件 526 2015-06-08 22:34 yuShenAnalysis\yuShenAnalysis\Program.cs
文件 1352 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\Properties\AssemblyInfo.cs
文件 2880 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\Properties\Resources.Designer.cs
文件 5612 2015-06-08 22:23 yuShenAnalysis\yuShenAnalysis\Properties\Resources.resx
............此处省略17个文件信息
- 上一篇:专升本数据结构试题及答案
- 下一篇:高校科研管理系统分析设计
评论
共有 条评论