• 大小: 415KB
    文件类型: .rar
    金币: 2
    下载: 2 次
    发布日期: 2023-07-19
  • 语言: C#
  • 标签: 网络编程  

资源简介

C#编写的局域网抓包工具,源码注释,本用于网络编程课程设计。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;

namespace _2010123066cdj_Sniffor
{
    public partial class Monitor : Form
    {
        private packetMonitorcs[] packetMonitor;//数据包抓取实例
        private List packetList = new List();//抓取的数据包集合
        private int totalPacketLength = 0;//抓取的数据包总大小(单位字节)
        public Monitor()
        {
            InitializeComponent();
        }

        private void Monitor_Load(object sender EventArgs e)
        {
            //初始化Ip列表
            this.InitIpList();
            //初始化IP抓取实例
            this.InitMonitor();
            //初始化窗体皮肤
            this.skinEngineMain.SkinFile = “Midsummer.ssk“;
        }
        
        private void btnStart_Click(object sender EventArgs e)
        {
            //开始抓取数据包
            if (btnStart.Text == “开始抓取“)
            {
                //循环抓取每个网卡的数据包
                for (int i = 0; i < packetMonitor.Length; i++)
                {
                    if (cmbIpList.SelectedIndex == 0)
                    {
                        try
                        {
                            //第i个开始抓取
                            packetMonitor[i].begainMonitor();
                        }
                        catch
                        {
                            MessageBox.Show(“内部错误,请联系管理员“);
                        }
                    }
                    else
                    {
                        try
                        {
                            //抓取指定的Ip
                            packetMonitor[cmbIpList.SelectedIndex - 1].begainMonitor();
                        }
                        catch
                        {
                            MessageBox.Show(“内部错误,请联系管理员“);
                        }
                    }
                    btnStart.Text = “停止抓取“;
                    toolStripStatusLabel1.Text = “开始监测所有端口“;
                }     
            }
            //停止抓取
            else
            {
                for (int i = 0; i < packetMonitor.Length; i++)
                {
                    packetMonitor[i].Stop();
                }
                btnStart.Text = “开始抓取“;
                toolStripStatusLabel1.Text = “停止监测“;
            }
       
        }

        /// 
        /// 初始化ip列表
        /// 

        public void InitIpList()
        {
            //获取IP列表
            IPAddress[] hostIpAdress = otherHandle.getLocalIPAddress();
            //没有网卡
            if (hostIpAdress.Length == 0)
            {
                MessageBox.Show(“未监测到本机网卡,请确认本机网卡!“);
                Application.Exit();
            }
            foreach (IPAddress ip in hostIpAdress)
            {
                cmbIpList.Ite

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4327  2012-11-18 12:27  2010123066cdj_Sniffor\2010123066cdj_Sniffor\2010123066cdj_Sniffor.csproj

     文件        144  2012-11-18 12:25  2010123066cdj_Sniffor\2010123066cdj_Sniffor\app.config

     文件     209408  2013-04-01 17:16  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\2010123066cdj_Sniffor.exe

     文件        144  2012-11-18 12:25  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\2010123066cdj_Sniffor.exe.config

     文件      60928  2013-04-01 17:16  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\2010123066cdj_Sniffor.pdb

     文件      22984  2013-04-01 17:17  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\2010123066cdj_Sniffor.vshost.exe

     文件        144  2012-11-18 12:25  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\2010123066cdj_Sniffor.vshost.exe.config

     文件        490  2009-08-31 00:40  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\2010123066cdj_Sniffor.vshost.exe.manifest

     文件      91782  2012-11-18 13:17  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\header.ico

     文件      91782  2012-11-18 13:18  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\header2.ico

     文件     520192  2007-11-02 09:06  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\irisskin.dll

     文件      12238  2008-06-04 11:46  2010123066cdj_Sniffor\2010123066cdj_Sniffor\bin\Debug\Midsummer.ssk

     文件       6285  2012-11-18 13:50  2010123066cdj_Sniffor\2010123066cdj_Sniffor\Monitor.cs

     文件      11033  2012-11-18 13:50  2010123066cdj_Sniffor\2010123066cdj_Sniffor\Monitor.Designer.cs

     文件     145101  2012-11-18 13:50  2010123066cdj_Sniffor\2010123066cdj_Sniffor\Monitor.resx

     文件       2308  2013-04-01 17:17  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\2010123066cdj_Sniffor.csproj.FileListAbsolute.txt

     文件       1042  2013-04-01 17:16  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\2010123066cdj_Sniffor.csproj.GenerateResource.Cache

     文件       9068  2013-04-01 17:16  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\2010123066cdj_Sniffor.csprojResolveAssemblyReference.cache

     文件     209408  2013-04-01 17:16  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\2010123066cdj_Sniffor.exe

     文件      60928  2013-04-01 17:16  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\2010123066cdj_Sniffor.pdb

     文件      13967  2012-11-18 12:20  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6955  2013-04-01 17:15  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        936  2012-11-18 13:50  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\GenerateResource.read.1.tlog

     文件       2720  2012-11-18 13:50  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\GenerateResource.write.1.tlog

     文件       7897  2012-11-17 11:05  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\ResolveAssemblyReference.cache

     文件       4608  2012-11-18 12:25  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件      92348  2012-11-18 13:50  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\_2010123066cdj_Sniffor.Monitor.resources

     文件      92348  2012-11-18 13:27  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\_2010123066cdj_Sniffor.packetDetail.resources

     文件        180  2012-11-18 12:27  2010123066cdj_Sniffor\2010123066cdj_Sniffor\obj\x86\Debug\_2010123066cdj_Sniffor.Properties.Resources.resources

     文件       2219  2012-11-17 20:58  2010123066cdj_Sniffor\2010123066cdj_Sniffor\otherHandle.cs

............此处省略27个文件信息

评论

共有 条评论