public override void Init(XmlElement fuzzLocationRoot, ITargetConnector connector, Dictionary<string, IFuzzLocation> predefinedFuzzers) { base.Init (fuzzLocationRoot, connector, predefinedFuzzers); IDictionary<string, string> config = DictionaryHelper.ReadDictionaryXml (fuzzLocationRoot, "FuzzerArg"); SetDataRegion (DictionaryHelper.GetString ("data_region", config, null), connector); SetDataType (DictionaryHelper.GetString ("data_type", config, null)); }
public void Init(XmlElement fuzzLocationRoot, ITargetConnector connector, Dictionary<string, IFuzzLocation> predefinedFuzzers) { IDictionary<string, string> config = DictionaryHelper.ReadDictionaryXml (fuzzLocationRoot, "FuzzerArg"); string id = DictionaryHelper.GetString ("id", config, null); if (!predefinedFuzzers.ContainsKey (id)) throw new ArgumentException (string.Format ("Could not find fuzzer with id '{0}'", id)); _childLocation = predefinedFuzzers[id]; }
/// <summary> /// Creates a new FuzzController. Once the snapshotBreakpoint is reached a snapshot is created. /// The snapshot gets restored once restore Breakpoint is reached /// </summary> /// <param name="connector">connector to use</param> /// <param name="snapshotBreakpoint">Location to create a snapshot</param> /// <param name="restoreBreakpoint">Location to restore the snapshot</param> public FuzzController(ITargetConnector connector, string logDestination, IDataLogger logger, FuzzDescription fuzzDescription, IFuzzLocation[] preConditions) { _connector = connector; _snapshot = null; _dataLogger = logger; _logDestination = logDestination; _errorLog = new ErrorLog (_logDestination); _fuzzDescription = fuzzDescription; _fuzzDescription.Init (); _preConditions = preConditions; }
public Trigger(string trigger, string triggerArgs, ITargetConnector connector) { _trigger = (TriggerEnum)Enum.Parse (typeof(TriggerEnum), trigger, true); if (_trigger == TriggerEnum.Location) { _data = FuzzDescriptionInfo.ParseRegionAddress (triggerArgs, false, connector); /*IBreakpoint myBreakpoint =*/ connector.SetSoftwareBreakpoint ( ((IAddressSpecifier)_data).ResolveAddress ().Value, 0, "Trigger at '" + triggerArgs + "'"); } else if (triggerArgs != null && triggerArgs.StartsWith ("!")) { _triggerFirst = true; _triggerCount = Int32.Parse (triggerArgs.Substring (1)); } else if(triggerArgs != null) _triggerCount = Int32.Parse (triggerArgs); }
public override void Init(XmlElement fuzzLocationRoot, ITargetConnector connector, Dictionary<string, IFuzzLocation> predefinedFuzzers) { base.Init (fuzzLocationRoot, connector, predefinedFuzzers); IDictionary<string, string> config = DictionaryHelper.ReadDictionaryXml (fuzzLocationRoot, "FuzzerArg"); _scriptEvaluator = new ScriptEvaluator<UnixSocketEnvironment> (config, this); _socket = new UnixSocketConnection (config); //Attach to the UnixSocketConnection hooks and call the associated user script _socket.Hook_BeforeSocketCreation += delegate(UnixSocketConnection conn) { _scriptEvaluator.Environment.HookType = UnixSocketHookType.BeforeSocketCreation; _scriptEvaluator.Run (); }; _socket.Hook_AfterSocketCreation += delegate(UnixSocketConnection conn) { _scriptEvaluator.Environment.HookType = UnixSocketHookType.AfterSocketCreation; _scriptEvaluator.Run (); }; _socket.Hook_AfterSocketConnect += delegate(UnixSocketConnection conn) { _scriptEvaluator.Environment.HookType = UnixSocketHookType.AfterSocketConnect; _scriptEvaluator.Run (); }; _socket.Hook_BeforeSocketClose += delegate(UnixSocketConnection conn) { _scriptEvaluator.Environment.HookType = UnixSocketHookType.BeforeSocketClose; _scriptEvaluator.Run (); }; _socket.Hook_AfterSocketClose += delegate(UnixSocketConnection conn) { _scriptEvaluator.Environment.HookType = UnixSocketHookType.AfterSocketClose; _scriptEvaluator.Run (); }; }
public CalculatedSymbolTableVariable(ITargetConnector connector, string expression, int size) { _connector = connector; _expression = expression; }
public MigratorService(ISourceConnector source, ITargetConnector target) { _source = source; _target = target; }
/// <summary> /// Initializes the connection to the target /// </summary> private void InitTargetConnection() { XmlElement connectorRoot = (XmlElement)_doc.DocumentElement.SelectSingleNode("TargetConnection"); if(connectorRoot == null) throw new ArgumentException("Could not find 'TargetConnection' node"); string connectorIdentifier = _formatter.Format(XmlHelper.ReadString(connectorRoot, "Connector")); ITargetConnector connector = GenericClassIdentifierFactory.CreateFromClassIdentifierOrType<ITargetConnector>(connectorIdentifier); if(connector == null) throw new ArgumentException(string.Format("Could not find connector with identifier '{0}'", connectorIdentifier)); IDictionary<string, string > configuration = new Dictionary<string, string>(); foreach(XmlElement configNode in connectorRoot.SelectNodes("Config")) configuration.Add(configNode.GetAttribute("key"), _formatter.Format(configNode.InnerXml)); connector.Setup(configuration); connector.Connect(); _connector = connector; }
private void ReadTriggers(XmlElement root, ITargetConnector connector) { List<ITrigger> triggers = new List<ITrigger> (); foreach (XmlElement triggerNode in root.SelectNodes ("Trigger")) { string[] splittedTrigger = triggerNode.InnerText.Split (new char[] { '|' }, 2); string triggerType = splittedTrigger[0]; string triggerArgs = null; if (splittedTrigger.Length > 1) triggerArgs = splittedTrigger[1]; triggers.Add (new Trigger (triggerType, triggerArgs, connector)); } _triggers = triggers.ToArray (); }
public virtual void Init(XmlElement fuzzLocationRoot, ITargetConnector connector, Dictionary<string, IFuzzLocation> predefinedFuzzers) { _connector = connector; }
public StackFrameLogger(ITargetConnector connector, string path) { _connector = connector; _path = path; }
private void SetDataRegion(string regionSpecifier, ITargetConnector connector) { KeyValuePair<string, string>? regionSpecifierPair = StringHelper.SplitToKeyValue (regionSpecifier, "|"); if (regionSpecifierPair == null) throw new FuzzParseException ("DataRegion contains invalid formatted specifier '{0}'", regionSpecifier); switch (regionSpecifierPair.Value.Key) { case "variable": _fuzzTarget = connector.SymbolTable.CreateVariable (regionSpecifierPair.Value.Value, 8); break; case "address": UInt64 address; if (regionSpecifierPair.Value.Value.StartsWith ("0x", StringComparison.InvariantCultureIgnoreCase) && UInt64.TryParse (regionSpecifierPair.Value.Value.Substring (2), NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out address)) _fuzzTarget = connector.SymbolTable.CreateVariable (new StaticAddress (address), 8); else throw new FuzzParseException ("Cannot parse address in format '{0}' use '0x12345678'", regionSpecifierPair.Value.Value); break; case "calc": _fuzzTarget = connector.SymbolTable.CreateCalculatedVariable (regionSpecifierPair.Value.Value, 8); break; case "cstyle_reference_operator": _fuzzTarget = connector.SymbolTable.CreateCStyleReferenceOperatorVariable(regionSpecifierPair.Value.Value, 8); break; default: throw new FuzzParseException ("Invalid data region specifier '{0}'", regionSpecifierPair.Value.Key); } }
public static IAddressSpecifier ParseRegionAddress(string regionSpecifier, bool allowMethodRet, ITargetConnector connector) { KeyValuePair<string, string>? regionSpecifierPair = StringHelper.SplitToKeyValue (regionSpecifier, "|"); if (regionSpecifierPair == null) throw new FuzzParseException ("RegionStart contains invalid formatted region specifier '{0}'", regionSpecifier); IAddressSpecifier breakAddress = null; switch (regionSpecifierPair.Value.Key) { case "method": AssertSymbolTable (connector); ISymbolTableMethod method = connector.SymbolTable.FindMethod (regionSpecifierPair.Value.Value); if (method == null) throw new FuzzParseException ("Could not find method with name '{0}', have you realy attached debugging symbols?", regionSpecifierPair.Value.Value); breakAddress = method.BreakpointAddressSpecifier; break; case "methodret": if(!allowMethodRet) throw new FuzzParseException ("Specifier 'methodret' is not allowed"); else throw new NotImplementedException(); case "address": UInt64 address; if (regionSpecifierPair.Value.Value.StartsWith ("0x", StringComparison.InvariantCultureIgnoreCase) && UInt64.TryParse (regionSpecifierPair.Value.Value.Substring (2), NumberStyles.HexNumber, NumberFormatInfo.InvariantInfo, out address)) breakAddress = new StaticAddress (address); else throw new FuzzParseException ("Cannot parse address in format '{0}' use '0x12345678'", regionSpecifierPair.Value.Value); break; case "source": AssertSymbolTable (connector); breakAddress = connector.SymbolTable.SourceToAddress (regionSpecifierPair.Value.Value); if (breakAddress == null) throw new FuzzParseException ("Specified source '{0}' is invalid", regionSpecifierPair.Value.Value); break; default: throw new FuzzParseException ("Specifier '{0}' is invalid", regionSpecifierPair.Value.Key); } return breakAddress; }
public FuzzDescriptionInfo(ITargetConnector connector) { _connector = connector; }
private static void AssertSymbolTable(ITargetConnector connector) { if(connector.SymbolTable == null) throw new ArgumentException("Connector does not have a symbol table"); }
public override void Init(XmlElement fuzzLocationRoot, ITargetConnector connector, Dictionary<string, IFuzzLocation> predefinedFuzzers) { base.Init (fuzzLocationRoot, connector, predefinedFuzzers); _myDelay = XmlHelper.ReadInt (fuzzLocationRoot, "Delay", 0); }