Java Code Examples for soot.jimple.infoflow.results.ResultSourceInfo#getPath()

The following examples show how to use soot.jimple.infoflow.results.ResultSourceInfo#getPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SMTPreparationPhase.java    From FuzzDroid with Apache License 2.0 6 votes vote down vote up
private ResultSourceInfo findDataFlowPathForSink(Stmt sinkStmt, Local sinkLokal, List<ResultSourceInfo> allDataFlows) {
	for(ResultSourceInfo singleFlow : allDataFlows){
		Stmt[] statements = singleFlow.getPath();
		AccessPath[] accessPath = singleFlow.getPathAccessPaths();
		
		for(int i = 0; i < statements.length; i++) {	
			Stmt currentStmt = statements[i];
			if(currentStmt == sinkStmt) {
				if(accessPath[i].getPlainValue() == sinkLokal)
					return singleFlow;
			}
			
			else if(currentStmt instanceof AssignStmt) {
				AssignStmt assignStmt = (AssignStmt)currentStmt;
				Value lhs = assignStmt.getLeftOp();
			
				if(lhs == sinkLokal)						
					return singleFlow;		
			}
		}
	}
	return null;
}
 
Example 2
Source File: Test.java    From JAADAS with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onResultsAvailable(
		IInfoflowCFG cfg, InfoflowResults results) {
	// Dump the results
	if (results == null) {
		print("No results found.");
	}
	else {
		for (ResultSinkInfo sink : results.getResults().keySet()) {
			print("Found a flow to sink " + sink + ", from the following sources:");
			for (ResultSourceInfo source : results.getResults().get(sink)) {
				print("\t- " + source.getSource() + " (in "
						+ cfg.getMethodOf(source.getSource()).getSignature()  + ")");
				if (source.getPath() != null && !source.getPath().isEmpty())
					print("\t\ton Path " + source.getPath());
			}
		}
	}
}
 
Example 3
Source File: FlowDroidLauncher.java    From soot-infoflow-android-iccta with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void onResultsAvailable(
		IInfoflowCFG cfg, InfoflowResults results) {
	// Dump the results
	if (results == null) {
		print("No results found.");
	}
	else {
		Test.cfg = cfg;
		Test.results = results;
		
		for (ResultSinkInfo sink : results.getResults().keySet()) {
			print("Found a flow to sink " + sink + ", from the following sources:");
			for (ResultSourceInfo source : results.getResults().get(sink)) {
				print("\t- " + source.getSource() + " (in "
						+ cfg.getMethodOf(source.getSource()).getSignature()  + ")");
				if (source.getPath() != null)
					print("\t\ton Path " + Arrays.toString(source.getPath()));
			}
		}
	}
}
 
Example 4
Source File: UtilSMT.java    From FuzzDroid with Apache License 2.0 5 votes vote down vote up
public static Set<ResultSourceInfo> removeDuplicatedFlows(Set<ResultSourceInfo> allDataFlows) {
	Set<ResultSourceInfo> copy = new HashSet<ResultSourceInfo>(allDataFlows);
	
	for(ResultSourceInfo dataFlow1 : allDataFlows) {
		Stmt[] dataFlowPath1 = dataFlow1.getPath();
		for(ResultSourceInfo dataFlow2 : allDataFlows) {
			Stmt[] dataFlowPath2 = dataFlow2.getPath();
			if(dataFlowPath1 != dataFlowPath2 &&
					Arrays.asList(dataFlowPath2).containsAll(Arrays.asList(dataFlowPath1)))
				copy.remove(dataFlow1);
		}
	}
	
	return copy;
}
 
