public void AppendChunk(int value) { _chunks.Add(value); string encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, value)); AddItemChunk("Integer", value, encoded); }
private void FTCreateBtn_Click(object sender, EventArgs e) { if (!IsFilterAuthorized(Header, Destination, Action)) { return; } HMessage packet = null; if (Action == FilterAction.Replace) { packet = GetPacket(); if (!Parent.IsInjectionAuthorized(packet)) { return; } _replacements[Destination][Header] = packet; } else { _blocked[Destination].Add(Header); } ListViewItem item = UI.FTFiltersVw.AddFocusedItem( Header, Destination, Action, (packet?.ToString() ?? string.Empty)); var filter = new Tuple <HDestination, ushort>(Destination, Header); item.Checked = true; item.Tag = filter; UpdateUI(); }
private void sendBt_Click(object sender, RoutedEventArgs e) { HMessageOptions mOptions = new HMessageOptions(); if (persistentCb.IsChecked.Value) { mOptions.Persistent = true; } else { mOptions.Persistent = false; } if (!string.IsNullOrEmpty(timeoutTbx.Text)) { mOptions.Timeout = int.Parse(timeoutTbx.Text); } if (!string.IsNullOrEmpty(relevantTbx.Text)) { mOptions.RelevanceOffset = int.Parse(relevantTbx.Text); } HMessage hMsg = client.BuildMessage(actorTbx.Text, "text", msgTbx.Text, mOptions); client.Send(hMsg, null); Debug.WriteLine(">>>Send Message<<<\n" + hMsg.ToString() + "\n"); }
public void Append(params object[] chunks) { _packet.Append(chunks); try { BeginUpdate(); ListViewItem item = null; byte[] data = new byte[0]; SuppressItemSelectedEvent = true; string typeName = string.Empty, value = string.Empty, encoded = string.Empty; foreach (object chunk in chunks) { value = chunk.ToString(); data = HMessage.Encode(chunk); encoded = HMessage.ToString(data); typeName = chunk.GetType().Name.Replace("Int32", "Integer"); item = FocusAdd(typeName, value, encoded); item.ToolTipText = string.Format(CHUNK_TIP, typeName, value, data.Length, encoded); } SuppressItemSelectedEvent = false; OnItemSelected(new ListViewItemSelectionChangedEventArgs(item, item.Index, true)); } finally { EndUpdate(); } }
public void AppendChunk(bool Value) { HMChunks.Add(Value); string Encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, Value)); AddItemChunk("Boolean", Value, Encoded); }
public void Write(params object[] values) { _packet.WriteObjects(values); try { BeginUpdate(); ListViewItem item = null; SuppressItemSelectedEvent = true; foreach (object value in values) { string valueString = value.ToString(); byte[] data = HMessage.GetBytes(value); string encoded = HMessage.ToString(data); string typeName = value.GetType().Name.Replace("Int32", "Integer"); item = FocusAdd(typeName, valueString, encoded); item.ToolTipText = string.Format(CHUNK_TIP, typeName, valueString, data.Length, encoded); } SuppressItemSelectedEvent = false; OnItemSelected(new ListViewItemSelectionChangedEventArgs(item, item.Index, true)); } finally { EndUpdate(); } }
public void ReplaceSelected(object value) { _lastHeader = 0; int index = SelectedIndices[0]; if (value.Equals(_chunks[index])) { return; } _chunks[index] = value; ListViewItem curItem = Items[index]; string type = value is string? "String" : value is int? "Integer" : "Boolean"; string encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, value)); curItem.SubItems[0].Text = type; curItem.SubItems[1].Text = value.ToString(); curItem.SubItems[2].Text = encoded; string encodedLength = string.Empty; if (value is string) { if ((Destination == HDestination.Server && Protocol == HProtocol.Ancient) || Protocol == HProtocol.Modern) { ushort valueLength = (ushort)value.ToString().Length; byte[] data = Protocol == HProtocol.Ancient ? Ancient.CypherShort(valueLength) : Modern.CypherShort(valueLength); encodedLength = HMessage.ToString(data) + " | "; } } curItem.ToolTipText = string.Format("Type: {0}\nValue: {1}\n{2}Encoded: {3}", type, value, string.Format("Length: {0}{1}\n", encodedLength, value.ToString().Length), encoded); }
private void PTPacketTxt_TextChanged(object sender, EventArgs e) { ushort header = 0; bool isCorrupted = false; string packetTxt = MainUI.PTPacketTxt.Text; byte[] data = HMessage.ToBytes(packetTxt); int length = data.Length; if (length < 6) { isCorrupted = true; } else { length = BigEndian.ToSI32(data); header = BigEndian.ToUI16(data, 4); int realLength = data.Length - 4; isCorrupted = (realLength != length); } MainUI.ITPacketTxt.Text = isCorrupted ? MainUI.PTPacketTxt.Text : HMessage.ToString(data); MainUI.PTPacketInfoLbl.Text = $"Header: {header} | Length: {length} | IsCorrupted:"; MainUI.PTIsCorruptedLbl.Text = isCorrupted.ToString(); MainUI.PTIsCorruptedLbl.ForeColor = isCorrupted ? Color.Firebrick : SystemColors.HotTrack; }
public void ReplaceSelected(object Value) { int Index = SelectedIndices[0]; if (Value.Equals(HMChunks[Index])) { return; } HMChunks[Index] = Value; ListViewItem CurItem = Items[Index]; string Type = Value is string? "String" : Value is int? "Integer" : "Boolean"; string Encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, Value)); Items[Index].SubItems[0].Text = Type; Items[Index].SubItems[1].Text = Value.ToString(); Items[Index].SubItems[2].Text = Encoded; string EncodedLength = string.Empty; if (Value is string) { if ((Destination == HDestinations.Server && Protocol == HProtocols.Ancient) || Protocol == HProtocols.Modern) { EncodedLength = (Protocol == HProtocols.Modern ? HMessage.ToString(BigEndian.CypherShort((ushort)Value.ToString().Length)) : HMessage.ToString(Ancient.CypherShort((ushort)Value.ToString().Length))) + " | "; } } Items[Index].ToolTipText = string.Format("Type: {0}\nValue: {1}\n{2}Encoded: {3}", Type, Value, string.Format("Length: {0}{1}\n", EncodedLength, Value.ToString().Length), Encoded); }
private void ReconstructList(bool stringsOnly) { BeginUpdate(); for (int i = 0; i < _chunks.Count; i++) { object chunk = _chunks[i]; if (!(chunk is string) && stringsOnly) { continue; } string encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, chunk)); Items[i].SubItems[2].Text = encoded; var value = chunk as string; if (value != null) { string encodedLength = string.Empty; if ((Destination == HDestination.Server && Protocol == HProtocol.Ancient) || Protocol == HProtocol.Modern) { ushort valueLength = (ushort)value.Length; byte[] data = Protocol == HProtocol.Ancient ? Ancient.CypherShort(valueLength) : Modern.CypherShort(valueLength); encodedLength = HMessage.ToString(data) + " | "; } Items[i].ToolTipText = string.Format("Type: String\nValue: {0}\n{1}Encoded: {2}", value, string.Format("Length: {0}{1}\n", encodedLength, value.Length), encoded); } else { Items[i].ToolTipText = Items[i].ToolTipText.Replace(Items[i].ToolTipText.GetChild("Encoded: ", '\n'), encoded); } } EndUpdate(); }
private void ReconstructList(bool StringsOnly) { BeginUpdate(); for (int i = 0; i < HMChunks.Count; i++) { object Chunk = HMChunks[i]; if (!(Chunk is string) && StringsOnly) { continue; } string Encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, Chunk)); Items[i].SubItems[2].Text = Encoded; if (Chunk is string) { string Value = (string)Chunk; string EncodedLength = string.Empty; if ((Destination == HDestinations.Server && Protocol == HProtocols.Ancient) || Protocol == HProtocols.Modern) { EncodedLength = (Protocol == HProtocols.Modern ? HMessage.ToString(BigEndian.CypherShort((ushort)Value.Length)) : HMessage.ToString(Ancient.CypherShort((ushort)Value.Length))) + " | "; } Items[i].ToolTipText = string.Format("Type: String\nValue: {0}\n{1}Encoded: {2}", Value, string.Format("Length: {0}{1}\n", EncodedLength, Value.Length), Encoded); } else { Items[i].ToolTipText = Items[i].ToolTipText.Replace(Items[i].ToolTipText.GetChild("Encoded: ", '\n'), Encoded); } } EndUpdate(); }
private void ICCopyPacketBtn_Click(object sender, EventArgs e) { HMessage packet = GetConstructerPacket(); if (packet != null) { Clipboard.SetText(packet.ToString()); } }
private void ICTransferBtn_Click(object sender, EventArgs e) { HMessage packet = GetConstructerPacket(); if (packet != null) { IPacketTxt.Text = packet.ToString(); } }
/// <summary> /// Initializes a new instance of the <see cref="DataInterceptedEventArgs"/> class. /// </summary> /// <param name="packet">The intercepted message.</param> /// <param name="step">The current count/step/order of the intercepted message.</param> public DataInterceptedEventArgs(HMessage packet, int step, bool isOutgoing) { _ogData = packet.ToBytes(); _ogString = packet.ToString(); Step = step; Packet = packet; IsOutgoing = isOutgoing; Timestamp = DateTime.Now; }
/// <summary> /// Initializes a new instance of the <see cref="DataInterceptedEventArgs"/> class. /// </summary> /// <param name="continuation">The <see cref="Func{TResult}"/> of type <see cref="Task"/> that will be invoked when <see cref="ContinueRead"/> is called.</param> /// <param name="step">The current count/step/order from which this data was intercepted.</param> /// <param name="packet">The intercepted data to read/write from.</param> public DataInterceptedEventArgs(HMessage packet, int step, Func <Task> continuation) : base(continuation) { _ogData = packet.ToBytes(); _ogString = packet.ToString(); _ogDestination = packet.Destination; Step = step; Packet = packet; Executions = new List <HMessage>(); }
private void ICSchedulerBtn_Click(object sender, EventArgs e) { IInjectionTabs.SelectTab(ISchedulerTab); HMessage packet = GetConstructerPacket(); if (packet != null) { ISPacketTxt.Text = packet.ToString(); } }
public void SetItemPacket(HMessage packet) { if (SelectedItems.Count < 1) { return; } ListViewItem item = SelectedItems[0]; _schedules[item].Packet = packet; item.SubItems[0].Text = packet.ToString(); item.SubItems[1].Text = packet.Destination.ToString(); }
private void EDCypherIntegerBtn_Click(object sender, EventArgs e) { int value; if (int.TryParse(EDIntegerInputTxt.Text, out value)) { EDIntegerOutputTxt.Text = HMessage.ToString(BigEndian.CypherInt(value)); } else { MessageBox.Show(NotInt32, "Tanji ~ Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AncientCypherShortBtn_Click(object sender, EventArgs e) { ushort value; if (ushort.TryParse(AncientShortInputTxt.Text, out value)) { AncientShortOutputTxt.Text = HMessage.ToString(Ancient.CypherShort(value)); } else { MessageBox.Show(NotUInt16, TanjiError, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AncientCypherIntegerBtn_Click(object sender, EventArgs e) { int value; if (int.TryParse(AncientIntegerInputTxt.Text, out value)) { AncientIntegerOutputTxt.Text = HMessage.ToString(Ancient.CypherInt(value)); } else { MessageBox.Show(NotInt32, TanjiError, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void EDCypherShortBtn_Click(object sender, EventArgs e) { ushort value; if (ushort.TryParse(EDShortInputTxt.Text, out value)) { EDShortOutputTxt.Text = HMessage.ToString(BigEndian.CypherShort(value)); } else { MessageBox.Show(NotUInt16, "Tanji ~ Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void AppendChunk(string Value) { HMChunks.Add(Value); string EncodedLength = string.Empty; string Encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, Value)); if ((Destination == HDestinations.Server && Protocol == HProtocols.Ancient) || Protocol == HProtocols.Modern) { EncodedLength = (Protocol == HProtocols.Modern ? HMessage.ToString(BigEndian.CypherShort((ushort)Value.Length)) : HMessage.ToString(Ancient.CypherShort((ushort)Value.Length))) + " | "; } AddItemChunk("String", Value, Encoded, string.Format("Length: {0}{1}\n", EncodedLength, Value.Length)); }
private void PTPacketTxt_TextChanged(object sender, EventArgs e) { HMessage packet = GetPacket(); UI.ITPacketTxt.Text = packet.ToString(); UI.PTHeaderTxt.Text = packet.Header.ToString(); UI.PTLengthTxt.Text = packet.Length.ToString("n0"); UI.PTCorruptedTxt.Text = packet.IsCorrupted.ToString(); UI.PTCorruptedTxt.BackColor = (packet.IsCorrupted ? UI.PacketLoggerUI.IncomingHighlight : UI.PacketLoggerUI.OutgoingHighlight); }
public void AppendChunk(string value) { _chunks.Add(value); string encodedLength = string.Empty; string encoded = HMessage.ToString(HMessage.ConstructBody(Destination, Protocol, value)); if (Destination == HDestination.Server || Protocol == HProtocol.Modern) { ushort valueLength = (ushort)value.Length; byte[] data = Protocol == HProtocol.Ancient ? Ancient.CypherShort(valueLength) : Modern.CypherShort(valueLength); encodedLength = HMessage.ToString(data) + " | "; } AddItemChunk("String", value, encoded, string.Format("Length: {0}{1}\n", encodedLength, value.Length)); }
public void ReplaceItem(object chunk) { ListViewItem item = SelectedItems[0]; _packet.ReplaceChunk(item.Index, chunk); item.SubItems[0].Text = chunk.GetType().Name .Replace("Int32", "Integer"); byte[] data = HMessage.Encode(chunk); item.SubItems[1].Text = chunk.ToString(); item.SubItems[2].Text = HMessage.ToString(data); item.ToolTipText = string.Format(CHUNK_TIP, item.SubItems[0].Text, item.SubItems[1].Text, data.Length, item.SubItems[2].Text); }
private void PTPacketTxt_TextChanged(object sender, System.EventArgs e) { var packet = new HMessage(UI.PTPacketTxt.Text); UI.ITPacketTxt.Text = packet.ToString(); UI.PTPacketInfoLbl.Text = $"Header: {packet.Header}, Length: {packet.Length}"; UI.PTCorruptedValueLbl.Text = packet.IsCorrupted.ToString(); UI.PTCorruptedValueLbl.ForeColor = (packet.IsCorrupted ? UI.PacketLoggerUI.IncomingHighlight : UI.PacketLoggerUI.OutgoingHighlight); }
public void ReplaceItem(object chunk) { ListViewItem item = SelectedItems[0]; _packet.ReplaceWritten(item.Index, chunk); ListViewItem.ListViewSubItemCollection subItems = item.SubItems; subItems[0].Text = chunk.GetType().Name .Replace("Int32", "Integer"); byte[] data = HMessage.GetBytes(chunk); subItems[1].Text = chunk.ToString(); subItems[2].Text = HMessage.ToString(data); item.ToolTipText = string.Format(CHUNK_TIP, subItems[0].Text, subItems[1].Text, data.Length, subItems[2].Text); }
public async Task <int> InjectInputAsync(HDestination destination) { HMessage packet = GetPacket(); if (!AuthorizeInjection(packet)) { return(0); } packet.Destination = destination; int length = await SendAsync(packet); if (length == (packet.Length + 4)) { AddAutocomplete(packet.ToString()); } return(length); }
private void EDExtractValuesBtn_Click(object sender, EventArgs e) { EDExtracterLstvw.Items.Clear(); byte[] encodedBlocks = HMessage.ToBytes(EDEncodedBlocksTxt.Text); if (encodedBlocks.Length % 4 == 0) { int value = 0; string encoded = string.Empty; byte[] encodedBlock = new byte[4]; for (int i = 0; i < encodedBlocks.Length; i += 4) { Buffer.BlockCopy(encodedBlocks, i, encodedBlock, 0, 4); value = BigEndian.DecypherInt(encodedBlock); encoded = HMessage.ToString(encodedBlock); EDExtracterLstvw.FocusAdd(value.ToString(), encoded, i.ToString()); } } }
private void RealignBtn_Click(object sender, EventArgs e) { if (InputBox == null) { return; } int packetHeaderEnd = 0; if (!InputBox.Text.StartsWith("{l}{u:")) { ushort packetHeader = 0; byte[] packetData = HMessage.ToBytes(InputBox.Text); if (packetData.Length >= 6) { int packetLength = BigEndian.ToInt32(packetData, 0); packetHeader = BigEndian.ToUInt16(packetData, 4); byte[] headerData = new byte[6]; Buffer.BlockCopy(packetData, 0, headerData, 0, 6); if (packetLength == (packetData.Length - 4)) { string formattedHeader = HMessage.ToString(headerData); InputBox.Text = InputBox.Text.Remove(0, formattedHeader.Length); } } InputBox.Text = InputBox.Text.Insert(0, $"{{l}}{{u:{packetHeader}}}"); packetHeaderEnd = packetHeader.ToString().Length; } else { string formattedHeader = InputBox.Text .GetChild("{l}{u:").GetParent("}"); packetHeaderEnd = formattedHeader.Length; } InputBox.Select(6, packetHeaderEnd); InputBox.ScrollToCaret(); }