dex
AnnotationElement
#
This class can parse an annotation_element
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_name_idx()
#
Return the index to the element name, represented as an index into the string_ids
section
Returns:
Type | Description |
---|---|
int
|
the index to the name |
get_value()
#
Return the element value (EncodedValue)
Returns:
Type | Description |
---|---|
EncodedValue
|
a : |
AnnotationItem
#
This class can parse an annotation_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_annotation()
#
Return the encoded annotation contents
Returns:
Type | Description |
---|---|
EncodedAnnotation
|
a |
get_visibility()
#
Return the intended visibility of this annotation
Returns:
Type | Description |
---|---|
int
|
the visibility of the annotation |
AnnotationOffItem
#
This class can parse an annotation_off_item
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
AnnotationSetItem
#
This class can parse an annotation_set_item
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_annotation_off_item()
#
Return the offset from the start of the file to an annotation
Returns:
Type | Description |
---|---|
list[AnnotationOffItem]
|
a list of |
AnnotationSetRefItem
#
This class can parse an annotation_set_ref_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_annotations_off()
#
Return the offset from the start of the file to the referenced annotation set or 0 if there are no annotations for this element.
Returns:
Type | Description |
---|---|
int
|
the offset |
Source code in androguard/core/dex/__init__.py
AnnotationSetRefList
#
This class can parse an annotation_set_ref_list_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a ClassManager object |
required |
Source code in androguard/core/dex/__init__.py
get_list()
#
Return list of AnnotationSetRefItem
Returns:
Type | Description |
---|---|
list[AnnotationSetRefItem]
|
list of |
AnnotationsDirectoryItem
#
This class can parse an annotations_directory_item
of a dex file
Source code in androguard/core/dex/__init__.py
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_annotated_fields_size()
#
Return the count of fields annotated by this item
Returns:
Type | Description |
---|---|
int
|
the offset |
get_annotated_methods_size()
#
Return the count of methods annotated by this item
Returns:
Type | Description |
---|---|
int
|
the count of methods |
get_annotated_parameters_size()
#
Return the count of method parameter lists annotated by this item
Returns:
Type | Description |
---|---|
int
|
the count of method parameter lists |
get_class_annotations_off()
#
Return the offset from the start of the file to the annotations made directly on the class, or 0 if the class has no direct annotations
Returns:
Type | Description |
---|---|
int
|
the offset |
Source code in androguard/core/dex/__init__.py
get_field_annotations()
#
Return the list of associated FieldAnnotation
Returns:
Type | Description |
---|---|
list[FieldAnnotation]
|
a list of |
get_method_annotations()
#
Return the list of associated MethodAnnotation
Returns:
Type | Description |
---|---|
list[MethodAnnotation]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_parameter_annotations()
#
Return the list of associated method ParameterAnnotation
Returns:
Type | Description |
---|---|
list[ParameterAnnotation]
|
a list of |
Source code in androguard/core/dex/__init__.py
ClassDataItem
#
This class can parse a class_data_item
of a dex file
Source code in androguard/core/dex/__init__.py
3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_direct_methods()
#
Return the defined direct (any of static, private, or constructor) methods, represented as a sequence of encoded elements
Returns:
Type | Description |
---|---|
list[EncodedMethod]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_direct_methods_size()
#
Return the number of direct methods defined in this item
Returns:
Type | Description |
---|---|
int
|
number of direct methods |
get_fields()
#
Return static and instance fields
Returns:
Type | Description |
---|---|
list[EncodedField]
|
a list of |
get_instance_fields()
#
Return the defined instance fields, represented as a sequence of encoded elements
Returns:
Type | Description |
---|---|
list[EncodedField]
|
list of |
get_instance_fields_size()
#
Return the number of instance fields defined in this item
Returns:
Type | Description |
---|---|
int
|
number of instance fields |
get_methods()
#
Return direct and virtual methods
Returns:
Type | Description |
---|---|
list[EncodedMethod]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_static_fields()
#
Return the defined static fields, represented as a sequence of encoded elements
Returns:
Type | Description |
---|---|
list[EncodedField]
|
a list of |
get_static_fields_size()
#
Return the number of static fields defined in this item
Returns:
Type | Description |
---|---|
int
|
number of static fields |
get_virtual_methods()
#
Return the defined virtual (none of static, private, or constructor) methods, represented as a sequence of encoded elements
Returns:
Type | Description |
---|---|
list[EncodedMethod]
|
a list |
Source code in androguard/core/dex/__init__.py
get_virtual_methods_size()
#
Return the number of virtual methods defined in this item
Returns:
Type | Description |
---|---|
int
|
number of virtual methods |
ClassDefItem
#
This class can parse a class_def_item
of a dex file
Source code in androguard/core/dex/__init__.py
3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_access_flags()
#
Return the access flags for the class (public
, final
, etc.)
Returns:
Type | Description |
---|---|
int
|
the access flags |
get_access_flags_string()
#
Return the access flags string of the class
Returns:
Type | Description |
---|---|
str
|
the access flag string |
Source code in androguard/core/dex/__init__.py
get_annotations()
#
Returns the class names of the annotations of this class.
For example, if the class is marked as @Deprecated
, this will return
['Ljava/lang/Deprecated;']
.
Returns:
Type | Description |
---|---|
list[str]
|
list of class names |
Source code in androguard/core/dex/__init__.py
get_annotations_off()
#
Return the offset from the start of the file to the annotations structure for this class, or 0 if there are no annotations on this class.
Returns:
Type | Description |
---|---|
int
|
the offset |
Source code in androguard/core/dex/__init__.py
get_class_data()
#
Return the associated class_data_item
Returns:
Type | Description |
---|---|
ClassDataItem
|
the associated |
get_class_data_off()
#
Return the offset from the start of the file to the associated class data for this item, or 0 if there is no class data for this class
Returns:
Type | Description |
---|---|
int
|
the offset |
Source code in androguard/core/dex/__init__.py
get_class_idx()
#
Return the index into the type_ids
list for this class
Returns:
Type | Description |
---|---|
int
|
the index |
get_fields()
#
Return all EncodedFields of this class
Returns:
Type | Description |
---|---|
list[EncodedField]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_interfaces()
#
Return the names of the interfaces
Returns:
Type | Description |
---|---|
list[str]
|
a list of string names |
get_interfaces_off()
#
Return the offset from the start of the file to the list of interfaces, or 0 if there are none
Returns:
Type | Description |
---|---|
int
|
the offset |
get_methods()
#
Return all EncodedMethods of this class
Returns:
Type | Description |
---|---|
list[EncodedMethod]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_name()
#
get_source()
#
return the source code of this class
Returns:
Type | Description |
---|---|
str
|
the source code string |
get_source_file_idx()
#
Return the index into the string_ids
list for the name of the file containing the original
source for (at least most of) this class, or the special value NO_INDEX
to represent a lack of this information
Returns:
Type | Description |
---|---|
int
|
the index |
Source code in androguard/core/dex/__init__.py
get_static_values_off()
#
Return the offset from the start of the file to the list of initial values for static fields, or 0 if there are none (and all static fields are to be initialized with 0 or null)
Returns:
Type | Description |
---|---|
int
|
the offset |
Source code in androguard/core/dex/__init__.py
get_superclass_idx()
#
Return the index into the type_ids
list for the superclass
Returns:
Type | Description |
---|---|
int
|
the index |
get_superclassname()
#
ClassHDefItem
#
This class can parse a list of class_def_item
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the list of |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 |
|
get_class_idx(idx)
#
return the associated ClassDefItem
from the class_def
list given an index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index |
required |
Returns:
Type | Description |
---|---|
ClassDefItem
|
the |
Source code in androguard/core/dex/__init__.py
get_method(name_class, name_method)
#
return a list of of EncodedMethod
objects given a class name and method name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name_class
|
str
|
the name of the class |
required |
name_method
|
str
|
the name of the method |
required |
Returns:
Type | Description |
---|---|
list[EncodedMethod]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_names()
#
return a list of class names found in class_def
Returns:
Type | Description |
---|---|
list[str]
|
a list of class names |
get_obj()
#
return a list of ClassDefItem
objects
Returns:
Type | Description |
---|---|
list[ClassDefItem]
|
list of |
ClassManager
#
This class is used to access to all elements (strings, type, proto ...) of the dex format based on their offset or index.
Source code in androguard/core/dex/__init__.py
7801 7802 7803 7804 7805 7806 7807 7808 7809 7810 7811 7812 7813 7814 7815 7816 7817 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 7832 7833 7834 7835 7836 7837 7838 7839 7840 7841 7842 7843 7844 7845 7846 7847 7848 7849 7850 7851 7852 7853 7854 7855 7856 7857 7858 7859 7860 7861 7862 7863 7864 7865 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 7887 7888 7889 7890 7891 7892 7893 7894 7895 7896 7897 7898 7899 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 7921 7922 7923 7924 7925 7926 7927 7928 7929 7930 7931 7932 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 7997 7998 7999 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 8010 8011 8012 8013 8014 8015 8016 8017 8018 8019 8020 8021 8022 8023 8024 8025 8026 8027 8028 8029 8030 8031 8032 8033 8034 8035 8036 8037 8038 8039 8040 8041 8042 8043 8044 8045 8046 8047 8048 8049 8050 8051 8052 8053 8054 8055 8056 8057 8058 8059 8060 8061 8062 8063 8064 8065 8066 8067 8068 8069 8070 8071 8072 8073 8074 8075 8076 8077 8078 8079 8080 8081 8082 8083 8084 8085 8086 8087 8088 8089 8090 8091 8092 8093 8094 8095 8096 8097 8098 8099 8100 8101 8102 8103 8104 8105 8106 8107 8108 8109 8110 8111 8112 8113 8114 8115 8116 8117 8118 8119 8120 8121 8122 8123 8124 8125 8126 8127 8128 8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 8140 8141 8142 8143 8144 8145 8146 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 8162 8163 8164 8165 8166 8167 8168 8169 8170 8171 8172 8173 8174 8175 8176 8177 8178 8179 8180 8181 8182 8183 |
|
__init__(vm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vm
|
DEX
|
the VM to create a |
required |
Source code in androguard/core/dex/__init__.py
get_obj_by_offset(offset)
#
get_odex_format()
#
Returns True
if the underlying VM is ODEX
Returns:
Type | Description |
---|---|
bool
|
|
get_raw_string(idx)
#
Return the (unprocessed) string from the string table at index idx
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index in the string section |
required |
Source code in androguard/core/dex/__init__.py
get_string(idx)
#
Return a string from the string table at index idx
If string is hooked, the hooked string is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
index in the string section |
required |
Returns:
Type | Description |
---|---|
str
|
string entry |
Source code in androguard/core/dex/__init__.py
get_type(idx)
#
Return the resolved type name based on the index
This returns the string associated with the type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
|
required |
Returns:
Type | Description |
---|---|
str
|
the type name |
Source code in androguard/core/dex/__init__.py
get_type_ref(idx)
#
Returns the string reference ID for a given type ID.
This method is similar to get_type but does not resolve the string but returns the ID into the string section.
If the type IDX is not found, -1 is returned.
Source code in androguard/core/dex/__init__.py
DCode
#
This class represents the instructions of a method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_manager
|
ClassManager
|
the |
required |
offset
|
int
|
the offset of the buffer |
required |
size
|
int
|
the total size of the buffer |
required |
buff
|
bytes
|
a raw buffer where are the instructions |
required |
Source code in androguard/core/dex/__init__.py
7087 7088 7089 7090 7091 7092 7093 7094 7095 7096 7097 7098 7099 7100 7101 7102 7103 7104 7105 7106 7107 7108 7109 7110 7111 7112 7113 7114 7115 7116 7117 7118 7119 7120 7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 |
|
add_inote(msg, idx, off=None)
#
Add a message to a specific instruction by using (default) the index of the address if specified
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
the message |
required |
idx
|
int
|
index of the instruction (the position in the list of the instruction) |
required |
off
|
Union[int, None]
|
address of the instruction |
None
|
Source code in androguard/core/dex/__init__.py
get_ins_off(off)
#
Get a particular instruction by using the address
Parameters:
Name | Type | Description | Default |
---|---|---|---|
off
|
int
|
address of the instruction |
required |
Returns:
Type | Description |
---|---|
Instruction
|
an |
Source code in androguard/core/dex/__init__.py
get_insn()
#
get_instruction(idx, off=None)
#
Get a particular instruction by using (default) the index of the address if specified
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
index of the instruction (the position in the list of the instruction) |
required |
off
|
Union[int, None]
|
address of the instruction |
None
|
Returns:
Type | Description |
---|---|
Instruction
|
an |
Source code in androguard/core/dex/__init__.py
get_instructions()
#
Return an iterator over Instruction
Returns:
Type | Description |
---|---|
Iterator[Instruction]
|
a generator of each |
Source code in androguard/core/dex/__init__.py
get_length()
#
get_raw()
#
Return the raw buffer of this object
Returns:
Type | Description |
---|---|
bytearray
|
buffer bytearray |
off_to_pos(off)
#
Get the position of an instruction by using the address
Parameters:
Name | Type | Description | Default |
---|---|---|---|
off
|
int
|
address of the instruction |
required |
Returns:
Type | Description |
---|---|
int
|
the offset |
Source code in androguard/core/dex/__init__.py
seek(idx)
#
Set the start address of the buffer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index |
required |
set_insn(insn)
#
Set a new raw buffer to disassemble
Parameters:
Name | Type | Description | Default |
---|---|---|---|
insn
|
bytes
|
the buffer |
required |
set_instructions(instructions)
#
Set the instructions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instructions
|
list[Instruction]
|
the list of instructions |
required |
show()
#
Display (with a pretty print) this object
Source code in androguard/core/dex/__init__.py
DEX
#
This class can parse a classes.dex file of an Android application (APK).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
a string which represents the classes.dex file |
required | |
decompiler
|
Union[DecompilerDAD, None]
|
associate a decompiler object to display the java source code Example: >>> d = DEX( read("classes.dex") ) |
None
|
Source code in androguard/core/dex/__init__.py
8307 8308 8309 8310 8311 8312 8313 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 8329 8330 8331 8332 8333 8334 8335 8336 8337 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 8356 8357 8358 8359 8360 8361 8362 8363 8364 8365 8366 8367 8368 8369 8370 8371 8372 8373 8374 8375 8376 8377 8378 8379 8380 8381 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 8412 8413 8414 8415 8416 8417 8418 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 8462 8463 8464 8465 8466 8467 8468 8469 8470 8471 8472 8473 8474 8475 8476 8477 8478 8479 8480 8481 8482 8483 8484 8485 8486 8487 8488 8489 8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 8592 8593 8594 8595 8596 8597 8598 8599 8600 8601 8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 8613 8614 8615 8616 8617 8618 8619 8620 8621 8622 8623 8624 8625 8626 8627 8628 8629 8630 8631 8632 8633 8634 8635 8636 8637 8638 8639 8640 8641 8642 8643 8644 8645 8646 8647 8648 8649 8650 8651 8652 8653 8654 8655 8656 8657 8658 8659 8660 8661 8662 8663 8664 8665 8666 8667 8668 8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 8684 8685 8686 8687 8688 8689 8690 8691 8692 8693 8694 8695 8696 8697 8698 8699 8700 8701 8702 8703 8704 8705 8706 8707 8708 8709 8710 8711 8712 8713 8714 8715 8716 8717 8718 8719 8720 8721 8722 8723 8724 8725 8726 8727 8728 8729 8730 8731 8732 8733 8734 8735 8736 8737 8738 8739 8740 8741 8742 8743 8744 8745 8746 8747 8748 8749 8750 8751 8752 8753 8754 8755 8756 8757 8758 8759 8760 8761 8762 8763 8764 8765 8766 8767 8768 8769 8770 8771 8772 8773 8774 8775 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 8826 8827 8828 8829 8830 8831 8832 8833 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 8915 8916 8917 8918 8919 8920 8921 8922 8923 8924 8925 8926 8927 8928 8929 8930 8931 8932 8933 8934 8935 8936 8937 8938 8939 8940 8941 8942 8943 8944 8945 8946 8947 8948 8949 8950 8951 8952 8953 8954 8955 8956 8957 8958 8959 8960 8961 8962 8963 8964 8965 8966 8967 8968 8969 8970 8971 8972 8973 8974 8975 8976 8977 8978 8979 8980 8981 8982 8983 8984 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 9015 9016 9017 9018 9019 9020 9021 9022 9023 9024 9025 9026 9027 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 9061 9062 9063 9064 9065 9066 9067 9068 9069 9070 9071 9072 9073 9074 9075 9076 9077 9078 9079 9080 9081 9082 9083 9084 9085 9086 9087 9088 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 9123 9124 9125 9126 9127 9128 9129 9130 9131 9132 9133 9134 9135 9136 9137 9138 9139 9140 9141 9142 9143 9144 9145 9146 9147 9148 9149 9150 9151 9152 9153 9154 9155 9156 9157 9158 9159 9160 9161 9162 9163 9164 9165 9166 9167 9168 9169 9170 9171 9172 9173 9174 9175 9176 9177 |
|
version
property
#
Returns the version number of the DEX Format
create_python_export()
#
Export classes/methods/fields' names in the python namespace
Source code in androguard/core/dex/__init__.py
disassemble(offset, size)
#
Disassembles a given offset in the DEX file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset
|
int
|
offset to disassemble in the file (from the beginning of the file) |
required |
size
|
int
|
|
required |
Returns:
Type | Description |
---|---|
Iterator[Instruction]
|
iterator over |
Source code in androguard/core/dex/__init__.py
fix_checksums(buff)
#
Fix a dex format buffer by setting all checksums
Returns:
Type | Description |
---|---|
bytes
|
bytes |
Source code in androguard/core/dex/__init__.py
get_api_version()
#
This method returns api version that should be used for loading api specific resources.
Returns:
Type | Description |
---|---|
int
|
api version string |
get_class(name)
#
Return a specific class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
the name of the class |
required |
Returns:
Type | Description |
---|---|
Union[ClassDefItem, None]
|
a |
Source code in androguard/core/dex/__init__.py
get_class_manager()
#
This function returns a ClassManager object which allow you to get access to all index references (strings, methods, fields, ....)
Returns:
Type | Description |
---|---|
ClassManager
|
|
Source code in androguard/core/dex/__init__.py
get_classes()
#
Return all classes
Returns:
Type | Description |
---|---|
list[ClassDefItem]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_classes_def_item()
#
This function returns the class def item
Returns:
Type | Description |
---|---|
ClassHDefItem
|
|
get_classes_names(update=False)
#
Return the names of classes
Parameters:
Name | Type | Description | Default |
---|---|---|---|
update
|
bool
|
|
False
|
Returns:
Type | Description |
---|---|
list[str]
|
a list of string names |
Source code in androguard/core/dex/__init__.py
get_cm_field(idx)
#
Get a specific field by using an index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
index of the field |
required |
get_cm_method(idx)
#
Get a specific method by using an index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
index of the method |
required |
get_cm_string(idx)
#
Get a specific string by using an index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
index of the string |
required |
Returns:
Type | Description |
---|---|
str
|
the string |
get_cm_type(idx)
#
Get a specific type by using an index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
index of the type |
required |
Returns:
Type | Description |
---|---|
str
|
the string type |
get_codes_item()
#
get_debug_info_item()
#
This function returns the debug info item
Returns:
Type | Description |
---|---|
DebugInfoItemEmpty
|
|
get_encoded_field(name)
#
Return a list all fields which corresponds to the regexp
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
the name of the field (a python string regexp) |
required |
Returns:
Type | Description |
---|---|
list[EncodedField]
|
a list with all |
Source code in androguard/core/dex/__init__.py
get_encoded_field_descriptor(class_name, field_name, descriptor)
#
Return the specific encoded field given a class name, field name, and descriptor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
the class name of the field |
required |
field_name
|
str
|
the name of the field |
required |
descriptor
|
str
|
the descriptor of the field |
required |
Returns:
Type | Description |
---|---|
EncodedField
|
|
Source code in androguard/core/dex/__init__.py
get_encoded_fields()
#
Return all field objects
Returns:
Type | Description |
---|---|
list[EncodedField]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_encoded_fields_class(class_name)
#
Return all encoded fields of a specific class by class name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
the class name |
required |
Returns:
Type | Description |
---|---|
list[EncodedField]
|
a list with |
Source code in androguard/core/dex/__init__.py
get_encoded_method(name)
#
Return a list all encoded methods whose name corresponds to the regexp
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
the name of the method (a python string regexp) |
required |
Returns:
Type | Description |
---|---|
list[EncodedMethod]
|
a list with all |
Source code in androguard/core/dex/__init__.py
get_encoded_method_by_idx(idx)
#
Return a specific encoded method by using an index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index of the method |
required |
Returns:
Type | Description |
---|---|
Union[EncodedMethod, None]
|
|
Source code in androguard/core/dex/__init__.py
get_encoded_method_descriptor(class_name, method_name, descriptor)
#
Return the specific encoded method given a class name, method name, and descriptor
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
the class name of the method |
required |
method_name
|
str
|
the name of the method |
required |
descriptor
|
str
|
the descriptor of the method |
required |
Returns:
Type | Description |
---|---|
Union[EncodedMethod, None]
|
|
Source code in androguard/core/dex/__init__.py
get_encoded_methods()
#
Return all encoded method objects
Returns:
Type | Description |
---|---|
list[EncodedMethod]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_encoded_methods_class(class_name)
#
Return all encoded methods of a specific class by class name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
the class name |
required |
Returns:
Type | Description |
---|---|
list[EncodedMethod]
|
a list with |
Source code in androguard/core/dex/__init__.py
get_encoded_methods_class_method(class_name, method_name)
#
Return the specific encoded methods of the class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
the class name of the method |
required |
method_name
|
str
|
the name of the method |
required |
Returns:
Type | Description |
---|---|
Union[EncodedMethod, None]
|
|
Source code in androguard/core/dex/__init__.py
get_field(name)
#
get field id item by name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
the name of the field (a python string regexp) |
required |
Returns:
Type | Description |
---|---|
list[FieldIdItem]
|
the list of matching |
Source code in androguard/core/dex/__init__.py
get_fields()
#
Return a list of field items
Returns:
Type | Description |
---|---|
list[FieldIdItem]
|
a list of |
get_fields_id_item()
#
get_format_type()
#
get_header_item()
#
get_hidden_api()
#
This function returns the hidden api item (from Android 10)
Returns:
Type | Description |
---|---|
HiddenApiClassDataItem
|
|
get_len_classes()
#
get_len_encoded_methods()
#
get_len_fields()
#
get_len_methods()
#
get_len_strings()
#
get_method(name)
#
get method id item by name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
the name of the field (a python string regexp) |
required |
Returns:
Type | Description |
---|---|
list[MethodIdItem]
|
the list of matching |
Source code in androguard/core/dex/__init__.py
get_methods()
#
Return a list of method items
Returns:
Type | Description |
---|---|
list[MethodIdItem]
|
a list of |
get_methods_id_item()
#
This function returns the method id item
Returns:
Type | Description |
---|---|
MethodHIdItem
|
|
get_regex_strings(regular_expressions)
#
Return all target strings matched the regex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
regular_expressions
|
str
|
the python regex string |
required |
Returns:
Type | Description |
---|---|
Union[list[str], None]
|
a list of strings matching the regex expression |
Source code in androguard/core/dex/__init__.py
get_string_data_item()
#
This function returns the string data item
Returns:
Type | Description |
---|---|
StringDataItem
|
|
get_strings()
#
Return all strings
The strings will have escaped surrogates, if only a single high or low surrogate is found. Complete surrogates are put together into the representing 32bit character.
Returns:
Type | Description |
---|---|
list[str]
|
a list with all strings used in the format (types, names ...) |
Source code in androguard/core/dex/__init__.py
list_classes_hierarchy()
#
Get a tree structure of the classes. The parent is always the superclass.
You can use pprint.pprint
to print the
dictionary in a pretty way.
Returns:
Type | Description |
---|---|
dict[str, list[dict[str, list]]]
|
a tree in dictionary format where the key is the class name and the value is a list of dictionaries containing a child class name as a key and subsequent child classes as a value list |
Source code in androguard/core/dex/__init__.py
save()
#
Return the dex (with the modifications) into raw format (fix checksums) (beta: do not use !)
Returns:
Type | Description |
---|---|
bytes
|
bytes |
Source code in androguard/core/dex/__init__.py
8490 8491 8492 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 |
|
DalvikCode
#
This class represents the instructions of a method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a raw buffer where are the instructions |
required |
cm
|
ClassManager
|
the |
required |
Source code in androguard/core/dex/__init__.py
7324 7325 7326 7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 7341 7342 7343 7344 7345 7346 7347 7348 7349 7350 7351 7352 7353 7354 7355 7356 7357 7358 7359 7360 7361 7362 7363 7364 7365 7366 7367 7368 7369 7370 7371 7372 7373 7374 7375 7376 7377 7378 7379 7380 7381 7382 7383 7384 7385 7386 7387 7388 7389 7390 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 7406 7407 7408 7409 7410 7411 7412 7413 7414 7415 7416 7417 7418 7419 7420 7421 7422 7423 7424 7425 7426 7427 7428 7429 7430 7431 7432 7433 7434 7435 7436 7437 7438 7439 7440 7441 7442 7443 7444 7445 7446 7447 7448 7449 7450 7451 7452 7453 7454 7455 7456 7457 7458 7459 7460 7461 7462 7463 7464 7465 7466 7467 7468 7469 7470 7471 7472 7473 7474 7475 7476 7477 7478 7479 7480 7481 7482 7483 7484 7485 7486 7487 7488 7489 7490 7491 7492 7493 7494 7495 7496 7497 7498 7499 7500 7501 7502 7503 7504 7505 7506 7507 7508 7509 7510 7511 7512 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 |
|
add_inote(msg, idx, off=None)
#
Add a message to a specific instruction by using (default) the index of the address if specified
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
the message |
required |
idx
|
int
|
index of the instruction (the position in the list of the instruction) |
required |
off
|
int
|
address of the instruction |
None
|
Source code in androguard/core/dex/__init__.py
get_bc()
#
get_debug()
#
Return the associated debug object
Returns:
Type | Description |
---|---|
DebugInfoItem
|
|
get_debug_info_off()
#
Get the offset from the start of the file to the debug info (line numbers + local variable info) sequence for this code, or 0 if there simply is no information
Returns:
Type | Description |
---|---|
int
|
offset int |
Source code in androguard/core/dex/__init__.py
get_handlers()
#
Get the bytes representing a list of lists of catch types and associated handler addresses.
Returns:
Type | Description |
---|---|
EncodedCatchHandlerList
|
|
get_ins_size()
#
Get the number of words of incoming arguments to the method that this code is for
Returns:
Type | Description |
---|---|
int
|
number of words |
get_insns_size()
#
Get the size of the instructions list, in 16-bit code units
Returns:
Type | Description |
---|---|
int
|
size int |
get_outs_size()
#
Get the number of words of outgoing argument space required by this code for method invocation
Returns:
Type | Description |
---|---|
int
|
number of words |
get_raw()
#
Get the reconstructed code as bytearray
Returns:
Type | Description |
---|---|
bytearray
|
code bytearray |
Source code in androguard/core/dex/__init__.py
get_registers_size()
#
Get the number of registers used by this code
Returns:
Type | Description |
---|---|
int
|
number of registers |
get_tries()
#
Get the array indicating where in the code exceptions are caught and how to handle them
Returns:
Type | Description |
---|---|
list[TryItem]
|
a list of |
DalvikPacker
#
Generic Packer class to unpack bytes based on different endianness
Source code in androguard/core/dex/__init__.py
EncodedAnnotation
#
This class can parse an encoded_annotation
of a dex file
Source code in androguard/core/dex/__init__.py
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_elements()
#
Return the elements of the annotation, represented directly in-line (not as offsets)
Returns:
Type | Description |
---|---|
a list of |
get_size()
#
Return the number of name-value mappings in this annotation
Returns:
Type | Description |
---|---|
the number of mappings |
get_type_idx()
#
Return the type of the annotation. This must be a class (not array or primitive) type
Returns:
Type | Description |
---|---|
the type of the annotation |
EncodedArray
#
This class can parse an encoded_array
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a ClassManager object |
required |
Source code in androguard/core/dex/__init__.py
get_size()
#
get_values()
#
Return a series of size encoded_value
byte sequences in the format specified by this section,
concatenated sequentially
Returns:
Type | Description |
---|---|
list[EncodedValue]
|
a list of |
Source code in androguard/core/dex/__init__.py
EncodedArrayItem
#
This class can parse an encoded_array_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_value()
#
Return the bytes representing the encoded array value
Returns:
Type | Description |
---|---|
EncodedArray
|
a |
EncodedCatchHandler
#
This class can parse an encoded_catch_handler
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 |
|
get_catch_all_addr()
#
Return the bytecode address of the catch-all handler. This element is only present if size is non-positive.
Returns:
Type | Description |
---|---|
int
|
the bytecode address |
get_handlers()
#
Return the stream of abs(size)
encoded items, one for each caught type, in the order that the types should be tested.
Returns:
Type | Description |
---|---|
list[EncodedTypeAddrPair]
|
a list of |
Source code in androguard/core/dex/__init__.py
get_size()
#
Return the number of catch types in this list
Returns:
Type | Description |
---|---|
int
|
the number of catch types |
EncodedCatchHandlerList
#
This class can parse an encoded_catch_handler_list
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_list()
#
Return the actual list of handler lists, represented directly (not as offsets), and concatenated sequentially
Returns:
Type | Description |
---|---|
list[EncodedCatchHandler]
|
a list of |
Source code in androguard/core/dex/__init__.py
EncodedField
#
This class can parse an encoded_field
of a dex file
Source code in androguard/core/dex/__init__.py
2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_access_flags()
#
get_access_flags_string()
#
Return the access flags string of the field
Returns:
Type | Description |
---|---|
str
|
the access flags |
Source code in androguard/core/dex/__init__.py
get_class_name()
#
Return the class name of the field
Returns:
Type | Description |
---|---|
str
|
the class name |
get_descriptor()
#
Return the descriptor of the field
The descriptor of a field is the type of the field.
Returns:
Type | Description |
---|---|
str
|
the descriptor |
Source code in androguard/core/dex/__init__.py
get_field_idx()
#
get_field_idx_diff()
#
Return the index into the field_ids list for the identity of this field (includes the name and descriptor), represented as a difference from the index of previous element in the list
Returns:
Type | Description |
---|---|
int
|
the index |
Source code in androguard/core/dex/__init__.py
get_init_value()
#
Return the init value object of the field
Returns:
Type | Description |
---|---|
EncodedValue
|
an |
get_name()
#
set_init_value(value)
#
Setup the init value object of the field
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
EncodedValue
|
the init value |
required |
show()
#
Display the information (with a pretty print) about the field
Source code in androguard/core/dex/__init__.py
EncodedMethod
#
This class can parse an encoded_method
of a dex file
Source code in androguard/core/dex/__init__.py
3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 |
|
descriptor
property
#
Get the descriptor of the method
full_name
property
#
Return class_name + name + descriptor, separated by spaces (no access flags)
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
add_inote(msg, idx, off=None)
#
Add a message to a specific instruction by using (default) the index of the address if specified
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
the message |
required |
idx
|
int
|
index of the instruction (the position in the list of the instruction) |
required |
off
|
Union[int, None]
|
address of the instruction |
None
|
Source code in androguard/core/dex/__init__.py
add_note(msg)
#
Add a message to this method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
the message |
required |
each_params_by_register(nb, proto)
#
From the Dalvik Bytecode documentation:
The N arguments to a method land in the last N registers of the method's invocation frame, in order. Wide arguments consume two registers. Instance methods are passed a this reference as their first argument.
This method will print a description of the register usage to stdout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nb
|
int
|
number of registers |
required |
proto
|
str
|
descriptor of method |
required |
Source code in androguard/core/dex/__init__.py
get_access_flags()
#
get_access_flags_string()
#
Return the access flags string of the method
A description of all access flags can be found here: https://source.android.com/devices/tech/dalvik/dex-format#access-flags
Returns:
Type | Description |
---|---|
str
|
the access flags |
Source code in androguard/core/dex/__init__.py
get_address()
#
Return the offset from the start of the file to the code structure for this method, or 0 if this method is either abstract or native
Returns:
Type | Description |
---|---|
int
|
the offset |
Source code in androguard/core/dex/__init__.py
get_class_name()
#
Return the class name of the method
Returns:
Type | Description |
---|---|
str
|
the class name |
get_code()
#
Return the code object associated to the method
Returns:
Type | Description |
---|---|
Union[DalvikCode, None]
|
the |
Source code in androguard/core/dex/__init__.py
get_code_off()
#
Return the offset from the start of the file to the code structure for this method, or 0 if this method is either abstract or native
Returns:
Type | Description |
---|---|
int
|
the offset |
get_debug()
#
Return the debug object associated to this method
Returns:
Type | Description |
---|---|
DebugInfoItem
|
|
get_descriptor()
#
Return the descriptor of the method
A method descriptor will have the form (A A A ...)R
Where A are the arguments to the method and R is the return type.
Basic types will have the short form, i.e. I for integer, V for void
and class types will be named like a classname, e.g. Ljava/lang/String;
.
Typical descriptors will look like this:
(I)I // one integer argument, integer return
(C)Z // one char argument, boolean as return
(Ljava/lang/CharSequence; I)I // CharSequence and integer as
argyument, integer as return
(C)Ljava/lang/String; // char as argument, String as return.
More information about type descriptors are found here: https://source.android.com/devices/tech/dalvik/dex-format#typedescriptor
Returns:
Type | Description |
---|---|
str
|
the descriptor |
Source code in androguard/core/dex/__init__.py
get_information()
#
Get brief information about the method's register use, parameters and return type.
The resulting dictionary has the form:
>>> {
>>> registers: (start, end),
>>> params: [(reg_1, type_1), (reg_2, type_2), ..., (reg_n, type_n)],
>>> return: type
>>> }
The end register is not the last register used, but the last register used not for parameters. Hence, they represent the local registers. The start register is always zero. The register numbers for the parameters can be found in the tuples for each parameter.
Returns:
Type | Description |
---|---|
dict[str, Union[str, tuple[int, int], list]]
|
a dictionary with the basic information about the method |
Source code in androguard/core/dex/__init__.py
get_instruction(idx, off=None)
#
Get a particular instruction by using (default) the index of the address if specified
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
index of the instruction (the position in the list of the instruction) |
required | |
off
|
Union[int, None]
|
address of the instruction |
None
|
Returns:
Type | Description |
---|---|
Iterator[Instruction]
|
a generator of |
Source code in androguard/core/dex/__init__.py
get_instructions()
#
Get the instructions
Returns:
Type | Description |
---|---|
Iterator[Instruction]
|
a generator of each |
Source code in androguard/core/dex/__init__.py
get_instructions_idx()
#
Iterate over all instructions of the method, but also return the current index. This is the same as using get_instructions and adding the instruction length to a variable each time.
Returns:
Type | Description |
---|---|
Iterator[tuple[int, Instruction]]
|
iterator over index and instructions |
Source code in androguard/core/dex/__init__.py
get_length()
#
Return the length of the associated code of the method
Returns:
Type | Description |
---|---|
int
|
the length of the source code |
get_locals()
#
Get the number of local registers used by the method
This number is equal to the number of registers minus the number of parameters minus 1.
Returns:
Type | Description |
---|---|
int
|
number of local registers |
Source code in androguard/core/dex/__init__.py
get_method_idx()
#
get_method_idx_diff()
#
Return index into the method_ids
list for the identity of this method (includes the name and descriptor),
represented as a difference from the index of previous element in the lis
Returns:
Type | Description |
---|---|
int
|
the index |
Source code in androguard/core/dex/__init__.py
get_name()
#
get_short_string()
#
Return a shorter formatted String which encodes this method.
The returned name has the form:
- All Class names are condensed to the actual name (no package).
- Access flags are not returned.
and are NOT replaced by the classname!
This name might not be unique!
Returns:
Type | Description |
---|---|
str
|
str |
Source code in androguard/core/dex/__init__.py
set_code_idx(idx)
#
Set the start address of the buffer to disassemble
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index |
required |
set_instructions(instructions)
#
Set the instructions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
instructions
|
list[Instruction]
|
the list of |
required |
Source code in androguard/core/dex/__init__.py
show()
#
Display the information (with a pretty print) about the method
Source code in androguard/core/dex/__init__.py
show_info()
#
Display the basic information about the method
Source code in androguard/core/dex/__init__.py
show_notes()
#
Display the notes about the method
source()
#
Return the source code of this method
Returns:
Type | Description |
---|---|
str
|
the source code |
EncodedTypeAddrPair
#
This class can parse an encoded_type_addr_pair
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
EncodedValue
#
This class can parse an encoded_value
of a dex file
Source code in androguard/core/dex/__init__.py
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_value()
#
Return the bytes representing the value, variable in length and interpreted differently for different value_type
bytes,
though always little-endian
Returns:
Type | Description |
---|---|
an object representing the value |
Source code in androguard/core/dex/__init__.py
ExportObject
#
FieldAnnotation
#
This class can parse a field_annotation
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a ClassManager object |
required |
Source code in androguard/core/dex/__init__.py
FieldHIdItem
#
This class can parse a list of field_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(size, buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the list of |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
FieldIdItem
#
This class can parse a field_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 |
|
__init__(buff, cm)
#
"
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_class_idx()
#
Return the index into the type_ids
list for the definer of this field
Returns:
Type | Description |
---|---|
int
|
the index |
get_class_name()
#
Return the class name of the field
Returns:
Type | Description |
---|---|
str
|
the class name |
Source code in androguard/core/dex/__init__.py
get_descriptor()
#
Return the descriptor of the field
Returns:
Type | Description |
---|---|
str
|
the desciptor |
Source code in androguard/core/dex/__init__.py
get_name()
#
Return the name of the field
Returns:
Type | Description |
---|---|
str
|
the name |
get_name_idx()
#
Return the index into the string_ids
list for the name of this field
Returns:
Type | Description |
---|---|
int
|
the index |
get_type()
#
Return the type of the field
Returns:
Type | Description |
---|---|
str
|
the type |
get_type_idx()
#
Return the index into the type_ids
list for the type of this field
Returns:
Type | Description |
---|---|
int
|
the index |
FillArrayData
#
This class can parse a FillArrayData
instruction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a Buff object which represents a buffer where the instruction is stored |
required |
Source code in androguard/core/dex/__init__.py
4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 |
|
add_note(msg)
#
Add a note to this instruction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
the message |
required |
get_data()
#
Return the data of this instruction (the payload)
Returns:
Type | Description |
---|---|
bytes
|
the instruction payload bytes |
get_hex()
#
Returns a HEX String, separated by spaces every byte
get_length()
#
Return the length of the instruction
Returns:
Type | Description |
---|---|
int
|
the length |
get_name()
#
get_notes()
#
Get all notes from this instruction
Returns:
Type | Description |
---|---|
list[str]
|
a list of string notes |
get_op_value()
#
get_output(idx=-1)
#
Return an additional output of the instruction
Returns:
Type | Description |
---|---|
str
|
additional output of the instruction |
Source code in androguard/core/dex/__init__.py
show(pos)
#
Print the instruction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos
|
int
|
the position of the instruction |
required |
show_buff(pos)
#
Return the display of the instruction
Returns:
Type | Description |
---|---|
str
|
display string |
Source code in androguard/core/dex/__init__.py
HeaderItem
#
This class can parse an header_item
of a dex file.
Several checks are performed to detect if this is not an header_item
.
Also the Adler32 checksum of the file is calculated in order to detect file
corruption.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Raises:
Type | Description |
---|---|
ValueError
|
if DEX file header is incorrect |
Source code in androguard/core/dex/__init__.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 |
|
HiddenApiClassDataItem
#
This class can parse an hiddenapi_class_data_item
of a dex file (from Android 10 dex version 039)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 |
|
get_flags(idx)
#
Return a tuple of the flags per class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
The index to return the flags of (index of the class) |
required |
Returns:
Type | Description |
---|---|
tuple[RestrictionApiFlag, DomapiApiFlag]
|
tuple of |
Source code in androguard/core/dex/__init__.py
get_section_size()
#
Instruction
#
This class represents a Dalvik instruction
It can both handle normal instructions as well as optimized instructions.
WARNING: There is not much documentation about the optimized opcodes! Hence, it relies on reverese engineered specification!
More information about the instruction format can be found in the official documentation: https://source.android.com/devices/tech/dalvik/instruction-formats.html
WARNING: Values stored in the instructions are already interpreted at this stage.
The Dalvik VM has a eight opcodes to create constant integer values.
There are four variants for 32bit values and four for 64bit.
If floating point numbers are required, you have to use the conversion opcodes
like int-to-float
, int-to-double
or the variants using long
.
Androguard will always show the values as they are used in the opcode and also extend signs
and shift values!
As an example: The opcode const/high16
can be used to create constant values
where the lower 16 bits are all zero.
In this case, androguard will process bytecode 15 00 CD AB
as beeing
const/high16 v0, 0xABCD0000
.
For the sign-extension, nothing is really done here, as it only affects the bit represenation
in the virtual machine. As androguard parses the values and uses python types internally,
we are not bound to specific size.
Source code in androguard/core/dex/__init__.py
4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 |
|
disasm()
#
Some small line for disassembly view
Source code in androguard/core/dex/__init__.py
get_hex()
#
Returns a HEX String, separated by spaces every byte
The hex string contains the raw bytes of the instruction, including the opcode and all arguments.
Returns:
Type | Description |
---|---|
str
|
the hex string |
Source code in androguard/core/dex/__init__.py
get_kind()
#
Return the 'kind' argument of the instruction
This is the type of the argument, i.e. in which kind of table you have
to look up the argument in the ClassManager
Returns:
Type | Description |
---|---|
int
|
the kind |
Source code in androguard/core/dex/__init__.py
get_length()
#
get_literals()
#
get_name()
#
Return the mnemonic of the instruction
Returns:
Type | Description |
---|---|
str
|
the mnemonic |
Source code in androguard/core/dex/__init__.py
get_op_value()
#
get_operands(idx=-1)
#
Not Implemented
Return all operands
This will return a list of tuples, containing the Enum Operand at the first position and the objects afterwards.
Returns:
Type | Description |
---|---|
list[tuple[Operand, object]]
|
List[Tuple(Operand, object, ...)] |
Source code in androguard/core/dex/__init__.py
get_output(idx=-1)
#
Not Implemented
Return an additional output of the instruction
Returns:
Type | Description |
---|---|
str
|
the additional output as a string |
get_raw()
#
get_ref_kind()
#
get_translated_kind()
#
Return the translated value of the 'kind' argument
Returns:
Type | Description |
---|---|
str
|
the translated value |
show(idx)
#
show_buff(idx)
#
Return the display of the instruction
Returns:
Type | Description |
---|---|
str
|
the display of the instruction |
Instruction00x
#
Bases: Instruction
A class for unused instructions, has zero length and raises an error on initialization
Source code in androguard/core/dex/__init__.py
Instruction10t
#
Bases: Instruction
This class represents all instructions which have the 10t format
Source code in androguard/core/dex/__init__.py
Instruction10x
#
Bases: Instruction
This class represents all instructions which have the 10x format
Source code in androguard/core/dex/__init__.py
Instruction11n
#
Bases: Instruction
This class represents all instructions which have the 11n format
Source code in androguard/core/dex/__init__.py
Instruction11x
#
Bases: Instruction
This class represents all instructions which have the 11x format
Source code in androguard/core/dex/__init__.py
Instruction12x
#
Bases: Instruction
This class represents all instructions which have the 12x format
Source code in androguard/core/dex/__init__.py
Instruction20bc
#
Bases: Instruction
This class represents all instructions which have the 20bc format
Source code in androguard/core/dex/__init__.py
Instruction20t
#
Bases: Instruction
This class represents all instructions which have the 20t format
Source code in androguard/core/dex/__init__.py
Instruction21c
#
Bases: Instruction
This class represents all instructions which have the 21c format
Source code in androguard/core/dex/__init__.py
Instruction21h
#
Bases: Instruction
This class represents all instructions which have the 21h format
Source code in androguard/core/dex/__init__.py
Instruction21s
#
Bases: Instruction
This class represents all instructions which have the 21s format
Source code in androguard/core/dex/__init__.py
Instruction21t
#
Bases: Instruction
This class represents all instructions which have the 21t format
Source code in androguard/core/dex/__init__.py
Instruction22b
#
Bases: Instruction
This class represents all instructions which have the 22b format
Source code in androguard/core/dex/__init__.py
Instruction22c
#
Bases: Instruction
This class represents all instructions which have the 22c format
Source code in androguard/core/dex/__init__.py
Instruction22cs
#
Bases: Instruction
This class represents all instructions which have the 22cs format
Source code in androguard/core/dex/__init__.py
Instruction22s
#
Bases: Instruction
This class represents all instructions which have the 22s format
Source code in androguard/core/dex/__init__.py
Instruction22t
#
Bases: Instruction
This class represents all instructions which have the 22t format
Source code in androguard/core/dex/__init__.py
Instruction22x
#
Bases: Instruction
This class represents all instructions which have the 22x format
Source code in androguard/core/dex/__init__.py
Instruction23x
#
Bases: Instruction
This class represents all instructions which have the 23x format
Source code in androguard/core/dex/__init__.py
Instruction30t
#
Bases: Instruction
This class represents all instructions which have the 30t format
Source code in androguard/core/dex/__init__.py
Instruction31c
#
Bases: Instruction
This class represents all instructions which have the 31c format
Source code in androguard/core/dex/__init__.py
get_string()
#
Return the string associated to the 'kind' argument
Returns:
Type | Description |
---|---|
str
|
string |
Instruction31i
#
Bases: Instruction
This class represents all instructions which have the 31i format
Source code in androguard/core/dex/__init__.py
Instruction31t
#
Bases: Instruction
This class represents all instructions which have the 31t format
Source code in androguard/core/dex/__init__.py
Instruction32x
#
Bases: Instruction
This class represents all instructions which have the 32x format
Source code in androguard/core/dex/__init__.py
Instruction35c
#
Bases: Instruction
This class represents all instructions which have the 35c format
Source code in androguard/core/dex/__init__.py
5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 |
|
Instruction35mi
#
Bases: Instruction
This class represents all instructions which have the 35mi format
Source code in androguard/core/dex/__init__.py
6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104 6105 6106 6107 6108 6109 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 |
|
Instruction35ms
#
Bases: Instruction
This class represents all instructions which have the 35ms format
Source code in androguard/core/dex/__init__.py
6134 6135 6136 6137 6138 6139 6140 6141 6142 6143 6144 6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156 6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 |
|
Instruction3rc
#
Bases: Instruction
This class represents all instructions which have the 3rc format
Source code in androguard/core/dex/__init__.py
Instruction3rmi
#
Bases: Instruction
This class represents all instructions which have the 3rmi format
Note, this instruction is similar to 3rc but holds an inline
Source code in androguard/core/dex/__init__.py
Instruction3rms
#
Bases: Instruction
This class represents all instructions which have the 3rms format
Note, this instruction is similar to 3rc but holds a vtaboff
Source code in androguard/core/dex/__init__.py
Instruction40sc
#
Bases: Instruction
This class represents all instructions which have the 40sc format
This instruction is only used in ODEX
Source code in androguard/core/dex/__init__.py
Instruction41c
#
Bases: Instruction
This class represents all instructions which have the 41c format
This instruction is only used in ODEX
Source code in androguard/core/dex/__init__.py
Instruction51l
#
Bases: Instruction
This class represents all instructions which have the 51l format
Source code in androguard/core/dex/__init__.py
Instruction52c
#
Bases: Instruction
This class represents all instructions which have the 52c format
This instruction is only used in ODEX
Source code in androguard/core/dex/__init__.py
Instruction5rc
#
Bases: Instruction
This class represents all instructions which have the 5rc format
This instruction is only used in ODEX
Source code in androguard/core/dex/__init__.py
LinearSweepAlgorithm
#
This class is used to disassemble a method. The algorithm used by this class is linear sweep.
Source code in androguard/core/dex/__init__.py
7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 |
|
get_instructions(cm, size, insn, idx)
staticmethod
#
Yields all instructions for the given bytecode sequence. If unknown/corrupt/unused instructions are encountered, the loop will stop and an error is written to the logger.
That means that the bytecode read might be corrupt or was crafted in this way, to break parsers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cm
|
ClassManager
|
a |
required |
size
|
int
|
the total size of the buffer in 16-bit units |
required |
insn
|
bytearray
|
a raw buffer where are the instructions |
required |
idx
|
int
|
a start address in the buffer |
required |
Returns:
Type | Description |
---|---|
Iterator[Instruction]
|
iterator over |
Raises:
Type | Description |
---|---|
InvalidInstruction
|
if an instruction is invalid |
Source code in androguard/core/dex/__init__.py
7023 7024 7025 7026 7027 7028 7029 7030 7031 7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073 7074 7075 7076 7077 7078 7079 7080 7081 7082 7083 7084 |
|
MapItem
#
Source code in androguard/core/dex/__init__.py
7590 7591 7592 7593 7594 7595 7596 7597 7598 7599 7600 7601 7602 7603 7604 7605 7606 7607 7608 7609 7610 7611 7612 7613 7614 7615 7616 7617 7618 7619 7620 7621 7622 7623 7624 7625 7626 7627 7628 7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 7757 7758 7759 7760 7761 7762 7763 7764 7765 7766 7767 7768 7769 7770 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 7791 7792 7793 7794 7795 7796 7797 7798 |
|
__init__(buff, cm)
#
Implementation of a map_item, which occours in a map_list
https://source.android.com/devices/tech/dalvik/dex-format#map-item
Source code in androguard/core/dex/__init__.py
get_obj()
#
Return the associated item itself.
Might return None
, if parse was not called yet.
This method is the same as item
.
Returns:
Type | Description |
---|---|
object
|
item object |
Source code in androguard/core/dex/__init__.py
get_off()
#
get_offset()
#
get_size()
#
Returns the number of items found at the location indicated by get_offset.
Returns:
Type | Description |
---|---|
int
|
number of items |
parse()
#
parse this map_item by parsing its potential TypeMapItem type and cast it appropriately.
Source code in androguard/core/dex/__init__.py
7629 7630 7631 7632 7633 7634 7635 7636 7637 7638 7639 7640 7641 7642 7643 7644 7645 7646 7647 7648 7649 7650 7651 7652 7653 7654 7655 7656 7657 7658 7659 7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 7674 7675 7676 7677 7678 7679 7680 7681 7682 7683 7684 7685 7686 7687 7688 7689 7690 7691 7692 7693 7694 7695 7696 7697 7698 7699 7700 7701 7702 7703 7704 7705 7706 7707 7708 7709 7710 7711 7712 7713 7714 7715 7716 7717 7718 7719 7720 7721 7722 7723 7724 7725 7726 7727 7728 7729 7730 7731 7732 7733 7734 7735 7736 7737 7738 7739 7740 7741 7742 7743 7744 7745 7746 7747 7748 7749 7750 7751 7752 7753 7754 7755 7756 |
|
MapList
#
This class can parse the "map_list" of the dex format
https://source.android.com/devices/tech/dalvik/dex-format#map-list
Source code in androguard/core/dex/__init__.py
8186 8187 8188 8189 8190 8191 8192 8193 8194 8195 8196 8197 8198 8199 8200 8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 8222 8223 8224 8225 8226 8227 8228 8229 8230 8231 8232 8233 8234 8235 8236 8237 8238 8239 8240 8241 8242 8243 8244 8245 8246 8247 8248 8249 8250 8251 8252 8253 8254 8255 8256 8257 8258 8259 8260 8261 8262 8263 8264 8265 8266 8267 8268 |
|
get_item_type(ttype)
#
Get a particular item type
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ttype
|
TypeMapItem
|
a |
required |
Returns:
Type | Description |
---|---|
object
|
|
Source code in androguard/core/dex/__init__.py
show()
#
Print with a pretty display the MapList object
Source code in androguard/core/dex/__init__.py
MethodAnnotation
#
This class can parse a method_annotation
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
MethodHIdItem
#
This class can parse a list of method_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(size, buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the list of |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
MethodIdItem
#
This class can parse a method_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_class_idx()
#
Return the index into the type_ids list for the definer of this method
Returns:
Type | Description |
---|---|
int
|
the index |
get_class_name()
#
Return the class name of the method
Returns:
Type | Description |
---|---|
str
|
the class name |
Source code in androguard/core/dex/__init__.py
get_descriptor()
#
get_name()
#
Return the name of the method
Returns:
Type | Description |
---|---|
str
|
the name of the of method |
Source code in androguard/core/dex/__init__.py
get_name_idx()
#
Return the index into the string_ids
list for the name of this method
Returns:
Type | Description |
---|---|
int
|
the index |
get_proto()
#
Return the prototype of the method
Returns:
Type | Description |
---|---|
str
|
the prototype |
Source code in androguard/core/dex/__init__.py
get_proto_idx()
#
Return the index into the proto_ids
list for the prototype of this method
Returns:
Type | Description |
---|---|
int
|
the index |
get_real_descriptor()
#
Return the real descriptor (i.e. without extra spaces)
Returns:
Type | Description |
---|---|
str
|
the real descriptor, without extra spaces |
Source code in androguard/core/dex/__init__.py
ODEX
#
Bases: DEX
This class can parse an odex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
byteswhich represents the odex file |
required | |
decompiler
|
Union[DecompilerDAD, None]
|
associate a decompiler object to display the java source code Example: >>> ODEX( read("classes.odex") ) |
None
|
Source code in androguard/core/dex/__init__.py
9273 9274 9275 9276 9277 9278 9279 9280 9281 9282 9283 9284 9285 9286 9287 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 9303 9304 9305 9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 9318 9319 9320 9321 9322 9323 9324 9325 9326 9327 9328 9329 9330 9331 9332 9333 9334 9335 9336 9337 9338 9339 9340 9341 9342 |
|
get_dependencies()
#
Return the odex dependencies object
Returns:
Type | Description |
---|---|
OdexDependencies
|
an |
get_format_type()
#
save()
#
OdexDependencies
#
This class can parse the odex dependencies
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a Buff object string which represents the odex dependencies |
required |
Source code in androguard/core/dex/__init__.py
get_dependencies()
#
Return the list of dependencies
Returns:
Type | Description |
---|---|
list[str]
|
a list of strings |
OdexHeaderItem
#
This class can parse the odex header
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a Buff object string which represents the odex dependencies |
required |
Source code in androguard/core/dex/__init__.py
PackedSwitch
#
This class can parse a PackedSwitch
instruction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
bytes
|
a Buff object which represents a buffer where the instruction is stored |
required |
Source code in androguard/core/dex/__init__.py
4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 |
|
add_note(msg)
#
Add a note to this instruction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
the message |
required |
get_hex()
#
Returns a HEX String, separated by spaces every byte
get_keys()
#
Return the keys of the instruction
Returns:
Type | Description |
---|---|
list[int]
|
a list of long (integer) |
get_name()
#
get_notes()
#
Get all notes from this instruction
Returns:
Type | Description |
---|---|
list[str]
|
a list of note strings |
get_op_value()
#
get_operands(idx=-1)
#
get_output(idx=-1)
#
Return an additional output of the instruction
Returns:
Type | Description |
---|---|
str
|
additional output string |
Source code in androguard/core/dex/__init__.py
get_targets()
#
Return the targets (address) of the instruction
Returns:
Type | Description |
---|---|
list[int]
|
a list of long (integer) |
show(pos)
#
show_buff(pos)
#
Return the display of the instruction
Returns:
Type | Description |
---|---|
str
|
display string |
Source code in androguard/core/dex/__init__.py
ParameterAnnotation
#
This class can parse a parameter_annotation
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_annotations_off()
#
Return the offset from the start of the file to the list of annotations for the method parameters
Returns:
Type | Description |
---|---|
int
|
the offset |
get_method_idx()
#
Return the index into the method_ids
list for the identity of the method whose parameters are being annotated
Returns:
Type | Description |
---|---|
int
|
the index |
ProtoHIdItem
#
This class can parse a list of proto_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(size, buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the list of |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
ProtoIdItem
#
This class can parse a proto_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_parameters_off()
#
Return the offset from the start of the file to the list of parameter types for this prototype, or 0 if this prototype has no parameters
Returns:
Type | Description |
---|---|
int
|
the offset |
Source code in androguard/core/dex/__init__.py
get_parameters_off_value()
#
Return the string associated to the parameters_off
Returns:
Type | Description |
---|---|
str
|
string |
Source code in androguard/core/dex/__init__.py
get_return_type_idx()
#
Return the index into the type_ids
list for the return type of this prototype
Returns:
Type | Description |
---|---|
int
|
the index |
get_return_type_idx_value()
#
Return the string associated to the return_type_idx
Returns:
Type | Description |
---|---|
str
|
string |
Source code in androguard/core/dex/__init__.py
get_shorty_idx()
#
Return the index into the string_ids
list for the short-form descriptor string of this prototype
Returns:
Type | Description |
---|---|
int
|
the index |
get_shorty_idx_value()
#
Return the string associated to the shorty_idx
Returns:
Type | Description |
---|---|
str
|
string |
Source code in androguard/core/dex/__init__.py
SparseSwitch
#
This class can parse a SparseSwitch instruction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
bytes
|
a Buff object which represents a buffer where the instruction is stored |
required |
Source code in androguard/core/dex/__init__.py
4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 |
|
add_note(msg)
#
Add a note to this instruction
Parameters:
Name | Type | Description | Default |
---|---|---|---|
msg
|
str
|
the message |
required |
get_hex()
#
Returns a HEX String, separated by spaces every byte
Returns:
Type | Description |
---|---|
str
|
hex string |
Source code in androguard/core/dex/__init__.py
get_keys()
#
Return the keys of the instruction
Returns:
Type | Description |
---|---|
list[int]
|
a list of long (integer) |
get_name()
#
get_notes()
#
Get all notes from this instruction
Returns:
Type | Description |
---|---|
list[str]
|
a list of note strings |
get_op_value()
#
get_operands(idx=-1)
#
Return an additional output of the instruction
Returns:
Type | Description |
---|---|
str
|
additional output string |
get_output(idx=-1)
#
Return an additional output of the instruction
Returns:
Type | Description |
---|---|
str
|
additional output string |
get_targets()
#
Return the targets (address) of the instruction
Returns:
Type | Description |
---|---|
list[int]
|
a list of long (integer) |
show(pos)
#
show_buff(pos)
#
Return the display of the instruction
Returns:
Type | Description |
---|---|
str
|
display string |
Source code in androguard/core/dex/__init__.py
StringDataItem
#
This class can parse a string_data_item
of a dex file
Strings in Dalvik files might not be representable in python! This is due to the fact, that you can store any UTF-16 character inside a Dalvik file, but this string might not be decodeable in python as it can contain invalid surrogate-pairs.
To circumvent this issue, this class has different methods how to access the string. There are also some fallbacks implemented to make a "invalid" string printable in python. Dalvik uses MUTF-8 as encoding for the strings. This encoding has the advantage to allow for null terminated strings in UTF-8 encoding, as the null character maps to something else. Therefore you can use get_data to retrieve the actual data of the string and can handle encoding yourself. If you want a representation of the string, which should be printable in python you ca use get which escapes invalid characters.
Source code in androguard/core/dex/__init__.py
2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 |
|
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get()
#
Returns a str object
Returns:
Type | Description |
---|---|
str
|
string |
Source code in androguard/core/dex/__init__.py
get_data()
#
Return a series of MUTF-8 code units (a.k.a. octets, a.k.a. bytes) followed by a byte of value 0
Returns:
Type | Description |
---|---|
str
|
string |
get_length()
#
Get the length of the raw string including the ULEB128 coded length and the null byte terminator
Returns:
Type | Description |
---|---|
int
|
int |
Source code in androguard/core/dex/__init__.py
get_raw()
#
Returns the raw string including the ULEB128 coded length and null byte string terminator
Returns:
Type | Description |
---|---|
bytes
|
bytes |
get_utf16_size()
#
Return the size of this string, in UTF-16 code units
Returns:
Type | Description |
---|---|
int
|
the size of the string |
StringIdItem
#
This class can parse a string_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the str`ing_id_item |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_string_data_off()
#
Return the offset from the start of the file to the string data for this item
Returns:
Type | Description |
---|---|
int
|
the offset |
TryItem
#
This class represents the try_item
format
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a raw buffer where are the |
required |
cm
|
ClassManager
|
the |
required |
Source code in androguard/core/dex/__init__.py
get_handler_off()
#
Get the offset in bytes from the start of the associated EncodedCatchHandlerList
to the EncodedCatchHandler
for this entry.
Returns:
Type | Description |
---|---|
int
|
int |
get_insn_count()
#
Get the number of 16-bit code units covered by this entry
Returns:
Type | Description |
---|---|
int
|
int |
get_start_addr()
#
Get the start address of the block of code covered by this entry. The address is a count of 16-bit code units to the start of the first covered instruction.
Returns:
Type | Description |
---|---|
int
|
address int |
Source code in androguard/core/dex/__init__.py
TypeHIdItem
#
This class can parse a list of type_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(size, buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the list of |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_type()
#
Return the list of type_id_item
Returns:
Type | Description |
---|---|
list[TypeIdItem]
|
a list of |
TypeIdItem
#
This class can parse a type_id_item
of a dex file
Source code in androguard/core/dex/__init__.py
__init__(buff, cm)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_descriptor_idx()
#
Return the index into the string_ids list for the descriptor string of this type
Returns:
Type | Description |
---|---|
int
|
int |
get_descriptor_idx_value()
#
Return the string associated to the descriptor
Returns:
Type | Description |
---|---|
str
|
string |
TypeItem
#
This class can parse a type_item
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
get_string()
#
TypeList
#
This class can parse a type_list
of a dex file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a string which represents a Buff object of the |
required |
cm
|
ClassManager
|
a |
required |
Source code in androguard/core/dex/__init__.py
1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 |
|
clean_name_instruction(instruction)
#
USED IN ELSIM
determineException(vm, m)
#
Returns try-catch handler inside the method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vm
|
DEX
|
a |
required |
m
|
EncodedMethod
|
|
required |
Returns:
Type | Description |
---|---|
list[list]
|
a list |
Source code in androguard/core/dex/__init__.py
determineNext(i, cur_idx, m)
#
Determine the next offsets inside the bytecode of an EncodedMethod. The offsets are calculated in number of bytes from the start of the method. Note, that offsets inside the bytecode are denoted in 16bit units but this method returns actual bytes!
Offsets inside the opcode are counted from the beginning of the opcode.
The returned type is a list, as branching opcodes will have multiple paths.
if
and switch
opcodes will return more than one item in the list, while
throw
, return
and goto
opcodes will always return a list with length one.
An offset of -1 indicates that the method is exited, for example by throw
or return
.
If the entered opcode is not branching or jumping, an empty list is returned.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
i
|
Instruction
|
the current Instruction |
required |
cur_idx
|
int
|
Index of the instruction |
required |
m
|
EncodedMethod
|
the current method |
required |
Returns:
Type | Description |
---|---|
list
|
|
Source code in androguard/core/dex/__init__.py
get_access_flags_string(value)
#
Transform an access flag field to the corresponding string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
the value of the access flags |
required |
Returns:
Type | Description |
---|---|
str
|
the transformed string |
Source code in androguard/core/dex/__init__.py
get_bytecodes_method(dex_object, analysis_object, method)
#
return a string representation of method and its code. Wraps get_bytecodes_methodx
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dex_object
|
unused |
required | |
analysis_object
|
Analysis
|
the |
required |
method
|
EncodedMethod
|
the |
required |
Source code in androguard/core/dex/__init__.py
get_bytecodes_methodx(method, mx)
#
return a string representation of a method and its code
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
EncodedMethod
|
the associated |
required |
mx
|
MethodAnalysis
|
the associated |
required |
Returns:
Type | Description |
---|---|
str
|
the string representation |
Source code in androguard/core/dex/__init__.py
9385 9386 9387 9388 9389 9390 9391 9392 9393 9394 9395 9396 9397 9398 9399 9400 9401 9402 9403 9404 9405 9406 9407 9408 9409 9410 9411 9412 9413 9414 9415 9416 9417 9418 9419 9420 9421 9422 9423 9424 9425 9426 9427 9428 9429 9430 9431 9432 9433 9434 9435 9436 9437 9438 9439 9440 9441 9442 9443 9444 9445 9446 9447 9448 9449 9450 9451 9452 9453 9454 9455 9456 9457 9458 9459 |
|
get_instruction(cm, op_value, buff)
#
Return the Instruction for the given opcode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cm
|
ClassManager
|
|
required |
op_value
|
int
|
integer value of the instruction |
required |
buff
|
bytearray
|
Bytecode starting with the |
required |
Returns:
Type | Description |
---|---|
Instruction
|
the parsed |
Raises:
Type | Description |
---|---|
InvalidInstruction
|
if instruction is invalid |
Source code in androguard/core/dex/__init__.py
get_kind(cm, kind, value)
#
Return the value of the 'kind' argument
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cm
|
ClassManager
|
a ClassManager object |
required |
kind
|
int
|
the type of the 'kind' argument |
required |
value
|
int
|
the value of the 'kind' argument |
required |
Returns:
Type | Description |
---|---|
str
|
string |
Source code in androguard/core/dex/__init__.py
get_optimized_instruction(cm, op_value, buff)
#
Return the Instruction for the given optimized opcode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cm
|
ClassManager
|
|
required |
op_value
|
int
|
integer value of the instruction |
required |
buff
|
bytearray
|
Bytecode starting with the |
required |
Returns:
Type | Description |
---|---|
Instruction
|
the parsed |
Raises:
Type | Description |
---|---|
InvalidInstruction
|
if instruction is invalid |
Source code in androguard/core/dex/__init__.py
get_params_info(nb, proto)
#
return a string of parameter info given a function prototype (proto)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nb
|
int
|
the number of parameters |
required |
proto
|
str
|
the function prototype with parameters |
required |
Returns:
Type | Description |
---|---|
str
|
a string representation of the parameter info |
Source code in androguard/core/dex/__init__.py
get_type(atype, size=None)
#
Retrieve the type of a descriptor (e.g : I)
Returns:
Type | Description |
---|---|
str
|
the descriptor string |
Source code in androguard/core/dex/__init__.py
read_null_terminated_string(f)
#
Read a null terminated string from a file-like object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
f
|
IO
|
file-like object |
required |
Returns:
Type | Description |
---|---|
bytearray
|
the bytes of the string read |
Source code in androguard/core/dex/__init__.py
readsleb128(cm, buff)
#
Read a signed LEB128 at the current position of the buffer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a file like object |
required |
Returns:
Type | Description |
---|---|
int
|
decoded sLEB128 |
Source code in androguard/core/dex/__init__.py
readuleb128(cm, buff)
#
Read an unsigned LEB128 at the current position of the buffer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a file like object |
required |
Returns:
Type | Description |
---|---|
int
|
decoded unsigned LEB128 |
Source code in androguard/core/dex/__init__.py
readuleb128p1(cm, buff)
#
Read an unsigned LEB128p1 at the current position of the buffer. This format is the same as uLEB128 but has the ability to store the value -1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
buff
|
BinaryIO
|
a file like object |
required |
Returns:
Type | Description |
---|---|
int
|
decoded uLEB128p1 |
Source code in androguard/core/dex/__init__.py
static_operand_instruction(instruction)
#
USED IN ELSIM
Source code in androguard/core/dex/__init__.py
writesleb128(cm, value)
#
Convert an integer value to the corresponding signed LEB128
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
integer value |
required |
Returns:
Type | Description |
---|---|
bytearray
|
bytes |
Source code in androguard/core/dex/__init__.py
writeuleb128(cm, value)
#
Convert an integer value to the corresponding unsigned LEB128.
Raises a value error, if the given value is negative.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
int
|
non-negative integer |
required |
Returns:
Type | Description |
---|---|
bytearray
|
bytes |
Raises:
Type | Description |
---|---|
ValueError
|
if given value is negative |