dex4java 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.4
2
+ Name: dex4java
3
+ Version: 1.0.0
4
+ Summary: A CLI tool to convert Android DEX files into Java JAR packages containing JVM bytecode.
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Operating System :: OS Independent
8
+ Classifier: Topic :: Security
9
+ Classifier: Topic :: Software Development :: Assemblers
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+
13
+ # dex4java 🚀
14
+
15
+ [![PyPI version](https://shields.io)](https://pypi.org)
16
+ [![License: MIT](https://shields.io)](https://opensource.org)
17
+
18
+ **dex4java** is a lightweight, easy-to-use Command-Line Interface (CLI) tool designed to seamlessly convert Android `.dex` (Dalvik Executable) files into standard Java `.jar` (Java Archive) packages containing valid JVM `.class` bytecode.
19
+
20
+ It acts as a modern Python wrapper around proven translation engines, offering a clean syntax for reverse engineers, malware analysts, and Android developers.
21
+
22
+ ---
23
+
24
+ ## ✨ Features
25
+
26
+ - **Simple CLI Syntax**: No complex arguments, just input and output.
27
+ - **Automated Engine Management**: Automatically downloads and configures the required backend translator on its first run.
28
+ - **Cross-Platform**: Works flawlessly on Windows, Linux, and macOS.
29
+ - **Clean Bytecode Translation**: Produces actual `.class` structures compatible with popular decompilers like JD-GUI or Bytecode Viewer.
30
+
31
+ ---
32
+
33
+ ## 📋 Prerequisites
34
+
35
+ Before using **dex4java**, please ensure you have the following installed on your system:
36
+
37
+ 1. **Python 3.7+**
38
+ 2. **Java (JRE or JDK)**: The underlying translation engine requires Java to be available in your system's PATH.
39
+
40
+ ---
41
+
42
+ ## 🚀 Installation
43
+
44
+ You can install **dex4java** directly from PyPI:
45
+
46
+ ```bash
47
+ pip install dex4java
48
+ ```
49
+
50
+ ---
51
+
52
+ ## 💻 Usage
53
+
54
+ Once installed, the `dex4java` command becomes available globally in your terminal. Use the following syntax to convert your files:
55
+
56
+ ```bash
57
+ dex4java <input_file.dex> -o <output_file.jar>
58
+ ```
59
+
60
+ ### Example:
61
+
62
+ ```bash
63
+ dex4java classes.dex -o classes_output.jar
64
+ ```
65
+
66
+ ### Help Command:
67
+
68
+ To see available arguments and information, run:
69
+ ```bash
70
+ dex4java --help
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 🛠️ How It Works
76
+
77
+ 1. **Check**: On the first execution, **dex4java** checks for the existence of the translation binaries. If missing, it securely downloads them.
78
+ 2. **Translate**: It maps Dalvik opcodes inside the `.dex` file directly into structured Java Virtual Machine (JVM) bytecode instructions.
79
+ 3. **Package**: It packs the compiled `.class` files into a single `.jar` archive, ready for analysis or execution.
80
+
81
+ ---
82
+
83
+ ## 📄 License
84
+
85
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,6 @@
1
+ dex4java.py,sha256=omow4gOSbNhrpmfpuCTDuEaUlgXu4jlTJziZJERvcW0,2636
2
+ dex4java-1.0.0.dist-info/METADATA,sha256=0HSY0Fy7Cg6UtcCApS7G68B-E6Oclz2_rPvAtar3O60,2770
3
+ dex4java-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
4
+ dex4java-1.0.0.dist-info/entry_points.txt,sha256=3mfyyVT0WfzEyKtqzxjXgO69IlTtk2NCpdfL1VKLfU8,43
5
+ dex4java-1.0.0.dist-info/top_level.txt,sha256=RQ6v-OOKIO_tHEPA9-Fi7iwaAlTolzzFEn30kNk9GI0,9
6
+ dex4java-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ dex4java = dex4java:main
@@ -0,0 +1 @@
1
+ dex4java
dex4java.py ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env python3
2
+ import sys
3
+ import argparse
4
+ import os
5
+ import subprocess
6
+ import urllib.request
7
+ import zipfile
8
+
9
+ ENGINE_URL = "https://github.com"
10
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
11
+ ENGINE_DIR = os.path.join(BASE_DIR, "dex4java_engine")
12
+
13
+ def download_engine():
14
+ if os.path.exists(ENGINE_DIR):
15
+ return
16
+
17
+ print("[*] dex4java: Core translation engine is missing, downloading...")
18
+ zip_path = os.path.join(BASE_DIR, "engine.zip")
19
+
20
+ try:
21
+ urllib.request.urlretrieve(ENGINE_URL, zip_path)
22
+ with zipfile.ZipFile(zip_path, 'r') as zip_ref:
23
+ zip_ref.extractall(ENGINE_DIR)
24
+ os.remove(zip_path)
25
+ print("[+] dex4java: Engine installed successfully.")
26
+ except Exception as e:
27
+ print(f"[-] dex4java Error: Failed to download engine: {e}", file=sys.stderr)
28
+ sys.exit(1)
29
+
30
+ def convert_dex_to_jar(dex_path, jar_path):
31
+ download_engine()
32
+
33
+ print(f"[*] dex4java: Converting '{dex_path}' to JVM Bytecode (.class)...")
34
+
35
+ subfolders = [d for d in os.listdir(ENGINE_DIR) if os.path.isdir(os.path.join(ENGINE_DIR, d))]
36
+ if not subfolders:
37
+ print("[-] dex4java Error: Engine directory is empty or corrupted.", file=sys.stderr)
38
+ return
39
+
40
+ engine_bin = os.path.join(ENGINE_DIR, subfolders[0])
41
+
42
+ if os.name == 'nt':
43
+ cmd_script = os.path.join(engine_bin, "d2j-dex2jar.bat")
44
+ else:
45
+ cmd_script = os.path.join(engine_bin, "d2j-dex2jar.sh")
46
+ subprocess.run(["chmod", "+x", cmd_script], stdout=subprocess.DEVNULL)
47
+
48
+ cmd = [cmd_script, dex_path, "-o", jar_path, "--force"]
49
+
50
+ try:
51
+ result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
52
+ if result.returncode == 0:
53
+ print(f"[+] dex4java: Success! JAR file created -> {jar_path}")
54
+ else:
55
+ print(f"[-] dex4java Error: Conversion failed:\n{result.stderr}", file=sys.stderr)
56
+ except FileNotFoundError:
57
+ print("[-] dex4java Error: Java (JRE/JDK) was not found on this system. Please install Java.", file=sys.stderr)
58
+
59
+ def main():
60
+ parser = argparse.ArgumentParser(
61
+ description="dex4java: Convert Android .dex files to standard Java .jar files.",
62
+ usage="dex4java file_name.dex -o file_name.jar"
63
+ )
64
+ parser.add_argument("input_file", help="Path to the input .dex file")
65
+ parser.add_argument("-o", "--output", required=True, help="Path to the output .jar file")
66
+
67
+ args = parser.parse_args()
68
+ convert_dex_to_jar(args.input_file, args.output)
69
+
70
+ if __name__ == "__main__":
71
+ main()