Package soot.jimple.infoflow.android
Class SetupApplication
java.lang.Object
soot.jimple.infoflow.android.SetupApplication
- All Implemented Interfaces:
ITaintWrapperDataFlowAnalysis
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceCommon interface for specialized versions of theInfoflowclass that allows the data flow analysis to be run inside an existing Soot instanceprotected classprotected classSpecializedInfoflowclass that allows the data flow analysis to be run inside an existing Soot instancestatic interfaceInterface for custom code transformations before the data flow analysis. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TaintPropagationHandlerprotected Stringprotected soot.util.MultiMap<soot.SootClass,AndroidCallbackDefinition> protected BiDirICFGFactoryprotected Set<soot.jimple.Stmt>protected Set<soot.jimple.Stmt>protected InfoflowAndroidConfigurationprotected AndroidEntryPointCreatorprotected Set<soot.SootClass>protected final booleanprotected soot.util.MultiMap<soot.SootClass,soot.SootClass> protected IccInstrumenterprotected SetupApplication.IInPlaceInfoflowprotected IIPCManagerprotected soot.util.MultiMap<soot.SootMethod,soot.jimple.Stmt> protected IManifestHandlerprotected List<SetupApplication.OptimizationPass>protected Set<PreAnalysisHandler>protected ARSCFileParserprotected Set<ResultsAvailableHandler>protected soot.SootClassprotected IInfoflowConfigprotected ISourceSinkManagerprotected ISourceSinkDefinitionProviderprotected TaintPropagationHandlerprotected ITaintPropagationWrapperprotected IUsageContextProviderprotected IValueProvider -
Constructor Summary
ConstructorsConstructorDescriptionSetupApplication(File androidJar, File apkFile) Creates a new instance of theSetupApplicationclassSetupApplication(File androidJar, File apkFileLocation, IIPCManager ipcManager) Creates a new instance of theSetupApplicationclassCreates a new instance of theSetupApplicationclassSetupApplication(InfoflowAndroidConfiguration config, IIPCManager ipcManager) Creates a new instance of theSetupApplicationclass -
Method Summary
Modifier and TypeMethodDescriptionvoidAborts the data flow analysis.voidAdd an optimization pass to be applied before the analysis.voidaddPreprocessor(PreAnalysisHandler preprocessor) Adds custom code to be executed before the taint propagation startsvoidAdds a new handler that shall be executed when the results of the data flow analysis are availablevoidClears the list of handlers that shall be executed when the data flow results are availableprotected voidConfigures the callgraph options for Soot according to FlowDroid's settingsvoidConstructs a callgraph only without running the actual data flow analysis.protected voidTriggers the callgraph construction in Sootprotected FlowDroidMemoryWatchercreateCallbackMemoryWatcher(AbstractCallbackAnalyzer jimpleClass) Creates the memory watcher for aborting the callback analysis in case it runs out of memory.protected FlowDroidTimeoutWatchercreateCallbackTimeoutWatcher(InfoflowAndroidConfiguration.CallbackConfiguration callbackConfig, AbstractCallbackAnalyzer analyzer) Creates the timeout watcher for aborting the callback analysis in case it runs out of time.protected AndroidEntryPointCreatorcreateEntryPointCreator(Set<soot.SootClass> components) Creates a new instance of the entry point creatorprotected IccInstrumenterCreates the ICC instrumentation classprotected SetupApplication.IInPlaceInfoflowInstantiates and configures the data flow engineprotected SetupApplication.IInPlaceInfoflowcreateInfoflowInternal(Collection<soot.SootMethod> lifecycleMethods) Creates the data flow engine on which to run the analysis.protected LayoutFileParserCreates a new layout file parser.protected IManifestHandlercreateManifestParser(File targetAPK) Creates the manifest handler for processing the app manifestprotected ISourceSinkManagercreateSourceSinkManager(LayoutFileParser lfp, Set<AndroidCallbackDefinition> callbacks) Creates an instance ofISourceSinkManagerthat defines what FlowDorid shall consider as a source or sink, respectively.protected voidcreateSourceSinkProvider(soot.SootClass entryPoint, LayoutFileParser lfp) Creates the source/sink providerGets the class names of callbacks.Set<soot.jimple.Stmt>Gets the concrete instances of sinks that have been collected inside the app.Set<soot.jimple.Stmt>Gets the concrete instances of sources that have been collected inside the app.Gets the data flow configurationsoot.SootMethodGets the dummy main method that was used for the last callgraph construction.Set<soot.SootClass>Gets the set of classes containing entry point methods for the lifecycleprotected LibraryClassPatcherGet the ARSC file parser to read resources.Collection<? extends ISourceSinkDefinition>getSinks()Gets the set of sinks loaded into FlowDroid These are the sinks as they are defined through the SourceSinkManager.Gets the extra Soot configuration options to be used when running the analysisCollection<? extends ISourceSinkDefinition>Gets the set of sources loaded into FlowDroid.Gets the source/sink manager constructed for FlowDroid.protected voidParses common app resources such as the manifest filevoidPrints list of classes containing entry points to stdoutvoidPrints the list of sinks registered with FlowDroud to stdoutvoidPrints the list of sources registered with FlowDroud to stdoutprotected voidprocessEntryPoint(ISourceSinkDefinitionProvider sourcesAndSinks, soot.jimple.infoflow.android.SetupApplication.MultiRunResultAggregator resultAggregator, int numEntryPoints, soot.SootClass entrypoint) Runs the data flow analysis on the given entry point classprotected voidReleases the callgraph and all intermediate objects associated with itvoidRemoves all simulated code elements generated during entry point creation and ICC instrumentation from the Soot SceneRuns the data flow analysis.runInfoflow(File sourceSinkFile) Runs the data flow analysis.runInfoflow(Set<AndroidMethod> sources, Set<AndroidMethod> sinks) Runs the data flow analysis.runInfoflow(ISourceSinkDefinitionProvider sourcesAndSinks) Runs the data flow analysis.protected voidserializeResults(InfoflowResults results, IInfoflowCFG cfg) Writes the given data flow results into the configured output filevoidsetAliasPropagationHandler(TaintPropagationHandler aliasPropagationHandler) Sets the alias propagation handler, which will be notified when the alias analysis processes an edge.voidsetCallbackClasses(Set<String> callbackClasses) Sets the class names of callbacks. hese are the callback classes defined by the Android SDK, and they are not mapped to the current application.voidsetCallbackFile(String callbackFile) voidsetIcfgFactory(BiDirICFGFactory factory) Sets the factory class to be used for constructing interprocedural control flow graphsvoidsetIpcManager(IIPCManager ipcManager) Sets the IPC manager for modeling inter-component and inter-application data flowsvoidsetSootConfig(IInfoflowConfig config) Sets the extra Soot configuration options to be used when running the analysisvoidsetTaintPropagationHandler(TaintPropagationHandler taintPropagationHandler) Sets the taint propagation handler, which will be notified when the data flow analysis processes an edge.voidsetTaintWrapper(ITaintPropagationWrapper taintWrapper) voidsetUsageContextProvider(IUsageContextProvider usageContextProvider) voidsetValueProvider(IValueProvider valueProvider) Sets the value provider that extracts constants from the Jimple codeprotected voidSome apps, especially malware, use namespaces like "com.google.myapp", which are also namespaces of system packages.
-
Field Details
-
sourceSinkProvider
-
callbackMethods
-
fragmentClasses
protected soot.util.MultiMap<soot.SootClass,soot.SootClass> fragmentClasses -
config
-
entrypoints
-
javascriptInterfaceStmts
protected soot.util.MultiMap<soot.SootMethod,soot.jimple.Stmt> javascriptInterfaceStmts -
callbackClasses
-
entryPointCreator
-
iccInstrumenter
-
resources
-
manifest
-
valueProvider
-
forceAndroidJar
protected final boolean forceAndroidJar -
taintWrapper
-
sourceSinkManager
-
sootConfig
-
cfgFactory
-
ipcManager
-
collectedSources
-
collectedSinks
-
callbackFile
-
scView
protected soot.SootClass scView -
preprocessors
-
resultsAvailableHandlers
-
taintPropagationHandler
-
aliasPropagationHandler
-
usageContextProvider
-
infoflow
-
opts
-
-
Constructor Details
-
SetupApplication
Creates a new instance of theSetupApplicationclass- Parameters:
config- The data flow configuration to use
-
SetupApplication
Creates a new instance of theSetupApplicationclass- Parameters:
androidJar- The path to the Android SDK's "platforms" directory if Soot shall automatically select the JAR file to be used or the path to a single JAR file to force one.apkFile- The APK file to be analyzed
-
SetupApplication
Creates a new instance of theSetupApplicationclass- Parameters:
androidJar- The path to the Android SDK's "platforms" directory if Soot shall automatically select the JAR file to be used or the path to a single JAR file to force one.apkFileLocation- The path to the APK file to be analyzedipcManager- The IPC manager to use for modeling inter-component and inter-application data flows
-
SetupApplication
Creates a new instance of theSetupApplicationclass- Parameters:
config- The data flow configuration to useipcManager- The IPC manager to use for modelling inter-component and inter-application data flows
-
-
Method Details
-
addOptimizationPass
Add an optimization pass to be applied before the analysis.- Parameters:
pass- optimization pass
-
getSinks
Gets the set of sinks loaded into FlowDroid These are the sinks as they are defined through the SourceSinkManager.- Returns:
- The set of sinks loaded into FlowDroid
-
getCollectedSinks
Gets the concrete instances of sinks that have been collected inside the app. This method returns null if source and sink logging has not been enabled (see InfoflowConfiguration.setLogSourcesAndSinks()).- Returns:
- The set of concrete sink instances in the app
-
printSinks
public void printSinks()Prints the list of sinks registered with FlowDroud to stdout -
getSources
Gets the set of sources loaded into FlowDroid. These are the sources as they are defined through the SourceSinkManager.- Returns:
- The set of sources loaded into FlowDroid
-
getCollectedSources
Gets the concrete instances of sources that have been collected inside the app. This method returns null if source and sink logging has not been enabled (see InfoflowConfiguration.setLogSourcesAndSinks()).- Returns:
- The set of concrete source instances in the app
-
printSources
public void printSources()Prints the list of sources registered with FlowDroud to stdout -
getEntrypointClasses
Gets the set of classes containing entry point methods for the lifecycle- Returns:
- The set of classes containing entry point methods for the lifecycle
-
printEntrypoints
public void printEntrypoints()Prints list of classes containing entry points to stdout -
setCallbackClasses
Sets the class names of callbacks. hese are the callback classes defined by the Android SDK, and they are not mapped to the current application. If this value is null, FlowDroid automatically loads the names from AndroidCallbacks.txt as the default behavior.- Parameters:
callbackClasses- The class names of callbacks or null to use the default file.
-
getCallbackClasses
Gets the class names of callbacks. These are the callback classes defined by the Android SDK, and they are not mapped to the current application.- Returns:
- The class names of callbacks or null to use the default file.
-
setTaintWrapper
- Specified by:
setTaintWrapperin interfaceITaintWrapperDataFlowAnalysis
-
getTaintWrapper
- Specified by:
getTaintWrapperin interfaceITaintWrapperDataFlowAnalysis
-
parseAppResources
Parses common app resources such as the manifest file- Throws:
IOException- Thrown if the given source/sink file could not be read.
-
getResources
Get the ARSC file parser to read resources.- Returns:
- ARSCFileParser
-
createManifestParser
Creates the manifest handler for processing the app manifest- Parameters:
targetAPK- The target APK file- Returns:
- The manifest handler for reading the given app's manifest file
- Throws:
IOException
-
createSourceSinkProvider
Creates the source/sink provider- Parameters:
entryPoint- The entry point on which to run the data flow analysislfp- The layout file parser
-
createLayoutFileParser
Creates a new layout file parser. Derived classes can override this method to supply their own parser.- Returns:
- The newly created layout file parser.
-
createSourceSinkManager
protected ISourceSinkManager createSourceSinkManager(LayoutFileParser lfp, Set<AndroidCallbackDefinition> callbacks) Creates an instance ofISourceSinkManagerthat defines what FlowDorid shall consider as a source or sink, respectively.- Parameters:
lfp- The parser that handles the layout XML filescallbacks- The callbacks that have been collected so far- Returns:
- The new source sink manager
-
constructCallgraphInternal
protected void constructCallgraphInternal()Triggers the callgraph construction in Soot -
createIccInstrumenter
Creates the ICC instrumentation class- Returns:
- An instance of the class for instrumenting the app's code for inter-component communication
-
createCallbackMemoryWatcher
Creates the memory watcher for aborting the callback analysis in case it runs out of memory. This method also starts the watchdog thread. Derived classes can implement their own timeout handling if necessary.- Parameters:
callbackConfig- The configuration for the callback analysisanalyzer- The callback analyzer- Returns:
- The memory watcher that keeps track of the amount of memory spent in the callback analysis
-
createCallbackTimeoutWatcher
protected FlowDroidTimeoutWatcher createCallbackTimeoutWatcher(InfoflowAndroidConfiguration.CallbackConfiguration callbackConfig, AbstractCallbackAnalyzer analyzer) Creates the timeout watcher for aborting the callback analysis in case it runs out of time. This method also starts the watchdog thread. Derived classes can implement their own timeout handling if necessary.- Parameters:
callbackConfig- The configuration for the callback analysisanalyzer- The callback analyzer- Returns:
- The timeout watcher that keeps track of the time spent in the callback analysis
-
releaseCallgraph
protected void releaseCallgraph()Releases the callgraph and all intermediate objects associated with it -
getSourceSinkManager
Gets the source/sink manager constructed for FlowDroid. Make sure to call constructCallgraph() first, or you will get a null result.- Returns:
- FlowDroid's source/sink manager
-
getLibraryClassPatcher
-
configureCallgraph
protected void configureCallgraph()Configures the callgraph options for Soot according to FlowDroid's settings -
constructCallgraph
public void constructCallgraph()Constructs a callgraph only without running the actual data flow analysis. If you want to run a data flow analysis, do not call this method. Instead, call runInfoflow() directly, which will take care all necessary prerequisites. -
runInfoflow
public InfoflowResults runInfoflow(Set<AndroidMethod> sources, Set<AndroidMethod> sinks) throws IOException Runs the data flow analysis.- Parameters:
sources- The methods that shall be considered as sourcessinks- The methods that shall be considered as sinks- Throws:
IOException- Thrown if the given source/sink file could not be read.
-
runInfoflow
Runs the data flow analysis.- Parameters:
sourceSinkFile- The full path and file name of the file containing the sources and sinks- Throws:
IOException- Thrown if the given source/sink file could not be read.
-
runInfoflow
Runs the data flow analysis.- Throws:
IOException- Thrown if the given source/sink file could not be read.
-
runInfoflow
Runs the data flow analysis.- Parameters:
sourcesAndSinks- The sources and sinks of the data flow analysis- Returns:
- The results of the data flow analysis
-
processEntryPoint
protected void processEntryPoint(ISourceSinkDefinitionProvider sourcesAndSinks, soot.jimple.infoflow.android.SetupApplication.MultiRunResultAggregator resultAggregator, int numEntryPoints, soot.SootClass entrypoint) Runs the data flow analysis on the given entry point class- Parameters:
sourcesAndSinks- The sources and sinks on which to run the data flow analysisresultAggregator- An object for aggregating the results from the individual data flow runsnumEntryPoints- The total number of runs (for logging)entrypoint- The current entry point to analyze
-
serializeResults
Writes the given data flow results into the configured output file- Parameters:
results- The data flow results to write outcfg- The control flow graph to use for writing out the results
-
createInfoflow
Instantiates and configures the data flow engine- Returns:
- A properly configured instance of the
Infoflowclass
-
createInfoflowInternal
protected SetupApplication.IInPlaceInfoflow createInfoflowInternal(Collection<soot.SootMethod> lifecycleMethods) Creates the data flow engine on which to run the analysis. Derived classes can override this method to use other data flow engines.- Parameters:
lifecycleMethods- The set of Android lifecycle methods to consider- Returns:
- The data flow engine
-
createEntryPointCreator
Creates a new instance of the entry point creator- Parameters:
components- The components for which the entry point creator shallk be responsible- Returns:
- The new instance of the entry point creator
-
getDummyMainMethod
public soot.SootMethod getDummyMainMethod()Gets the dummy main method that was used for the last callgraph construction. You need to run a data flow analysis or call constructCallgraph() first, otherwise you will get a null result.- Returns:
- The dummy main method
-
getSootConfig
Gets the extra Soot configuration options to be used when running the analysis- Returns:
- The extra Soot configuration options to be used when running the analysis, null if the defaults shall be used
-
setSootConfig
Sets the extra Soot configuration options to be used when running the analysis- Parameters:
config- The extra Soot configuration options to be used when running the analysis, null if the defaults shall be used
-
setIcfgFactory
Sets the factory class to be used for constructing interprocedural control flow graphs- Parameters:
factory- The factory to be used. If null is passed, the default factory is used.
-
getConfig
Gets the data flow configuration- Returns:
- The current data flow configuration
-
setCallbackFile
-
addPreprocessor
Adds custom code to be executed before the taint propagation starts- Parameters:
preprocessor- The callback to invoke before starting the taint propagation
-
addResultsAvailableHandler
Adds a new handler that shall be executed when the results of the data flow analysis are available- Parameters:
handler- The callback to invoke when the data flow results are available
-
clearResultsAvailableHandlers
public void clearResultsAvailableHandlers()Clears the list of handlers that shall be executed when the data flow results are available -
abortAnalysis
public void abortAnalysis()Aborts the data flow analysis. This is useful when the analysis controller is running in a different thread and the main thread (e.g., a GUI) wants to abort the analysis -
setIpcManager
Sets the IPC manager for modeling inter-component and inter-application data flows- Parameters:
ipcManager- The IPC manager to use for modeling inter-component and inter-application data flows
-
setTaintPropagationHandler
Sets the taint propagation handler, which will be notified when the data flow analysis processes an edge. Use this callback if you need a hook into the low-level data flow analysis.- Parameters:
taintPropagationHandler- The propagation handler to register
-
setAliasPropagationHandler
Sets the alias propagation handler, which will be notified when the alias analysis processes an edge. Use this callback if you need a hook into the low-level alias analysis.- Parameters:
aliasPropagationHandler- The propagation handler to register
-
setValueProvider
Sets the value provider that extracts constants from the Jimple code- Parameters:
valueProvider- The value provider for extracting constants from the code
-
removeSimulatedCodeElements
public void removeSimulatedCodeElements()Removes all simulated code elements generated during entry point creation and ICC instrumentation from the Soot Scene -
setUsageContextProvider
-
tagUserCodeClasses
protected void tagUserCodeClasses()Some apps, especially malware, use namespaces like "com.google.myapp", which are also namespaces of system packages. To distinguish bad namespaces from actual system packages, we tag user classes that also match system packages as withFlowDroidUserClass.
-