public List <ProcessingBehave> SearchPB(MySqlConnection myConnect, string startTime, string endTime, string sender, string receiver, bool game, bool entertainment) { List <ProcessingBehave> datalist = new List <ProcessingBehave>(); myConnect.Open(); string sql = ""; MySqlCommand myCmd = null; sql = "select * from behave_info where time >= '" + startTime + "'" + " and time <= '" + endTime + "'"; if (sender != "") { sql += "and sender like '" + sender + "%'"; } if (receiver != "") { sql += "and receiver like '" + receiver + "%'"; } if (game && (!entertainment)) { sql += "and reason = " + "'娱乐'"; } if ((!game) && entertainment) { sql += "and reason = " + "'购物'"; } if (game && entertainment) { sql += "and reason = " + "'娱乐'" + "or reason = " + "'购物'"; } Debug.WriteLine(sql); try { myCmd = new MySqlCommand(get_uft8(sql), myConnect); MySqlDataReader reader = myCmd.ExecuteReader(); ProcessingBehave row; while (reader.Read()) { row = new ProcessingBehave(); row.UserIPA = reader[1].ToString(); row.UserIPB = reader[2].ToString(); row.Reason = reader[3].ToString(); row.DetailReason = reader[4].ToString(); row.Time = reader[5].ToString(); datalist.Add(row); } } catch (Exception ex) { } finally { myConnect.Close(); } return(datalist); }
private string SetSQLString(ProcessingBehave pb) { string senderIP; string receiverIP; string reason; string detailReason; string time; senderIP = pb.UserIPA; receiverIP = pb.UserIPB; reason = pb.Reason; detailReason = pb.DetailReason; time = pb.Time; return("insert into behave_info(sender,receiver,reason,detailReason,time) values('" + senderIP + "','" + receiverIP + "','" + reason + "','" + detailReason + "','" + time + "')"); }
private void ShowDataRows(ProcessingBehave pb) { try { rowsLine[1] = pb.UserIPA; rowsLine[2] = pb.UserIPB; rowsLine[3] = pb.Reason; rowsLine[0] = pb.Time; rowsLine[4] = pb.DetailReason; monitoringResultslistView.Rows.Add(rowsLine); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void SaveAll(MySqlConnection myConnect, ProcessingBehave rowData) { myConnect.Open(); string sql = ""; MySqlCommand myCmd = null; /// sql = SetSQLString(rowData); Debug.WriteLine(sql); try { myCmd = new MySqlCommand(get_uft8(sql), myConnect); myCmd.ExecuteNonQuery(); } finally { myConnect.Close(); } //MySqlCommand mycmd = new MySqlCommand("insert into buyer(name,password,email) values('小王','dikd3939','*****@*****.**')", mycon); }
private void ShowDataRows(RawCapture packet) { try { temp_packetIndex = packetIndex + 1; dataGridPacket.Rows.Add(rowsBulider.Row(packet, temp_packetIndex));//加载DataGridRows; string[] rowsLinebuffer = new string[7]; rowsLinebuffer = rowsBulider.Row(packet, ++packetIndex); //Console.WriteLine("rowsLinebuffer的长度是:"+ rowsLinebuffer.Length); if (rowsLinebuffer[1] == "TCP" || rowsLinebuffer[1] == "SMTP" || rowsLinebuffer[1] == "POP3" || rowsLinebuffer[1] == "HTTP" || rowsLinebuffer[1] == "OICQ") { rowData = new ProcessingAllData(); rowData.Id = rowsLinebuffer[0]; rowData.Protocol = rowsLinebuffer[1]; rowData.Length = rowsLinebuffer[2]; rowData.SourceAddress = rowsLinebuffer[3]; rowData.DestinationAddress = rowsLinebuffer[4]; rowData.HardwareType = rowsLinebuffer[5]; //Console.WriteLine("305 索引前rowsLinebuffer的长度是:" + rowsLinebuffer.Length); rowData.Time = rowsLinebuffer[6]; //Console.WriteLine("308 索引后rowsLinebuffer的长度是:" + rowsLinebuffer.Length); rowData.BinaryData = packet.Data; //? rowData.Data = HexConvert.ConvertToAscii(packet.Data); //Console.WriteLine("311 rowsLinebuffer的长度是:" + rowsLinebuffer.Length); //添加总的数据 lock (padList.SyncRoot) { padList.Add(rowData); } if (rowsLinebuffer[1] == "OICQ") { pqll = new ProcessingQQLoginLogout(); countQQ += pqll.Analysis(rowData); if (pqll.QqLogin == 1 || pqll.QqLogin == 2) { lock (pqllList.SyncRoot) { pqllList.Add(pqll); //这里写存入数据库的代码 saveAllData.SaveAll(saveAllData.MyConnect, pqll); } } } //员工行为 if (rowsLinebuffer[1] == "TCP" || rowsLinebuffer[1] == "HTTP") { pb = new ProcessingBehave(); String key = pb.Analysis(rowData, ht, pbList); if (!key.Equals("key")) { ht.Remove(key); countBehave++; saveAllData.SaveAll(saveAllData.MyConnect, pb); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.qqNoticeLabel.Text = "已捕获QQ上下线记录" + countQQ + "条"; this.staffNoticeLabel.Text = "已捕获影音娱乐记录" + countBehave + "条"; }