Skip to content

Commit

Permalink
add readme + fix dc command help
Browse files Browse the repository at this point in the history
  • Loading branch information
brxxn committed Aug 8, 2022
1 parent 9e38efa commit 7707f90
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 2 deletions.
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# jdcli

`jdcli` is a lightweight command line interface tool to extract and decompile java classes in .jar files by using
[jd-core](https://github.com/java-decompiler/jd-core), the library behind [JD-GUI](https://java-decompiler.github.io/).

This tool also supports extracting jar files with case-insensitive class name conflicts (which commonly occur in
obfuscated jar files) on case-insensitive filesystems. It also does not stop when it fails to decompile a singular
file, allowing complicated jar files crafted using different tools to still be analyzed.

Usage:

```
usage: jdcli <command> [arguments...]
valid commands:
jdcli dj|decompile-jar <jar file> [output directory] [--verbose] [--skip-cleanup] - Decompile a jar file into a directory
jdcli dcs|decompile-classes <directory> [--verbose] [--delete-class-files] - Decompile classes in a directory
jdcli dc|decompile-class <base directory> <file> - Decompile a .class file
jdcli cleanup <directory> - removes all .class files in a directory
jdcli h|help - Show this menu
jdcli v|version - Show version information
options:
-v --verbose | Log additional debug information
```

Example: `jdcli decompile-jar ./test.jar ./test.classes/`

This can also be used with APK files by using a tool like [dex2jar](https://github.com/pxb1988/dex2jar) to convert it to
a .jar file.

### Installation

Installation requires Java/OpenJDK version >= 16. To install, download the latest jar file from the
[releases page](https://github.com/brxxn/jdcli/releases).

If you use Linux or macOS, you may want to add
`alias jdcli="java -jar [jdcli jar location]"` to your `~/.bashrc` or `~/.zshrc` so that you can invoke jdcli using just
`jdcli`. Once you complete that and restart your terminal, you should be able to use `jdcli`. If you can't do this, you
can always use `java -jar [jdcli jar location]` instead.

### Commands

* `jdcli dj|decompile-jar <jar file> [output directory] [--verbose] [--skip-cleanup]`
* Decompiles a .jar file into .java files
* Arguments:
* `<jar file>`: the .jar file to extract from
* `[output directory]`: the directory to put the extracted files in (default: `[jar path].classes/`)
* Options:
* `--verbose`: adds heavy logging output (warning: it will spam your terminal), useful for debugging.
* `--skip-cleanup`: skips removing .class files (this will use more storage per decompile)
* `jdcli dcs|decompile-classes <directory> [--verbose] [--delete-class-files]`
* Recursively decompiles all .class files into .java files
* Arguments:
* `<directory>`: the target directory in which classes should be decompiled
* Options:
* `--verbose`: adds heavy logging output (warning: it will spam your terminal), useful for debugging.
* `--delete-class-files`: deletes all .class files after decompiling is complete
* `jdcli dc|decompile-class <base directory> <file>`
* Decompiles a specified .class file and shows any errors that occur
* Arguments:
* `<base directory>`: the directory that should be used as the base for the class (so it can identify packages)
* `<file>`: the targeted .class file to decompile
* `jdcli cleanup <directory>`
* Recursively removes all .class files in a directory
* Arguments:
* `<directory>`: the directory in which class files should be deleted
* `jdcli h|help`
* Show the help menu
* `jdcli v|version`
* Shows the version and a link to the releases page

### Building

This project should be able to be imported into IntelliJ IDEA and have all dependencies installed using `mvn install`.
To build, use `mvn package`. Note that the target version for jdcli is Java/OpenJDK 16.
2 changes: 1 addition & 1 deletion src/main/java/me/brian/jdcli/JDCliRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void printHelp() {
System.out.println("valid commands:");
System.out.println(" jdcli dj|decompile-jar <jar file> [output directory] [--verbose] [--skip-cleanup] - Decompile a jar file into a directory");
System.out.println(" jdcli dcs|decompile-classes <directory> [--verbose] [--delete-class-files] - Decompile classes in a directory");
System.out.println(" jdcli dc|decompile-class <base directory> <file> [output name] - Decompile a .class file");
System.out.println(" jdcli dc|decompile-class <base directory> <file> - Decompile a .class file");
System.out.println(" jdcli cleanup <directory> - removes all .class files in a directory");
System.out.println(" jdcli h|help - Show this menu");
System.out.println(" jdcli v|version - Show version information");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public boolean shouldPrintUsage(int argumentCount) {
}

public String getUsage() {
return "jdcli dj|decompile-jar <jar file> [output directory] [--verbose]";
return "jdcli dj|decompile-jar <jar file> [--verbose]";
}

}

0 comments on commit 7707f90

Please sign in to comment.