droidasc 0.1.2.post3__tar.gz → 0.1.2.post4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {droidasc-0.1.2.post3/droidasc.egg-info → droidasc-0.1.2.post4}/PKG-INFO +2 -2
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/README.md +1 -1
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/core/dex/__init__.py +1 -4
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/writer.py +2 -2
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/disassembler.py +15 -1
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/string_locator.py +20 -19
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4/droidasc.egg-info}/PKG-INFO +2 -2
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc.egg-info/SOURCES.txt +2 -1
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/pyproject.toml +1 -1
- droidasc-0.1.2.post4/tests/test_string_locator_order.py +81 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/LICENSE +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/core/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/core/analysis/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/core/analysis/analysis.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/core/androconf.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/core/bytecode.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/core/dex/dex_types.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/core/mutf8/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/basic_blocks.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/control_flow.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/dast.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/dataflow.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/decompile.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/graph.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/instruction.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/node.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/opcode_ins.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/decompiler/util.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/dadguard/util.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/__main__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/apk/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/apk/dex_reader.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/apk/loader.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/apk/worker.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/apk_handler.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/asc_handler.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/dex_container.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/app.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/backend/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/backend/search.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/backend/store.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/backend/worker.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/editor/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/editor/controller.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/editor/source.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/editor/view.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/state.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/ui/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/ui/class_tree.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/ui/dialogs.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/ui/tab_bar.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/gui/ui/theme.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_client/manifest_handler.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/core/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/core/dex/dex_builder.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/core/dex/dex_constructor.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/core/dex/dex_manager.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/core/dex/dex_remapper.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/core/dvm_handlers.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/core/dvm_interpreter.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/findrefs_manager.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/base_locator.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/field_locator.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/insn_locator.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/method_locator.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/type_locator.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/scan/class_def_item_scan.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/scan/code_item_scan.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/models/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/models/dvm_opcode.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/resource/dvmopcode_template.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/resource/gen_dvmopcode.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/utils/__init__.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/utils/decompiler.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/utils/dex_parser.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/utils/dvm_regdec.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/utils/leb128.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/utils/tinydex.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/cli.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc.egg-info/dependency_links.txt +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc.egg-info/entry_points.txt +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc.egg-info/requires.txt +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc.egg-info/top_level.txt +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/setup.cfg +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_apk_modules.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_decompiler.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_disassembler.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_gui_backend.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_gui_editor.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_gui_views.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_listclass.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_mutf8_strings.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_performance_compare.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_references.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_release.py +0 -0
- {droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/tests/test_source_edit.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: droidasc
|
|
3
|
-
Version: 0.1.2.
|
|
3
|
+
Version: 0.1.2.post4
|
|
4
4
|
Summary: ASC is a super FAST python Android Decompiler for Agents/Mobile Researchers
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -12,7 +12,7 @@ Dynamic: license-file
|
|
|
12
12
|
|
|
13
13
|
# Droid ASC: R8 Compiler Optimization as a DeCompiler Primitive
|
|
14
14
|
|
|
15
|
-
> **Rust version:** This project has been rewritten 1:1 in Rust as [rust_ASC](https://github.com/MG1937/rust_ASC). The Rust version is 10× faster and supports full APK decompilation: with 16 threads, it decompiles a 383 MB APK in just 4 seconds.
|
|
15
|
+
> **Rust version:** This project has been rewritten 1:1 in Rust as [rust_ASC](https://github.com/MG1937/rust_ASC). The Rust version is 10× faster and supports full APK decompilation: with 16 threads, it decompiles a 383 MB APK in just 4 seconds.
|
|
16
16
|
>
|
|
17
17
|
> If your workflow is written in Python, you can continue integrating with this project; it remains the fastest Python Android decompiler available. If you only need a binary, please use [rust_ASC](https://github.com/MG1937/rust_ASC).
|
|
18
18
|
>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Droid ASC: R8 Compiler Optimization as a DeCompiler Primitive
|
|
2
2
|
|
|
3
|
-
> **Rust version:** This project has been rewritten 1:1 in Rust as [rust_ASC](https://github.com/MG1937/rust_ASC). The Rust version is 10× faster and supports full APK decompilation: with 16 threads, it decompiles a 383 MB APK in just 4 seconds.
|
|
3
|
+
> **Rust version:** This project has been rewritten 1:1 in Rust as [rust_ASC](https://github.com/MG1937/rust_ASC). The Rust version is 10× faster and supports full APK decompilation: with 16 threads, it decompiles a 383 MB APK in just 4 seconds.
|
|
4
4
|
>
|
|
5
5
|
> If your workflow is written in Python, you can continue integrating with this project; it remains the fastest Python Android decompiler available. If you only need a binary, please use [rust_ASC](https://github.com/MG1937/rust_ASC).
|
|
6
6
|
>
|
|
@@ -4475,10 +4475,7 @@ def get_kind(cm: ClassManager, kind: int, value: int) -> str:
|
|
|
4475
4475
|
method = cm.get_method_ref(value)
|
|
4476
4476
|
class_name = method.get_class_name()
|
|
4477
4477
|
name = method.get_name()
|
|
4478
|
-
|
|
4479
|
-
descriptor = method.get_real_descriptor()
|
|
4480
|
-
else:
|
|
4481
|
-
descriptor = "".join(method.get_descriptor().split())
|
|
4478
|
+
descriptor = method.get_descriptor()
|
|
4482
4479
|
|
|
4483
4480
|
return "{}->{}{}".format(class_name, name, descriptor)
|
|
4484
4481
|
|
|
@@ -181,8 +181,8 @@ class Writer:
|
|
|
181
181
|
params = self.method.lparams
|
|
182
182
|
if 'static' not in access:
|
|
183
183
|
params = params[1:]
|
|
184
|
-
if len(params) != len(self.method.params_type):
|
|
185
|
-
params = list(range(len(self.method.params_type)))
|
|
184
|
+
if len(params) != len(self.method.params_type):
|
|
185
|
+
params = list(range(len(self.method.params_type)))
|
|
186
186
|
proto = ''
|
|
187
187
|
self.write_ext(('PARENTHESIS_START', '('))
|
|
188
188
|
if self.method.params_type:
|
|
@@ -51,6 +51,7 @@ _ANNOTATION_VISIBILITY = {
|
|
|
51
51
|
2: "system",
|
|
52
52
|
}
|
|
53
53
|
_BRANCH_OFFSET_RE = re.compile(r"([+-]?[0-9a-fA-F]+)h$")
|
|
54
|
+
_METHOD_DESCRIPTOR_RE = re.compile(r"(->[^,\s]+)\(([^)]*)\)([^\s,]+)")
|
|
54
55
|
|
|
55
56
|
|
|
56
57
|
def _format_instruction(index: int, offset: int, instruction) -> str:
|
|
@@ -89,6 +90,17 @@ def _compact_descriptor(descriptor) -> str:
|
|
|
89
90
|
return "".join(str(descriptor).split())
|
|
90
91
|
|
|
91
92
|
|
|
93
|
+
def _compact_method_descriptors(text: str) -> str:
|
|
94
|
+
return _METHOD_DESCRIPTOR_RE.sub(
|
|
95
|
+
lambda match: "{}({}){}".format(
|
|
96
|
+
match.group(1),
|
|
97
|
+
_compact_descriptor(match.group(2)),
|
|
98
|
+
match.group(3),
|
|
99
|
+
),
|
|
100
|
+
text,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
92
104
|
def _normalize_method_signature(signature: str) -> str:
|
|
93
105
|
if not signature or "(" not in signature or ")" not in signature:
|
|
94
106
|
raise ValueError(
|
|
@@ -518,7 +530,9 @@ def _smali_instructions(
|
|
|
518
530
|
for label in catch_labels:
|
|
519
531
|
lines.append(" :{}".format(label))
|
|
520
532
|
lines.extend(debug_events.get(offset, []))
|
|
521
|
-
output =
|
|
533
|
+
output = _compact_method_descriptors(
|
|
534
|
+
instruction.get_output(offset)
|
|
535
|
+
)
|
|
522
536
|
target = _branch_target(offset, instruction)
|
|
523
537
|
if target is not None and labels.get(target):
|
|
524
538
|
output = _replace_branch_operand(output, labels[target][0])
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/string_locator.py
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
from .base_locator import BaseLocator
|
|
2
|
+
from bisect import bisect_right
|
|
2
3
|
import struct
|
|
3
4
|
from ...utils.leb128 import read_uleb128_len
|
|
4
5
|
import re
|
|
5
6
|
import time
|
|
6
7
|
|
|
7
8
|
# Auth: MG1937
|
|
8
|
-
_STRUCT_I = struct.Struct('<I')
|
|
9
9
|
|
|
10
10
|
# r8 using MUTF8 to handle string payload,
|
|
11
11
|
# so 0x00 will be encoded to 0xC0 0x80
|
|
@@ -13,6 +13,7 @@ class StringLocator(BaseLocator):
|
|
|
13
13
|
def __init__(self, dex):
|
|
14
14
|
super().__init__(dex)
|
|
15
15
|
self.stridx_map = {} # {string_data_off : string_idx}
|
|
16
|
+
self.starts = [] # string_data_off of every item, ascending
|
|
16
17
|
self.strdata_start = 0
|
|
17
18
|
self.strdata_end = 0
|
|
18
19
|
self.parsed = False
|
|
@@ -28,19 +29,17 @@ class StringLocator(BaseLocator):
|
|
|
28
29
|
self.parsed = True
|
|
29
30
|
self._debug_log("build_map", t_start, 0)
|
|
30
31
|
return
|
|
31
|
-
#
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
# for the final item without changing that mapping scheme.
|
|
32
|
+
# the format does not require the items to be written in string_ids order,
|
|
33
|
+
# so neither the first nor the last entry bounds the region
|
|
34
|
+
offsets = struct.unpack_from(f'<{string_ids_size}I', buf, string_ids_off)
|
|
35
|
+
stridx_map.update(zip(offsets, range(string_ids_size)))
|
|
36
|
+
self.starts = sorted(offsets)
|
|
37
|
+
self.strdata_start = self.starts[0]
|
|
38
|
+
# the item with the largest offset is written last; its terminator closes it
|
|
39
|
+
last = self.starts[-1]
|
|
40
40
|
self.strdata_end = buf.obj.find(
|
|
41
|
-
b'\x00',
|
|
41
|
+
b'\x00', last + read_uleb128_len(buf, last)
|
|
42
42
|
) + 1
|
|
43
|
-
stridx_map[self.strdata_end] = string_ids_size
|
|
44
43
|
self.parsed = True
|
|
45
44
|
self._debug_log("build_map", t_start, len(stridx_map))
|
|
46
45
|
|
|
@@ -57,15 +56,15 @@ class StringLocator(BaseLocator):
|
|
|
57
56
|
strdata_start = self.strdata_start
|
|
58
57
|
strdata_end = self.strdata_end
|
|
59
58
|
submem = buf[strdata_start: strdata_end]
|
|
60
|
-
|
|
61
|
-
mm = submem.obj
|
|
62
59
|
pattern = re.compile(pattern_bytes)
|
|
63
|
-
|
|
60
|
+
starts = self.starts
|
|
64
61
|
# offsets = []
|
|
65
62
|
for match in pattern.finditer(submem):
|
|
66
|
-
|
|
67
|
-
offset
|
|
68
|
-
|
|
63
|
+
# resolve the item that physically holds the match: its start is the
|
|
64
|
+
# greatest item offset not behind the match, regardless of its index
|
|
65
|
+
pos = bisect_right(starts, strdata_start + match.start()) - 1
|
|
66
|
+
if pos >= 0:
|
|
67
|
+
yield starts[pos]
|
|
69
68
|
# offsets.append(offset + 1) # skip over 00 byte
|
|
70
69
|
# return offsets
|
|
71
70
|
|
|
@@ -76,7 +75,9 @@ class StringLocator(BaseLocator):
|
|
|
76
75
|
stridx_map = self.stridx_map
|
|
77
76
|
located_idx = set()
|
|
78
77
|
for offset in self._match_string_offset(string):
|
|
79
|
-
|
|
78
|
+
idx = stridx_map.get(offset)
|
|
79
|
+
if idx is not None:
|
|
80
|
+
located_idx.add(idx)
|
|
80
81
|
# return set for O(1) lookup
|
|
81
82
|
self._debug_log("locate", t_start, len(located_idx))
|
|
82
83
|
return located_idx
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: droidasc
|
|
3
|
-
Version: 0.1.2.
|
|
3
|
+
Version: 0.1.2.post4
|
|
4
4
|
Summary: ASC is a super FAST python Android Decompiler for Agents/Mobile Researchers
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -12,7 +12,7 @@ Dynamic: license-file
|
|
|
12
12
|
|
|
13
13
|
# Droid ASC: R8 Compiler Optimization as a DeCompiler Primitive
|
|
14
14
|
|
|
15
|
-
> **Rust version:** This project has been rewritten 1:1 in Rust as [rust_ASC](https://github.com/MG1937/rust_ASC). The Rust version is 10× faster and supports full APK decompilation: with 16 threads, it decompiles a 383 MB APK in just 4 seconds.
|
|
15
|
+
> **Rust version:** This project has been rewritten 1:1 in Rust as [rust_ASC](https://github.com/MG1937/rust_ASC). The Rust version is 10× faster and supports full APK decompilation: with 16 threads, it decompiles a 383 MB APK in just 4 seconds.
|
|
16
16
|
>
|
|
17
17
|
> If your workflow is written in Python, you can continue integrating with this project; it remains the fastest Python Android decompiler available. If you only need a binary, please use [rust_ASC](https://github.com/MG1937/rust_ASC).
|
|
18
18
|
>
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "droidasc"
|
|
7
|
-
version = "0.1.2-
|
|
7
|
+
version = "0.1.2-post4"
|
|
8
8
|
description = "ASC is a super FAST python Android Decompiler for Agents/Mobile Researchers"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import unittest
|
|
2
|
+
|
|
3
|
+
from dex_fixture import make_dex, reorder_string_data
|
|
4
|
+
from droidasc.asc_client.asc_handler import AscHandler
|
|
5
|
+
from droidasc.asc_core.findrefs.locator.string_locator import StringLocator
|
|
6
|
+
from droidasc.asc_core.utils.tinydex import DEX
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# the string table of dex_fixture.make_dex(), in string_ids order
|
|
10
|
+
STRINGS = {
|
|
11
|
+
'Lexample/Test;': 0,
|
|
12
|
+
'Ljava/lang/Object;': 1,
|
|
13
|
+
'V': 2,
|
|
14
|
+
'first': 3,
|
|
15
|
+
'second': 4,
|
|
16
|
+
'token': 5,
|
|
17
|
+
}
|
|
18
|
+
INDEX_ORDER = [0, 1, 2, 3, 4, 5]
|
|
19
|
+
REVERSED = [5, 4, 3, 2, 1, 0]
|
|
20
|
+
MIDDLE = [0, 5, 4, 3, 2, 1]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class StringLayoutTests(unittest.TestCase):
|
|
24
|
+
def dex(self, data):
|
|
25
|
+
return DEX.parse(memoryview(data), 'layout.dex')
|
|
26
|
+
|
|
27
|
+
def assert_layout(self, data):
|
|
28
|
+
locator = StringLocator(self.dex(data))
|
|
29
|
+
for text, idx in STRINGS.items():
|
|
30
|
+
with self.subTest(text=text):
|
|
31
|
+
self.assertEqual(locator.locate(text), {idx})
|
|
32
|
+
|
|
33
|
+
def test_permutation_keeps_the_string_table(self):
|
|
34
|
+
# the layouts below must only move bytes around: every index has to keep
|
|
35
|
+
# naming the same string, otherwise the tests would pass on a broken fixture
|
|
36
|
+
for order in (INDEX_ORDER, REVERSED, MIDDLE):
|
|
37
|
+
with self.subTest(order=order):
|
|
38
|
+
dex = self.dex(reorder_string_data(make_dex(), order))
|
|
39
|
+
self.assertEqual(
|
|
40
|
+
[dex.get_string(idx) for idx in range(len(STRINGS))],
|
|
41
|
+
list(STRINGS),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
def test_index_order_layout(self):
|
|
45
|
+
self.assert_layout(make_dex())
|
|
46
|
+
|
|
47
|
+
def test_reversed_layout(self):
|
|
48
|
+
self.assert_layout(reorder_string_data(make_dex(), REVERSED))
|
|
49
|
+
|
|
50
|
+
def test_middle_permutation(self):
|
|
51
|
+
self.assert_layout(reorder_string_data(make_dex(), MIDDLE))
|
|
52
|
+
|
|
53
|
+
def test_substring_maps_to_the_item_that_holds_it(self):
|
|
54
|
+
# 'oken' only appears inside 'secret-token', whose index is 5
|
|
55
|
+
self.assertEqual(
|
|
56
|
+
StringLocator(self.dex(reorder_string_data(make_dex(), REVERSED)))
|
|
57
|
+
.locate('oken'),
|
|
58
|
+
{5},
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
def test_match_across_two_items_names_no_string(self):
|
|
62
|
+
# 'first' and 'second' are neighbours on disk, but a match may not run from
|
|
63
|
+
# one item through the terminator into the next
|
|
64
|
+
self.assertEqual(StringLocator(self.dex(make_dex())).locate('first\x00second'), set())
|
|
65
|
+
|
|
66
|
+
def test_findrefs_matches_the_index_order_layout(self):
|
|
67
|
+
handler = AscHandler()
|
|
68
|
+
expected = handler.findrefs(
|
|
69
|
+
'fixture.dex', make_dex(), 'string', {'string': 'token'})
|
|
70
|
+
reordered = handler.findrefs(
|
|
71
|
+
'fixture.dex',
|
|
72
|
+
reorder_string_data(make_dex(), REVERSED),
|
|
73
|
+
'string',
|
|
74
|
+
{'string': 'token'},
|
|
75
|
+
)
|
|
76
|
+
self.assertEqual(reordered, expected)
|
|
77
|
+
self.assertEqual(len(expected), 2)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if __name__ == '__main__':
|
|
81
|
+
unittest.main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/findrefs_manager.py
RENAMED
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/__init__.py
RENAMED
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/base_locator.py
RENAMED
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/field_locator.py
RENAMED
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/insn_locator.py
RENAMED
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/method_locator.py
RENAMED
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/locator/type_locator.py
RENAMED
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/scan/class_def_item_scan.py
RENAMED
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/findrefs/scan/code_item_scan.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{droidasc-0.1.2.post3 → droidasc-0.1.2.post4}/droidasc/asc_core/resource/dvmopcode_template.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|