/// <summary> /// Evaluates all values to string if it is possible and creates index identifier. /// </summary> /// <param name="entry">Memory entry with all possible values to convert to index.</param> /// <param name="isAlwaysLegal">Indicates that there is no compound (forbidden) value.</param> /// <returns>Member identifier created from all values of the memory entry.</returns> public MemberIdentifier EvaluateToIdentifiers(MemoryEntry entry, out bool isAlwaysLegal) { var integerValues = new HashSet <IntegerValue>(); var stringValues = new HashSet <StringValue>(); bool isAlwaysConcrete; bool isAlwaysInteger; Evaluate(entry, integerValues, stringValues, out isAlwaysConcrete, out isAlwaysInteger, out isAlwaysLegal); if (isAlwaysConcrete) { var indices = new HashSet <string>(); foreach (var integerValue in integerValues) { indices.Add(TypeConversion.ToString(integerValue.Value)); } foreach (var stringValue in stringValues) { indices.Add(stringValue.Value); } return(new MemberIdentifier(indices)); } else { return(MemberIdentifier.getAnyMemberIdentifier()); } }
private void initTaintedVariable(FlowOutputSet outSet, String name) { outSet.Snapshot.SetMode(SnapshotMode.InfoLevel); var TaintedVar = outSet.GetVariable(new VariableIdentifier(name), true); var taint = new TaintInfo(); taint.taint = new Taint(true); taint.priority = new TaintPriority(true); taint.tainted = true; var Taint = outSet.CreateInfo(taint); //TaintedVar.WriteMemory(outSet.Snapshot, new MemoryEntry(Taint)); var entry = TaintedVar.ReadIndex(EntryInput.Snapshot, MemberIdentifier.getAnyMemberIdentifier()); entry.WriteMemory(EntryInput.Snapshot, new MemoryEntry(Taint)); /* * TaintedVar = outSet.GetVariable(new VariableIdentifier(name), true); * Taint = outSet.CreateInfo(taint); * * TaintedVar.WriteMemory(outSet.Snapshot, new MemoryEntry(Taint));*/ }
private void initTaintedArray(string name) { // Get the variable var varName = new VariableName(name); EntryInput.FetchFromGlobal(varName); var variable = EntryInput.GetVariable(new VariableIdentifier(varName), true); // Create array and write it into the variable var array = EntryInput.CreateArray(); array.SetInfo(new Flags(Flags.CreateDirtyFlags())); variable.WriteMemory(EntryInput.Snapshot, new MemoryEntry(array)); // Create tainted any value var anyValue = EntryInput.AnyValue.SetInfo(new Flags(Flags.CreateDirtyFlags())); // Write tainted anyvalue to unknown field of the array (now stored in the variable) var entry = variable.ReadIndex(EntryInput.Snapshot, MemberIdentifier.getAnyMemberIdentifier()); entry.WriteMemory(EntryInput.Snapshot, new MemoryEntry(anyValue)); }