Created
September 15, 2020 09:52
-
-
Save nil0x42/7ba2193dbe1230f474f1d72d2bbc8acc to your computer and use it in GitHub Desktop.
[JAVA Reverse Engineering]]: Quickly decompile a .jar AND its relevant classes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# author: @nil0x42 | |
# Quickly decompile a .jar AND its interesting classes for reversing | |
PROCYON="procyon-decompiler" | |
JAR="jar" | |
OUT="$1.decompile" | |
if [[ $# -ne 1 ]] || [[ "$1" != *".jar" ]]; then | |
echo "Usage: $0 FILE.jar" >&2 | |
exit 1 | |
fi | |
if ! [ -x "$(command -v $PROCYON)" ]; then | |
PROCYON="procyon" | |
if ! [ -x "$(command -v $PROCYON)" ]; then | |
echo "Error: $PROCYON is not installed." >&2 | |
exit 1 | |
fi | |
fi | |
if ! [ -x "$(command -v $JAR)" ]; then | |
echo "Error: $JAR is not installed." >&2 | |
exit 1 | |
fi | |
if [ ! -f "$1" ]; then | |
echo "Error: $1: file does not exist." >&2 | |
exit 1 | |
fi | |
if [ -e "$OUT" ]; then | |
echo "Error: Output directory $OUT already exists." >&2 | |
exit 1 | |
fi | |
mkdir "$OUT" | |
cp "$1" "$OUT" | |
pushd "$OUT" | |
archive="`echo *.jar`" | |
$JAR -xf "$archive" | |
rm "$archive" | |
find . -type f -name '*.class' \ | |
-not -path "./org/*" \ | |
-not -path "./com/*" \ | |
-not -path "./net/*" \ | |
-not -path "./de/*" \ | |
| xargs "$PROCYON" -o . | |
# uncomment if you wish to remove .class files from decompiled JAR | |
#find . -type f -name '*.class' -exec /bin/rm '{}' ';' | |
popd | |
echo "" | |
echo "[+] $1 correctly decompressed into $OUT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment