private void loadPcap(string fileName, bool asMessages, bool dontList = false) { Text = "AC Log View - " + Path.GetFileName(fileName); pcapFilePath = Path.GetFullPath(fileName); toolStripStatus.Text = pcapFilePath; btnHighlight.Enabled = true; menuItem_ReOpen.Enabled = true; menuItem_ReOpenAsMessages.Enabled = true; if (opCodesToHighlight.Count > 0) { Text += " Highlighted OpCodes: "; foreach (var opcode in opCodesToHighlight) { Text += opcode + " (" + opcode.ToString("X4") + "),"; } } records.Clear(); listItems.Clear(); bool abort = false; records = PCapReader.LoadPcap(fileName, asMessages, ref abort); if (!dontList) { foreach (PacketRecord record in records) { ListViewItem newItem = new ListViewItem(record.index.ToString()); newItem.SubItems.Add(record.isSend ? "Send" : "Recv"); newItem.SubItems.Add(record.tsSec.ToString()); newItem.SubItems.Add(record.packetHeadersStr); newItem.SubItems.Add(record.packetTypeStr); newItem.SubItems.Add(record.data.Length.ToString()); newItem.SubItems.Add(record.extraInfo); // This one requires special handling and cannot use function. if (record.opcodes.Count == 0) { newItem.SubItems.Add(string.Empty); } else { newItem.SubItems.Add(record.opcodes[0].ToString("X").Substring(4, 4)); } listItems.Add(newItem); } } if (!dontList && records.Count > 0) { listView_Packets.VirtualListSize = records.Count; listView_Packets.RedrawItems(0, records.Count - 1, false); updateData(); } else { listView_Packets.VirtualListSize = 0; } }
private void ProcessFile(string fileName) { int hits = 0; int exceptions = 0; bool isPcapng = false; var records = PCapReader.LoadPcap(fileName, true, ref searchAborted, ref isPcapng); foreach (PacketRecord record in records) { if (searchAborted || Disposing || IsDisposed) { return; } try { if (record.data.Length <= 4 || (TextToSearchFor.Length > record.data.Length)) { continue; } //BinaryReader messageDataReader = new BinaryReader(new MemoryStream(record.data)); //var messageCode = messageDataReader.ReadUInt32(); int messageCode = BitConverter.ToInt32(record.data, 0); var result = SearchForText(record, TextToSearchFor, caseSensitive); if (result > 0) { hits++; } } catch { // Do something with the exception maybe exceptions++; Interlocked.Increment(ref totalExceptions); } } Interlocked.Increment(ref filesProcessed); processFileResults.Add(new ProcessFileResult() { FileName = fileName, Hits = hits, Exceptions = exceptions }); }
private void ProcessFile(string fileName) { int hits = 0; int exceptions = 0; var records = PCapReader.LoadPcap(fileName, false, ref searchAborted); foreach (var record in records) { if (searchAborted || Disposing || IsDisposed) { return; } if (record.opcodes.Contains((PacketOpcode)opCodeToSearchFor)) { hits++; Interlocked.Increment(ref totalHits); } // ******************************************************************** // ************************ CUSTOM SEARCH CODE ************************ // ******************************************************************** // Custom search code that can output information to Special Output // Below are several commented out examples on how you can search through bulk pcaps for targeted data, and output detailed information to the output tab. foreach (BlobFrag frag in record.frags) { try { if (frag.dat_.Length <= 4) { continue; } BinaryReader fragDataReader = new BinaryReader(new MemoryStream(frag.dat_)); var messageCode = fragDataReader.ReadUInt32(); /*if (messageCode == 0x02BB) // Creature Message * { * var parsed = CM_Communication.HearSpeech.read(fragDataReader); * * //if (parsed.ChatMessageType != 0x0C) * // continue; * * var output = parsed.ChatMessageType.ToString("X4") + " " + parsed.MessageText; * * if (!specialOutputHits.ContainsKey(output)) * { * if (specialOutputHits.TryAdd(output, 0)) * specialOutputHitsQueue.Enqueue(output); * } * }*/ /*if (messageCode == 0xF745) // Create Object * { * var parsed = CM_Physics.CreateObject.read(fragDataReader); * }*/ /*if (messageCode == 0xF7B0) // Game Event * { * var character = fragDataReader.ReadUInt32(); // Character * var sequence = fragDataReader.ReadUInt32(); // Sequence * var _event = fragDataReader.ReadUInt32(); // Event * * if (_event == 0x0147) // Group Chat * { * var parsed = CM_Communication.ChannelBroadcast.read(fragDataReader); * * var output = parsed.GroupChatType.ToString("X4"); * if (!specialOutputHits.ContainsKey(output)) * { * if (specialOutputHits.TryAdd(output, 0)) * specialOutputHitsQueue.Enqueue(output); * } * } * * if (_event == 0x02BD) // Tell * { * var parsed = CM_Communication.HearDirectSpeech.read(fragDataReader); * * var output = parsed.ChatMessageType.ToString("X4"); * * if (!specialOutputHits.ContainsKey(output)) * { * if (specialOutputHits.TryAdd(output, 0)) * specialOutputHitsQueue.Enqueue(output); * } * } * }*/ /*if (messageCode == 0xF7B1) // Game Action * { * }*/ /*if (messageCode == 0xF7DE) // TurbineChat * { * var parsed = CM_Admin.ChatServerData.read(fragDataReader); * * string output = parsed.TurbineChatType.ToString("X2"); * * if (!specialOutputHits.ContainsKey(output)) * { * if (specialOutputHits.TryAdd(output, 0)) * specialOutputHitsQueue.Enqueue(output); * } * }*/ /*if (messageCode == 0xF7E0) // Server Message * { * var parsed = CM_Communication.TextBoxString.read(fragDataReader); * * //var output = parsed.ChatMessageType.ToString("X4") + " " + parsed.MessageText + ","; * var output = parsed.ChatMessageType.ToString("X4"); * * if (!specialOutputHits.ContainsKey(output)) * { * if (specialOutputHits.TryAdd(output, 0)) * specialOutputHitsQueue.Enqueue(output); * } * }*/ } catch { // Do something with the exception maybe exceptions++; Interlocked.Increment(ref totalExceptions); } } } Interlocked.Increment(ref filesProcessed); processFileResuts.Add(new ProcessFileResut() { FileName = fileName, Hits = hits, Exceptions = exceptions }); }
private void ProcessFileForBuild(string fileName) { var records = PCapReader.LoadPcap(fileName, ref searchAborted); // Temperorary objects var allFrags = new List <FragDatListFile.FragDatInfo>(); var createObjectFrags = new List <FragDatListFile.FragDatInfo>(); foreach (var record in records) { if (searchAborted || Disposing || IsDisposed) { return; } // ******************************************************************** // ************************ Custom Search Code ************************ // ******************************************************************** foreach (BlobFrag frag in record.netPacket.fragList_) { try { if (frag.dat_.Length <= 4) { continue; } Interlocked.Increment(ref fragmentsProcessed); FragDatListFile.PacketDirection packetDirection = (record.isSend ? FragDatListFile.PacketDirection.ClientToServer : FragDatListFile.PacketDirection.ServerToClient); // Write to emperorary object allFrags.Add(new FragDatListFile.FragDatInfo(packetDirection, record.index, frag.dat_)); BinaryReader fragDataReader = new BinaryReader(new MemoryStream(frag.dat_)); var messageCode = fragDataReader.ReadUInt32(); // Write to emperorary object if (messageCode == 0xF745) // Create Object { Interlocked.Increment(ref totalHits); createObjectFrags.Add(new FragDatListFile.FragDatInfo(packetDirection, record.index, frag.dat_)); } } catch { // Do something with the exception maybe Interlocked.Increment(ref totalExceptions); } } } string outputFileName = (chkIncludeFullPathAndFileName.Checked ? fileName : (Path.GetFileName(fileName))); // ******************************************************************** // ************************* Write The Output ************************* // ******************************************************************** allFragDatFile.Write(new KeyValuePair <string, IList <FragDatListFile.FragDatInfo> >(outputFileName, allFrags)); createObjectFragDatFile.Write(new KeyValuePair <string, IList <FragDatListFile.FragDatInfo> >(outputFileName, createObjectFrags)); Interlocked.Increment(ref filesProcessed); }
private void ProcessFileForBuild(string fileName) { // NOTE: If you want to get fully constructed/merged messages instead of fragments: // Pass true below and use record.data as the full message, instead of individual record.frags var isPcapng = false; var records = PCapReader.LoadPcap(fileName, false, ref searchAborted, ref isPcapng); // Temperorary objects var allFrags = new List <FragDatListFile.FragDatInfo>(); var createObjectFrags = new List <FragDatListFile.FragDatInfo>(); foreach (var record in records) { if (searchAborted || Disposing || IsDisposed) { return; } // ******************************************************************** // ************************ Custom Search Code ************************ // ******************************************************************** foreach (BlobFrag frag in record.frags) { try { if (frag.dat_.Length <= 4) { continue; } Interlocked.Increment(ref fragmentsProcessed); FragDatListFile.PacketDirection packetDirection = (record.isSend ? FragDatListFile.PacketDirection.ClientToServer : FragDatListFile.PacketDirection.ServerToClient); // Write to emperorary object allFrags.Add(new FragDatListFile.FragDatInfo(packetDirection, record.index, frag.dat_)); //BinaryReader fragDataReader = new BinaryReader(new MemoryStream(frag.dat_)); //var messageCode = fragDataReader.ReadUInt32(); int messageCode = BitConverter.ToInt32(frag.dat_, 0); // Write to emperorary object if (messageCode == 0xF745) // Create Object { Interlocked.Increment(ref totalHits); createObjectFrags.Add(new FragDatListFile.FragDatInfo(packetDirection, record.index, frag.dat_)); } } catch { // Do something with the exception maybe Interlocked.Increment(ref totalExceptions); } } } string outputFileName = (chkIncludeFullPathAndFileName.Checked ? fileName : (Path.GetFileName(fileName))); // ******************************************************************** // ************************* Write The Output ************************* // ******************************************************************** allFragDatFile.Write(new KeyValuePair <string, IList <FragDatListFile.FragDatInfo> >(outputFileName, allFrags)); createObjectFragDatFile.Write(new KeyValuePair <string, IList <FragDatListFile.FragDatInfo> >(outputFileName, createObjectFrags)); Interlocked.Increment(ref filesProcessed); }