Class AbstractCallbackAnalyzer
java.lang.Object
soot.jimple.infoflow.android.callbacks.AbstractCallbackAnalyzer
- Direct Known Subclasses:
DefaultCallbackAnalyzer,FastCallbackAnalyzer
Analyzes the classes in the APK file to find custom implementations of the
well-known Android callback and handler interfaces.
- Author:
- Steven Arzt
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.google.common.cache.LoadingCache<soot.SootField,List<soot.Type>> protected final List<ICallbackFilter>protected final soot.util.MultiMap<soot.SootClass,AndroidCallbackDefinition> protected final InfoflowAndroidConfigurationprotected final Set<soot.SootClass>protected final Set<soot.SootClass>protected final Set<soot.SootClass>protected final soot.util.MultiMap<soot.SootClass,soot.SootClass> protected final soot.util.MultiMap<soot.SootClass,soot.SootClass> protected final soot.util.MultiMap<soot.SootClass,Integer> protected final org.slf4j.Loggerprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected final soot.SootClassprotected IValueProvider -
Constructor Summary
ConstructorsConstructorDescriptionAbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses) AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses, InputStream inputStream) AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses, Reader reader) AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses, String callbackFile) AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses, Set<String> androidCallbacks) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCallbackFilter(ICallbackFilter filter) Adds a new filter that checks every callback before it is associated with the respective host componentprotected voidanalyzeClassInterfaceCallbacks(soot.SootClass baseClass, soot.SootClass sootClass, soot.SootClass lifecycleElement) protected voidanalyzeMethodForCallbackRegistrations(soot.SootClass lifecycleElement, soot.SootMethod method) Analyzes the given method and looks for callback registrationsprotected voidanalyzeMethodForDynamicBroadcastReceiver(soot.SootMethod method) Checks whether the given method dynamically registers a new broadcast receiverprotected voidanalyzeMethodForFragmentTransaction(soot.SootClass lifecycleElement, soot.SootMethod method) Checks whether the given method executes a fragment transaction that creates new fragmentprotected voidanalyzeMethodForJavascriptInterfaces(soot.SootMethod method) protected voidanalyzeMethodForServiceConnection(soot.SootMethod method) Checks whether the given method dynamically registers a new service connectionprotected voidanalyzeMethodForViewPagers(soot.SootClass clazz, soot.SootMethod method) Check whether a method registers a FragmentStatePagerAdapter to a ViewPager.protected voidanalyzeMethodOverrideCallbacks(soot.SootClass sootClass) protected voidcheckAndAddCallback(Set<soot.SootClass> callbackClasses, soot.Type argType) Adds the class that implements the given type to the set of callback classes.protected voidcheckAndAddFragment(soot.SootClass componentClass, soot.SootClass fragmentClass) Registers a fragment that belongs to a given componentprotected booleancheckAndAddMethod(soot.SootMethod method, soot.SootMethod parentMethod, soot.SootClass lifecycleClass, AndroidCallbackDefinition.CallbackType callbackType) Checks whether the given Soot method comes from a system class.voidCollects the callback methods for all Android default handlers implemented in the source code.voidexcludeEntryPoint(soot.SootClass entryPoint) Excludes an entry point from all further processing.soot.util.MultiMap<soot.SootClass,AndroidCallbackDefinition> Set<soot.SootClass>soot.util.MultiMap<soot.SootClass,soot.SootClass> soot.util.MultiMap<soot.SootMethod,soot.jimple.Stmt> Returns a set of all statements which add a javascript interfacesoot.util.MultiMap<soot.SootClass,Integer> protected booleaninvokesInflate(soot.jimple.InvokeExpr inv) Checks whether this invocation calls Android's LayoutInflater.inflate methodprotected booleaninvokesSetContentView(soot.jimple.InvokeExpr inv) Checks whether this invocation calls Android's Activity.setContentView methodbooleanisExcludedEntryPoint(soot.SootClass entryPoint) Checks whether the given class is an excluded entry pointprotected booleanisInheritedMethod(soot.jimple.Stmt stmt, String... classNames) Gets whether the call in the given statement can end up in the respective method inherited from one of the given classes.loadAndroidCallbacks(Reader reader) Loads the set of interfaces that are used to implement Android callback handlers from a file on diskvoidsetValueProvider(IValueProvider valueProvider) Sets the provider that shall be used for obtaining constant values during the callback analysis
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
scContext
protected final soot.SootClass scContext -
scBroadcastReceiver
protected final soot.SootClass scBroadcastReceiver -
scServiceConnection
protected final soot.SootClass scServiceConnection -
scFragmentTransaction
protected final soot.SootClass scFragmentTransaction -
scFragment
protected final soot.SootClass scFragment -
scSupportFragmentTransaction
protected final soot.SootClass scSupportFragmentTransaction -
scAndroidXFragmentTransaction
protected final soot.SootClass scAndroidXFragmentTransaction -
scSupportFragment
protected final soot.SootClass scSupportFragment -
scAndroidXFragment
protected final soot.SootClass scAndroidXFragment -
scSupportViewPager
protected final soot.SootClass scSupportViewPager -
scAndroidXViewPager
protected final soot.SootClass scAndroidXViewPager -
scFragmentStatePagerAdapter
protected final soot.SootClass scFragmentStatePagerAdapter -
scFragmentPagerAdapter
protected final soot.SootClass scFragmentPagerAdapter -
scAndroidXFragmentStatePagerAdapter
protected final soot.SootClass scAndroidXFragmentStatePagerAdapter -
scAndroidXFragmentPagerAdapter
protected final soot.SootClass scAndroidXFragmentPagerAdapter -
config
-
entryPointClasses
-
androidCallbacks
-
callbackMethods
-
layoutClasses
-
dynamicManifestComponents
-
fragmentClasses
protected final soot.util.MultiMap<soot.SootClass,soot.SootClass> fragmentClasses -
fragmentClassesRev
protected final soot.util.MultiMap<soot.SootClass,soot.SootClass> fragmentClassesRev -
fragmentIDs
-
callbackFilters
-
excludedEntryPoints
-
valueProvider
-
arrayToContentTypes
-
-
Constructor Details
-
AbstractCallbackAnalyzer
public AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses) throws IOException - Throws:
IOException
-
AbstractCallbackAnalyzer
public AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses, String callbackFile) throws IOException - Throws:
IOException
-
AbstractCallbackAnalyzer
public AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses, InputStream inputStream) throws IOException - Throws:
IOException
-
AbstractCallbackAnalyzer
public AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses, Reader reader) throws IOException - Throws:
IOException
-
AbstractCallbackAnalyzer
public AbstractCallbackAnalyzer(InfoflowAndroidConfiguration config, Set<soot.SootClass> entryPointClasses, Set<String> androidCallbacks) throws IOException - Throws:
IOException
-
-
Method Details
-
loadAndroidCallbacks
Loads the set of interfaces that are used to implement Android callback handlers from a file on disk- Parameters:
reader- A file reader- Returns:
- A set containing the names of the interfaces that are used to implement Android callback handlers
- Throws:
IOException
-
collectCallbackMethods
public void collectCallbackMethods()Collects the callback methods for all Android default handlers implemented in the source code. -
analyzeMethodForCallbackRegistrations
protected void analyzeMethodForCallbackRegistrations(soot.SootClass lifecycleElement, soot.SootMethod method) Analyzes the given method and looks for callback registrations- Parameters:
lifecycleElement- The lifecycle element (activity, etc.) with which to associate the found callbacksmethod- The method in which to look for callbacks
-
checkAndAddCallback
Adds the class that implements the given type to the set of callback classes. This method deals withAnyTypetypes as well.- Parameters:
callbackClasses- The set to which to add the callback classesargType- The type to add
-
analyzeMethodForDynamicBroadcastReceiver
protected void analyzeMethodForDynamicBroadcastReceiver(soot.SootMethod method) Checks whether the given method dynamically registers a new broadcast receiver- Parameters:
method- The method to check
-
analyzeMethodForJavascriptInterfaces
protected void analyzeMethodForJavascriptInterfaces(soot.SootMethod method) -
analyzeMethodForServiceConnection
protected void analyzeMethodForServiceConnection(soot.SootMethod method) Checks whether the given method dynamically registers a new service connection- Parameters:
method- The method to check
-
analyzeMethodForFragmentTransaction
protected void analyzeMethodForFragmentTransaction(soot.SootClass lifecycleElement, soot.SootMethod method) Checks whether the given method executes a fragment transaction that creates new fragment- Parameters:
method- The method to check
-
analyzeMethodForViewPagers
protected void analyzeMethodForViewPagers(soot.SootClass clazz, soot.SootMethod method) Check whether a method registers a FragmentStatePagerAdapter to a ViewPager. This pattern is very common for tabbed apps.- Parameters:
clazz-method-
-
isInheritedMethod
Gets whether the call in the given statement can end up in the respective method inherited from one of the given classes.- Parameters:
stmt- The statement containing the call sitesclassNames- The base classes in which the call can potentially end up- Returns:
- True if the given call can end up in a method inherited from one of the given classes, otherwise falae
-
invokesSetContentView
protected boolean invokesSetContentView(soot.jimple.InvokeExpr inv) Checks whether this invocation calls Android's Activity.setContentView method- Parameters:
inv- The invocaton to check- Returns:
- True if this invocation calls setContentView, otherwise false
-
invokesInflate
protected boolean invokesInflate(soot.jimple.InvokeExpr inv) Checks whether this invocation calls Android's LayoutInflater.inflate method- Parameters:
inv- The invocaton to check- Returns:
- True if this invocation calls inflate, otherwise false
-
analyzeMethodOverrideCallbacks
protected void analyzeMethodOverrideCallbacks(soot.SootClass sootClass) -
analyzeClassInterfaceCallbacks
protected void analyzeClassInterfaceCallbacks(soot.SootClass baseClass, soot.SootClass sootClass, soot.SootClass lifecycleElement) -
checkAndAddMethod
protected boolean checkAndAddMethod(soot.SootMethod method, soot.SootMethod parentMethod, soot.SootClass lifecycleClass, AndroidCallbackDefinition.CallbackType callbackType) Checks whether the given Soot method comes from a system class. If not, it is added to the list of callback methods.- Parameters:
method- The method to check and addparentMethod- The original method in the Android framework that declared the callback. This can, for example, be the method in the interface.lifecycleClass- The base class (activity, service, etc.) to which this callback method belongscallbackType- The type of callback to be registered- Returns:
- True if the method is new, i.e., has not been seen before, otherwise false
-
checkAndAddFragment
protected void checkAndAddFragment(soot.SootClass componentClass, soot.SootClass fragmentClass) Registers a fragment that belongs to a given component- Parameters:
componentClass- The component (usually an activity) to which the fragment belongsfragmentClass- The fragment class
-
getCallbackMethods
-
getLayoutClasses
-
getFragmentClasses
public soot.util.MultiMap<soot.SootClass,soot.SootClass> getFragmentClasses() -
getDynamicManifestComponents
-
addCallbackFilter
Adds a new filter that checks every callback before it is associated with the respective host component- Parameters:
filter- The filter to add
-
excludeEntryPoint
public void excludeEntryPoint(soot.SootClass entryPoint) Excludes an entry point from all further processing. No more callbacks will be collected for the given entry point- Parameters:
entryPoint- The entry point to exclude
-
isExcludedEntryPoint
public boolean isExcludedEntryPoint(soot.SootClass entryPoint) Checks whether the given class is an excluded entry point- Parameters:
entryPoint- The entry point to check- Returns:
- True if the given class is an excluded entry point, otherwise false
-
setValueProvider
Sets the provider that shall be used for obtaining constant values during the callback analysis- Parameters:
valueProvider- The value provider to use
-
getJavaScriptInterfaces
public soot.util.MultiMap<soot.SootMethod,soot.jimple.Stmt> getJavaScriptInterfaces()Returns a set of all statements which add a javascript interface- Returns:
- the statement list
-