Class BaseProcessManifest<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>
java.lang.Object
soot.jimple.infoflow.android.manifest.BaseProcessManifest<A,S,C,B>
- All Implemented Interfaces:
Closeable,AutoCloseable,IManifestHandler<A,S, C, B>
- Direct Known Subclasses:
ProcessManifest
public abstract class BaseProcessManifest<A extends IActivity,S extends IService,C extends IContentProvider,B extends IBroadcastReceiver>
extends Object
implements IManifestHandler<A,S,C,B>
This class provides easy access to all data of an AppManifest.
Nodes and attributes of a parsed manifest can be changed. A new byte compressed manifest considering the changes can be generated.
Nodes and attributes of a parsed manifest can be changed. A new byte compressed manifest considering the changes can be generated.
- Author:
- Steven Arzt, Stefan Haas, Mario Schlipf
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceBaseProcessManifest.IComponentFactory<A extends IActivity,S extends IService, C extends IContentProvider, B extends IBroadcastReceiver> Factory class for creating component implementations -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AXmlNodeprotected ARSCFileParserprotected AXmlHandlerHandler for android xml filesprotected BaseProcessManifest.IComponentFactory<A,S, C, B> protected AXmlNode -
Constructor Summary
ConstructorsConstructorDescriptionBaseProcessManifest(File apkFile) Processes an AppManifest which is within the givenFile.BaseProcessManifest(File apkFile, ARSCFileParser arscParser) Processes an AppManifest which is within the givenFile.BaseProcessManifest(InputStream manifestIS, ARSCFileParser arscParser) Processes an AppManifest which is provided by the givenInputStream.BaseProcessManifest(String apkPath) Processes an AppManifest which is within the file identified by the given path. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActivity(AXmlNode node) Adds a new activity to the manifestvoidaddPermission(String permissionName) Adds a new permission to the manifest.voidaddProvider(AXmlNode node) Adds a new provider to the manifestvoidaddReceiver(AXmlNode node) Adds a new receiver to the manifestvoidaddService(AXmlNode node) Adds a new service to the manifestvoidclose()Closes this apk file and all resources associated with itprotected abstract BaseProcessManifest.IComponentFactory<A,S, C, B> Creates a factory that can instantiate data objects for Android componentsexpandClassName(String className) Generates a full class name from a short class name by appending the globally-defined package when necessaryReturns all activities in the Android appgetActivity(String name) Returns theactivitywhich has the givenname.Returns a list containing all nodes with tagactivity-aliasgetAliasActivity(String name) Returns thealias analysiswhich has the givennamegetAliasActivityTarget(AXmlNode aliasActivity) Returns the target activity specified in thetargetActivityattribute of the alias activityGets the Android application objectGets the Android resource parsergetAXml()Returns the handler which parsed and holds the manifest's data.Returns all broadcast receivers providers in the Android appgetComponentType(String className) Gets the type of the component identified by the given class nameReturns all content providers in the Android appGets the hardware components this application requests* Gets the intent-filter components this application usedReturns all activity nodes that are "launchable", i.e. that are called when the user clicks on the button in the launcher.The uniquemanifestnode of the AppManifest.intGets the minimum SDK version on which this application is supposed to runprotected AXmlNodegetNodeWithName(List<AXmlNode> list, String name) Iterates overlistand checks which node has the givenname.byte[]Returns the Manifest as a compressed android xml byte array.Gets the application's package nameGets the permissions this application requestsgetProvider(String name) Returns theproviderwhich has the givenname.getReceiver(String name) Returns thereceiverwhich has the givenname.getService(String name) Returns theservicewhich has the givenname.Returns all services providers in the Android appintGets the target SDK version for which this application was developedintGets the version code of the application.Gets the application's version name as it is displayed to the userprotected voidhandle(InputStream manifestIS) Initialises theBaseProcessManifestby parsing the manifest provided by the givenInputStream.static booleanisAliasActivity(AXmlNode activity) Returns whether the given activity is an alias activity or notMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface soot.jimple.infoflow.android.manifest.IManifestHandler
checkAndAddComponent, getAllComponents, getEntryPointClasses
-
Field Details
-
axml
Handler for android xml files -
arscParser
-
manifest
-
application
-
providers
-
services
-
activities
-
aliasActivities
-
receivers
-
factory
protected BaseProcessManifest.IComponentFactory<A extends IActivity,S extends IService, factoryC extends IContentProvider, B extends IBroadcastReceiver>
-
-
Constructor Details
-
BaseProcessManifest
Processes an AppManifest which is within the file identified by the given path.- Parameters:
apkPath- file path to an APK.- Throws:
IOException- if an I/O error occurs.
-
BaseProcessManifest
Processes an AppManifest which is within the givenFile.- Parameters:
apkFile- the AppManifest within the given APK will be parsed.- Throws:
IOException- if an I/O error occurs.- See Also:
-
BaseProcessManifest
Processes an AppManifest which is within the givenFile.- Parameters:
apkFile- the AppManifest within the given APK will be parsed.arscParser- The parser for the Android resource database- Throws:
IOException- if an I/O error occurs.- See Also:
-
BaseProcessManifest
Processes an AppManifest which is provided by the givenInputStream.- Parameters:
manifestIS- InputStream for an AppManifest.arscParser- The Android resource file parser- Throws:
IOException- if an I/O error occurs.
-
-
Method Details
-
handle
Initialises theBaseProcessManifestby parsing the manifest provided by the givenInputStream.- Parameters:
manifestIS- InputStream for an AppManifest.- Throws:
IOException- if an I/O error occurs.XmlPullParserException- can occur due to a malformed manifest.
-
getAXml
Returns the handler which parsed and holds the manifest's data.- Returns:
- Android XML handler
-
getManifest
The uniquemanifestnode of the AppManifest.- Returns:
- manifest node
-
getApplication
Description copied from interface:IManifestHandlerGets the Android application object- Specified by:
getApplicationin interfaceIManifestHandler<A extends IActivity,S extends IService, C extends IContentProvider, B extends IBroadcastReceiver> - Returns:
- The Android application object
-
getContentProviders
Description copied from interface:IManifestHandlerReturns all content providers in the Android app- Specified by:
getContentProvidersin interfaceIManifestHandler<A extends IActivity,S extends IService, C extends IContentProvider, B extends IBroadcastReceiver> - Returns:
- list with all providers
-
getServices
Description copied from interface:IManifestHandlerReturns all services providers in the Android app- Specified by:
getServicesin interfaceIManifestHandler<A extends IActivity,S extends IService, C extends IContentProvider, B extends IBroadcastReceiver> - Returns:
- list with all services
-
getComponentType
Gets the type of the component identified by the given class name- Parameters:
className- The class name for which to get the component type- Returns:
- The component type of the given class if this class has been registered as a component in the manifest file, otherwise null
-
getActivities
Description copied from interface:IManifestHandlerReturns all activities in the Android app- Specified by:
getActivitiesin interfaceIManifestHandler<A extends IActivity,S extends IService, C extends IContentProvider, B extends IBroadcastReceiver> - Returns:
- list with all activities
-
getAliasActivities
Returns a list containing all nodes with tagactivity-alias- Returns:
- list with all alias activities
-
getBroadcastReceivers
Description copied from interface:IManifestHandlerReturns all broadcast receivers providers in the Android app- Specified by:
getBroadcastReceiversin interfaceIManifestHandler<A extends IActivity,S extends IService, C extends IContentProvider, B extends IBroadcastReceiver> - Returns:
- list with all receivers
-
getProvider
Returns theproviderwhich has the givenname.- Parameters:
name- the provider's name- Returns:
- provider with
name
-
getService
Returns theservicewhich has the givenname.- Parameters:
name- the service's name- Returns:
- service with
name
-
getActivity
Returns theactivitywhich has the givenname.- Parameters:
name- the activitie's name- Returns:
- activitiy with
name
-
getAliasActivity
Returns thealias analysiswhich has the givenname- Parameters:
name- the alias activity's name- Returns:
- alias activity with
name
-
getReceiver
Returns thereceiverwhich has the givenname.- Parameters:
name- the receiver's name- Returns:
- receiver with
name
-
getNodeWithName
Iterates overlistand checks which node has the givenname.- Parameters:
list- contains nodes.name- the node's name.- Returns:
- node with
name.
-
getAliasActivityTarget
Returns the target activity specified in thetargetActivityattribute of the alias activity- Parameters:
aliasActivity-- Returns:
- activity
-
isAliasActivity
Returns whether the given activity is an alias activity or not- Parameters:
activity-- Returns:
- True if the activity is an alias activity, False otherwise
-
getAllActivities
-
getOutput
public byte[] getOutput()Returns the Manifest as a compressed android xml byte array. This will consider all changes made to the manifest and application nodes respectively to their child nodes.- Returns:
- byte compressed AppManifest
- See Also:
-
getPackageName
Gets the application's package name- Specified by:
getPackageNamein interfaceIManifestHandler<A extends IActivity,S extends IService, C extends IContentProvider, B extends IBroadcastReceiver> - Returns:
- The package name of the application
-
getVersionCode
public int getVersionCode()Gets the version code of the application. This code is used to compare versions for updates.- Returns:
- The version code of the application
-
getVersionName
Gets the application's version name as it is displayed to the user- Returns:
- The application#s version name as in pretty print
-
getMinSdkVersion
public int getMinSdkVersion()Gets the minimum SDK version on which this application is supposed to run- Returns:
- The minimum SDK version on which this application is supposed to run
-
getTargetSdkVersion
public int getTargetSdkVersion()Gets the target SDK version for which this application was developed- Returns:
- The target SDK version for which this application was developed
-
getPermissions
Gets the permissions this application requests- Returns:
- The permissions requested by this application
-
getIntentFilter
* Gets the intent-filter components this application used- Returns:
- the intent filter used by this application
-
getHardware
Gets the hardware components this application requests- Returns:
- the hardware requested by this application
-
addPermission
Adds a new permission to the manifest.- Parameters:
permissionName- complete permission name e.g. "android.permission.INTERNET"
-
addProvider
Adds a new provider to the manifest- Parameters:
node- provider represented as an AXmlNode
-
addReceiver
Adds a new receiver to the manifest- Parameters:
node- receiver represented as an AXmlNode
-
addActivity
Adds a new activity to the manifest- Parameters:
node- activity represented as an AXmlNode
-
addService
Adds a new service to the manifest- Parameters:
node- service represented as an AXmlNode
-
close
public void close()Closes this apk file and all resources associated with it- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getLaunchableActivityNodes
Returns all activity nodes that are "launchable", i.e. that are called when the user clicks on the button in the launcher.- Returns:
- all launchable activity nodes
-
expandClassName
Generates a full class name from a short class name by appending the globally-defined package when necessary- Parameters:
className- The class name to expand- Returns:
- The expanded class name for the given short name
-
getArscParser
Gets the Android resource parser- Returns:
- The Android resource parser
-
createComponentFactory
Creates a factory that can instantiate data objects for Android components- Returns:
- The new factory
-