Documentation ¶
Overview ¶
Package apk implements a parser for Android APKs.
The APK type represents an APK file and is the API most users should use. You can open an APK file with apk.Open, or if you want more control over resource resolution, apk.OpenWithConfig.
Most information about an APK is contained in its manifest. The Manifest() method will return an APK's Manifest.
BUG(lberrymage): Some resource table references in binary XML are incorrectly parsed as empty strings.
Index ¶
- Variables
- type APK
- func (a *APK) DataExtractionRules() (*schemas.DataExtractionRules, error)
- func (a *APK) Manifest() Manifest
- func (a *APK) NetworkSecurityConfig() (*schemas.NetworkSecurityConfig, error)
- func (a *APK) OpenXML(name string) (*XMLFile, error)
- func (a *APK) OpenXMLWithConfig(name string, config *ResTableConfig) (*XMLFile, error)
- func (a *APK) SetConfig(config *ResTableConfig)
- type Action
- type Activity
- type ActivityAlias
- type Application
- type Category
- type Data
- type IntentFilter
- type Manifest
- type MetaData
- type Package
- type Profileable
- type Provider
- type Query
- type Receiver
- type ResTable
- type ResTableConfig
- type Service
- type SupportsScreen
- type UsesPermission
- type UsesSDK
- type XMLFile
- Bugs
Constants ¶
This section is empty.
Variables ¶
var ( // BadIndex is returned when a bad index is encountered in parsing. ErrBadIndex = errors.New("bad index") // MalformedHeader is returned when an incorrect or invalid chunk header is encountered. ErrMalformedHeader = errors.New("malformed header") // InvalidChunkType is returned when an invalid chunk type is encountered. ErrInvalidChunkType = errors.New("encountered invalid chunk type") // XMLResourceNotFound is returned when a requested XML resource is not found. ErrResourceNotFound = errors.New("XML resource not found") )
Functions ¶
This section is empty.
Types ¶
type APK ¶
type APK struct {
// contains filtered or unexported fields
}
APK is a representation of an Android APK file.
func FromReader ¶ added in v0.1.1
FromReader opens an APK of the given size from reader r and returns a new APK if successful. It automatically parses the app's Android manifest and resource table, resolving table references from the manifest as necessary.
func FromReaderWithConfig ¶ added in v0.1.1
FromReaderWithConfig opens an APK of the given size from reader r and returns a new APK if successful. It automatically parses the app's Android manifest and resource table, using config to resolve resource table references from the manifest as necessary.
func Open ¶
Open opens an APK at path name and returns a new APK if successful. It automatically parses the app's Android manifest and resource table, resolving resource table references from the manifest as necessary.
func OpenWithConfig ¶
func OpenWithConfig(name string, config *ResTableConfig) (*APK, error)
OpenWithConfig opens an APK an path name and returns a new APK if successful. It automatically parses the app's Android manifest and resource table, using config to resolve resource table references from the manifest as necessary.
func (*APK) DataExtractionRules ¶
func (a *APK) DataExtractionRules() (*schemas.DataExtractionRules, error)
DataExtractionRules is a utility function which parses an APK's data extraction rules into a struct.
func (*APK) NetworkSecurityConfig ¶
func (a *APK) NetworkSecurityConfig() (*schemas.NetworkSecurityConfig, error)
NetworkSecurityConfig is a utility function which parses an APK's network security config into a struct.
func (*APK) OpenXML ¶
OpenXML is a utility function for opening an arbitrary Android binary XML file within an APK. If a resource table config was specified when opening the APK with apk.OpenWithConfig, it will be used.
func (*APK) OpenXMLWithConfig ¶
func (a *APK) OpenXMLWithConfig(name string, config *ResTableConfig) (*XMLFile, error)
OpenXMLWithConfig is like OpenXML, but allows for specifying a ResTableConfig after opening the APK. It overrides the APK's ResTableConfig for this function call but doesn't modify the APK's ResTableConfig that was specified at open time.
func (*APK) SetConfig ¶
func (a *APK) SetConfig(config *ResTableConfig)
SetConfig sets the APK's ResTableConfig for future operations.
type Action ¶
type Action struct {
Name string `xml:"http://schemas.android.com/apk/res/android name,attr"`
}
Action adds an action to an intent filter.
type Activity ¶
type Activity struct { Exported *string `xml:"http://schemas.android.com/apk/res/android exported,attr"` Label *string `xml:"http://schemas.android.com/apk/res/android label,attr"` Name string `xml:"http://schemas.android.com/apk/res/android name,attr"` IntentFilters *[]IntentFilter `xml:"intent-filter"` MetaData *[]MetaData `xml:"meta-data"` }
Activity is an activity that implements part of an application's visual user interface.
type ActivityAlias ¶
type ActivityAlias struct { Enabled *bool `xml:"http://schemas.android.com/apk/res/android enabled,attr"` Exported bool `xml:"http://schemas.android.com/apk/res/android exported,attr"` Label *string `xml:"http://schemas.android.com/apk/res/android label,attr"` Name string `xml:"http://schemas.android.com/apk/res/android name,attr"` Permission *string `xml:"http://schemas.android.com/apk/res/android permission,attr"` TargetActivity string `xml:"http://schemas.android.com/apk/res/android targetActivity,attr"` IntentFilters *[]IntentFilter `xml:"intent-filter"` MetaData *[]MetaData `xml:"meta-data"` }
ActivityAlias is an alias for an activity named by the TargetActivity attribute.
type Application ¶
type Application struct { AllowTaskReparenting *bool `xml:"http://schemas.android.com/apk/res/android allowTaskReparenting,attr"` AllowBackup *bool `xml:"http://schemas.android.com/apk/res/android allowBackup,attr"` BackupAgent *string `xml:"http://schemas.android.com/apk/res/android backupAgent,attr"` BackupInForeground *bool `xml:"http://schemas.android.com/apk/res/android backupInForeground,attr"` DataExtractionRules *string `xml:"http://schemas.android.com/apk/res/android dataExtractionRules,attr"` Debuggable *bool `xml:"http://schemas.android.com/apk/res/android debuggable,attr"` Label *string `xml:"http://schemas.android.com/apk/res/android label,attr"` ManageSpaceActivity *string `xml:"http://schemas.android.com/apk/res/android manageSpaceActivity,attr"` Name *string `xml:"http://schemas.android.com/apk/res/android name,attr"` NetworkSecurityConfig *string `xml:"http://schemas.android.com/apk/res/android networkSecurityConfig,attr"` RequestLegacyExternalStorage *bool `xml:"http://schemas.android.com/apk/res/android requestLegacyExternalStorage,attr"` SupportsRTL *bool `xml:"http://schemas.android.com/apk/res/android supportsRtl,attr"` TestOnly *bool `xml:"http://schemas.android.com/apk/res/android testOnly,attr"` UsesCleartextTraffic *bool `xml:"http://schemas.android.com/apk/res/android usesCleartextTraffic,attr"` Activities *[]Activity `xml:"activity"` ActivityAliases *[]ActivityAlias `xml:"activity-alias"` MetaData *[]MetaData `xml:"meta-data"` Services *[]Service `xml:"service"` Receivers *[]Receiver `xml:"receiver"` Profileable *Profileable `xml:"profileable"` Providers *[]Provider `xml:"provider"` }
Application is a declaration of an application.
type Category ¶
type Category struct {
Name string `xml:"http://schemas.android.com/apk/res/android name,attr"`
}
Category adds a category name to an intent filter.
type Data ¶
type Data struct { Scheme *string `xml:"http://schemas.android.com/apk/res/android scheme,attr"` Host *string `xml:"http://schemas.android.com/apk/res/android host,attr"` Port *string `xml:"http://schemas.android.com/apk/res/android port,attr"` Path *string `xml:"http://schemas.android.com/apk/res/android path,attr"` PathPattern *string `xml:"http://schemas.android.com/apk/res/android pathPattern,attr"` PathPrefix *string `xml:"http://schemas.android.com/apk/res/android pathPrefix,attr"` MimeType *string `xml:"http://schemas.android.com/apk/res/android mimeType,attr"` }
Data adds a data specification to an intent filter. A specification can be just a data type, just a URI, or both a data type and a URI.
type IntentFilter ¶
type IntentFilter struct { Priority *uint32 `xml:"http://schemas.android.com/apk/res/android priority,attr"` Order *int32 `xml:"http://schemas.android.com/apk/res/android order,attr"` AutoVerify *bool `xml:"http://schemas.android.com/apk/res/android autoVerify,attr"` Actions []Action `xml:"action"` Categories *[]Category `xml:"category"` Data *[]Data `xml:"data"` }
IntentFilter specifies the types of intents that an activity, service, or broadcast receiver can respond to.
type Manifest ¶
type Manifest struct { Package string `xml:"package,attr"` VersionCode int32 `xml:"http://schemas.android.com/apk/res/android versionCode,attr"` VersionName string `xml:"http://schemas.android.com/apk/res/android versionName,attr"` Application Application `xml:"application"` Queries *[]Query `xml:"queries"` SupportsScreens *[]SupportsScreen `xml:"supports-screens"` UsesPermissions *[]UsesPermission `xml:"uses-permission"` UsesSDK *UsesSDK `xml:"uses-sdk"` }
Manifest is the root element of an AndroidManifest.xml file.
type MetaData ¶
type MetaData struct { Name string `xml:"http://schemas.android.com/apk/res/android name,attr"` Resource *string `xml:"http://schemas.android.com/apk/res/android resource,attr"` Value *string `xml:"http://schemas.android.com/apk/res/android value,attr"` }
MetaData is a name-value pair for an item of additional, arbitrary data that can be supplied to the parent component. A component element can contain any number of MetaData subelements.
type Package ¶
type Package struct {
Name string `xml:"http://schemas.android.com/apk/res/android name,attr"`
}
Package specifies a single app that an app intends to access. This other app might integrate with said app, or said app might use services the other app provides.
type Profileable ¶
type Profileable struct { Shell *bool `xml:"http://schemas.android.com/apk/res/android shell,attr"` Enabled *bool `xml:"http://schemas.android.com/apk/res/android enabled,attr"` }
Profileable specifies how profilies can access the application.
type Provider ¶
type Provider struct { Authorities string `xml:"http://schemas.android.com/apk/res/android authorities,attr"` Enabled *bool `xml:"http://schemas.android.com/apk/res/android enabled,attr"` DirectBootAware *bool `xml:"http://schemas.android.com/apk/res/android directBootAware,attr"` Exported bool `xml:"http://schemas.android.com/apk/res/android exported,attr"` GrantURIPermissions *bool `xml:"http://schemas.android.com/apk/res/android grantUriPermissions,attr"` InitOrder *int32 `xml:"http://schemas.android.com/apk/res/android initOrder,attr"` Lable *string `xml:"http://schemas.android.com/apk/res/android label,attr"` MultiProcess *bool `xml:"http://schemas.android.com/apk/res/android multiprocess,attr"` Name string `xml:"http://schemas.android.com/apk/res/android name,attr"` Permission *string `xml:"http://schemas.android.com/apk/res/android permission,attr"` Process *string `xml:"http://schemas.android.com/apk/res/android process,attr"` ReadPermission *string `xml:"http://schemas.android.com/apk/res/android readPermission,attr"` Syncable *bool `xml:"http://schemas.android.com/apk/res/android syncable,attr"` WritePermission *string `xml:"http://schemas.android.com/apk/res/android writePermission,attr"` MetaData *[]MetaData `xml:"meta-data"` IntentFilters *[]IntentFilter `xml:"intent-filter"` }
Provider declares a content provider component which supplies structured access to data managed by the application.
type Query ¶
type Query struct { Packages *[]Package `xml:"package"` Intents *[]IntentFilter `xml:"intent"` Providers *[]Provider `xml:"provider"` }
Query specifies the set of other apps that an app intends to interact with. These other apps can be specified by package name, by intent signature, or by provider authority.
type Receiver ¶
type Receiver struct { DirectBootAware *bool `xml:"http://schemas.android.com/apk/res/android directBootAware,attr"` Enabled bool `xml:"http://schemas.android.com/apk/res/android enabled,attr"` Exported *bool `xml:"http://schemas.android.com/apk/res/android exported,attr"` Label *string `xml:"http://schemas.android.com/apk/res/android label,attr"` Name string `xml:"http://schemas.android.com/apk/res/android name,attr"` IntentFilters *[]IntentFilter `xml:"intent-filter"` MetaData *[]MetaData `xml:"meta-data"` }
Receiver declares a broadcast receiver as one of the application's components.
type ResTable ¶
type ResTable struct {
// contains filtered or unexported fields
}
ResTable is a representation of an Android resource table. It can be referenced from XMLFile attributes to resolve resource table references.
type ResTableConfig ¶
type ResTableConfig struct { Size uint32 MCC uint16 MNC uint16 Language [2]uint8 Country [2]uint8 Orientation uint8 Touchscreen uint8 Density uint16 Keyboard uint8 InputFlags uint8 InputPad0 uint8 ScreenWidth uint16 ScreenHeight uint16 SDKVersion uint16 MinorVersion uint16 ScreenLayout uint8 UIMode uint8 SmallestScreenWidthDP uint16 ScreenWidthDP uint16 ScreenHeightDP uint16 LocaleScript [4]uint8 LocaleVariant [8]uint8 ScreenLayout2 uint8 ColorMode uint8 ScreenConfigPad2 uint16 LocaleScriptWasComputed bool LocaleNumberingSystem [8]uint8 }
ResTableConfig describes a particular resource configuration.
type Service ¶
type Service struct { Description *string `xml:"http://schemas.android.com/apk/res/android description,attr"` DirectBootAware *bool `xml:"http://schemas.android.com/apk/res/android directBootAware,attr"` Enabled *bool `xml:"http://schemas.android.com/apk/res/android enabled,attr"` Exported bool `xml:"http://schemas.android.com/apk/res/android exported,attr"` IsolatedProcess *bool `xml:"http://schemas.android.com/apk/res/android isolatedProcess,attr"` Label *string `xml:"http://schemas.android.com/apk/res/android label,attr"` Name string `xml:"http://schemas.android.com/apk/res/android name,attr"` Permission *string `xml:"http://schemas.android.com/apk/res/android permission,attr"` IntentFilters *[]IntentFilter `xml:"intent-filter"` MetaData *[]MetaData `xml:"meta-data"` }
Service declares a service as one of the application's components.
type SupportsScreen ¶
type SupportsScreen struct { Resizeable *bool `xml:"http://schemas.android.com/apk/res/android resizeable,attr"` SmallScreens *bool `xml:"http://schemas.android.com/apk/res/android smallScreens,attr"` NormalScreens *bool `xml:"http://schemas.android.com/apk/res/android normalScreens,attr"` LargeScreens *bool `xml:"http://schemas.android.com/apk/res/android largeScreens,attr"` XLargeScreens *bool `xml:"http://schemas.android.com/apk/res/android xlargeScreens,attr"` AnyDensity *bool `xml:"http://schemas.android.com/apk/res/android anyDensity,attr"` RequiresSmallestWidthDP *int32 `xml:"http://schemas.android.com/apk/res/android requiresSmallestWidthDp,attr"` CompatibleWidthLimitDP *int32 `xml:"http://schemas.android.com/apk/res/android compatibleWidthLimitDp,attr"` LargestWidthLimitDP *int32 `xml:"http://schemas.android.com/apk/res/android largestWidthLimitDp,attr"` }
SupportsScreen specifies the screen sizes an application supports and whether screen compatibility mode is enabled for screens larger than what the application supports.
type UsesPermission ¶
type UsesPermission struct { Name string `xml:"http://schemas.android.com/apk/res/android name,attr"` MaxSDKVersion *int32 `xml:"http://schemas.android.com/apk/res/android maxSdkVersion,attr"` }
UsesPermission specifies a system permission that the user must grant for the application to operate correctly.
type UsesSDK ¶
type UsesSDK struct { MinSDKVersion *uint `xml:"http://schemas.android.com/apk/res/android minSdkVersion,attr"` TargetSDKVersion *uint `xml:"http://schemas.android.com/apk/res/android targetSdkVersion,attr"` MaxSDKVersion *uint `xml:"http://schemas.android.com/apk/res/android maxSdkVersion,attr"` }
UsesSDK is an expression of an application's compatibility with one or more versions of the Android platform by means of an API level integer.
type XMLFile ¶
type XMLFile struct {
// contains filtered or unexported fields
}
XMLFile is a representation of an Android binary XML file.
func NewXMLFile ¶
NewXMLFile creates a new XMLFile instance from a reader of Android binary XML. If t is provided, resource table references will be followed as necessary. If t is nil, references will be replaced with a hexadecimal resource ID in the XML text accessible by calling String().
Notes ¶
Bugs ¶
Some resource table references in binary XML are incorrectly parsed as empty strings.