unidecompiler-cli 0.1.0__tar.gz → 0.1.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.
- unidecompiler_cli-0.1.2/PKG-INFO +43 -0
- unidecompiler_cli-0.1.2/README.md +28 -0
- unidecompiler_cli-0.1.2/pyproject.toml +28 -0
- {unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli/cli.py +6 -4
- unidecompiler_cli-0.1.2/src/unidecompiler_cli/simulation.py +84 -0
- unidecompiler_cli-0.1.2/src/unidecompiler_cli.egg-info/PKG-INFO +43 -0
- {unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli.egg-info/SOURCES.txt +1 -0
- unidecompiler_cli-0.1.2/src/unidecompiler_cli.egg-info/requires.txt +3 -0
- unidecompiler_cli-0.1.0/PKG-INFO +0 -21
- unidecompiler_cli-0.1.0/README.md +0 -13
- unidecompiler_cli-0.1.0/pyproject.toml +0 -17
- unidecompiler_cli-0.1.0/src/unidecompiler_cli.egg-info/PKG-INFO +0 -21
- unidecompiler_cli-0.1.0/src/unidecompiler_cli.egg-info/requires.txt +0 -1
- {unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/setup.cfg +0 -0
- {unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli/__init__.py +0 -0
- {unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli/input_sources.py +0 -0
- {unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli.egg-info/dependency_links.txt +0 -0
- {unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli.egg-info/entry_points.txt +0 -0
- {unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unidecompiler-cli
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Command-line host for unidecompiler plugins
|
|
5
|
+
Author-email: Wker <1670133844@qq.com>
|
|
6
|
+
License-Expression: AGPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/Wker666/unidecompiler
|
|
8
|
+
Project-URL: Repository, https://github.com/Wker666/unidecompiler
|
|
9
|
+
Project-URL: Issues, https://github.com/Wker666/unidecompiler/issues
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: unidecompiler<0.2.0,>=0.1.10
|
|
13
|
+
Requires-Dist: unidecompiler-simulator<0.2.0,>=0.1.5
|
|
14
|
+
Requires-Dist: unidecompiler-simulation-host-python<0.2.0,>=0.1.2
|
|
15
|
+
|
|
16
|
+
# unidecompiler-cli
|
|
17
|
+
|
|
18
|
+
`unidecompiler-cli` is the command-line host for installed `unidecompiler`
|
|
19
|
+
frontend plugins. It discovers plugins through the `unidecompiler.frontends`
|
|
20
|
+
entry-point group and uses the public `DecompilerEngine` facade.
|
|
21
|
+
|
|
22
|
+
Install the CLI and one or more frontend packages:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
python -m pip install unidecompiler-cli unidecompiler-plugin-python-pyc
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Run `unidecompiler --help` for command-line usage.
|
|
29
|
+
|
|
30
|
+
The optional simulator command is hosted here, while execution remains in the
|
|
31
|
+
separate simulator library:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
unidecompiler simulate sample.bytecode --function 'Example.run' --args '[1, 2]'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For trusted programs that require functions outside the lifted module, pass a
|
|
38
|
+
Python environment file. Top-level functions are matched by name, while their
|
|
39
|
+
stdout and stderr are returned as structured simulation events:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
unidecompiler simulate sample.pyc --function main --environment runtime.py
|
|
43
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# unidecompiler-cli
|
|
2
|
+
|
|
3
|
+
`unidecompiler-cli` is the command-line host for installed `unidecompiler`
|
|
4
|
+
frontend plugins. It discovers plugins through the `unidecompiler.frontends`
|
|
5
|
+
entry-point group and uses the public `DecompilerEngine` facade.
|
|
6
|
+
|
|
7
|
+
Install the CLI and one or more frontend packages:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
python -m pip install unidecompiler-cli unidecompiler-plugin-python-pyc
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Run `unidecompiler --help` for command-line usage.
|
|
14
|
+
|
|
15
|
+
The optional simulator command is hosted here, while execution remains in the
|
|
16
|
+
separate simulator library:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
unidecompiler simulate sample.bytecode --function 'Example.run' --args '[1, 2]'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
For trusted programs that require functions outside the lifted module, pass a
|
|
23
|
+
Python environment file. Top-level functions are matched by name, while their
|
|
24
|
+
stdout and stderr are returned as structured simulation events:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
unidecompiler simulate sample.pyc --function main --environment runtime.py
|
|
28
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "unidecompiler-cli"
|
|
7
|
+
version = "0.1.2"
|
|
8
|
+
description = "Command-line host for unidecompiler plugins"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "AGPL-3.0-or-later"
|
|
11
|
+
authors = [{ name = "Wker", email = "1670133844@qq.com" }]
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"unidecompiler>=0.1.10,<0.2.0",
|
|
15
|
+
"unidecompiler-simulator>=0.1.5,<0.2.0",
|
|
16
|
+
"unidecompiler-simulation-host-python>=0.1.2,<0.2.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/Wker666/unidecompiler"
|
|
21
|
+
Repository = "https://github.com/Wker666/unidecompiler"
|
|
22
|
+
Issues = "https://github.com/Wker666/unidecompiler/issues"
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
unidecompiler = "unidecompiler_cli.cli:main"
|
|
26
|
+
|
|
27
|
+
[tool.setuptools.packages.find]
|
|
28
|
+
where = ["src"]
|
|
@@ -17,6 +17,11 @@ from unidecompiler.input_sources import expand_input_path
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
def main(argv: list[str] | None = None, *, registry: FrontendRegistry | None = None) -> int:
|
|
20
|
+
command_argv = sys.argv[1:] if argv is None else argv
|
|
21
|
+
if command_argv[:1] == ["simulate"]:
|
|
22
|
+
from unidecompiler_cli.simulation import main as simulate_main
|
|
23
|
+
|
|
24
|
+
return simulate_main(command_argv[1:], registry=registry)
|
|
20
25
|
parser = argparse.ArgumentParser(
|
|
21
26
|
prog="unidecompiler",
|
|
22
27
|
description="Decompile bytecode into generic pseudocode.",
|
|
@@ -38,7 +43,7 @@ def main(argv: list[str] | None = None, *, registry: FrontendRegistry | None = N
|
|
|
38
43
|
default="pseudocode",
|
|
39
44
|
help="output format (default: pseudocode)",
|
|
40
45
|
)
|
|
41
|
-
args = parser.parse_args(
|
|
46
|
+
args = parser.parse_args(command_argv)
|
|
42
47
|
|
|
43
48
|
registry = registry or FrontendRegistry.discover()
|
|
44
49
|
if args.versions:
|
|
@@ -61,9 +66,6 @@ def main(argv: list[str] | None = None, *, registry: FrontendRegistry | None = N
|
|
|
61
66
|
ast_modules: list[dict[str, Any]] = []
|
|
62
67
|
processed = 0
|
|
63
68
|
for artifact in artifacts:
|
|
64
|
-
if artifact.kind == "resource":
|
|
65
|
-
print(f"resource: {artifact.display_path}", file=sys.stderr)
|
|
66
|
-
continue
|
|
67
69
|
try:
|
|
68
70
|
frontend = registry.select(
|
|
69
71
|
artifact.data, artifact.display_path, explicit_id=args.frontend
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Simulation command hosted by the unidecompiler CLI package."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
from unidecompiler.plugin_registry import FrontendRegistry
|
|
11
|
+
from unidecompiler_simulator import SimulationEngine, SimulationLimits
|
|
12
|
+
from unidecompiler_simulation_host_python import PythonFileEnvironment
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def main(argv: list[str] | None = None, *, registry: FrontendRegistry | None = None) -> int:
|
|
16
|
+
parser = argparse.ArgumentParser(prog="unidecompiler simulate")
|
|
17
|
+
parser.add_argument("input")
|
|
18
|
+
parser.add_argument("--function", required=True, help="frontend-owned function query")
|
|
19
|
+
parser.add_argument("--args", default="[]", help="JSON array of function arguments")
|
|
20
|
+
parser.add_argument("--frontend")
|
|
21
|
+
parser.add_argument("--max-steps", type=int, default=100_000)
|
|
22
|
+
parser.add_argument("--max-call-depth", type=int, default=128)
|
|
23
|
+
parser.add_argument("--environment", type=Path, help="trusted Python file providing unresolved functions")
|
|
24
|
+
parser.add_argument(
|
|
25
|
+
"--show-host-output",
|
|
26
|
+
action="store_true",
|
|
27
|
+
help="write captured environment stdout and stderr to stderr",
|
|
28
|
+
)
|
|
29
|
+
args = parser.parse_args(argv)
|
|
30
|
+
try:
|
|
31
|
+
values = json.loads(args.args)
|
|
32
|
+
if not isinstance(values, list):
|
|
33
|
+
raise ValueError("--args must be a JSON array")
|
|
34
|
+
environment = PythonFileEnvironment.load(args.environment) if args.environment else None
|
|
35
|
+
engine = SimulationEngine.from_registry(registry or FrontendRegistry.discover())
|
|
36
|
+
result = engine.simulate_path(
|
|
37
|
+
Path(args.input),
|
|
38
|
+
args.function,
|
|
39
|
+
frontend_id=args.frontend,
|
|
40
|
+
args=tuple(values),
|
|
41
|
+
environment=environment,
|
|
42
|
+
limits=SimulationLimits(args.max_steps, args.max_call_depth),
|
|
43
|
+
)
|
|
44
|
+
except (OSError, ValueError, json.JSONDecodeError) as error:
|
|
45
|
+
print(f"invalid simulation request: {error}", file=sys.stderr)
|
|
46
|
+
return 2
|
|
47
|
+
if args.show_host_output:
|
|
48
|
+
for event in result.events:
|
|
49
|
+
if event.kind != "external-call":
|
|
50
|
+
continue
|
|
51
|
+
if event.stdout:
|
|
52
|
+
print(event.stdout, file=sys.stderr, end="")
|
|
53
|
+
if event.stderr:
|
|
54
|
+
print(event.stderr, file=sys.stderr, end="")
|
|
55
|
+
print(json.dumps(_result_payload(result), default=repr, sort_keys=True))
|
|
56
|
+
return 0 if result.status.value == "completed" else 1
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _result_payload(result):
|
|
60
|
+
return {
|
|
61
|
+
"status": result.status.value,
|
|
62
|
+
"values": result.values,
|
|
63
|
+
"exception": result.exception,
|
|
64
|
+
"locals": result.locals,
|
|
65
|
+
"steps": result.steps,
|
|
66
|
+
"diagnostic": result.diagnostic,
|
|
67
|
+
"trace_truncated": result.trace_truncated,
|
|
68
|
+
"events": [
|
|
69
|
+
{
|
|
70
|
+
"function": event.function,
|
|
71
|
+
"function_index": event.function_index,
|
|
72
|
+
"block": event.block,
|
|
73
|
+
"kind": event.kind,
|
|
74
|
+
"detail": event.detail,
|
|
75
|
+
"args": event.args,
|
|
76
|
+
"values": event.values,
|
|
77
|
+
"exception": event.exception,
|
|
78
|
+
"stdout": event.stdout,
|
|
79
|
+
"stderr": event.stderr,
|
|
80
|
+
"source": event.source,
|
|
81
|
+
}
|
|
82
|
+
for event in result.events
|
|
83
|
+
],
|
|
84
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unidecompiler-cli
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Command-line host for unidecompiler plugins
|
|
5
|
+
Author-email: Wker <1670133844@qq.com>
|
|
6
|
+
License-Expression: AGPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/Wker666/unidecompiler
|
|
8
|
+
Project-URL: Repository, https://github.com/Wker666/unidecompiler
|
|
9
|
+
Project-URL: Issues, https://github.com/Wker666/unidecompiler/issues
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: unidecompiler<0.2.0,>=0.1.10
|
|
13
|
+
Requires-Dist: unidecompiler-simulator<0.2.0,>=0.1.5
|
|
14
|
+
Requires-Dist: unidecompiler-simulation-host-python<0.2.0,>=0.1.2
|
|
15
|
+
|
|
16
|
+
# unidecompiler-cli
|
|
17
|
+
|
|
18
|
+
`unidecompiler-cli` is the command-line host for installed `unidecompiler`
|
|
19
|
+
frontend plugins. It discovers plugins through the `unidecompiler.frontends`
|
|
20
|
+
entry-point group and uses the public `DecompilerEngine` facade.
|
|
21
|
+
|
|
22
|
+
Install the CLI and one or more frontend packages:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
python -m pip install unidecompiler-cli unidecompiler-plugin-python-pyc
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Run `unidecompiler --help` for command-line usage.
|
|
29
|
+
|
|
30
|
+
The optional simulator command is hosted here, while execution remains in the
|
|
31
|
+
separate simulator library:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
unidecompiler simulate sample.bytecode --function 'Example.run' --args '[1, 2]'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
For trusted programs that require functions outside the lifted module, pass a
|
|
38
|
+
Python environment file. Top-level functions are matched by name, while their
|
|
39
|
+
stdout and stderr are returned as structured simulation events:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
unidecompiler simulate sample.pyc --function main --environment runtime.py
|
|
43
|
+
```
|
{unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli.egg-info/SOURCES.txt
RENAMED
|
@@ -3,6 +3,7 @@ pyproject.toml
|
|
|
3
3
|
src/unidecompiler_cli/__init__.py
|
|
4
4
|
src/unidecompiler_cli/cli.py
|
|
5
5
|
src/unidecompiler_cli/input_sources.py
|
|
6
|
+
src/unidecompiler_cli/simulation.py
|
|
6
7
|
src/unidecompiler_cli.egg-info/PKG-INFO
|
|
7
8
|
src/unidecompiler_cli.egg-info/SOURCES.txt
|
|
8
9
|
src/unidecompiler_cli.egg-info/dependency_links.txt
|
unidecompiler_cli-0.1.0/PKG-INFO
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: unidecompiler-cli
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Command-line host for unidecompiler plugins
|
|
5
|
-
Requires-Python: >=3.11
|
|
6
|
-
Description-Content-Type: text/markdown
|
|
7
|
-
Requires-Dist: unidecompiler<0.2.0,>=0.1.0
|
|
8
|
-
|
|
9
|
-
# unidecompiler-cli
|
|
10
|
-
|
|
11
|
-
`unidecompiler-cli` is the command-line host for installed `unidecompiler`
|
|
12
|
-
frontend plugins. It discovers plugins through the `unidecompiler.frontends`
|
|
13
|
-
entry-point group and uses the public `DecompilerEngine` facade.
|
|
14
|
-
|
|
15
|
-
Install the CLI and one or more frontend packages:
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
python -m pip install unidecompiler-cli unidecompiler-plugin-python-pyc
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Run `unidecompiler --help` for command-line usage.
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# unidecompiler-cli
|
|
2
|
-
|
|
3
|
-
`unidecompiler-cli` is the command-line host for installed `unidecompiler`
|
|
4
|
-
frontend plugins. It discovers plugins through the `unidecompiler.frontends`
|
|
5
|
-
entry-point group and uses the public `DecompilerEngine` facade.
|
|
6
|
-
|
|
7
|
-
Install the CLI and one or more frontend packages:
|
|
8
|
-
|
|
9
|
-
```sh
|
|
10
|
-
python -m pip install unidecompiler-cli unidecompiler-plugin-python-pyc
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Run `unidecompiler --help` for command-line usage.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=68"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "unidecompiler-cli"
|
|
7
|
-
version = "0.1.0"
|
|
8
|
-
description = "Command-line host for unidecompiler plugins"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.11"
|
|
11
|
-
dependencies = ["unidecompiler>=0.1.0,<0.2.0"]
|
|
12
|
-
|
|
13
|
-
[project.scripts]
|
|
14
|
-
unidecompiler = "unidecompiler_cli.cli:main"
|
|
15
|
-
|
|
16
|
-
[tool.setuptools.packages.find]
|
|
17
|
-
where = ["src"]
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: unidecompiler-cli
|
|
3
|
-
Version: 0.1.0
|
|
4
|
-
Summary: Command-line host for unidecompiler plugins
|
|
5
|
-
Requires-Python: >=3.11
|
|
6
|
-
Description-Content-Type: text/markdown
|
|
7
|
-
Requires-Dist: unidecompiler<0.2.0,>=0.1.0
|
|
8
|
-
|
|
9
|
-
# unidecompiler-cli
|
|
10
|
-
|
|
11
|
-
`unidecompiler-cli` is the command-line host for installed `unidecompiler`
|
|
12
|
-
frontend plugins. It discovers plugins through the `unidecompiler.frontends`
|
|
13
|
-
entry-point group and uses the public `DecompilerEngine` facade.
|
|
14
|
-
|
|
15
|
-
Install the CLI and one or more frontend packages:
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
python -m pip install unidecompiler-cli unidecompiler-plugin-python-pyc
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Run `unidecompiler --help` for command-line usage.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
unidecompiler<0.2.0,>=0.1.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{unidecompiler_cli-0.1.0 → unidecompiler_cli-0.1.2}/src/unidecompiler_cli.egg-info/top_level.txt
RENAMED
|
File without changes
|