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