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

 

//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;

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值