code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def show(self) -> None:
"""
Prints the content of this method to stdout.
This will print the method signature and the decompiled code.
"""
args, ret = self.method.get_descriptor()[1:].split(")")
if self.code:
# We patch the descriptor here and add the registe... |
Prints the content of this method to stdout.
This will print the method signature and the decompiled code.
| show | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def __init__(self, value: str) -> None:
"""Instantiate a new [StringAnalysis][androguard.core.analysis.analysis.StringAnalysis]
:param value: the original string value
"""
self.value = value
self.orig_value = value
self.xreffrom = set() | Instantiate a new [StringAnalysis][androguard.core.analysis.analysis.StringAnalysis]
:param value: the original string value
| __init__ | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_from(
self, classobj: ClassAnalysis, methodobj: MethodAnalysis, off: int
) -> None:
"""
Adds a xref from the given method to this string
:param classobj:
:param methodobj:
:param off: offset in the bytecode of the call
"""
self.xreffrom.a... |
Adds a xref from the given method to this string
:param classobj:
:param methodobj:
:param off: offset in the bytecode of the call
| add_xref_from | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_xref_from(
self, with_offset: bool = False
) -> list[tuple[ClassAnalysis, MethodAnalysis]]:
"""
Returns a list of xrefs accessing the String.
The list contains tuples of the originating class and methods,
where the class is represented as a [ClassAnalysis][androguard... |
Returns a list of xrefs accessing the String.
The list contains tuples of the originating class and methods,
where the class is represented as a [ClassAnalysis][androguard.core.analysis.analysis.ClassAnalysis],
while the method is a [MethodAnalysis][androguard.core.analysis.analysis.Me... | get_xref_from | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def __init__(self, field: dex.EncodedField) -> None:
"""Initialize a new [FieldAnalysis][androguard.core.analysis.analysis.FieldAnalysis] object
:param field:
"""
self.field = field
self.xrefread = set()
self.xrefwrite = set() | Initialize a new [FieldAnalysis][androguard.core.analysis.analysis.FieldAnalysis] object
:param field:
| __init__ | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_read(
self, classobj: ClassAnalysis, methodobj: MethodAnalysis, offset: int
) -> None:
"""
:param classobj:
:param methodobj:
:param offset: offset in the bytecode
"""
self.xrefread.add((classobj, methodobj, offset)) |
:param classobj:
:param methodobj:
:param offset: offset in the bytecode
| add_xref_read | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_xref_read(
self, with_offset: bool = False
) -> list[tuple[ClassAnalysis, MethodAnalysis]]:
"""
Returns a list of xrefs where the field is read.
The list contains tuples of the originating class and methods,
where the class is represented as a [ClassAnalysis][androgu... |
Returns a list of xrefs where the field is read.
The list contains tuples of the originating class and methods,
where the class is represented as a [ClassAnalysis][androguard.core.analysis.analysis.ClassAnalysis],
while the method is a [MethodAnalysis][androguard.core.analysis.analysis... | get_xref_read | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_xref_write(
self, with_offset: bool = False
) -> list[tuple[ClassAnalysis, MethodAnalysis]]:
"""
Returns a list of xrefs where the field is written to.
The list contains tuples of the originating class and methods,
where the class is represented as a [ClassAnalysis][... |
Returns a list of xrefs where the field is written to.
The list contains tuples of the originating class and methods,
where the class is represented as a [ClassAnalysis][androguard.core.analysis.analysis.ClassAnalysis],
while the method is a [MethodAnalysis][androguard.core.analysis.an... | get_xref_write | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def __init__(self, name: str) -> None:
"""Instantiate a new [ExternalClass][androguard.core.analysis.analysis.ExternalClass] object
:param name: Name of the external class
"""
self.name = name
self.methods = [] | Instantiate a new [ExternalClass][androguard.core.analysis.analysis.ExternalClass] object
:param name: Name of the external class
| __init__ | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def __init__(self, class_name: str, name: str, descriptor: str) -> None:
"""Initialize a new [ExternalMethod][androguard.core.analysis.analysis.ExternalMethod] object
:param class_name: name of the class
:param name: name of the method
:param descriptor: descriptor string
"""
... | Initialize a new [ExternalMethod][androguard.core.analysis.analysis.ExternalMethod] object
:param class_name: name of the class
:param name: name of the method
:param descriptor: descriptor string
| __init__ | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def full_name(self) -> str:
"""Returns classname + name + descriptor, separated by spaces (no access flags)'
:returns: the formatted name
"""
return (
self.class_name
+ " "
+ self.name
+ " "
+ str(self.get_descriptor())... | Returns classname + name + descriptor, separated by spaces (no access flags)'
:returns: the formatted name
| full_name | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def permission_api_name(self) -> str:
"""Returns a name which can be used to look up in the permission maps
:returns: the formatted name
"""
return (
self.class_name
+ "-"
+ self.name
+ "-"
+ str(self.get_descriptor())
... | Returns a name which can be used to look up in the permission maps
:returns: the formatted name
| permission_api_name | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_access_flags_string(self) -> str:
"""
Returns the access flags string.
Right now, this is always an empty strings, as we can not say what
kind of access flags an external method might have.
"""
# TODO can we assume that external methods are always public?
... |
Returns the access flags string.
Right now, this is always an empty strings, as we can not say what
kind of access flags an external method might have.
| get_access_flags_string | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def __init__(
self, classobj: Union[dex.ClassDefItem, ExternalClass]
) -> None:
"""Initialize a new [ClassAnalysis][androguard.core.analysis.analysis.ClassAnalysis] object
:param classobj: the original class
"""
logger.info(f"Adding new ClassAnalysis: {classobj}")
#... | Initialize a new [ClassAnalysis][androguard.core.analysis.analysis.ClassAnalysis] object
:param classobj: the original class
| __init__ | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_method(self, method_analysis: MethodAnalysis) -> None:
"""
Add the given method to this analyis.
usually only called during [Analysis.add][androguard.core.analysis.analysis.Analysis.add] and `Analysis._resolve_method`
:param method_analysis: the method to add
"""
... |
Add the given method to this analyis.
usually only called during [Analysis.add][androguard.core.analysis.analysis.Analysis.add] and `Analysis._resolve_method`
:param method_analysis: the method to add
| add_method | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def implements(self) -> list[str]:
"""
Get a list of interfaces which are implemented by this class
:returns: a list of Interface names
"""
if self.is_external():
return []
return self.orig_class.get_interfaces() |
Get a list of interfaces which are implemented by this class
:returns: a list of Interface names
| implements | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def extends(self) -> str:
"""
Return the parent class
For external classes, this is not sure, thus we return always Object (which is the parent of all classes)
:returns: a string of the parent class name
"""
if self.is_external():
return "Ljava/lang/Object;"... |
Return the parent class
For external classes, this is not sure, thus we return always Object (which is the parent of all classes)
:returns: a string of the parent class name
| extends | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def is_android_api(self) -> bool:
"""
Tries to guess if the current class is an Android API class.
This might be not very precise unless an apilist is given, with classes that
are in fact known APIs.
Such a list might be generated by using the android.jar files.
:return... |
Tries to guess if the current class is an Android API class.
This might be not very precise unless an apilist is given, with classes that
are in fact known APIs.
Such a list might be generated by using the android.jar files.
:returns: True if the class is an Andorid API class,... | is_android_api | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_methods(self) -> list[MethodAnalysis]:
"""
Return all [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis] objects of this class
:returns: the `MethodAnalysis` objects in this class
"""
return self._methods.values()
# return list(self._methods.value... |
Return all [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis] objects of this class
:returns: the `MethodAnalysis` objects in this class
| get_methods | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_field(self, field_analysis: FieldAnalysis) -> None:
"""
Add the given field to this analyis.
usually only called during [Analysis.add][androguard.core.analysis.analysis.Analysis.add]
:param field_analysis: the `FieldAnalysis` to add
"""
self._fields[field_analysi... |
Add the given field to this analyis.
usually only called during [Analysis.add][androguard.core.analysis.analysis.Analysis.add]
:param field_analysis: the `FieldAnalysis` to add
| add_field | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_field_xref_read(
self,
method: MethodAnalysis,
classobj: ClassAnalysis,
field: dex.EncodedField,
off: int,
) -> None:
"""
Add a Field Read to this class
:param method:
:param classobj:
:param field:
:param int off:
... |
Add a Field Read to this class
:param method:
:param classobj:
:param field:
:param int off:
| add_field_xref_read | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_field_xref_write(
self,
method: MethodAnalysis,
classobj: ClassAnalysis,
field: dex.EncodedField,
off: int,
) -> None:
"""
Add a Field Write to this class in a given method
:param method:
:param classobj:
:param field:
... |
Add a Field Write to this class in a given method
:param method:
:param classobj:
:param field:
:param int off:
| add_field_xref_write | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_method_xref_to(
self,
method1: MethodAnalysis,
classobj: ClassAnalysis,
method2: MethodAnalysis,
offset: int,
) -> None:
"""
:param method1: the calling method
:param classobj: the calling class
:param method2: the called method
... |
:param method1: the calling method
:param classobj: the calling class
:param method2: the called method
:param int offset: offset in the bytecode of calling method
| add_method_xref_to | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_method_xref_from(
self,
method1: MethodAnalysis,
classobj: ClassAnalysis,
method2: MethodAnalysis,
offset: int,
) -> None:
"""
:param method1:
:param classobj:
:param method2:
:param int offset:
"""
# FIXME: Not ... |
:param method1:
:param classobj:
:param method2:
:param int offset:
| add_method_xref_from | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_to(
self,
ref_kind: REF_TYPE,
classobj: ClassAnalysis,
methodobj: MethodAnalysis,
offset: int,
) -> None:
"""
Creates a crossreference to another class.
XrefTo means, that the current class calls another class.
The current class sh... |
Creates a crossreference to another class.
XrefTo means, that the current class calls another class.
The current class should also be contained in the another class' XrefFrom list.
WARNING: The implementation of this specific method might not be what you expect! the parameter `methodob... | add_xref_to | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_from(
self,
ref_kind: REF_TYPE,
classobj: ClassAnalysis,
methodobj: MethodAnalysis,
offset: int,
) -> None:
"""
Creates a crossreference from this class.
XrefFrom means, that the current class is called by another class.
:param re... |
Creates a crossreference from this class.
XrefFrom means, that the current class is called by another class.
:param ref_kind: type of call
:param classobj: `ClassAnalysis` object to link
:param methodobj:
:param offset: Offset in the methods bytecode, where the call hap... | add_xref_from | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_xref_from(
self,
) -> dict[ClassAnalysis, tuple[REF_TYPE, MethodAnalysis, int]]:
"""
Returns a dictionary of all classes calling the current class.
This dictionary contains also information from which method the class is accessed.
Note: this method might contains wro... |
Returns a dictionary of all classes calling the current class.
This dictionary contains also information from which method the class is accessed.
Note: this method might contains wrong information about class usage!
The dictionary contains the classes as keys (stored as [ClassAnalysis... | get_xref_from | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_xref_to(
self,
) -> dict[ClassAnalysis, tuple[REF_TYPE, MethodAnalysis, int]]:
"""
Returns a dictionary of all classes which are called by the current class.
This dictionary contains also information about the method which is called.
Note: this method might contains ... |
Returns a dictionary of all classes which are called by the current class.
This dictionary contains also information about the method which is called.
Note: this method might contains wrong information about class usage!
The dictionary contains the classes as keys (stored as [ClassAna... | get_xref_to | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_new_instance(
self, methobj: MethodAnalysis, offset: int
) -> None:
"""
Add a crossreference to another method that is
instancing this class.
:param methobj: The `MethodAnalysis` that this class calls
:param offset: integer where in the method the instan... |
Add a crossreference to another method that is
instancing this class.
:param methobj: The `MethodAnalysis` that this class calls
:param offset: integer where in the method the instantiation happens
| add_xref_new_instance | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add_xref_const_class(
self, methobj: MethodAnalysis, offset: int
) -> None:
"""
Add a crossreference to a method referencing this classtype.
:param methobj: The `MethodAnalysis` that this class calls
:param offset: integer where in the method the classtype is referenced
... |
Add a crossreference to a method referencing this classtype.
:param methobj: The `MethodAnalysis` that this class calls
:param offset: integer where in the method the classtype is referenced
| add_xref_const_class | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def set_restriction_flag(
self, flag: dex.HiddenApiClassDataItem.RestrictionApiFlag
) -> None:
"""
Set the level of restriction for this class (hidden level, from Android 10)
(only applicable to internal classes)
:param flag: The flag to set to
"""
if self.is... |
Set the level of restriction for this class (hidden level, from Android 10)
(only applicable to internal classes)
:param flag: The flag to set to
| set_restriction_flag | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def set_domain_flag(
self, flag: dex.HiddenApiClassDataItem.DomapiApiFlag
) -> None:
"""
Set the api domain for this class (hidden level, from Android 10)
(only applicable to internal classes)
:param flag: The flag to set to
"""
if self.is_external():
... |
Set the api domain for this class (hidden level, from Android 10)
(only applicable to internal classes)
:param flag: The flag to set to
| set_domain_flag | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def __init__(self, vm: Union[dex.DEX, None] = None) -> None:
"""Initialize a new [Analysis][androguard.core.analysis.analysis.Analysis] object
:param vm: inital DEX object (default None)
"""
# Contains DEX objects
self.vms = []
# A dict of {classname: ClassAnalys... | Initialize a new [Analysis][androguard.core.analysis.analysis.Analysis] object
:param vm: inital DEX object (default None)
| __init__ | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def add(self, vm: dex.DEX) -> None:
"""
Add a DEX to this Analysis.
:param vm: `dex.DEX` to add to this Analysis
"""
self.vms.append(vm)
logger.info("Adding DEX file version {}".format(vm.version))
# TODO: This step can easily be multithreaded, as there is no ... |
Add a DEX to this Analysis.
:param vm: `dex.DEX` to add to this Analysis
| add | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def create_xref(self) -> None:
"""
Create Class, Method, String and Field crossreferences
for all classes in the Analysis.
If you are using multiple DEX files, this function must
be called when all DEX files are added.
If you call the function after every DEX file, it wi... |
Create Class, Method, String and Field crossreferences
for all classes in the Analysis.
If you are using multiple DEX files, this function must
be called when all DEX files are added.
If you call the function after every DEX file, it will only work
for the first time.
... | create_xref | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def _create_xref(self, current_class: dex.ClassDefItem) -> None:
"""
Create the xref for `current_class`
There are four steps involved in getting the xrefs:
* Xrefs for class instantiation and static class usage
* for method calls
* for string usage
*... |
Create the xref for `current_class`
There are four steps involved in getting the xrefs:
* Xrefs for class instantiation and static class usage
* for method calls
* for string usage
* for field manipulation
All these information are stored in t... | _create_xref | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_method(
self, method: dex.EncodedMethod
) -> Union[MethodAnalysis, None]:
"""
Get the [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis] object for a given [EncodedMethod][androguard.core.dex.EncodedMethod].
This Analysis object is used to enhance `EncodedMeth... |
Get the [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis] object for a given [EncodedMethod][androguard.core.dex.EncodedMethod].
This Analysis object is used to enhance `EncodedMethods`.
:param method: `EncodedMethod` to search for
:returns: `MethodAnalysis` object for... | get_method | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def _resolve_method(
self, class_name: str, method_name: str, method_descriptor: list[str]
) -> MethodAnalysis:
"""
Resolves the Method and returns [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis].
Will automatically create [ExternalMethods][androguard.core.analysis... |
Resolves the Method and returns [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis].
Will automatically create [ExternalMethods][androguard.core.analysis.analysis.ExternalMethod] if can not resolve and add to the ClassAnalysis etc
:param class_name:
:param method_name:
... | _resolve_method | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_method_by_name(
self, class_name: str, method_name: str, method_descriptor: str
) -> Union[dex.EncodedMethod, None]:
"""
Search for a [EncodedMethod][androguard.core.dex.EncodedMethod] in all classes in this analysis
:param class_name: name of the class, for example `'Ljava/... |
Search for a [EncodedMethod][androguard.core.dex.EncodedMethod] in all classes in this analysis
:param class_name: name of the class, for example `'Ljava/lang/Object;'`
:param method_name: name of the method, for example `'onCreate'`
:param method_descriptor: descriptor, for example `'... | get_method_by_name | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_method_analysis_by_name(
self, class_name: str, method_name: str, method_descriptor: str
) -> Union[MethodAnalysis, None]:
"""
Returns the crossreferencing object for a given method.
This function is similar to [get_method_analysis][androguard.core.analysis.analysis.ClassAna... |
Returns the crossreferencing object for a given method.
This function is similar to [get_method_analysis][androguard.core.analysis.analysis.ClassAnalysis.get_method_analysis], with the difference
that you can look up the Method by name
:param class_name: name of the class, for example... | get_method_analysis_by_name | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_field_analysis(
self, field: dex.EncodedField
) -> Union[FieldAnalysis, None]:
"""
Get the [FieldAnalysis][androguard.core.analysis.analysis.FieldAnalysis] for a given [EncodedField][androguard.core.dex.EncodedField]
:param field: the `EncodedField`
:returns: the `Fi... |
Get the [FieldAnalysis][androguard.core.analysis.analysis.FieldAnalysis] for a given [EncodedField][androguard.core.dex.EncodedField]
:param field: the `EncodedField`
:returns: the `FieldAnalysis`
| get_field_analysis | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_external_classes(self) -> Iterator[ClassAnalysis]:
"""
Returns all external classes, that means all classes that are not
defined in the given set of [DEX][androguard.core.dex.DEX].
:returns: the external classes
"""
for cls in self.classes.values():
i... |
Returns all external classes, that means all classes that are not
defined in the given set of [DEX][androguard.core.dex.DEX].
:returns: the external classes
| get_external_classes | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_internal_classes(self) -> Iterator[ClassAnalysis]:
"""
Returns all internal classes, that means all classes that are
defined in the given set of [DEX][androguard.core.dex.DEX].
:returns: the internal classes
"""
for cls in self.classes.values():
if no... |
Returns all internal classes, that means all classes that are
defined in the given set of [DEX][androguard.core.dex.DEX].
:returns: the internal classes
| get_internal_classes | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_internal_methods(self) -> Iterator[MethodAnalysis]:
"""
Returns all internal methods, that means all methods that are
defined in the given set of [DEX][androguard.core.dex.DEX].
:returns: the internal methods
"""
for m in self.methods.values():
if not... |
Returns all internal methods, that means all methods that are
defined in the given set of [DEX][androguard.core.dex.DEX].
:returns: the internal methods
| get_internal_methods | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_external_methods(self) -> Iterator[MethodAnalysis]:
"""
Returns all external methods, that means all methods that are not
defined in the given set of [DEX][androguard.core.dex.DEX].
:returns: the external methods
"""
for m in self.methods.values():
if... |
Returns all external methods, that means all methods that are not
defined in the given set of [DEX][androguard.core.dex.DEX].
:returns: the external methods
| get_external_methods | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_fields(self) -> Iterator[FieldAnalysis]:
"""
Returns a generator of [FieldAnalysis][androguard.core.analysis.analysis.FieldAnalysis] objects
:returns: generator of `FieldAnalysis` objects
"""
for c in self.classes.values():
for f in c.get_fields():
... |
Returns a generator of [FieldAnalysis][androguard.core.analysis.analysis.FieldAnalysis] objects
:returns: generator of `FieldAnalysis` objects
| get_fields | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def find_classes(
self, name: str = ".*", no_external: bool = False
) -> Iterator[ClassAnalysis]:
"""
Find classes by name, using regular expression
This method will return all [ClassAnalysis][androguard.core.analysis.analysis.ClassAnalysis] Object that match the name of
the ... |
Find classes by name, using regular expression
This method will return all [ClassAnalysis][androguard.core.analysis.analysis.ClassAnalysis] Object that match the name of
the class.
:param name: regular expression for class name (default ".*")
:param no_external: Remove external... | find_classes | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def find_methods(
self,
classname: str = ".*",
methodname: str = ".*",
descriptor: str = ".*",
accessflags: str = ".*",
no_external: bool = False,
) -> Iterator[MethodAnalysis]:
"""
Find a method by name using regular expression.
This method wi... |
Find a method by name using regular expression.
This method will return all [MethodAnalysis][androguard.core.analysis.analysis.MethodAnalysis] objects, which match the
classname, methodname, descriptor and accessflags of the method.
:param classname: regular expression for the classnam... | find_methods | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def find_strings(self, string: str = ".*") -> Iterator[StringAnalysis]:
"""
Find strings by regex
:param string: regular expression for the string to search for
:returns: generator of `StringAnalysis` objects
"""
for s, sa in self.strings.items():
if re.match... |
Find strings by regex
:param string: regular expression for the string to search for
:returns: generator of `StringAnalysis` objects
| find_strings | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def find_fields(
self,
classname: str = ".*",
fieldname: str = ".*",
fieldtype: str = ".*",
accessflags: str = ".*",
) -> Iterator[FieldAnalysis]:
"""
find fields by regex
:param classname: regular expression of the classname
:param fieldname:... |
find fields by regex
:param classname: regular expression of the classname
:param fieldname: regular expression of the fieldname
:param fieldtype: regular expression of the fieldtype
:param accessflags: regular expression of the access flags
:returns: generator of `Fiel... | find_fields | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_call_graph(
self,
classname: str = ".*",
methodname: str = ".*",
descriptor: str = ".*",
accessflags: str = ".*",
no_isolated: bool = False,
entry_points: list = [],
) -> nx.DiGraph:
"""
Generate a directed graph based on the methods fo... |
Generate a directed graph based on the methods found by the filters applied.
The filters are the same as in [find_methods][androguard.core.analysis.analysis.Analysis.find_methods]
A `networkx.DiGraph` is returned, containing all edges only once!
that means, if a method calls some metho... | get_call_graph | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def _add_node(G, method, _entry_points):
"""
Wrapper to add methods to a graph
"""
if method not in G:
if isinstance(method, ExternalMethod):
is_external = True
else:
is_external = False
... |
Wrapper to add methods to a graph
| _add_node | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def create_ipython_exports(self) -> None:
"""
WARNING: this feature is experimental and is currently not enabled by default! Use with caution!
Creates attributes for all classes, methods and fields on the `Analysis` object itself.
This makes it easier to work with `Analysis` module in a... |
WARNING: this feature is experimental and is currently not enabled by default! Use with caution!
Creates attributes for all classes, methods and fields on the `Analysis` object itself.
This makes it easier to work with `Analysis` module in an iPython shell.
Classes can be search by ty... | create_ipython_exports | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_permissions(
self, apilevel: Union[str, int, None] = None
) -> Iterator[MethodAnalysis, list[str]]:
"""
Returns the permissions and the API method based on the API level specified.
This can be used to find usage of API methods which require a permission.
Should be use... |
Returns the permissions and the API method based on the API level specified.
This can be used to find usage of API methods which require a permission.
Should be used in combination with an [APK][androguard.core.apk.APK]
The returned permissions are a list, as some API methods require m... | get_permissions | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_permission_usage(
self, permission: str, apilevel: Union[str, int, None] = None
) -> Iterator[MethodAnalysis]:
"""
Find the usage of a permission inside the Analysis.
Examples:
>>> from androguard.misc import AnalyzeAPK
>>> a, d, dx = AnalyzeAPK("som... |
Find the usage of a permission inside the Analysis.
Examples:
>>> from androguard.misc import AnalyzeAPK
>>> a, d, dx = AnalyzeAPK("somefile.apk")
>>> for meth in dx.get_permission_usage('android.permission.SEND_SMS', a.get_effective_target_sdk_version()):
... | get_permission_usage | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def get_android_api_usage(self) -> Iterator[MethodAnalysis]:
"""
Get all usage of the Android APIs inside the `Analysis`.
:returns: yields `MethodAnalysis` objects for all Android APIs methods
"""
for cls in self.get_external_classes():
for meth_analysis in cls.get_... |
Get all usage of the Android APIs inside the `Analysis`.
:returns: yields `MethodAnalysis` objects for all Android APIs methods
| get_android_api_usage | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def is_ascii_obfuscation(vm: dex.DEX) -> bool:
"""
Tests if any class inside a [DEX][androguard.core.dex.DEX]
uses ASCII Obfuscation (e.g. UTF-8 Chars in Classnames)
:param vm: `DEX`
:returns: `True` if ascii obfuscation otherwise `False`
"""
for classe in vm.get_classes():
if is_as... |
Tests if any class inside a [DEX][androguard.core.dex.DEX]
uses ASCII Obfuscation (e.g. UTF-8 Chars in Classnames)
:param vm: `DEX`
:returns: `True` if ascii obfuscation otherwise `False`
| is_ascii_obfuscation | python | androguard/androguard | androguard/core/analysis/analysis.py | https://github.com/androguard/androguard/blob/master/androguard/core/analysis/analysis.py | Apache-2.0 |
def load_permissions(
apilevel: Union[str, int], permtype: str = 'permissions'
) -> dict[str, dict[str, str]]:
"""
Load the Permissions for the given apilevel.
The permissions lists are generated using this tool: https://github.com/U039b/aosp_permissions_extraction
Has a fallback to select the max... |
Load the Permissions for the given apilevel.
The permissions lists are generated using this tool: https://github.com/U039b/aosp_permissions_extraction
Has a fallback to select the maximum or minimal available API level.
For example, if 28 is requested but only 26 is available, 26 is returned.
If ... | load_permissions | python | androguard/androguard | androguard/core/api_specific_resources/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/api_specific_resources/__init__.py | Apache-2.0 |
def load_permission_mappings(
apilevel: Union[str, int]
) -> dict[str, list[str]]:
"""
Load the API/Permission mapping for the requested API level.
If the requetsed level was not found, None is returned.
:param apilevel: integer value of the API level, i.e. 24 for Android 7.0
:return: a diction... |
Load the API/Permission mapping for the requested API level.
If the requetsed level was not found, None is returned.
:param apilevel: integer value of the API level, i.e. 24 for Android 7.0
:return: a dictionary of {MethodSignature: [List of Permissions]}
| load_permission_mappings | python | androguard/androguard | androguard/core/api_specific_resources/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/api_specific_resources/__init__.py | Apache-2.0 |
def _dump_additional_attributes(additional_attributes):
"""try to parse additional attributes, but ends up to hexdump if the scheme is unknown"""
attributes_raw = io.BytesIO(additional_attributes)
attributes_hex = binascii.hexlify(additional_attributes)
if not len(additional_attributes):
retur... | try to parse additional attributes, but ends up to hexdump if the scheme is unknown | _dump_additional_attributes | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def __init__(
self,
filename: str,
raw: bool = False,
magic_file: Union[str, None] = None,
skip_analysis: bool = False,
testzip: bool = False,
) -> None:
"""
This class can access to all elements in an APK file
Examples:
>>> APK("... |
This class can access to all elements in an APK file
Examples:
>>> APK("myfile.apk")
>>> APK(read("myfile.apk"), raw=True)
:param filename: specify the path of the file, or raw data
:param raw: specify if the filename is a path or raw data (optional)
:... | __init__ | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def _apk_analysis(self):
"""
Run analysis on the APK file.
This method is usually called by __init__ except if skip_analysis is False.
It will then parse the `AndroidManifest.xml` and set all fields in the APK class which can be
extracted from the Manifest.
"""
i... |
Run analysis on the APK file.
This method is usually called by __init__ except if skip_analysis is False.
It will then parse the `AndroidManifest.xml` and set all fields in the APK class which can be
extracted from the Manifest.
| _apk_analysis | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def __getstate__(self):
"""
Function for pickling APK Objects.
We remove the zip from the Object, as it is not pickable
And it does not make any sense to pickle it anyways.
:returns: the picklable APK Object without zip.
"""
# Upon pickling, we need to remove th... |
Function for pickling APK Objects.
We remove the zip from the Object, as it is not pickable
And it does not make any sense to pickle it anyways.
:returns: the picklable APK Object without zip.
| __getstate__ | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def __setstate__(self, state):
"""
Load a pickled APK Object and restore the state
We load the zip file back by reading __raw from the Object.
:param state: pickled state
"""
self.__dict__ = state
self.zip = zipfile.ZipFile(io.BytesIO(self.get_raw()), mode="r") |
Load a pickled APK Object and restore the state
We load the zip file back by reading __raw from the Object.
:param state: pickled state
| __setstate__ | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_app_name(self, locale=None) -> str:
"""
Return the appname of the APK
This name is read from the `AndroidManifest.xml`
using the application `android:label`.
If no label exists, the `android:label` of the main activity is used.
If there is also no main activity l... |
Return the appname of the APK
This name is read from the `AndroidManifest.xml`
using the application `android:label`.
If no label exists, the `android:label` of the main activity is used.
If there is also no main activity label, an empty string is returned.
:returns: t... | get_app_name | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_app_icon(self, max_dpi: int = 65536) -> Union[str, None]:
"""
Return the first icon file name, which density is not greater than max_dpi,
unless exact icon resolution is set in the manifest, in which case
return the exact file.
This information is read from the `AndroidM... |
Return the first icon file name, which density is not greater than max_dpi,
unless exact icon resolution is set in the manifest, in which case
return the exact file.
This information is read from the `AndroidManifest.xml`
From <https://developer.android.com/guide/practices/scr... | get_app_icon | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def _get_file_magic_name(self, buffer: bytes) -> str:
"""
Return the filetype guessed for a buffer
:param buffer: bytes
:returns: guessed filetype, or "Unknown" if not resolved
"""
default = "Unknown"
# Faster way, test once, return default.
if self.__no... |
Return the filetype guessed for a buffer
:param buffer: bytes
:returns: guessed filetype, or "Unknown" if not resolved
| _get_file_magic_name | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_files_types(self) -> dict[str, str]:
"""
Return the files inside the APK with their associated types (by using [python-magic](https://pypi.org/project/python-magic/))
At the same time, the CRC32 are calculated for the files.
:returns: the files inside the APK with their associa... |
Return the files inside the APK with their associated types (by using [python-magic](https://pypi.org/project/python-magic/))
At the same time, the CRC32 are calculated for the files.
:returns: the files inside the APK with their associated types
| get_files_types | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def _patch_magic(self, buffer, orig):
"""
Overwrite some probably wrong detections by mime libraries
:param buffer: bytes of the file to detect
:param orig: guess by mime libary
:returns: corrected guess
"""
if (
("Zip" in orig)
or ('(JAR)... |
Overwrite some probably wrong detections by mime libraries
:param buffer: bytes of the file to detect
:param orig: guess by mime libary
:returns: corrected guess
| _patch_magic | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def _get_crc32(self, filename):
"""
Calculates and compares the CRC32 and returns the raw buffer.
The CRC32 is added to [files_crc32][androguard.core.apk.APK.files_crc32] dictionary, if not present.
:param filename: filename inside the zipfile
:rtype: bytes
"""
... |
Calculates and compares the CRC32 and returns the raw buffer.
The CRC32 is added to [files_crc32][androguard.core.apk.APK.files_crc32] dictionary, if not present.
:param filename: filename inside the zipfile
:rtype: bytes
| _get_crc32 | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_files_crc32(self) -> dict[str, int]:
"""
Calculates and returns a dictionary of filenames and CRC32
:returns: dict of filename: CRC32
"""
if self.files_crc32 == {}:
for i in self.get_files():
self._get_crc32(i)
return self.files_crc32 |
Calculates and returns a dictionary of filenames and CRC32
:returns: dict of filename: CRC32
| get_files_crc32 | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_files_information(self) -> Iterator[tuple[str, str, int]]:
"""
Return the files inside the APK with their associated types and crc32
:returns: the files inside the APK with their associated types and crc32
"""
for k in self.get_files():
yield k, self.get_file... |
Return the files inside the APK with their associated types and crc32
:returns: the files inside the APK with their associated types and crc32
| get_files_information | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_raw(self) -> bytes:
"""
Return raw bytes of the APK
:returns: bytes of the APK
"""
if self.__raw:
return self.__raw
else:
with open(self.filename, 'rb') as f:
self.__raw = bytearray(f.read())
return self.__raw |
Return raw bytes of the APK
:returns: bytes of the APK
| get_raw | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_file(self, filename: str) -> bytes:
"""
Return the raw data of the specified filename
inside the APK
:param filename: the filename to get
:raises FileNotPresent: if filename not found inside the apk
:returns: bytes of the specified filename
"""
tr... |
Return the raw data of the specified filename
inside the APK
:param filename: the filename to get
:raises FileNotPresent: if filename not found inside the apk
:returns: bytes of the specified filename
| get_file | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_dex(self) -> bytes:
"""
Return the raw data of the classes dex file
This will give you the data of the file called `classes.dex`
inside the APK. If the APK has multiple DEX files, you need to use [get_all_dex][androguard.core.apk.APK.get_all_dex].
:raises FileNotPresent... |
Return the raw data of the classes dex file
This will give you the data of the file called `classes.dex`
inside the APK. If the APK has multiple DEX files, you need to use [get_all_dex][androguard.core.apk.APK.get_all_dex].
:raises FileNotPresent: if classes.dex is not found
:... | get_dex | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_dex_names(self) -> list[str]:
"""
Return the names of all DEX files found in the APK.
This method only accounts for "offical" dex files, i.e. all files
in the root directory of the APK named `classes.dex` or `classes[0-9]+.dex`
:returns: the names of all DEX files found ... |
Return the names of all DEX files found in the APK.
This method only accounts for "offical" dex files, i.e. all files
in the root directory of the APK named `classes.dex` or `classes[0-9]+.dex`
:returns: the names of all DEX files found in the APK
| get_dex_names | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def is_multidex(self) -> bool:
"""
Test if the APK has multiple DEX files
:returns: True if multiple dex found, otherwise False
"""
dexre = re.compile(r"^classes(\d+)?.dex$")
return (
len(
[
instance
for... |
Test if the APK has multiple DEX files
:returns: True if multiple dex found, otherwise False
| is_multidex | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def _format_value(self, value):
"""
Format a value with packagename, if not already set.
For example, the name `'.foobar'` will be transformed into `'package.name.foobar'`.
Names which do not contain any dots are assumed to be packagename-less as well:
`foobar` will also transfo... |
Format a value with packagename, if not already set.
For example, the name `'.foobar'` will be transformed into `'package.name.foobar'`.
Names which do not contain any dots are assumed to be packagename-less as well:
`foobar` will also transform into `package.name.foobar`.
:pa... | _format_value | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_all_attribute_value(
self,
tag_name: str,
attribute: str,
format_value: bool = True,
**attribute_filter,
) -> Iterator[str]:
"""
Yields all the attribute values in xml files which match with the tag name and the specific attribute
:param str t... |
Yields all the attribute values in xml files which match with the tag name and the specific attribute
:param str tag_name: specify the tag name
:param str attribute: specify the attribute
:param bool format_value: specify if the value needs to be formatted with packagename
:re... | get_all_attribute_value | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_attribute_value(
self,
tag_name: str,
attribute: str,
format_value: bool = False,
**attribute_filter,
) -> str:
"""
Return the attribute value in xml files which matches the tag name and the specific attribute
:param str tag_name: specify the ... |
Return the attribute value in xml files which matches the tag name and the specific attribute
:param str tag_name: specify the tag name
:param str attribute: specify the attribute
:param bool format_value: specify if the value needs to be formatted with packagename
:returns: t... | get_attribute_value | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_value_from_tag(
self, tag: Element, attribute: str
) -> Union[str, None]:
"""
Return the value of the android prefixed attribute in a specific tag.
This function will always try to get the attribute with a `android:` prefix first,
and will try to return the attribute... |
Return the value of the android prefixed attribute in a specific tag.
This function will always try to get the attribute with a `android:` prefix first,
and will try to return the attribute without the prefix, if the attribute could not be found.
This is useful for some broken `Android... | get_value_from_tag | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def find_tags(self, tag_name: str, **attribute_filter) -> list[str]:
"""
Return a list of all the matched tags in all available xml
:param tag_name: specify the tag name
:returns: the matched tags
"""
all_tags = [
self.find_tags_from_xml(i, tag_name, **attri... |
Return a list of all the matched tags in all available xml
:param tag_name: specify the tag name
:returns: the matched tags
| find_tags | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def find_tags_from_xml(
self, xml_name: str, tag_name: str, **attribute_filter
) -> list[str]:
"""
Return a list of all the matched tags in a specific xml
:param str xml_name: specify from which xml to pick the tag from
:param str tag_name: specify the tag name
... |
Return a list of all the matched tags in a specific xml
:param str xml_name: specify from which xml to pick the tag from
:param str tag_name: specify the tag name
:returns: the matched tags
| find_tags_from_xml | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def is_tag_matched(self, tag: lxml.etree.Element, **attribute_filter) -> bool:
r"""
Return `True` if the attributes matches in attribute filter.
An attribute filter is a dictionary containing: {attribute_name: value}.
This function will return `True` if and only if all attributes have t... |
Return `True` if the attributes matches in attribute filter.
An attribute filter is a dictionary containing: {attribute_name: value}.
This function will return `True` if and only if all attributes have the same value.
This function allows to set the dictionary via kwargs, thus you can ... | is_tag_matched | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_main_activities(self) -> set[str]:
"""
Return names of the main activities
These values are read from the `AndroidManifest.xml`
:returns: names of the main activities
"""
x = set()
y = set()
for i in self.xml:
if self.xml[i] is None:... |
Return names of the main activities
These values are read from the `AndroidManifest.xml`
:returns: names of the main activities
| get_main_activities | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_main_activity(self) -> Union[str, None]:
"""
Return the name of the main activity
This value is read from the `AndroidManifest.xml`
:returns: the name of the main activity
"""
activities = self.get_main_activities()
if len(activities) == 1:
r... |
Return the name of the main activity
This value is read from the `AndroidManifest.xml`
:returns: the name of the main activity
| get_main_activity | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_activity_aliases(self) -> list[dict[str, str]]:
"""
Return the `android:name` and `android:targetActivity` attribute of all activity aliases.
:returns: the list of `android:name` and `android:targetActivity` attribute of all activitiy aliases
"""
ali = []
for ali... |
Return the `android:name` and `android:targetActivity` attribute of all activity aliases.
:returns: the list of `android:name` and `android:targetActivity` attribute of all activitiy aliases
| get_activity_aliases | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_res_value(self, name: str) -> str:
"""
Return the literal value with a resource id
:returns: the literal value with a resource id
"""
res_parser = self.get_android_resources()
if not res_parser:
return name
res_id = res_parser.parse_id(name)... |
Return the literal value with a resource id
:returns: the literal value with a resource id
| get_res_value | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_intent_filters(
self, itemtype: str, name: str
) -> dict[str, list[str]]:
"""
Find intent filters for a given item and name.
Intent filter are attached to activities, services or receivers.
You can search for the intent filters of such items and get a dictionary of a... |
Find intent filters for a given item and name.
Intent filter are attached to activities, services or receivers.
You can search for the intent filters of such items and get a dictionary of all
attached actions and intent categories.
:param itemtype: the type of parent item to l... | get_intent_filters | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_uses_implied_permission_list(self) -> list[str]:
"""
Return all permissions implied by the target SDK or other permissions.
:returns: list of all permissions implied by the target SDK or other permissions as strings
"""
target_sdk_version = self.get_effective_tar... |
Return all permissions implied by the target SDK or other permissions.
:returns: list of all permissions implied by the target SDK or other permissions as strings
| get_uses_implied_permission_list | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_details_permissions(self) -> dict[str, list[str]]:
"""
Return permissions with details.
This can only return details about the permission, if the permission is
defined in the AOSP.
:returns: permissions with details: dict of `{permission: [protectionLevel, label, descri... |
Return permissions with details.
This can only return details about the permission, if the permission is
defined in the AOSP.
:returns: permissions with details: dict of `{permission: [protectionLevel, label, description]}`
| get_details_permissions | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_requested_aosp_permissions(self) -> list[str]:
"""
Returns requested permissions declared within AOSP project.
This includes several other permissions as well, which are in the platform apps.
:returns: requested permissions
"""
aosp_permissions = []
all_... |
Returns requested permissions declared within AOSP project.
This includes several other permissions as well, which are in the platform apps.
:returns: requested permissions
| get_requested_aosp_permissions | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_requested_aosp_permissions_details(self) -> dict[str, list[str]]:
"""
Returns requested aosp permissions with details.
:returns: requested aosp permissions
"""
l = {}
for i in self.permissions:
try:
l[i] = self.permission_module[i]
... |
Returns requested aosp permissions with details.
:returns: requested aosp permissions
| get_requested_aosp_permissions_details | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_requested_third_party_permissions(self) -> list[str]:
"""
Returns list of requested permissions not declared within AOSP project.
:returns: requested permissions
"""
third_party_permissions = []
all_permissions = self.get_permissions()
for perm in all_per... |
Returns list of requested permissions not declared within AOSP project.
:returns: requested permissions
| get_requested_third_party_permissions | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_effective_target_sdk_version(self) -> int:
"""
Return the effective `targetSdkVersion`, always returns int > 0.
If the `targetSdkVersion` is not set, it defaults to 1. This is
set based on defaults as defined in:
<https://developer.android.com/guide/topics/manifest/uses... |
Return the effective `targetSdkVersion`, always returns int > 0.
If the `targetSdkVersion` is not set, it defaults to 1. This is
set based on defaults as defined in:
<https://developer.android.com/guide/topics/manifest/uses-sdk-element.html>
:returns: the effective `targetSdk... | get_effective_target_sdk_version | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def is_androidtv(self) -> bool:
"""
Checks if this application does not require a touchscreen,
as this is the rule to get into the TV section of the Play Store
See: https://developer.android.com/training/tv/start/start.html for more information.
:returns: `True` if 'android.hard... |
Checks if this application does not require a touchscreen,
as this is the rule to get into the TV section of the Play Store
See: https://developer.android.com/training/tv/start/start.html for more information.
:returns: `True` if 'android.hardware.touchscreen' is not required, `False` ... | is_androidtv | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_certificate_der(
self, filename: str, max_sdk_version: int = None
) -> Union[bytes, None]:
"""
Return the DER coded X.509 certificate from the signature file.
If minSdkVersion is prior to Android N only the first SignerInfo is used.
If signed attributes are present, t... |
Return the DER coded X.509 certificate from the signature file.
If minSdkVersion is prior to Android N only the first SignerInfo is used.
If signed attributes are present, they are taken into account
Note that unsupported critical extensions and key usage are not verified!
[V1Sc... | get_certificate_der | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def find_certificate(
self,
signed_data_certificates: asn1crypto.cms.CertificateSet,
signer_info: asn1crypto.cms.SignerInfo) -> Union[asn1crypto.x509.Certificate, None]:
"""
From the bag of certs, obtain the certificate referenced by the `asn1crypto.cms.SignerInfo`.
:par... |
From the bag of certs, obtain the certificate referenced by the `asn1crypto.cms.SignerInfo`.
:param signed_data_certificates: List of certificates in the SignedData.
:param signer_info: `SignerInfo` object containing the issuer and serial number reference.
:returns: The matching certi... | find_certificate | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def get_certificate(self, filename: str) -> Union[asn1crypto.x509.Certificate, None]:
"""
Return a X.509 certificate object by giving the name in the apk file
:param filename: filename of the signature file in the APK
:returns: the certificate object
"""
cert = self.get_... |
Return a X.509 certificate object by giving the name in the apk file
:param filename: filename of the signature file in the APK
:returns: the certificate object
| get_certificate | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
def new_zip(
self,
filename: str,
deleted_files: Union[str, None] = None,
new_files: dict = {},
) -> None:
"""
Create a new zip file
:param filename: the output filename of the zip
:param deleted_files: a regex pattern to remove specific file, or `Non... |
Create a new zip file
:param filename: the output filename of the zip
:param deleted_files: a regex pattern to remove specific file, or `None`
:param new_files: a dictionnary of new files (key:filename, value:content of the file)
| new_zip | python | androguard/androguard | androguard/core/apk/__init__.py | https://github.com/androguard/androguard/blob/master/androguard/core/apk/__init__.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.