analysis
Analysis
#
Analysis Object
The Analysis contains a lot of information about (multiple) DEX objects Features are for example XREFs between Classes, Methods, Fields and Strings. Yet another part is the creation of BasicBlocks, which is important in the usage of the Androguard Decompiler.
Multiple DEX Objects can be added using the function add.
XREFs are created for:
-
classes (ClassAnalysis)
-
methods (MethodAnalysis)
-
strings (StringAnalysis)
-
fields (FieldAnalysis)
The Analysis should be the only object you are using next to the APK. It encapsulates all the Dalvik related functions into a single place, while you have still the ability to use the functions from DEX and the related classes.
Source code in androguard/core/analysis/analysis.py
1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 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 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 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 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 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 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 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 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 |
|
fields
property
#
Returns FieldAnalysis generator of this Analysis
Returns:
Type | Description |
---|---|
Iterator[FieldAnalysis]
|
iterator of |
__init__(vm=None)
#
Initialize a new Analysis object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vm
|
Union[DEX, None]
|
inital DEX object (default None) |
None
|
Source code in androguard/core/analysis/analysis.py
add(vm)
#
Add a DEX to this Analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vm
|
DEX
|
|
required |
Source code in androguard/core/analysis/analysis.py
create_ipython_exports()
#
WARNING: this feature is experimental and is currently not enabled by default! Use with caution!
Creates attributes for all classes, methods and fields on the Analysis
object itself.
This makes it easier to work with Analysis
module in an iPython shell.
Classes can be search by typing dx.CLASS_<tab>
, as each class is added via this attribute name.
Each class will have all methods attached to it via dx.CLASS_Foobar.METHOD_<tab>
.
Fields have a similar syntax: dx.CLASS_Foobar.FIELD_<tab>
.
As Strings can contain nearly anything, use find_strings instead.
- Each
CLASS_
item will return a ClassAnalysis - Each
METHOD_
item will return a MethodAnalysis - Each
FIELD_
item will return a FieldAnalysis
Source code in androguard/core/analysis/analysis.py
create_xref()
#
Create Class, Method, String and Field crossreferences for all classes in the Analysis.
If you are using multiple DEX files, this function must be called when all DEX files are added. If you call the function after every DEX file, it will only work for the first time.
Source code in androguard/core/analysis/analysis.py
find_classes(name='.*', no_external=False)
#
Find classes by name, using regular expression This method will return all ClassAnalysis Object that match the name of the class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
regular expression for class name (default ".*") |
'.*'
|
no_external
|
bool
|
Remove external classes from the output (default False) |
False
|
Returns:
Type | Description |
---|---|
Iterator[ClassAnalysis]
|
generator of |
Source code in androguard/core/analysis/analysis.py
find_fields(classname='.*', fieldname='.*', fieldtype='.*', accessflags='.*')
#
find fields by regex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classname
|
str
|
regular expression of the classname |
'.*'
|
fieldname
|
str
|
regular expression of the fieldname |
'.*'
|
fieldtype
|
str
|
regular expression of the fieldtype |
'.*'
|
accessflags
|
str
|
regular expression of the access flags |
'.*'
|
Returns:
Type | Description |
---|---|
Iterator[FieldAnalysis]
|
generator of |
Source code in androguard/core/analysis/analysis.py
find_methods(classname='.*', methodname='.*', descriptor='.*', accessflags='.*', no_external=False)
#
Find a method by name using regular expression. This method will return all MethodAnalysis objects, which match the classname, methodname, descriptor and accessflags of the method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classname
|
str
|
regular expression for the classname |
'.*'
|
methodname
|
str
|
regular expression for the method name |
'.*'
|
descriptor
|
str
|
regular expression for the descriptor |
'.*'
|
accessflags
|
str
|
regular expression for the accessflags |
'.*'
|
no_external
|
bool
|
Remove external method from the output (default False) |
False
|
Returns:
Type | Description |
---|---|
Iterator[MethodAnalysis]
|
generator of |
Source code in androguard/core/analysis/analysis.py
find_strings(string='.*')
#
Find strings by regex
Parameters:
Name | Type | Description | Default |
---|---|---|---|
string
|
str
|
regular expression for the string to search for |
'.*'
|
Returns:
Type | Description |
---|---|
Iterator[StringAnalysis]
|
generator of |
Source code in androguard/core/analysis/analysis.py
get_android_api_usage()
#
Get all usage of the Android APIs inside the Analysis
.
Returns:
Type | Description |
---|---|
Iterator[MethodAnalysis]
|
yields |
Source code in androguard/core/analysis/analysis.py
get_call_graph(classname='.*', methodname='.*', descriptor='.*', accessflags='.*', no_isolated=False, entry_points=[])
#
Generate a directed graph based on the methods found by the filters applied. The filters are the same as in find_methods
A networkx.DiGraph
is returned, containing all edges only once!
that means, if a method calls some method twice or more often, there will
only be a single connection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classname
|
str
|
regular expression of the classname (default: ".*") |
'.*'
|
methodname
|
str
|
regular expression of the methodname (default: ".*") |
'.*'
|
descriptor
|
str
|
regular expression of the descriptor (default: ".*") |
'.*'
|
accessflags
|
str
|
regular expression of the access flags (default: ".*") |
'.*'
|
no_isolated
|
bool
|
remove isolated nodes from the graph, e.g. methods which do not call anything (default: |
False
|
entry_points
|
list
|
A list of classes that are marked as entry point |
[]
|
Returns:
Type | Description |
---|---|
DiGraph
|
the |
Source code in androguard/core/analysis/analysis.py
2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 |
|
get_class_analysis(class_name)
#
Returns the ClassAnalysis object for a given classname.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
classname like |
required |
Returns:
Type | Description |
---|---|
ClassAnalysis
|
|
Source code in androguard/core/analysis/analysis.py
get_classes()
#
Returns a list of ClassAnalysis objects
Returns both internal and external classes (if any)
Returns:
Type | Description |
---|---|
list[ClassAnalysis]
|
list of |
Source code in androguard/core/analysis/analysis.py
get_external_classes()
#
Returns all external classes, that means all classes that are not defined in the given set of DEX.
Returns:
Type | Description |
---|---|
Iterator[ClassAnalysis]
|
the external classes |
Source code in androguard/core/analysis/analysis.py
get_external_methods()
#
Returns all external methods, that means all methods that are not defined in the given set of DEX.
Returns:
Type | Description |
---|---|
Iterator[MethodAnalysis]
|
the external methods |
Source code in androguard/core/analysis/analysis.py
get_field_analysis(field)
#
Get the FieldAnalysis for a given EncodedField
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
EncodedField
|
the |
required |
Returns:
Type | Description |
---|---|
Union[FieldAnalysis, None]
|
the |
Source code in androguard/core/analysis/analysis.py
get_fields()
#
Returns a generator of FieldAnalysis objects
Returns:
Type | Description |
---|---|
Iterator[FieldAnalysis]
|
generator of |
Source code in androguard/core/analysis/analysis.py
get_internal_classes()
#
Returns all internal classes, that means all classes that are defined in the given set of DEX.
Returns:
Type | Description |
---|---|
Iterator[ClassAnalysis]
|
the internal classes |
Source code in androguard/core/analysis/analysis.py
get_internal_methods()
#
Returns all internal methods, that means all methods that are defined in the given set of DEX.
Returns:
Type | Description |
---|---|
Iterator[MethodAnalysis]
|
the internal methods |
Source code in androguard/core/analysis/analysis.py
get_method(method)
#
Get the MethodAnalysis object for a given EncodedMethod.
This Analysis object is used to enhance EncodedMethods
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
EncodedMethod
|
|
required |
Returns:
Type | Description |
---|---|
Union[MethodAnalysis, None]
|
|
Source code in androguard/core/analysis/analysis.py
get_method_analysis_by_name(class_name, method_name, method_descriptor)
#
Returns the crossreferencing object for a given method.
This function is similar to get_method_analysis, with the difference that you can look up the Method by name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
name of the class, for example |
required |
method_name
|
str
|
name of the method, for example |
required |
method_descriptor
|
str
|
method descriptor, for example |
required |
Returns:
Type | Description |
---|---|
Union[MethodAnalysis, None]
|
|
Source code in androguard/core/analysis/analysis.py
get_method_by_name(class_name, method_name, method_descriptor)
#
Search for a EncodedMethod in all classes in this analysis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
name of the class, for example |
required |
method_name
|
str
|
name of the method, for example |
required |
method_descriptor
|
str
|
descriptor, for example |
required |
Returns:
Type | Description |
---|---|
Union[EncodedMethod, None]
|
|
Source code in androguard/core/analysis/analysis.py
get_methods()
#
Returns a generator of MethodAnalysis objects
Returns:
Type | Description |
---|---|
Iterator[MethodAnalysis]
|
generator of |
Source code in androguard/core/analysis/analysis.py
get_permission_usage(permission, apilevel=None)
#
Find the usage of a permission inside the Analysis.
Examples:
>>> from androguard.misc import AnalyzeAPK
>>> a, d, dx = AnalyzeAPK("somefile.apk")
>>> for meth in dx.get_permission_usage('android.permission.SEND_SMS', a.get_effective_target_sdk_version()):
>>> print("Using API method {}".format(meth))
>>> print("used in:")
>>> for _, m, _ in meth.get_xref_from():
>>> print(m.full_name)
The permission mappings might be incomplete! See also get_permissions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
permission
|
str
|
the name of the android permission (usually 'android.permission.XXX') |
required |
apilevel
|
Union[str, int, None]
|
the requested API level or None for default |
None
|
Returns:
Type | Description |
---|---|
Iterator[MethodAnalysis]
|
yields |
Source code in androguard/core/analysis/analysis.py
get_permissions(apilevel=None)
#
Returns the permissions and the API method based on the API level specified. This can be used to find usage of API methods which require a permission. Should be used in combination with an APK
The returned permissions are a list, as some API methods require multiple permissions at once.
The following example shows the usage and how to get the calling methods using XREF:
Examples:
>>> from androguard.misc import AnalyzeAPK
>>> a, d, dx = AnalyzeAPK("somefile.apk")
>>> for meth, perm in dx.get_permissions(a.get_effective_target_sdk_version()):
>>> print("Using API method {} for permission {}".format(meth, perm))
>>> print("used in:")
>>> for _, m, _ in meth.get_xref_from():
>>> print(m.full_name)
.Note: This method might be unreliable and might not extract all used permissions. The permission mapping is based on Axplorer and might be incomplete due to the nature of the extraction process. Unfortunately, there is no official API<->Permission mapping.
The output of this method relies also on the set API level.
If the wrong API level is used, the results might be wrong.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
apilevel
|
Union[str, int, None]
|
API level to load, or None for default |
None
|
Returns:
Type | Description |
---|---|
Iterator[MethodAnalysis, list[str]]
|
yields tuples of |
Source code in androguard/core/analysis/analysis.py
get_strings()
#
Returns a list of StringAnalysis objects
Returns:
Type | Description |
---|---|
list[StringAnalysis]
|
list of `StringAnalysis objects |
Source code in androguard/core/analysis/analysis.py
get_strings_analysis()
#
Returns a dictionary of strings and their corresponding StringAnalysis
Returns:
Type | Description |
---|---|
dict[str, StringAnalysis]
|
the dictionary of strings |
Source code in androguard/core/analysis/analysis.py
is_class_present(class_name)
#
Checks if a given class name is part of this Analysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
classname like 'Ljava/lang/Object;' (including L and ;) |
required |
Returns:
Type | Description |
---|---|
bool
|
True if class was found, False otherwise |
Source code in androguard/core/analysis/analysis.py
BasicBlocks
#
This class represents all basic blocks of a method.
It is a collection of many DEXBasicBlock.
Source code in androguard/core/analysis/analysis.py
__getitem__(item)
#
Get the basic block at the index
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
int
|
index |
required |
Returns:
Type | Description |
---|---|
DEXBasicBlock
|
The basic block |
__iter__()
#
Returns:
Type | Description |
---|---|
Iterator[DEXBasicBlock]
|
yields each basic block ( |
get_basic_block(idx)
#
return the DEXBasicBlock at idx
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index of the |
required |
Returns:
Type | Description |
---|---|
Union[DEXBasicBlock, None]
|
the |
Source code in androguard/core/analysis/analysis.py
gets()
#
Returns:
Type | Description |
---|---|
list[DEXBasicBlock]
|
a list of DEXBasicBlock |
pop(idx)
#
remove and return DEXBasicBlock at idx
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index of the |
required |
Returns:
Type | Description |
---|---|
DEXBasicBlock
|
the popped |
Source code in androguard/core/analysis/analysis.py
push(bb)
#
Adds another basic block to the collection
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bb
|
DEXBasicBlock
|
the |
required |
ClassAnalysis
#
ClassAnalysis contains the XREFs from a given Class. It is also used to wrap [ClassDefItem[androguard.core.dex.ClassDefItem], which contain the actual class content like bytecode.
Also external classes will generate xrefs, obviously only XREF_FROM are shown for external classes.
Source code in androguard/core/analysis/analysis.py
1149 1150 1151 1152 1153 1154 1155 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 1312 1313 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 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 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 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 |
|
extends
property
#
Return the parent class
For external classes, this is not sure, thus we return always Object (which is the parent of all classes)
Returns:
Type | Description |
---|---|
str
|
a string of the parent class name |
implements
property
#
Get a list of interfaces which are implemented by this class
Returns:
Type | Description |
---|---|
list[str]
|
a list of Interface names |
name
property
#
Return the class name
Returns:
Type | Description |
---|---|
str
|
|
__init__(classobj)
#
Initialize a new ClassAnalysis object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classobj
|
Union[ClassDefItem, ExternalClass]
|
the original class |
required |
Source code in androguard/core/analysis/analysis.py
add_field(field_analysis)
#
Add the given field to this analyis. usually only called during Analysis.add
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field_analysis
|
FieldAnalysis
|
the |
required |
Source code in androguard/core/analysis/analysis.py
add_field_xref_read(method, classobj, field, off)
#
Add a Field Read to this class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
MethodAnalysis
|
|
required |
classobj
|
ClassAnalysis
|
|
required |
field
|
EncodedField
|
|
required |
off
|
int
|
|
required |
Source code in androguard/core/analysis/analysis.py
add_field_xref_write(method, classobj, field, off)
#
Add a Field Write to this class in a given method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
MethodAnalysis
|
|
required |
classobj
|
ClassAnalysis
|
|
required |
field
|
EncodedField
|
|
required |
off
|
int
|
|
required |
Source code in androguard/core/analysis/analysis.py
add_method(method_analysis)
#
Add the given method to this analyis.
usually only called during Analysis.add and Analysis._resolve_method
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method_analysis
|
MethodAnalysis
|
the method to add |
required |
Source code in androguard/core/analysis/analysis.py
add_method_xref_from(method1, classobj, method2, offset)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method1
|
MethodAnalysis
|
|
required |
classobj
|
ClassAnalysis
|
|
required |
method2
|
MethodAnalysis
|
|
required |
offset
|
int
|
|
required |
Source code in androguard/core/analysis/analysis.py
add_method_xref_to(method1, classobj, method2, offset)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method1
|
MethodAnalysis
|
the calling method |
required |
classobj
|
ClassAnalysis
|
the calling class |
required |
method2
|
MethodAnalysis
|
the called method |
required |
offset
|
int
|
offset in the bytecode of calling method |
required |
Source code in androguard/core/analysis/analysis.py
add_xref_const_class(methobj, offset)
#
Add a crossreference to a method referencing this classtype.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
methobj
|
MethodAnalysis
|
The |
required |
offset
|
int
|
integer where in the method the classtype is referenced |
required |
Source code in androguard/core/analysis/analysis.py
add_xref_from(ref_kind, classobj, methodobj, offset)
#
Creates a crossreference from this class. XrefFrom means, that the current class is called by another class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_kind
|
REF_TYPE
|
type of call |
required |
classobj
|
ClassAnalysis
|
|
required |
methodobj
|
MethodAnalysis
|
|
required |
offset
|
int
|
Offset in the methods bytecode, where the call happens |
required |
Source code in androguard/core/analysis/analysis.py
add_xref_new_instance(methobj, offset)
#
Add a crossreference to another method that is instancing this class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
methobj
|
MethodAnalysis
|
The |
required |
offset
|
int
|
integer where in the method the instantiation happens |
required |
Source code in androguard/core/analysis/analysis.py
add_xref_to(ref_kind, classobj, methodobj, offset)
#
Creates a crossreference to another class. XrefTo means, that the current class calls another class. The current class should also be contained in the another class' XrefFrom list.
WARNING: The implementation of this specific method might not be what you expect! the parameter methodobj
is the source method and not the destination in the case that ref_kind
is const-class or new-instance!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_kind
|
REF_TYPE
|
type of call |
required |
classobj
|
ClassAnalysis
|
|
required |
methodobj
|
MethodAnalysis
|
|
required |
offset
|
int
|
Offset in the Methods Bytecode, where the call happens |
required |
Source code in androguard/core/analysis/analysis.py
get_field_analysis(field)
#
Return the FieldAnalysis object for a given EncodedMethod
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
EncodedMethod
|
the method to get a |
required |
Returns:
Type | Description |
---|---|
FieldAnalysis
|
the related |
Source code in androguard/core/analysis/analysis.py
get_fields()
#
Return all FieldAnalysis objects of this class
Returns:
Type | Description |
---|---|
list[FieldAnalysis]
|
the |
Source code in androguard/core/analysis/analysis.py
get_method_analysis(method)
#
Return the MethodAnalysis object for a given EncodedMethod
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method
|
EncodedMethod
|
the method to get a |
required |
Returns:
Type | Description |
---|---|
MethodAnalysis
|
the related |
Source code in androguard/core/analysis/analysis.py
get_methods()
#
Return all MethodAnalysis objects of this class
Returns:
Type | Description |
---|---|
list[MethodAnalysis]
|
the |
Source code in androguard/core/analysis/analysis.py
get_nb_methods()
#
Get the number of methods in this class
Returns:
Type | Description |
---|---|
int
|
the number of methods |
get_vm_class()
#
Returns the original Dalvik VM class or the external class object.
Returns:
Type | Description |
---|---|
Union[ClassDefItem, ExternalClass]
|
the |
Source code in androguard/core/analysis/analysis.py
get_xref_const_class()
#
Returns a list of tuples containing the method and offset referencing this classtype.
The list of tuples has the form:
(MethodAnalysis,
int
)
Returns:
Type | Description |
---|---|
list[tuple[MethodAnalysis, int]]
|
the list of tuples |
Source code in androguard/core/analysis/analysis.py
get_xref_from()
#
Returns a dictionary of all classes calling the current class. This dictionary contains also information from which method the class is accessed.
Note: this method might contains wrong information about class usage!
The dictionary contains the classes as keys (stored as ClassAnalysis)
and has a tuple as values, where the first item is the ref_kind
(which is an Enum of type REF_TYPE),
the second one is the method in which the class is called (MethodAnalysis)
and the third the offset in the method where the call is originating.
Examples:
>>> # dx is an Analysis object
for cls in dx.find_classes('.*some/name.*'):
>>> print("Found class {} in Analysis".format(cls.name)
>>> for caller, refs in cls.get_xref_from().items():
>>> print(" called from {}".format(caller.name))
>>> for ref_kind, ref_method, ref_offset in refs:
>>> print(" in method {} {}".format(ref_kind, ref_method))
Returns:
Type | Description |
---|---|
dict[ClassAnalysis, tuple[REF_TYPE, MethodAnalysis, int]]
|
|
Source code in androguard/core/analysis/analysis.py
get_xref_new_instance()
#
Returns a list of tuples containing the set of methods with offsets that instance this class
The list of tuples has the form:
(MethodAnalysis,
int
)
Returns:
Type | Description |
---|---|
list[tuple[MethodAnalysis, int]]
|
the list of tuples |
Source code in androguard/core/analysis/analysis.py
get_xref_to()
#
Returns a dictionary of all classes which are called by the current class. This dictionary contains also information about the method which is called.
Note: this method might contains wrong information about class usage!
The dictionary contains the classes as keys (stored as ClassAnalysis)
and has a tuple as values, where the first item is the ref_kind
(which is an Enum of type REF_TYPE),
the second one is the method called (MethodAnalysis)
and the third the offset in the method where the call is originating.
Examples:
>>> # dx is an Analysis object
>>> for cls in dx.find_classes('.*some/name.*'):
>>> print("Found class {} in Analysis".format(cls.name)
>>> for calling, refs in cls.get_xref_from().items():
>>> print(" calling class {}".format(calling.name))
>>> for ref_kind, ref_method, ref_offset in refs:
>>> print(" calling method {} {}".format(ref_kind, ref_method))
Returns:
Type | Description |
---|---|
dict[ClassAnalysis, tuple[REF_TYPE, MethodAnalysis, int]]
|
|
Source code in androguard/core/analysis/analysis.py
is_android_api()
#
Tries to guess if the current class is an Android API class.
This might be not very precise unless an apilist is given, with classes that are in fact known APIs. Such a list might be generated by using the android.jar files.
Returns:
Type | Description |
---|---|
bool
|
True if the class is an Andorid API class, else False. |
Source code in androguard/core/analysis/analysis.py
is_external()
#
Tests if this class is an external class
Returns:
Type | Description |
---|---|
bool
|
True if the Class is external, False otherwise |
set_domain_flag(flag)
#
Set the api domain for this class (hidden level, from Android 10) (only applicable to internal classes)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flag
|
DomapiApiFlag
|
The flag to set to |
required |
Source code in androguard/core/analysis/analysis.py
set_restriction_flag(flag)
#
Set the level of restriction for this class (hidden level, from Android 10) (only applicable to internal classes)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flag
|
RestrictionApiFlag
|
The flag to set to |
required |
Source code in androguard/core/analysis/analysis.py
DEXBasicBlock
#
A simple basic block of a DEX method.
A basic block consists of a series of Instruction
which are not interrupted by branch or jump instructions such as goto
, if
, throw
, return
, switch
etc.
Source code in androguard/core/analysis/analysis.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
|
__init__(start, vm, method, context)
#
Initialize a new DEXBasicBlock
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start
|
int
|
start address of the basic block |
required |
vm
|
DEX
|
|
required |
method
|
EncodedMethod
|
|
required |
context
|
BasicBlocks
|
|
required |
Source code in androguard/core/analysis/analysis.py
get_end()
#
get_instructions()
#
Get all instructions from a basic block.
Returns:
Type | Description |
---|---|
Iterator[Instruction]
|
Return all instructions in the current basic block |
Source code in androguard/core/analysis/analysis.py
get_last()
#
Get the last instruction in the basic block
Returns:
Type | Description |
---|---|
Instruction
|
the last |
get_method()
#
Returns the originating method
Returns:
Type | Description |
---|---|
EncodedMethod
|
the originating |
get_next()
#
Get next basic blocks
Returns:
Type | Description |
---|---|
DEXBasicBlock
|
a list of the next |
get_prev()
#
Get previous basic blocks
Returns:
Type | Description |
---|---|
DEXBasicBlock
|
a list of the previous |
get_special_ins(idx)
#
Return the associated instruction to a specific instruction (for example a packed/sparse switch)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx
|
int
|
the index of the instruction |
required |
Returns:
Type | Description |
---|---|
Union[Instruction, None]
|
the associated |
Source code in androguard/core/analysis/analysis.py
get_start()
#
ExternalClass
#
The ExternalClass is used for all classes that are not defined in the DEX file, thus are external classes.
Source code in androguard/core/analysis/analysis.py
__init__(name)
#
Instantiate a new ExternalClass object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
Name of the external class |
required |
get_methods()
#
Return the list of stored MethodAnalysis for this external class
Returns:
Type | Description |
---|---|
list[MethodAnalysis]
|
the list of |
Source code in androguard/core/analysis/analysis.py
get_name()
#
Returns the name of the ExternalClass object
Returns:
Type | Description |
---|---|
str
|
the name of the external class |
ExternalMethod
#
ExternalMethod is a stub class for methods that are not part of the current Analysis. There are two possibilities for this:
1) The method is defined inside another DEX file which was not loaded into the Analysis 2) The method is an API method, hence it is defined in the Android system
External methods should have a similar API to EncodedMethod but obviously they have no code attached. The only known information about such methods are the class name, the method name and its descriptor.
Source code in androguard/core/analysis/analysis.py
1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 |
|
full_name
property
#
Returns classname + name + descriptor, separated by spaces (no access flags)'
Returns:
Type | Description |
---|---|
str
|
the formatted name |
permission_api_name
property
#
Returns a name which can be used to look up in the permission maps
Returns:
Type | Description |
---|---|
str
|
the formatted name |
__init__(class_name, name, descriptor)
#
Initialize a new ExternalMethod object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
class_name
|
str
|
name of the class |
required |
name
|
str
|
name of the method |
required |
descriptor
|
str
|
descriptor string |
required |
Source code in androguard/core/analysis/analysis.py
get_access_flags_string()
#
Returns the access flags string.
Right now, this is always an empty strings, as we can not say what kind of access flags an external method might have.
Source code in androguard/core/analysis/analysis.py
get_class_name()
#
return the name of the class of this external method
Returns:
Type | Description |
---|---|
str
|
the name of the class |
get_descriptor()
#
return the descriptor of this external method
Returns:
Type | Description |
---|---|
str
|
the descriptor of the external method |
get_name()
#
return the name of the external method
Returns:
Type | Description |
---|---|
str
|
the name of the external method |
FieldAnalysis
#
FieldAnalysis contains the XREFs for a class field.
Instead of using XREF_FROM/XREF_TO, this object has methods for READ and WRITE access to the field.
That means, that it will show you, where the field is read or written.
Source code in androguard/core/analysis/analysis.py
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
|
__init__(field)
#
Initialize a new FieldAnalysis object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
field
|
EncodedField
|
|
required |
Source code in androguard/core/analysis/analysis.py
add_xref_read(classobj, methodobj, offset)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classobj
|
ClassAnalysis
|
|
required |
methodobj
|
MethodAnalysis
|
|
required |
offset
|
int
|
offset in the bytecode |
required |
Source code in androguard/core/analysis/analysis.py
add_xref_write(classobj, methodobj, offset)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classobj
|
ClassAnalysis
|
|
required |
methodobj
|
MethodAnalysis
|
|
required |
offset
|
int
|
offset in the bytecode |
required |
Source code in androguard/core/analysis/analysis.py
get_field()
#
Returns the actual EncodedField object
Returns:
Type | Description |
---|---|
EncodedField
|
the |
get_xref_read(with_offset=False)
#
Returns a list of xrefs where the field is read.
The list contains tuples of the originating class and methods, where the class is represented as a ClassAnalysis, while the method is a MethodAnalysis.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
with_offset
|
bool
|
return the xrefs including the offset |
False
|
Returns:
Type | Description |
---|---|
list[tuple[ClassAnalysis, MethodAnalysis]]
|
the |
Source code in androguard/core/analysis/analysis.py
get_xref_write(with_offset=False)
#
Returns a list of xrefs where the field is written to.
The list contains tuples of the originating class and methods, where the class is represented as a ClassAnalysis, while the method is a MethodAnalysis`.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
with_offset
|
bool
|
return the xrefs including the offset |
False
|
Returns:
Type | Description |
---|---|
list[tuple[ClassAnalysis, MethodAnalysis]]
|
the |
Source code in androguard/core/analysis/analysis.py
MethodAnalysis
#
This class analyzes in details a method of a class/dex file It is a wrapper around a androguard.core.dex.EncodedMethod and enhances it by using multiple DEXBasicBlock encapsulated in a BasicBlocks object.
Source code in androguard/core/analysis/analysis.py
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 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 798 799 800 801 802 803 804 805 806 807 808 809 |
|
access
property
#
Returns the access flags to the method as a string
Returns:
Type | Description |
---|---|
str
|
the access flags |
class_name
property
#
Returns the name of the class of this method
Returns:
Type | Description |
---|---|
str
|
the name of the class |
descriptor
property
#
Returns the type descriptor for this method
Returns:
Type | Description |
---|---|
str
|
the type descriptor |
full_name
property
#
Returns classname + name + descriptor, separated by spaces (no access flags)
Returns:
Type | Description |
---|---|
str
|
the method full name |
name
property
#
Returns the name of this method
Returns:
Type | Description |
---|---|
str
|
the name |
__init__(vm, method)
#
Initialize new MethodAnalysis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vm
|
DEX
|
the |
required |
method
|
EncodedMethod
|
the |
required |
Source code in androguard/core/analysis/analysis.py
add_xref_const_class(classobj, offset)
#
add_xref_from(classobj, methodobj, offset)
#
Add a crossrefernece from another method (this method is called by another method)
Source code in androguard/core/analysis/analysis.py
add_xref_new_instance(classobj, offset)
#
Add a crossreference to another class that is instanced within this method.
add_xref_read(classobj, fieldobj, offset)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classobj
|
ClassAnalysis
|
|
required |
fieldobj
|
FieldAnalysis
|
|
required |
offset
|
int
|
offset in the bytecode |
required |
Source code in androguard/core/analysis/analysis.py
add_xref_to(classobj, methodobj, offset)
#
Add a crossreference to another method (this method calls another method)
Source code in androguard/core/analysis/analysis.py
add_xref_write(classobj, fieldobj, offset)
#
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classobj
|
ClassAnalysis
|
|
required |
fieldobj
|
FieldAnalysis
|
|
required |
offset
|
int
|
offset in the bytecode |
required |
Source code in androguard/core/analysis/analysis.py
get_access_flags_string()
#
Returns the concatenated access flags string
Returns:
Type | Description |
---|---|
str
|
the access flags |
get_basic_blocks()
#
Returns the BasicBlocks generated for this method. The BasicBlocks can be used to get a control flow graph (CFG) of the method.
Returns:
Type | Description |
---|---|
BasicBlocks
|
a |
Source code in androguard/core/analysis/analysis.py
get_class_name()
#
get_length()
#
get_method()
#
get_vm()
#
get_xref_const_class()
#
Returns a list of tuples containing the class and offset of the references to another classtype by this method.
The list of tuples has the form:
(ClassAnalysis,
int
)
Returns:
Type | Description |
---|---|
list[tuple[ClassAnalysis, int]]
|
the |
Source code in androguard/core/analysis/analysis.py
get_xref_from()
#
Returns a list of tuples containing the class, method and offset of the call, from where this object was called.
The list of tuples has the form:
(ClassAnalysis,
MethodAnalysis,
int
)
Returns:
Type | Description |
---|---|
list[tuple[ClassAnalysis, MethodAnalysis, int]]
|
the |
Source code in androguard/core/analysis/analysis.py
get_xref_new_instance()
#
Returns a list of tuples containing the class and offset of the creation of a new instance of a class by this method.
The list of tuples has the form:
(ClassAnalysis,
int
)
Returns:
Type | Description |
---|---|
list[tuple[ClassAnalysis, int]]
|
the |
Source code in androguard/core/analysis/analysis.py
get_xref_read()
#
Returns a list of xrefs where a field is read by this method.
The list contains tuples of the originating class and methods, where the class is represented as a ClassAnalysis, while the Field is a FieldAnalysis.
Returns:
Type | Description |
---|---|
list[tuple[ClassAnalysis, FieldAnalysis]]
|
the |
Source code in androguard/core/analysis/analysis.py
get_xref_to()
#
Returns a list of tuples containing the class, method and offset of the call, which are called by this method.
The list of tuples has the form:
(ClassAnalysis,
MethodAnalysis,
int
)
Returns:
Type | Description |
---|---|
list[tuple[ClassAnalysis, MethodAnalysis, int]]
|
the |
Source code in androguard/core/analysis/analysis.py
get_xref_write()
#
Returns a list of xrefs where a field is written to by this method.
The list contains tuples of the originating class and methods, where the class is represented as a ClassAnalysis, while the Field is a FieldAnalysis.
Returns:
Type | Description |
---|---|
list[tuple[ClassAnalysis, FieldAnalysis]]
|
the |
Source code in androguard/core/analysis/analysis.py
is_android_api()
#
Returns True
if the method seems to be an Android API method.
This method might be not very precise unless an list of known API methods is given.
Returns:
Type | Description |
---|---|
bool
|
|
Source code in androguard/core/analysis/analysis.py
is_external()
#
Returns True
if the underlying method is external
Returns:
Type | Description |
---|---|
bool
|
|
show()
#
Prints the content of this method to stdout.
This will print the method signature and the decompiled code.
Source code in androguard/core/analysis/analysis.py
REF_TYPE
#
Bases: IntEnum
Stores the opcodes for the type of usage in an XREF.
Used in ClassAnalysis to store the type of reference to the class.
Source code in androguard/core/analysis/analysis.py
StringAnalysis
#
StringAnalysis contains the XREFs of a string.
As Strings are only used as a source, they only contain the XREF_FROM set, i.e. where the string is used.
This Array stores the information in which method the String is used.
Source code in androguard/core/analysis/analysis.py
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
|
__init__(value)
#
Instantiate a new StringAnalysis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
the original string value |
required |
Source code in androguard/core/analysis/analysis.py
add_xref_from(classobj, methodobj, off)
#
Adds a xref from the given method to this string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
classobj
|
ClassAnalysis
|
|
required |
methodobj
|
MethodAnalysis
|
|
required |
off
|
int
|
offset in the bytecode of the call |
required |
Source code in androguard/core/analysis/analysis.py
get_orig_value()
#
Return the original, read only, value of the string
Returns:
Type | Description |
---|---|
str
|
the original value |
get_value()
#
Return the (possible overwritten) value of the string
Returns:
Type | Description |
---|---|
str
|
the value of the string |
get_xref_from(with_offset=False)
#
Returns a list of xrefs accessing the String.
The list contains tuples of the originating class and methods, where the class is represented as a ClassAnalysis, while the method is a MethodAnalysis.
Source code in androguard/core/analysis/analysis.py
is_overwritten()
#
Returns True
if the string was overwritten
Returns:
Type | Description |
---|---|
bool
|
|
set_value(value)
#
Overwrite the current value of the String with a new value. The original value is not lost and can still be retrieved using get_orig_value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
str
|
new string value |
required |
Source code in androguard/core/analysis/analysis.py
is_ascii_obfuscation(vm)
#
Tests if any class inside a DEX uses ASCII Obfuscation (e.g. UTF-8 Chars in Classnames)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
vm
|
DEX
|
|
required |
Returns:
Type | Description |
---|---|
bool
|
|