il2cpp-ghidrah 0.2.0__tar.gz → 0.2.2__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.
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/CHANGELOG.md +20 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/PKG-INFO +11 -3
- il2cpp_ghidrah-0.2.0/src/il2cpp_ghidrah.egg-info/PKG-INFO → il2cpp_ghidrah-0.2.2/README.md +8 -13
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/pyproject.toml +5 -1
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/__init__.py +1 -1
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/cli.py +7 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/config.py +3 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/generators.py +5 -5
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/headless_process.py +17 -3
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/pipeline.py +5 -1
- il2cpp_ghidrah-0.2.0/README.md → il2cpp_ghidrah-0.2.2/src/il2cpp_ghidrah.egg-info/PKG-INFO +21 -2
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/tests/test_cli.py +93 -1
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/tests/test_headless_process.py +84 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/LICENSE +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/MANIFEST.in +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/setup.cfg +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/__main__.py +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/export_contract.py +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/ghidra_scripts/ImportIl2CppCParser.java +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/headless_manifest.py +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/inputs.py +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/installation.py +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/process.py +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah/selection.py +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah.egg-info/SOURCES.txt +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah.egg-info/dependency_links.txt +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah.egg-info/entry_points.txt +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah.egg-info/top_level.txt +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/tests/test_export_contract.py +0 -0
- {il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/tests/test_headless_manifest.py +0 -0
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.2
|
|
4
|
+
|
|
5
|
+
- Show TurboHeader warnings as one yellow line on interactive terminals; keep redirected output plain.
|
|
6
|
+
- Honor NO_COLOR and TERM=dumb, preserve saved logs, and escape control characters before applying colour.
|
|
7
|
+
|
|
8
|
+
## 0.2.1
|
|
9
|
+
|
|
10
|
+
- Use local non-return discovery instead of legacy address-only seed files.
|
|
11
|
+
- Request the Ghidra artifact profile from the AOT generator.
|
|
12
|
+
- Allow `--profile full` while keeping `ghidra` as the default artifact profile.
|
|
13
|
+
|
|
3
14
|
## 0.2.0
|
|
4
15
|
|
|
5
16
|
- Replaced the embedded PyGhidra launcher with fixed `analyzeHeadless` Java entry points.
|
|
@@ -11,3 +22,12 @@
|
|
|
11
22
|
- Hardened archive handling, path validation, process environments, and export verification.
|
|
12
23
|
|
|
13
24
|
This release requires TurboHeader 1.3.9 or newer.
|
|
25
|
+
|
|
26
|
+
## 0.1.5
|
|
27
|
+
|
|
28
|
+
- Final release using the PyGhidra-based export pipeline.
|
|
29
|
+
- Supports Python 3.9 and newer.
|
|
30
|
+
- Compatible with TurboHeader 1.3.8.
|
|
31
|
+
- Includes the legacy Python import and export scripts.
|
|
32
|
+
|
|
33
|
+
New installations should use il2cpp-ghidrah 0.2.0 with TurboHeader 1.3.10.
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: il2cpp-ghidrah
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Headless Ghidra pipeline for Unity IL2CPP applications
|
|
5
5
|
Author: il2cpp-ghidrah contributors
|
|
6
6
|
License: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/TeamRocketIst/il2cpp-ghidrah
|
|
8
|
+
Project-URL: Changelog, https://github.com/TeamRocketIst/il2cpp-ghidrah/releases
|
|
7
9
|
Requires-Python: >=3.9
|
|
8
10
|
Description-Content-Type: text/markdown
|
|
9
11
|
License-File: LICENSE
|
|
@@ -11,7 +13,9 @@ Dynamic: license-file
|
|
|
11
13
|
|
|
12
14
|
# il2cpp-ghidrah
|
|
13
15
|
|
|
14
|
-
`il2cpp-ghidrah`
|
|
16
|
+
`il2cpp-ghidrah` runs artifact generation, typed Ghidra import and targeted C++ export through [two headless Ghidra processes](https://github.com/TeamRocketIst/il2cpp-ghidrah/blob/e3a8a05654b0a416bdafb6c3362acd213135d18e/src/il2cpp_ghidrah/pipeline.py#L106-L190). [Class and assembly selection](https://github.com/TeamRocketIst/turboHeader/blob/ed24c5adf77ba926a942c8836befb19f517d65ff/src/main/java/turboheader/il2cpp/exporting/Il2CppClassSelector.java#L60-L90) avoids wasting time decompiling framework code.
|
|
17
|
+
|
|
18
|
+
The workflow is developed and tested mainly for ARM64. x86-64 support is currently experimental.
|
|
15
19
|
|
|
16
20
|
## Requirements
|
|
17
21
|
|
|
@@ -167,7 +171,7 @@ Cpp2IL forced-file mode requires the exact Unity version. The Dumper flow stops
|
|
|
167
171
|
|
|
168
172
|
```text
|
|
169
173
|
output/
|
|
170
|
-
├── artifacts/ il2cpp.h, script.json,
|
|
174
|
+
├── artifacts/ il2cpp.h, script.json, dump.cs, optional type_offsets.json
|
|
171
175
|
├── cpp2il/ DiffableCs class tree
|
|
172
176
|
├── project/ Ghidra project
|
|
173
177
|
├── decompiled/ assembly/namespace/class.cpp
|
|
@@ -176,3 +180,7 @@ output/
|
|
|
176
180
|
```
|
|
177
181
|
|
|
178
182
|
The first Ghidra process imports and types the binary. The second reopens the project and exports the requested classes. Automatic whole-program analysis remains disabled in both phases.
|
|
183
|
+
|
|
184
|
+
## Acknowledgments
|
|
185
|
+
|
|
186
|
+
This project was developed together with Antonio Freire ([TSelecta](https://github.com/TSelecta)). His work and contributions were essential to making it possible.
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: il2cpp-ghidrah
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: Headless Ghidra pipeline for Unity IL2CPP applications
|
|
5
|
-
Author: il2cpp-ghidrah contributors
|
|
6
|
-
License: MIT
|
|
7
|
-
Requires-Python: >=3.9
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Dynamic: license-file
|
|
11
|
-
|
|
12
1
|
# il2cpp-ghidrah
|
|
13
2
|
|
|
14
|
-
`il2cpp-ghidrah`
|
|
3
|
+
`il2cpp-ghidrah` runs artifact generation, typed Ghidra import and targeted C++ export through [two headless Ghidra processes](https://github.com/TeamRocketIst/il2cpp-ghidrah/blob/e3a8a05654b0a416bdafb6c3362acd213135d18e/src/il2cpp_ghidrah/pipeline.py#L106-L190). [Class and assembly selection](https://github.com/TeamRocketIst/turboHeader/blob/ed24c5adf77ba926a942c8836befb19f517d65ff/src/main/java/turboheader/il2cpp/exporting/Il2CppClassSelector.java#L60-L90) avoids wasting time decompiling framework code.
|
|
4
|
+
|
|
5
|
+
The workflow is developed and tested mainly for ARM64. x86-64 support is currently experimental.
|
|
15
6
|
|
|
16
7
|
## Requirements
|
|
17
8
|
|
|
@@ -167,7 +158,7 @@ Cpp2IL forced-file mode requires the exact Unity version. The Dumper flow stops
|
|
|
167
158
|
|
|
168
159
|
```text
|
|
169
160
|
output/
|
|
170
|
-
├── artifacts/ il2cpp.h, script.json,
|
|
161
|
+
├── artifacts/ il2cpp.h, script.json, dump.cs, optional type_offsets.json
|
|
171
162
|
├── cpp2il/ DiffableCs class tree
|
|
172
163
|
├── project/ Ghidra project
|
|
173
164
|
├── decompiled/ assembly/namespace/class.cpp
|
|
@@ -176,3 +167,7 @@ output/
|
|
|
176
167
|
```
|
|
177
168
|
|
|
178
169
|
The first Ghidra process imports and types the binary. The second reopens the project and exports the requested classes. Automatic whole-program analysis remains disabled in both phases.
|
|
170
|
+
|
|
171
|
+
## Acknowledgments
|
|
172
|
+
|
|
173
|
+
This project was developed together with Antonio Freire ([TSelecta](https://github.com/TSelecta)). His work and contributions were essential to making it possible.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "il2cpp-ghidrah"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "Headless Ghidra pipeline for Unity IL2CPP applications"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -12,6 +12,10 @@ license = { text = "MIT" }
|
|
|
12
12
|
authors = [{ name = "il2cpp-ghidrah contributors" }]
|
|
13
13
|
dependencies = []
|
|
14
14
|
|
|
15
|
+
[project.urls]
|
|
16
|
+
Repository = "https://github.com/TeamRocketIst/il2cpp-ghidrah"
|
|
17
|
+
Changelog = "https://github.com/TeamRocketIst/il2cpp-ghidrah/releases"
|
|
18
|
+
|
|
15
19
|
[project.scripts]
|
|
16
20
|
il2cpp-ghidrah = "il2cpp_ghidrah.cli:main"
|
|
17
21
|
|
|
@@ -44,6 +44,12 @@ def parser() -> argparse.ArgumentParser:
|
|
|
44
44
|
run_parser.add_argument("input", type=Path, help="APK/XAPK/APKS/ZIP, extracted directory, or native binary")
|
|
45
45
|
run_parser.add_argument("-o", "--output", type=Path, required=True)
|
|
46
46
|
run_parser.add_argument("-g", "--generator", choices=("auto", "aotopsy", "dumper"), default="auto")
|
|
47
|
+
run_parser.add_argument(
|
|
48
|
+
"--profile",
|
|
49
|
+
choices=("ghidra", "full"),
|
|
50
|
+
default="ghidra",
|
|
51
|
+
help="AOT generator artifact profile (default: ghidra)",
|
|
52
|
+
)
|
|
47
53
|
run_parser.add_argument("--importer", choices=("turbo", "cparser"), default="turbo")
|
|
48
54
|
run_parser.add_argument("-l", "--layout", choices=("inferred", "external", "authoritative"), default="external")
|
|
49
55
|
run_parser.add_argument("-s", "--scope", choices=("whitelist", "blacklist", "all"), default="blacklist")
|
|
@@ -92,6 +98,7 @@ def _run(args: argparse.Namespace) -> None:
|
|
|
92
98
|
input_path=args.input,
|
|
93
99
|
output=args.output,
|
|
94
100
|
generator=args.generator,
|
|
101
|
+
artifact_profile=args.profile,
|
|
95
102
|
layout=args.layout,
|
|
96
103
|
scope=args.scope,
|
|
97
104
|
metadata=args.metadata,
|
|
@@ -16,6 +16,7 @@ class RunConfig:
|
|
|
16
16
|
input_path: Path
|
|
17
17
|
output: Path
|
|
18
18
|
generator: str = "auto"
|
|
19
|
+
artifact_profile: str = "ghidra"
|
|
19
20
|
layout: str = "external"
|
|
20
21
|
scope: str = "blacklist"
|
|
21
22
|
metadata: Path | None = None
|
|
@@ -38,6 +39,8 @@ class RunConfig:
|
|
|
38
39
|
keep_temporary: bool = False
|
|
39
40
|
|
|
40
41
|
def __post_init__(self) -> None:
|
|
42
|
+
if self.artifact_profile not in {"ghidra", "full"}:
|
|
43
|
+
raise ValueError("artifact_profile must be ghidra or full")
|
|
41
44
|
if type(self.decompile_jobs) is not int or not 0 <= self.decompile_jobs <= 12:
|
|
42
45
|
raise ValueError("decompile_jobs must be an integer from 0 through 12")
|
|
43
46
|
|
|
@@ -82,6 +82,8 @@ def generate(
|
|
|
82
82
|
generator, generator_command, cpp2il_command = select_generator(config)
|
|
83
83
|
cpp2il_unity_version = None
|
|
84
84
|
if generator == "dumper":
|
|
85
|
+
if config.artifact_profile != "ghidra":
|
|
86
|
+
raise ValueError("--profile full requires the AOT generator")
|
|
85
87
|
cpp2il_unity_version = _cpp2il_unity_version(config)
|
|
86
88
|
print(f"Artifact generator selected: {generator}")
|
|
87
89
|
if generator == "aotopsy":
|
|
@@ -90,6 +92,8 @@ def generate(
|
|
|
90
92
|
"gen",
|
|
91
93
|
str(resolved.original),
|
|
92
94
|
str(artifacts_dir),
|
|
95
|
+
"--profile",
|
|
96
|
+
config.artifact_profile,
|
|
93
97
|
*input_options,
|
|
94
98
|
]
|
|
95
99
|
else:
|
|
@@ -152,10 +156,6 @@ def generate(
|
|
|
152
156
|
missing = [str(path) for path in required if not path.exists()]
|
|
153
157
|
if missing:
|
|
154
158
|
raise FileNotFoundError("generator did not produce: " + ", ".join(missing))
|
|
155
|
-
noreturn_seeds = artifacts_dir / "noreturn-seeds.txt" if generator == "aotopsy" else None
|
|
156
|
-
if noreturn_seeds is not None and not config.dry_run:
|
|
157
|
-
if not noreturn_seeds.is_file() or noreturn_seeds.stat().st_size == 0:
|
|
158
|
-
noreturn_seeds = None
|
|
159
159
|
return Artifacts(
|
|
160
160
|
artifacts_dir,
|
|
161
161
|
header,
|
|
@@ -163,5 +163,5 @@ def generate(
|
|
|
163
163
|
offsets,
|
|
164
164
|
cpp2il_dir / "DiffableCs",
|
|
165
165
|
generator,
|
|
166
|
-
|
|
166
|
+
None,
|
|
167
167
|
)
|
|
@@ -155,7 +155,7 @@ def _environment(source: Mapping[str, str], private_root: Path) -> Mapping[str,
|
|
|
155
155
|
return environment
|
|
156
156
|
|
|
157
157
|
|
|
158
|
-
def _terminal_text(value: str) -> str:
|
|
158
|
+
def _terminal_text(value: str, *, color: bool = False) -> str:
|
|
159
159
|
output = []
|
|
160
160
|
for character in value:
|
|
161
161
|
if character in ("\n", "\t"):
|
|
@@ -164,7 +164,20 @@ def _terminal_text(value: str) -> str:
|
|
|
164
164
|
output.append(f"\\u{ord(character):04x}")
|
|
165
165
|
else:
|
|
166
166
|
output.append(character)
|
|
167
|
-
|
|
167
|
+
text = "".join(output)
|
|
168
|
+
marker = "WARNING: TurboHeader "
|
|
169
|
+
if marker not in text:
|
|
170
|
+
return text
|
|
171
|
+
newline = "\n" if text.endswith("\n") else ""
|
|
172
|
+
warning = marker + text.partition(marker)[2].rstrip()
|
|
173
|
+
warning = warning.removesuffix(" (GhidraScript)")
|
|
174
|
+
if color:
|
|
175
|
+
return f"\x1b[33m{warning}\x1b[0m{newline}"
|
|
176
|
+
return warning + newline
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def _warning_color(environment: Mapping[str, str]) -> bool:
|
|
180
|
+
return sys.stdout.isatty() and "NO_COLOR" not in environment and environment.get("TERM") != "dumb"
|
|
168
181
|
|
|
169
182
|
|
|
170
183
|
def _log_path(path: Path, description: str) -> Path:
|
|
@@ -303,6 +316,7 @@ class GhidraHeadlessRunner:
|
|
|
303
316
|
return HeadlessResult(command, application_log, script_log, launcher_log, 0.0)
|
|
304
317
|
if timeout_seconds is not None and timeout_seconds <= 0:
|
|
305
318
|
raise ValueError("headless timeout must be greater than zero")
|
|
319
|
+
color = _warning_color(self._base_environment)
|
|
306
320
|
|
|
307
321
|
application_log.parent.mkdir(parents=True, exist_ok=True)
|
|
308
322
|
launcher_log.write_text(f"$ {rendered}\n", encoding="utf-8")
|
|
@@ -349,7 +363,7 @@ class GhidraHeadlessRunner:
|
|
|
349
363
|
output.write(line)
|
|
350
364
|
output.flush()
|
|
351
365
|
if stream_output:
|
|
352
|
-
sys.stdout.write(_terminal_text(line))
|
|
366
|
+
sys.stdout.write(_terminal_text(line, color=color))
|
|
353
367
|
sys.stdout.flush()
|
|
354
368
|
return_code = process.wait()
|
|
355
369
|
except BaseException:
|
|
@@ -86,7 +86,10 @@ def run(config: RunConfig) -> None:
|
|
|
86
86
|
print(f" Metadata: {resolved.metadata}")
|
|
87
87
|
print(f" Unity data: {resolved.unity_data or '-'}")
|
|
88
88
|
print(f" Assets: {resolved.assets or '-'}")
|
|
89
|
-
print(
|
|
89
|
+
print(
|
|
90
|
+
f" Generator: {config.generator}; profile: {config.artifact_profile}; "
|
|
91
|
+
f"layout: {config.layout}; scope: {config.scope}"
|
|
92
|
+
)
|
|
90
93
|
print(f" Header importer: {importer}")
|
|
91
94
|
|
|
92
95
|
artifacts = generate(config, resolved, output / "artifacts", output / "cpp2il", logs)
|
|
@@ -205,6 +208,7 @@ def run(config: RunConfig) -> None:
|
|
|
205
208
|
"binary": str(resolved.binary),
|
|
206
209
|
"metadata": str(resolved.metadata),
|
|
207
210
|
"generator": artifacts.generator,
|
|
211
|
+
"artifact_profile": config.artifact_profile,
|
|
208
212
|
"importer": importer,
|
|
209
213
|
"layout": config.layout,
|
|
210
214
|
"scope": config.scope,
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: il2cpp-ghidrah
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: Headless Ghidra pipeline for Unity IL2CPP applications
|
|
5
|
+
Author: il2cpp-ghidrah contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/TeamRocketIst/il2cpp-ghidrah
|
|
8
|
+
Project-URL: Changelog, https://github.com/TeamRocketIst/il2cpp-ghidrah/releases
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
1
14
|
# il2cpp-ghidrah
|
|
2
15
|
|
|
3
|
-
`il2cpp-ghidrah`
|
|
16
|
+
`il2cpp-ghidrah` runs artifact generation, typed Ghidra import and targeted C++ export through [two headless Ghidra processes](https://github.com/TeamRocketIst/il2cpp-ghidrah/blob/e3a8a05654b0a416bdafb6c3362acd213135d18e/src/il2cpp_ghidrah/pipeline.py#L106-L190). [Class and assembly selection](https://github.com/TeamRocketIst/turboHeader/blob/ed24c5adf77ba926a942c8836befb19f517d65ff/src/main/java/turboheader/il2cpp/exporting/Il2CppClassSelector.java#L60-L90) avoids wasting time decompiling framework code.
|
|
17
|
+
|
|
18
|
+
The workflow is developed and tested mainly for ARM64. x86-64 support is currently experimental.
|
|
4
19
|
|
|
5
20
|
## Requirements
|
|
6
21
|
|
|
@@ -156,7 +171,7 @@ Cpp2IL forced-file mode requires the exact Unity version. The Dumper flow stops
|
|
|
156
171
|
|
|
157
172
|
```text
|
|
158
173
|
output/
|
|
159
|
-
├── artifacts/ il2cpp.h, script.json,
|
|
174
|
+
├── artifacts/ il2cpp.h, script.json, dump.cs, optional type_offsets.json
|
|
160
175
|
├── cpp2il/ DiffableCs class tree
|
|
161
176
|
├── project/ Ghidra project
|
|
162
177
|
├── decompiled/ assembly/namespace/class.cpp
|
|
@@ -165,3 +180,7 @@ output/
|
|
|
165
180
|
```
|
|
166
181
|
|
|
167
182
|
The first Ghidra process imports and types the binary. The second reopens the project and exports the requested classes. Automatic whole-program analysis remains disabled in both phases.
|
|
183
|
+
|
|
184
|
+
## Acknowledgments
|
|
185
|
+
|
|
186
|
+
This project was developed together with Antonio Freire ([TSelecta](https://github.com/TSelecta)). His work and contributions were essential to making it possible.
|
|
@@ -12,7 +12,7 @@ from unittest.mock import patch
|
|
|
12
12
|
|
|
13
13
|
from il2cpp_ghidrah.cli import _class_list, parser
|
|
14
14
|
from il2cpp_ghidrah.config import RunConfig
|
|
15
|
-
from il2cpp_ghidrah.generators import Artifacts, _cpp2il_unity_version, select_generator
|
|
15
|
+
from il2cpp_ghidrah.generators import Artifacts, _cpp2il_unity_version, generate, select_generator
|
|
16
16
|
from il2cpp_ghidrah.headless_process import HeadlessOperation, HeadlessResult
|
|
17
17
|
from il2cpp_ghidrah.inputs import ResolvedInput, resolve_input
|
|
18
18
|
from il2cpp_ghidrah.installation import Installation, discover, doctor
|
|
@@ -26,6 +26,7 @@ class CliTests(unittest.TestCase):
|
|
|
26
26
|
def test_default_generator_is_auto(self) -> None:
|
|
27
27
|
args = parser().parse_args(["run", "game.apk", "-o", "out"])
|
|
28
28
|
self.assertEqual("auto", args.generator)
|
|
29
|
+
self.assertEqual("ghidra", args.profile)
|
|
29
30
|
self.assertEqual("turbo", args.importer)
|
|
30
31
|
self.assertEqual(8, args.decompile_jobs)
|
|
31
32
|
|
|
@@ -35,6 +36,12 @@ class CliTests(unittest.TestCase):
|
|
|
35
36
|
])
|
|
36
37
|
self.assertEqual(3, args.decompile_jobs)
|
|
37
38
|
|
|
39
|
+
def test_artifact_profile_can_be_overridden(self) -> None:
|
|
40
|
+
args = parser().parse_args([
|
|
41
|
+
"run", "game.apk", "-o", "out", "--profile", "full",
|
|
42
|
+
])
|
|
43
|
+
self.assertEqual("full", args.profile)
|
|
44
|
+
|
|
38
45
|
def test_full_and_short_options(self) -> None:
|
|
39
46
|
args = parser().parse_args([
|
|
40
47
|
"run", "game.apk", "-o", "out", "-g", "dumper", "-l", "inferred",
|
|
@@ -59,6 +66,10 @@ class CliTests(unittest.TestCase):
|
|
|
59
66
|
with self.assertRaisesRegex(ValueError, "from 0 through 12"):
|
|
60
67
|
RunConfig(Path("input"), Path("output"), decompile_jobs=13)
|
|
61
68
|
|
|
69
|
+
def test_run_config_rejects_unsupported_artifact_profile(self) -> None:
|
|
70
|
+
with self.assertRaisesRegex(ValueError, "must be ghidra or full"):
|
|
71
|
+
RunConfig(Path("input"), Path("output"), artifact_profile="unknown")
|
|
72
|
+
|
|
62
73
|
|
|
63
74
|
class InputTests(unittest.TestCase):
|
|
64
75
|
def test_nested_apk_resolution_prefers_requested_abi(self) -> None:
|
|
@@ -118,6 +129,87 @@ class GeneratorTests(unittest.TestCase):
|
|
|
118
129
|
self.assertEqual(str(dumper), selected_command)
|
|
119
130
|
self.assertEqual(str(cpp2il), diffable_command)
|
|
120
131
|
|
|
132
|
+
def test_aotopsy_uses_ghidra_profile_and_ignores_legacy_seed_file(self) -> None:
|
|
133
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
134
|
+
root = Path(directory)
|
|
135
|
+
binary = root / "libil2cpp.so"
|
|
136
|
+
metadata = root / "global-metadata.dat"
|
|
137
|
+
artifacts_dir = root / "artifacts"
|
|
138
|
+
cpp2il_dir = root / "cpp2il"
|
|
139
|
+
binary.touch()
|
|
140
|
+
metadata.touch()
|
|
141
|
+
artifacts_dir.mkdir()
|
|
142
|
+
(artifacts_dir / "il2cpp.h").touch()
|
|
143
|
+
(artifacts_dir / "script.json").write_text("[]", encoding="utf-8")
|
|
144
|
+
(artifacts_dir / "type_offsets.json").write_text("{}", encoding="utf-8")
|
|
145
|
+
(artifacts_dir / "noreturn-seeds.txt").write_text("0x1000\n", encoding="utf-8")
|
|
146
|
+
(cpp2il_dir / "DiffableCs").mkdir(parents=True)
|
|
147
|
+
config = RunConfig(binary, root / "output", generator="aotopsy")
|
|
148
|
+
resolved = ResolvedInput(binary, binary, metadata, None, None)
|
|
149
|
+
with (
|
|
150
|
+
patch(
|
|
151
|
+
"il2cpp_ghidrah.generators.select_generator",
|
|
152
|
+
return_value=("aotopsy", "il2cpp", None),
|
|
153
|
+
),
|
|
154
|
+
patch("il2cpp_ghidrah.generators.run_command") as run_command_mock,
|
|
155
|
+
):
|
|
156
|
+
result = generate(
|
|
157
|
+
config,
|
|
158
|
+
resolved,
|
|
159
|
+
artifacts_dir,
|
|
160
|
+
cpp2il_dir,
|
|
161
|
+
root / "logs",
|
|
162
|
+
)
|
|
163
|
+
generation_command = run_command_mock.call_args_list[0].args[0]
|
|
164
|
+
self.assertEqual(["--profile", "ghidra"], generation_command[4:6])
|
|
165
|
+
self.assertIsNone(result.noreturn_seeds)
|
|
166
|
+
|
|
167
|
+
def test_aotopsy_forwards_full_profile(self) -> None:
|
|
168
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
169
|
+
root = Path(directory)
|
|
170
|
+
binary = root / "libil2cpp.so"
|
|
171
|
+
metadata = root / "global-metadata.dat"
|
|
172
|
+
binary.touch()
|
|
173
|
+
metadata.touch()
|
|
174
|
+
config = RunConfig(
|
|
175
|
+
binary,
|
|
176
|
+
root / "output",
|
|
177
|
+
generator="aotopsy",
|
|
178
|
+
artifact_profile="full",
|
|
179
|
+
dry_run=True,
|
|
180
|
+
)
|
|
181
|
+
resolved = ResolvedInput(binary, binary, metadata, None, None)
|
|
182
|
+
with (
|
|
183
|
+
patch(
|
|
184
|
+
"il2cpp_ghidrah.generators.select_generator",
|
|
185
|
+
return_value=("aotopsy", "il2cpp", None),
|
|
186
|
+
),
|
|
187
|
+
patch("il2cpp_ghidrah.generators.run_command") as run_command_mock,
|
|
188
|
+
):
|
|
189
|
+
generate(config, resolved, root / "artifacts", root / "cpp2il", root / "logs")
|
|
190
|
+
generation_command = run_command_mock.call_args_list[0].args[0]
|
|
191
|
+
self.assertEqual(["--profile", "full"], generation_command[4:6])
|
|
192
|
+
|
|
193
|
+
def test_full_profile_rejects_dumper_generator(self) -> None:
|
|
194
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
195
|
+
root = Path(directory)
|
|
196
|
+
binary = root / "libil2cpp.so"
|
|
197
|
+
metadata = root / "global-metadata.dat"
|
|
198
|
+
config = RunConfig(
|
|
199
|
+
binary,
|
|
200
|
+
root / "output",
|
|
201
|
+
generator="dumper",
|
|
202
|
+
artifact_profile="full",
|
|
203
|
+
unity="2022.3.0f1",
|
|
204
|
+
)
|
|
205
|
+
resolved = ResolvedInput(binary, binary, metadata, None, None)
|
|
206
|
+
with patch(
|
|
207
|
+
"il2cpp_ghidrah.generators.select_generator",
|
|
208
|
+
return_value=("dumper", "Il2CppDumper", "Cpp2IL"),
|
|
209
|
+
):
|
|
210
|
+
with self.assertRaisesRegex(ValueError, "requires the AOT generator"):
|
|
211
|
+
generate(config, resolved, root / "artifacts", root / "cpp2il", root / "logs")
|
|
212
|
+
|
|
121
213
|
|
|
122
214
|
class ProcessTests(unittest.TestCase):
|
|
123
215
|
def test_logged_command_output_is_also_visible(self) -> None:
|
|
@@ -8,6 +8,7 @@ import sys
|
|
|
8
8
|
import tempfile
|
|
9
9
|
import unittest
|
|
10
10
|
from pathlib import Path
|
|
11
|
+
from unittest.mock import patch
|
|
11
12
|
|
|
12
13
|
from il2cpp_ghidrah.headless_process import (
|
|
13
14
|
GhidraHeadlessRunner,
|
|
@@ -15,6 +16,8 @@ from il2cpp_ghidrah.headless_process import (
|
|
|
15
16
|
HeadlessRequest,
|
|
16
17
|
_environment,
|
|
17
18
|
_terminal_text,
|
|
19
|
+
_warning_color,
|
|
20
|
+
require_clean_ghidra_log,
|
|
18
21
|
)
|
|
19
22
|
|
|
20
23
|
|
|
@@ -244,6 +247,87 @@ class HeadlessProcessTests(unittest.TestCase):
|
|
|
244
247
|
def test_terminal_control_sequences_are_escaped(self) -> None:
|
|
245
248
|
self.assertEqual("name\\u001b[31m\n", _terminal_text("name\x1b[31m\n"))
|
|
246
249
|
|
|
250
|
+
def test_warnings_are_one_plain_line_without_logger_prefixes(self) -> None:
|
|
251
|
+
for message in (
|
|
252
|
+
"skipped ambiguous methods: 2; see _ambiguous_matches.txt.",
|
|
253
|
+
"skipped metadata entries in ELF loader tables: 1.",
|
|
254
|
+
"skipped string entries in ELF loader tables: 1.",
|
|
255
|
+
):
|
|
256
|
+
with self.subTest(message=message):
|
|
257
|
+
warning = "WARNING: TurboHeader " + message
|
|
258
|
+
line = "INFO ExportIl2Cpp.java> " + warning + " (GhidraScript) \n"
|
|
259
|
+
self.assertEqual(warning + "\n", _terminal_text(line))
|
|
260
|
+
self.assertEqual("\x1b[33m" + warning + "\x1b[0m\n", _terminal_text(line, color=True))
|
|
261
|
+
|
|
262
|
+
def test_warning_without_newline_does_not_gain_one(self) -> None:
|
|
263
|
+
warning = "WARNING: TurboHeader skipped 2 methods."
|
|
264
|
+
self.assertEqual(warning, _terminal_text(warning))
|
|
265
|
+
self.assertEqual("\x1b[33m" + warning + "\x1b[0m", _terminal_text(warning, color=True))
|
|
266
|
+
|
|
267
|
+
def test_warning_controls_are_escaped_before_colouring(self) -> None:
|
|
268
|
+
warning = "WARNING: TurboHeader sample\x1b[2J\r\u202e\n"
|
|
269
|
+
self.assertEqual(
|
|
270
|
+
"\x1b[33mWARNING: TurboHeader sample\\u001b[2J\\u000d\\u202e\x1b[0m\n",
|
|
271
|
+
_terminal_text(warning, color=True),
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
def test_normal_output_and_fatal_errors_are_not_reformatted(self) -> None:
|
|
275
|
+
for line in ("progress\n", "ERROR REPORT SCRIPT ERROR: failed\n", "java.lang.IllegalStateException\n"):
|
|
276
|
+
self.assertEqual(line, _terminal_text(line, color=True))
|
|
277
|
+
|
|
278
|
+
def test_warning_colour_requires_a_terminal_and_respects_environment(self) -> None:
|
|
279
|
+
for tty, environment, expected in (
|
|
280
|
+
(True, {}, True),
|
|
281
|
+
(False, {}, False),
|
|
282
|
+
(True, {"NO_COLOR": "1"}, False),
|
|
283
|
+
(True, {"NO_COLOR": ""}, False),
|
|
284
|
+
(True, {"TERM": "dumb"}, False),
|
|
285
|
+
(True, {"TERM": "xterm-256color"}, True),
|
|
286
|
+
):
|
|
287
|
+
with self.subTest(tty=tty, environment=environment):
|
|
288
|
+
with patch("sys.stdout.isatty", return_value=tty):
|
|
289
|
+
self.assertEqual(expected, _warning_color(environment))
|
|
290
|
+
|
|
291
|
+
def test_warnings_do_not_hide_fatal_log_markers(self) -> None:
|
|
292
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
293
|
+
log = Path(directory) / "ghidra.log"
|
|
294
|
+
log.write_text("WARNING: TurboHeader skipped 1 method.\n", encoding="utf-8")
|
|
295
|
+
require_clean_ghidra_log(log)
|
|
296
|
+
log.write_text(log.read_text() + "ERROR REPORT SCRIPT ERROR: failure\n", encoding="utf-8")
|
|
297
|
+
with self.assertRaisesRegex(RuntimeError, "REPORT SCRIPT ERROR"):
|
|
298
|
+
require_clean_ghidra_log(log)
|
|
299
|
+
|
|
300
|
+
@unittest.skipUnless(os.name == "posix", "fixture uses a POSIX executable")
|
|
301
|
+
def test_runner_colours_only_terminal_output_not_saved_logs(self) -> None:
|
|
302
|
+
class Terminal(io.StringIO):
|
|
303
|
+
def isatty(self) -> bool:
|
|
304
|
+
return True
|
|
305
|
+
|
|
306
|
+
with tempfile.TemporaryDirectory() as directory:
|
|
307
|
+
root = Path(directory)
|
|
308
|
+
installation = make_installation(root)
|
|
309
|
+
launcher = installation / "support" / "analyzeHeadless"
|
|
310
|
+
line = "INFO ExportIl2Cpp.java> WARNING: TurboHeader skipped 2 methods. (GhidraScript)"
|
|
311
|
+
launcher.write_text(
|
|
312
|
+
f"#!{sys.executable}\n"
|
|
313
|
+
"import pathlib, sys\n"
|
|
314
|
+
"args = sys.argv[1:]\n"
|
|
315
|
+
f"line = {line!r}\n"
|
|
316
|
+
"pathlib.Path(args[args.index('-log') + 1]).write_text(line + '\\n')\n"
|
|
317
|
+
"pathlib.Path(args[args.index('-scriptlog') + 1]).write_text(line + '\\n')\n"
|
|
318
|
+
"print(line)\n",
|
|
319
|
+
encoding="utf-8",
|
|
320
|
+
)
|
|
321
|
+
launcher.chmod(0o755)
|
|
322
|
+
runner = GhidraHeadlessRunner(installation, platform="posix", environment={"PATH": "/usr/bin"})
|
|
323
|
+
visible = Terminal()
|
|
324
|
+
with contextlib.redirect_stdout(visible):
|
|
325
|
+
result = runner.run(make_request(root), log=root / "ghidra.log")
|
|
326
|
+
self.assertEqual("\x1b[33mWARNING: TurboHeader skipped 2 methods.\x1b[0m\n", visible.getvalue())
|
|
327
|
+
for path in (result.application_log, result.script_log, result.launcher_log):
|
|
328
|
+
self.assertNotIn("\x1b", path.read_text())
|
|
329
|
+
self.assertIn(line, path.read_text())
|
|
330
|
+
|
|
247
331
|
@unittest.skipUnless(os.name == "posix", "fixture uses a POSIX executable")
|
|
248
332
|
def test_runner_executes_without_a_shell_and_collects_logs(self) -> None:
|
|
249
333
|
with tempfile.TemporaryDirectory() as directory:
|
|
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
|
{il2cpp_ghidrah-0.2.0 → il2cpp_ghidrah-0.2.2}/src/il2cpp_ghidrah.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|