public void Write(DataFrames.DataFrame frame) { if (frame == null) { _eventHandle.Set(); } }
private void SendPacket(DataFrames.DataFrame frame) { if (!_drop) { WriteOutput(frame); } }
protected override void OnInput(DataFrames.DataFrame frame) { DataNode[] nodes = frame.SelectNodes(SelectionPath); foreach (DataNode node in nodes) { byte[] data = node.ToArray(); bool match = false; int i = 0; for (i = 0; i < data.Length - Config.Match.Length + 1; ++i) { match = GeneralUtils.MatchArray(data, i, Config.Match); if (match) { break; } } if (match) { byte[] newArray = new byte[data.Length - Config.Match.Length + Config.Replacement.Length]; Buffer.BlockCopy(data, 0, newArray, 0, i); Buffer.BlockCopy(Config.Replacement, 0, newArray, i, Config.Replacement.Length); Buffer.BlockCopy(data, i + Config.Match.Length, newArray, i + Config.Replacement.Length, data.Length - i - Config.Match.Length); node.ReplaceNode(newArray); } } WriteOutput(frame); }
protected override void OnInput(DataFrames.DataFrame frame) { DataNode[] nodes = frame.SelectNodes(SelectionPath); Encoding encoding = GeneralUtils.GetEncodingFromType(Config.Encoding); foreach (DataNode node in nodes) { MemoryStream stm = new MemoryStream(node.ToArray()); DataReader reader = new DataReader(stm); StringBuilder builder = new StringBuilder(); try { while (!reader.Eof) { builder.Append(reader.ReadChar(encoding)); } } catch (EndOfStreamException) { } node.ReplaceNode(builder.ToString(), encoding); } WriteOutput(frame); }
protected override void OnInput(DataFrames.DataFrame frame) { DataNode node = frame.SelectSingleNode(Config.PathName); if (node != null) { frame.Current = node; } WriteOutput(frame); }
/// <summary> /// Write data adapter /// </summary> /// <param name="data">The frame to write</param> public override void Write(DataFrames.DataFrame data) { if (_boundAdapter != null) { _boundAdapter.Write(data); } else { throw new InvalidOperationException(); } }
protected override void OnInput(DataFrames.DataFrame frame) { if ((!_init) && (Config.PacketLog != null)) { _packets = Config.PacketLog.GetPackets(); _prefix = Config.Prefix; _drop = Config.DropTrigger; _currPacket = 0; _init = true; } if (!_prefix) { SendPacket(frame.CloneFrame()); } if (_init) { if (Config.Sequential) { if (_currPacket < _packets.Length) { WriteOutput(_packets[_currPacket++].Frame.CloneFrame()); } if (_currPacket == _packets.Length) { if (Config.Repeat) { _currPacket = 0; } } } else if (!_sent) { foreach (LogPacket packet in _packets) { WriteOutput(packet.Frame.CloneFrame()); } if (!Config.Repeat) { _sent = true; } } } if (_prefix) { SendPacket(frame.CloneFrame()); } }
protected override void OnInput(DataFrames.DataFrame frame) { DataNode[] nodes = frame.SelectNodes(SelectionPath); foreach (DataNode node in nodes) { DataValue value = node as DataValue; if ((value != null) && (value.Value is string)) { value.Value = _re.Replace(value.Value, Config.Replacement); } else { string s = _re.Replace(_encoding.GetString(node.ToArray()), Config.Replacement); node.ReplaceNode(_encoding.GetBytes(s)); } } WriteOutput(frame); }
protected override void OnInput(DataFrames.DataFrame frame) { DataNode[] nodes = frame.SelectNodes(SelectionPath); DataFrame preFuzzFrame = null; int nodeCount = nodes.Length; bool fuzzed = false; if (nodeCount > 0) { if (Config.LogPackets) { preFuzzFrame = frame.CloneFrame(); } } foreach (DataNode node in nodes) { DataValue value = node as DataValue; string fuzzString; if ((value != null) && (value.Value is string)) { fuzzString = value.Value; } else { if (Config.NoConversion) { continue; } value = null; fuzzString = _encoding.GetString(node.ToArray()); } int fuzzLength = FuzzerUtils.GetFuzzLength(fuzzString.Length, Config.FuzzStart, Config.FuzzLength); string newString; if ((Config.FuzzStart == 0) && (fuzzLength == fuzzString.Length)) { newString = FuzzString(fuzzString); } else if ((Config.FuzzStart >= 0) && (fuzzLength > 0)) { string prefixString = fuzzString.Substring(0, Config.FuzzStart); string suffixString = fuzzString.Substring(Config.FuzzStart + fuzzLength); newString = String.Concat(prefixString, FuzzString(fuzzString.Substring(Config.FuzzStart, fuzzLength)), suffixString); } else { continue; } if (newString != fuzzString) { fuzzed = true; if (Config.LogFuzzText) { LogInfo("Fuzzed string '{0}'", fuzzString); } } if (value != null) { value.Value = newString; } else { node.ReplaceNode(_encoding.GetBytes(newString)); } } if (nodeCount > 0) { if (Config.LogPackets) { if (fuzzed) { Graph.DoLogPacket(String.Format("{0}: Pre-fuzz", Name), Config.Color, preFuzzFrame, Config.ConvertToBytes); Graph.DoLogPacket(String.Format("{0}: Post-fuzz", Name), Config.Color, frame, Config.ConvertToBytes); } } } WriteOutput(frame); }
/// <summary> /// /// </summary> /// <param name="frame"></param> protected override void OnInput(DataFrames.DataFrame frame) { bool writtenOutput = false; DataNode node = SelectSingleNode(frame); if (node != null) { string name = node.ToString(); if (_mode == SwitchNodeSelectionMode.ExactMatch) { if (HasOutput(name)) { WriteOutput(frame, name); writtenOutput = true; } } else { foreach (OutputNode output in _output) { try { if (!String.IsNullOrEmpty(output.PathName)) { Regex r; if (_regexs.ContainsKey(output.PathName)) { r = _regexs[output.PathName]; } else { r = _mode == SwitchNodeSelectionMode.RegexMatch ? new Regex(output.PathName, RegexOptions.Multiline | RegexOptions.IgnoreCase) : GeneralUtils.GlobToRegex(output.PathName); _regexs[output.PathName] = r; } if (r.IsMatch(name)) { WriteOutput(frame, output.PathName); writtenOutput = true; break; } } } catch (ArgumentException ex) { LogException(ex); } } } } if (!writtenOutput && !_dropUnknown) { WriteOutput(frame); } }
/// <summary> /// /// </summary> /// <param name="frame"></param> protected override sealed void ClientWrite(DataFrames.DataFrame frame) { WriteClientFrame(_client, frame); }
/// <summary> /// /// </summary> /// <param name="frame"></param> protected override void ServerWrite(DataFrames.DataFrame frame) { WriteServerFrame(_server, frame); }
protected override void OnInput(DataFrames.DataFrame frame) { // Do nothing, anything matching the filters should be dropped }
protected override void OnInput(DataFrames.DataFrame frame) { Frames.Add(frame); }
public override void Write(DataFrames.DataFrame data) { _adapter.Enqueue(data); }
protected override void OnInput(DataFrames.DataFrame frame) { DataNode[] nodes = frame.SelectNodes(SelectionPath); DataFrame preFuzz = null; bool fuzzed = false; if (nodes.Length > 0) { if (Config.LogPackets) { preFuzz = frame.CloneFrame(); } } foreach (DataNode node in nodes) { U[] data = NodeToArray(node); if (data == null) { LogVerbose(CANAPE.NodeLibrary.Properties.Resources.BaseRandomArrayFuzzer_IgnoringData, node.Name); continue; } int fuzzLength = FuzzerUtils.GetFuzzLength(data.Length, Config.FuzzStart, Config.FuzzLength); if (fuzzLength > 0) { int points = GetPointCount(fuzzLength); if (Config.LogFuzzText) { LogVerbose(CANAPE.NodeLibrary.Properties.Resources.BaseRandomArrayFuzzer_FuzzCount, points); } while (points > 0) { int pos = _random.Next(Config.FuzzStart, Config.FuzzStart + fuzzLength); BaseRandomArrayFuzzerConfig.FuzzCombinationMode mode = Config.CombinationMode; if (mode == BaseRandomArrayFuzzerConfig.FuzzCombinationMode.Random) { mode = (BaseRandomArrayFuzzerConfig.FuzzCombinationMode)_random.Next((int)BaseRandomArrayFuzzerConfig.FuzzCombinationMode.Max); } if ((pos >= 0) && (pos < data.Length)) { U value = FuzzValue(mode, data[pos]); if (!value.Equals(data[pos])) { fuzzed = true; if (Config.LogFuzzText) { LogInfo(CANAPE.NodeLibrary.Properties.Resources.BaseRandomArrayFuzzer_FuzzInfo, pos, data[pos], value); } } data[pos] = value; } points--; } node.ReplaceNode(ArrayToNode(data, node)); } } if (fuzzed) { if (Config.LogPackets) { Graph.DoLogPacket(String.Format(CANAPE.NodeLibrary.Properties.Resources.BaseRandomArrayFuzzer_PreFuzzInfo, Name), Config.Color, preFuzz, Config.ConvertToBytes); Graph.DoLogPacket(String.Format(CANAPE.NodeLibrary.Properties.Resources.BaseRandomArrayFuzzer_PostFuzzInfo, Name), Config.Color, frame, Config.ConvertToBytes); } } WriteOutput(frame); }