/// <summary> /// Save log file button, opens save dialog to save all logged packets. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnSave_Click(object sender, EventArgs e) { SaveLogDialog.FileName = DateTime.Now.ToString("yyyyMMdd_HHmmss"); if (SaveLogDialog.ShowDialog() == DialogResult.Cancel) { return; } try { using (var stream = SaveLogDialog.OpenFile()) using (var sw = new StreamWriter(stream)) { for (int i = LstPackets.Items.Count - 1; i >= 0; --i) { var palePacket = (PalePacket)LstPackets.Items[i].Tag; var method = palePacket.Received ? "Recv" : "Send"; var time = palePacket.Time.ToString("hh:mm:ss.fff"); var packetStr = HexTool.ToString(palePacket.Packet.GetBuffer()); sw.WriteLine(method + "@" + time + " " + packetStr); } LblCurrentFileName.Text = Path.GetFileName(SaveLogDialog.FileName); } } catch (Exception ex) { MessageBox.Show("Failed to save file (" + ex.Message + ").", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <param name="packet">Packet to test.</param> /// <param name="opNames">Definitions pairing opcodes with their human-readable name.</param> /// <returns>Whether <paramref name="packet"/> matches against this SearchParametres object.</returns> /// <exception cref="InvalidOperationException">Thrown if this SearchParametres object has its search mode set to 'NoOp'.</exception> public bool IsMatch(PalePacket packet, Dictionary <int, string> opNames) { // Handle obvious mismatches if (this.SearchMode == SearchModes.NoOp) { throw new InvalidOperationException("This object has its search mode set to 'NoOp'. Cannot evaluate packet."); return(false); } if (!this.PacketBounds.HasFlag(packet.Received ? SendOrRecv.Recv : SendOrRecv.Send)) { return(false); } // Begin probing packet if (this.SearchMode == SearchModes.Hexadecimal) { return(HexTool.ToString(packet.Packet.GetBuffer()).IndexOf(this.StringQuery, StringComparison.OrdinalIgnoreCase) >= 0); } else //if (this.SearchMode == SearchModes.String) { StringComparison comp = this.CaseSensitive ? StringComparison.Ordinal : StringComparison.OrdinalIgnoreCase; if (this.LookAt.HasFlag(LookAtCandidates.Ops)) { if ((opNames.ContainsKey(packet.Op) && opNames[packet.Op].IndexOf(this.StringQuery, comp) >= 0) || // Try op name (packet.Op.ToString("X8").IndexOf(this.StringQuery, StringComparison.OrdinalIgnoreCase) >= 0)) // Try op code { return(true); } } if (this.LookAt.HasFlag(LookAtCandidates.Ids)) { if (packet.Id.ToString("X16").IndexOf(this.StringQuery, StringComparison.OrdinalIgnoreCase) >= 0) { return(true); } } if (this.LookAt.HasFlag(LookAtCandidates.Data_String)) { if (packet.ToString().IndexOf(this.StringQuery, comp) >= 0) { return(true); } } return(false); } }
/// <summary> /// Copies selected packet's buffer as hex string. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnMenuPacketsCopyHex_Click(object sender, EventArgs e) { var selected = GetSelectedPacket(); if (selected == null) { return; } var str = HexTool.ToString(selected.Packet.GetBuffer()); Clipboard.SetText(str); }
/// <param name="packet">Packet to test.</param> /// <param name="opNames">Definitions pairing opcodes with their human-readable name.</param> /// <returns>Whether <paramref name="packet"/> matches against this SearchParametres object.</returns> /// <exception cref="InvalidOperationException">Thrown if this SearchParametres object has its search mode set to 'NoOp'.</exception> public bool IsMatch(PalePacket packet, Dictionary <int, string> opNames) { // Handle obvious mismatches if (this.SearchMode == SearchModes.NoOp) { throw new InvalidOperationException("This object has its search mode set to 'NoOp'. Cannot evaluate packet."); return(false); } if (!this.PacketBounds.HasFlag(packet.Received ? SendOrRecv.Recv : SendOrRecv.Send)) { return(false); } // Begin probing packet if (this.SearchMode == SearchModes.Hexadecimal) { return(HexTool.ToString(packet.Packet.GetBuffer()).Contains(this.StringQuery)); } else //if (this.SearchMode == SearchModes.String) { if (this.LookAt.HasFlag(LookAtCandidates.Ops)) { if (opNames.ContainsKey(packet.Op) && opNames[packet.Op].Contains(this.StringQuery)) { return(true); } } if (this.LookAt.HasFlag(LookAtCandidates.Ids)) { if (packet.Id.ToString("X16").Contains(this.StringQuery.ToUpper())) { return(true); } } if (this.LookAt.HasFlag(LookAtCandidates.Data_String)) { if (packet.ToString().Contains(this.StringQuery)) { return(true); } } return(false); } }
public new void SendPacket(COutPacket packet) { var buffer = packet.ToArray(); var opcode = (SendOps)BitConverter.ToInt16(buffer, 0); if (Constants.FilterSendOpCode(opcode) == false) { var name = Enum.GetName(typeof(SendOps), opcode); var str = HexTool.ToString(buffer); Log.InfoFormat("Send [{0}] {1}", name, str); } base.SendPacket(packet); }
protected override void HandlePacket(TClient client, CInPacket packet) { var buffer = packet.ToArray(); var opcode = (RecvOps)BitConverter.ToInt16(buffer, 0); if (Constants.FilterRecvOpCode(opcode) == false) { var name = Enum.GetName(typeof(RecvOps), opcode); var str = HexTool.ToString(buffer); Log.InfoFormat("Recv [{0}] {1}", name, str); } PacketHandler.Handle(client, packet); }
private void Handle_ClientDumpLog(WvsLoginClient c, CInPacket p) { //Thank you to Mordred for this handler! var callType = p.Decode2(); var errorCode = p.Decode4(); var backupBufferSize = p.Decode2(); var rawSeq = p.Decode4(); var type = p.Decode2(); var backupBuffer = p.DecodeBuffer(backupBufferSize - 6); var callTypeName = Enum.GetName(typeof(CrashCallType), callType); var logTypeName = Enum.GetName(typeof(SendOps), type); Log.DebugFormat( "RawSeq: {0} CallType: {1} ErrorCode: {2} BackupBufferSize: {3} Type: {4} - {5} Packet: {6}", rawSeq, callTypeName, errorCode, backupBufferSize, type, logTypeName, HexTool.ToString(backupBuffer) ); }
private void SetDefaultTextBoxAESUserKey() { byte[] AESUserKey = MapleCryptoConstants.MAPLESTORY_USERKEY_DEFAULT; textBox_AESUserKey1.Text = HexTool.ToString(AESUserKey[0 * 4]); textBox_AESUserKey2.Text = HexTool.ToString(AESUserKey[1 * 4]); textBox_AESUserKey3.Text = HexTool.ToString(AESUserKey[2 * 4]); textBox_AESUserKey4.Text = HexTool.ToString(AESUserKey[3 * 4]); textBox_AESUserKey5.Text = HexTool.ToString(AESUserKey[4 * 4]); textBox_AESUserKey6.Text = HexTool.ToString(AESUserKey[5 * 4]); textBox_AESUserKey7.Text = HexTool.ToString(AESUserKey[6 * 4]); textBox_AESUserKey8.Text = HexTool.ToString(AESUserKey[7 * 4]); textBox_AESUserKey9.Text = HexTool.ToString(AESUserKey[8 * 4]); textBox_AESUserKey10.Text = HexTool.ToString(AESUserKey[9 * 4]); textBox_AESUserKey11.Text = HexTool.ToString(AESUserKey[10 * 4]); textBox_AESUserKey12.Text = HexTool.ToString(AESUserKey[11 * 4]); textBox_AESUserKey13.Text = HexTool.ToString(AESUserKey[12 * 4]); textBox_AESUserKey14.Text = HexTool.ToString(AESUserKey[13 * 4]); textBox_AESUserKey15.Text = HexTool.ToString(AESUserKey[14 * 4]); textBox_AESUserKey16.Text = HexTool.ToString(AESUserKey[15 * 4]); textBox_AESUserKey17.Text = HexTool.ToString(AESUserKey[16 * 4]); textBox_AESUserKey18.Text = HexTool.ToString(AESUserKey[17 * 4]); textBox_AESUserKey19.Text = HexTool.ToString(AESUserKey[18 * 4]); textBox_AESUserKey20.Text = HexTool.ToString(AESUserKey[19 * 4]); textBox_AESUserKey21.Text = HexTool.ToString(AESUserKey[20 * 4]); textBox_AESUserKey22.Text = HexTool.ToString(AESUserKey[21 * 4]); textBox_AESUserKey23.Text = HexTool.ToString(AESUserKey[22 * 4]); textBox_AESUserKey24.Text = HexTool.ToString(AESUserKey[23 * 4]); textBox_AESUserKey25.Text = HexTool.ToString(AESUserKey[24 * 4]); textBox_AESUserKey26.Text = HexTool.ToString(AESUserKey[25 * 4]); textBox_AESUserKey27.Text = HexTool.ToString(AESUserKey[26 * 4]); textBox_AESUserKey28.Text = HexTool.ToString(AESUserKey[27 * 4]); textBox_AESUserKey29.Text = HexTool.ToString(AESUserKey[28 * 4]); textBox_AESUserKey30.Text = HexTool.ToString(AESUserKey[29 * 4]); textBox_AESUserKey31.Text = HexTool.ToString(AESUserKey[30 * 4]); textBox_AESUserKey32.Text = HexTool.ToString(AESUserKey[31 * 4]); }