C#做的配套C做的SNIFFER(C#)--C#简单而实用

这是一个使用C#编写的简单网络嗅探器应用,它结合了几个程序来实现网络数据包的捕获和分析。通过启动telnet、iptool和FTP进程,该程序能够进行数据包跟踪、捕获和文件传输。同时,它还包含了一个功能,从log.txt文件读取数据并将其导入到SQL Server数据库中,并根据数据包ID的高八位进行查询。此外,该程序还提供了一个简单的用户界面,用户可以输入数据包ID,程序会显示匹配的数据库记录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

//C#实现系统界面
//本模块完成几个程序的连接
//并实现文件扫描后数据库的信息导入,
//通过对伪IP数据包标识符&65280(获取高八位)查询数据库相关记录获取IP
//按照visual studio C#windows窗体设计步骤

 

//Program.cs
using System;
using System.IO;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using System.Diagnostics;
using System.Data;
using System.Data.SqlClient;
namespace WMF_WIP系统
{
   
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
   public  class IPscanDYc
    {    
       public static void track()
        {
          // 实例一个Process类,启动一个独立进程
         Process p1 = new Process();
         p1.StartInfo.FileName = "Telnet.exe";
         p1.StartInfo.CreateNoWindow =false;
         p1.Start();

        }
       public static void capture()
       {
           Process p2 = new Process();
           p2.StartInfo.FileName ="iptool\\IpTool.exe";
           p2.StartInfo.CreateNoWindow = false;
           p2.Start();

       }
       public static void BUG()
       {
           Process p3 = new Process();
           p3.StartInfo.FileName = "FTP\\xlight.exe";
           p3.StartInfo.CreateNoWindow = false;
           p3.Start();
       }
       public static void help(string s)
       {
           Process p4 = new Process();
           p4.StartInfo.FileName = s;
           p4.StartInfo.CreateNoWindow = false;
           p4.Start();
       }

     }
   public class DBQ
   {
       static string ID = Application.StartupPath;
       public static void _TxtInDB(TextBox info)
       {
           char fenge= '#';//按照#分割
           StreamReader sr = new StreamReader(new FileStream("log.txt", FileMode.Open, FileAccess.Read), System.Text.Encoding.Default);
           SqlConnection cn = new SqlConnection("Server=.;uid=wmf;pwd=wmf;database=WIP"); ;
           string insertCmd = "insert into WIP values (@ID, @SIP, @Content)";
           string[] WMF = null;//得到的一行的数据()
           string strTemp = sr.ReadLine();
           while(strTemp != null)
           {
               WMF = strTemp.Split(fenge);
               SqlCommand cmd = new SqlCommand(insertCmd, cn);
               cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = WMF[0];
               cmd.Parameters.Add("@SIP", SqlDbType.VarChar).Value = WMF[1];
               cmd.Parameters.Add("@Content", SqlDbType.VarChar).Value = WMF[2];
               cn.Open();
               try
               {
                   cmd.ExecuteNonQuery();
               }
               catch (System.Data.SqlClient.SqlException e)
               {
                   info.Text = "错误";
               }
               cn.Close();
               strTemp = sr.ReadLine();
           }
           sr.Close();
       }


       public static void _SDB(TextBox T3,TextBox T5, string p)
       {
           //创建数据库连接
           int i=0,n=0;   
           if(T3.Text.Length==0) i=0; 
           else i=Convert.ToInt32(p)&65280;
           T3.AppendText(i.ToString());
           SqlConnection objSqlConnection=new SqlConnection("server=.;uid=wmf;pwd=wmf;database=WIP"); 
           objSqlConnection.Open();
           T5.Text = "连接成功"; 
           string query="SELECT * from WIP where PacketID&65280="+i;
           SqlCommand objSqlCommand=new SqlCommand(query,objSqlConnection);
           SqlDataReader objSqlReader=objSqlCommand.ExecuteReader();
           while(objSqlReader.Read()) 
           {  n+=1;
           T3.Text= objSqlReader.GetValue(1).ToString();
           T5.Text=objSqlReader.GetValue(2).ToString();
           }
           if(n==0)  T5.AppendText("数据库中没有这样的记录!");
       }

   }

}

 

//from1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace WMF_WIP系统
{

    public partial class Form1 : Form
    {

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值