Class AbstractCallbackAnalyzer

java.lang.Object
soot.jimple.infoflow.android.callbacks.AbstractCallbackAnalyzer
Direct Known Subclasses:
DefaultCallbackAnalyzer, FastCallbackAnalyzer

public abstract class AbstractCallbackAnalyzer extends Object
Analyzes the classes in the APK file to find custom implementations of the well-known Android callback and handler interfaces.
Author:
Steven Arzt
  • 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

      protected final InfoflowAndroidConfiguration config
    • entryPointClasses

      protected final Set<soot.SootClass> entryPointClasses
    • androidCallbacks

      protected final Set<String> androidCallbacks
    • callbackMethods

      protected final soot.util.MultiMap<soot.SootClass,AndroidCallbackDefinition> callbackMethods
    • layoutClasses

      protected final soot.util.MultiMap<soot.SootClass,Integer> layoutClasses
    • dynamicManifestComponents

      protected final Set<soot.SootClass> dynamicManifestComponents
    • fragmentClasses

      protected final soot.util.MultiMap<soot.SootClass,soot.SootClass> fragmentClasses
    • fragmentClassesRev

      protected final soot.util.MultiMap<soot.SootClass,soot.SootClass> fragmentClassesRev
    • fragmentIDs

      protected final Map<soot.SootClass,Integer> fragmentIDs
    • callbackFilters

      protected final List<ICallbackFilter> callbackFilters
    • excludedEntryPoints

      protected final Set<soot.SootClass> excludedEntryPoints
    • valueProvider

      protected IValueProvider valueProvider
    • arrayToContentTypes

      protected com.google.common.cache.LoadingCache<soot.SootField,List<soot.Type>> arrayToContentTypes
  • Constructor Details

  • Method Details

    • loadAndroidCallbacks

      public static Set<String> loadAndroidCallbacks(Reader reader) throws IOException
      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 callbacks
      method - The method in which to look for callbacks
    • checkAndAddCallback

      protected void checkAndAddCallback(Set<soot.SootClass> callbackClasses, soot.Type argType)
      Adds the class that implements the given type to the set of callback classes. This method deals with AnyType types as well.
      Parameters:
      callbackClasses - The set to which to add the callback classes
      argType - 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

      protected boolean isInheritedMethod(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.
      Parameters:
      stmt - The statement containing the call sites
      classNames - 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 add
      parentMethod - 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 belongs
      callbackType - 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 belongs
      fragmentClass - The fragment class
    • getCallbackMethods

      public soot.util.MultiMap<soot.SootClass,AndroidCallbackDefinition> getCallbackMethods()
    • getLayoutClasses

      public soot.util.MultiMap<soot.SootClass,Integer> getLayoutClasses()
    • getFragmentClasses

      public soot.util.MultiMap<soot.SootClass,soot.SootClass> getFragmentClasses()
    • getDynamicManifestComponents

      public Set<soot.SootClass> getDynamicManifestComponents()
    • addCallbackFilter

      public void addCallbackFilter(ICallbackFilter filter)
      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

      public void setValueProvider(IValueProvider valueProvider)
      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