Example 5
Source File: SmartConstantDataExtractorFuzzyAnalysis.java    From FuzzDroid with Apache License 2.0 4 votes vote down vote up
private void standardDataFlowToSMTConvertion(ResultSourceInfo dataFlow, IInfoflowCFG cfg, Set<ResultSourceInfo> preparedDataFlowsForSMT, Table<Stmt, Integer, Set<String>> splitInfos) {
	SMTConverter converter = new SMTConverter(sources);
	for(int i = 0; i < dataFlow.getPath().length; i++) {				
		System.out.println("\t" + dataFlow.getPath()[i]);
		System.out.println("\t\t" + dataFlow.getPathAccessPaths()[i]);
	}
	
	converter.convertJimpleToSMT(dataFlow.getPath(),
			dataFlow.getPathAccessPaths(), targetUnits, cfg, splitInfos);
	
	dataFlowsToSMTPrograms.put(new DataFlowObject(dataFlow.getPath()), converter.getSmtPrograms());

	//dynamic value information
	dynamicValueInfos.putAll(converter.getDynamicValueInfos());
	
	converter.printProgramToCmdLine();
	
	File z3str2Script = new File(FrameworkOptions.Z3SCRIPT_LOCATION);
	if(!z3str2Script.exists())
		throw new RuntimeException("There is no z3-script available");
	SMTExecutor smtExecutor = new SMTExecutor(converter.getSmtPrograms(), z3str2Script);
	Set<File> smtFiles = smtExecutor.createSMTFile();
	
	Set<Object> values = new HashSet<Object>();
	for(File smtFile : smtFiles) {
		String loggingPointValue = smtExecutor.executeZ3str2ScriptAndExtractLoggingPointValue(smtFile);
		if(loggingPointValue != null) {					
			loggingPointValue = fixSMTSolverIntegerOutput(loggingPointValue, dataFlow.getPath()[0]);					
			
			//SMT solver only returns hex-based UTF-8 values in some cases; we fixed this with our own hexToUnicode converter
			if(loggingPointValue != null && loggingPointValue.contains("\\x")) 
				addAdditionalUnicodeValue(loggingPointValue, values);
			if(loggingPointValue != null)
				values.add(loggingPointValue);
			System.out.println(String.format("Extracted loggingpoint-value: %s", loggingPointValue));
		}
	}
	
	System.out.println("####################################");
	
	//add values to fuzzy-seed
	Stmt stmt = dataFlow.getSource();
	CodePosition position = codePositionManager.getCodePositionForUnit(stmt);
	if(constantBasedValuesToFuzz.containsKey(position.getID()))
		constantBasedValuesToFuzz.get(position.getID()).addAll(values);
	else
		constantBasedValuesToFuzz.put(position.getID(), values);
}
 
Example 6
Source File: SmartConstantDataExtractorFuzzyAnalysis.java    From FuzzDroid with Apache License 2.0 4 votes vote down vote up
private void splitAPI_DataFlowtoSMTConvertion(ResultSourceInfo dataFlow, IInfoflowCFG cfg, Set<ResultSourceInfo> preparedDataFlowsForSMT, Table<Stmt, Integer, Set<String>> splitInfos) {			
	SMTConverter converter = new SMTConverter(sources);
	for(int i = 0; i < dataFlow.getPath().length; i++) {				
		System.out.println("\t" + dataFlow.getPath()[i]);
		System.out.println("\t\t" + dataFlow.getPathAccessPaths()[i]);
	}
	
	//we remove the first statement (split-API method)
	int n = dataFlow.getPath().length-1;
	Stmt[] reducedDataFlow = new Stmt[n];
	System.arraycopy(dataFlow.getPath(), 1, reducedDataFlow, 0, n);
				
	//currently only possible if there is a constant index for the array
	if(hasConstantIndexAtArrayForSplitDataFlow(reducedDataFlow)) {
		String valueOfInterest = getValueOfInterestForSplitDataflow(reducedDataFlow);
		
		converter.convertJimpleToSMT(reducedDataFlow,
				dataFlow.getPathAccessPaths(), targetUnits, cfg, null);
					
		converter.printProgramToCmdLine();
		
		File z3str2Script = new File(FrameworkOptions.Z3SCRIPT_LOCATION);
		if(!z3str2Script.exists())
			throw new RuntimeException("There is no z3-script available");
		SMTExecutor smtExecutor = new SMTExecutor(converter.getSmtPrograms(), z3str2Script);
		Set<File> smtFiles = smtExecutor.createSMTFile();
		
		for(File smtFile : smtFiles) {
			String loggingPointValue = smtExecutor.executeZ3str2ScriptAndExtractValue(smtFile, valueOfInterest);
			if(loggingPointValue != null) {
				Stmt splitStmt = dataFlow.getPath()[0];
				int index = getConstantArrayIndexForSplitDataFlow(reducedDataFlow);
				
				if(splitInfos.contains(splitStmt, index))
					splitInfos.get(splitStmt, index).add(loggingPointValue);
				else {
					Set<String> values = new HashSet<String>();
					values.add(loggingPointValue);
					splitInfos.put(splitStmt, index, values);
				}
			}
			System.out.println(loggingPointValue);
		}
		
		System.out.println("####################################");
	}			
}