找传奇、传世资源到传世资源站!

C#网络抓包工具源码

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

C#网络抓包工具源码 C#语言基础-第1张
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using Tamir.IPLib;using Tamir.IPLib.Packets;namespace PcapExceptionTest{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { /* Retrieve the device list */ PcapDeviceList devices = SharpPcap.GetAllDevices(); /*If no device exists, print error */ if (devices.Count < 1) { MessageBox.Show("No device found on this machine"); return; } PcapDevice device = devices[0]; //Open the device for capturing //true -- means promiscuous mode //1000 -- means a read wait of 1000ms device.PcapOpen(true, 1000); //tcpdump filter to capture only TCP/IP packets //string filter = "host or net 127.0.0.1 and tcp and port 80and len> 50"; string filter = textBox1.Text; //Associate the filter with this capture try { device.PcapSetFilter(filter); } catch (PcapException ex) { textBox2.Text = ex.Message; return; } finally { device.PcapClose(); } textBox2.Text = "Success"; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复