Skip to content

Commit

Permalink
Fix Unicode (#64) and JADX update
Browse files Browse the repository at this point in the history
- Unicode error (Arabic languages, etc)
- JADX update: skylot/jadx#253
  • Loading branch information
vincentcox authored Jun 8, 2018
1 parent 331c1ae commit fe0bc41
Show file tree
Hide file tree
Showing 22 changed files with 136 additions and 125 deletions.
2 changes: 1 addition & 1 deletion src/helpers/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class __Logger:

def dump(self):
Logger.log_html_document.footer()
with open(self.logpath, 'w') as f:
with open(self.logpath, 'w', encoding="utf-8") as f:
print(Logger.log_html_document.gethtml(), file=f)

def __init__(self, message, level, rewriteLine):
Expand Down
81 changes: 40 additions & 41 deletions src/jadx/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
## JADX

[![Build Status](https://travis-ci.org/skylot/jadx.png?branch=master)](https://travis-ci.org/skylot/jadx)
[![Build Status](https://drone.io/github.com/skylot/jadx/status.png)](https://drone.io/github.com/skylot/jadx/latest)
[![Coverage Status](https://coveralls.io/repos/skylot/jadx/badge.png)](https://coveralls.io/r/skylot/jadx)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/2166/badge.svg)](https://scan.coverity.com/projects/2166)
[![Code Coverage](https://codecov.io/gh/skylot/jadx/branch/master/graph/badge.svg)](https://codecov.io/gh/skylot/jadx)
[![SonarQube Bugs](https://sonarcloud.io/api/badges/measure?key=jadx&metric=bugs)](https://sonarcloud.io/dashboard?id=jadx)
[![License](http://img.shields.io/:license-apache-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)

**jadx** - Dex to Java decompiler

Command line and GUI tools for produce Java source code from Android Dex and Apk files

![jadx-gui screenshot](http://skylot.github.io/jadx/jadx-gui.png)
![jadx-gui screenshot](https://i.imgur.com/h917IBZ.png)


### Downloads
- [unstable](https://drone.io/github.com/skylot/jadx/files)
- from [github](https://github.com/skylot/jadx/releases)
- from [sourceforge](http://sourceforge.net/projects/jadx/files/)
- latest [unstable build: ![Download](https://api.bintray.com/packages/skylot/jadx/unstable/images/download.svg) ](https://bintray.com/skylot/jadx/unstable/_latestVersion#files)
- release from [github: ![Latest release](https://img.shields.io/github/release/skylot/jadx.svg)](https://github.com/skylot/jadx/releases/latest)
- release from [bintray: ![Download](https://api.bintray.com/packages/skylot/jadx/releases/images/download.svg) ](https://bintray.com/skylot/jadx/releases/_latestVersion#files)
- release from [sourceforge](http://sourceforge.net/projects/jadx/files/)

After download unpack zip file go to `bin` directory and run:
- `jadx` - command line version
- `jadx-gui` - graphical version

On Windows run `.bat` files with double-click\
**Note:** ensure you have installed Java 8 64-bit version

### Building from source
Java 8 JDK or higher must be installed:

git clone https://github.com/skylot/jadx.git
cd jadx
./gradlew dist
Expand All @@ -34,35 +43,39 @@ Run **jadx** on itself:

cd build/jadx/
bin/jadx -d out lib/jadx-core-*.jar
#or
# or
bin/jadx-gui lib/jadx-core-*.jar


### Usage
```
jadx[-gui] [options] <input file> (.dex, .apk, .jar or .class)
options:
-d, --output-dir - output directory
-j, --threads-count - processing threads count
-r, --no-res - do not decode resources
-s, --no-src - do not decompile source code
-e, --export-gradle - save as android gradle project
--show-bad-code - show inconsistent code (incorrectly decompiled)
--no-replace-consts - don't replace constant value with matching constant field
--escape-unicode - escape non latin characters in strings (with \u)
--deobf - activate deobfuscation
--deobf-min - min length of name
--deobf-max - max length of name
--deobf-rewrite-cfg - force to save deobfuscation map
--deobf-use-sourcename - use source file name as class name alias
--cfg - save methods control flow graph to dot file
--raw-cfg - save methods control flow graph (use raw instructions)
-f, --fallback - make simple dump (using goto instead of 'if', 'for', etc)
-v, --verbose - verbose output
-h, --help - print this help
-d, --output-dir - output directory
-ds, --output-dir-src - output directory for sources
-dr, --output-dir-res - output directory for resources
-j, --threads-count - processing threads count
-r, --no-res - do not decode resources
-s, --no-src - do not decompile source code
-e, --export-gradle - save as android gradle project
--show-bad-code - show inconsistent code (incorrectly decompiled)
--no-imports - disable use of imports, always write entire package name
--no-replace-consts - don't replace constant value with matching constant field
--escape-unicode - escape non latin characters in strings (with \u)
--deobf - activate deobfuscation
--deobf-min - min length of name
--deobf-max - max length of name
--deobf-rewrite-cfg - force to save deobfuscation map
--deobf-use-sourcename - use source file name as class name alias
--cfg - save methods control flow graph to dot file
--raw-cfg - save methods control flow graph (use raw instructions)
-f, --fallback - make simple dump (using goto instead of 'if', 'for', etc)
-v, --verbose - verbose output
-h, --help - print this help
Example:
jadx -d out classes.dex
```
These options also worked on jadx-gui running from command line and override options from preferences dialog

### Troubleshooting
##### Out of memory error:
Expand All @@ -73,21 +86,7 @@ Example:
* edit 'jadx' script (jadx.bat on Windows) and setup bigger heap size:
`DEFAULT_JVM_OPTS="-Xmx2500M"`


### Contribution

To support this project you can:
- Post thoughts about new features/optimizations that important to you
- Submit bug using one of following patterns:
* Java code examples which decompiles incorrectly
* Error log and link to _public available_ apk file or app page on Google play

And any other comments will be very helpfull,
because at current stage of development it is very time consuming
to **find** new bugs, design and implement new features.
Also I need to **prioritize** these task for complete most important at first.

---------------------------------------
*Licensed under the Apache 2.0 License*

*Copyright 2015 by Skylot*
*Copyright 2018 by Skylot*
72 changes: 42 additions & 30 deletions src/jadx/bin/jadx
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
## jadx start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and JADX_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/.." >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="jadx"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and JADX_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xms2g" "-Xmx4g"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -40,27 +59,12 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/.." >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/lib/jadx-cli-0.6.1.jar:$APP_HOME/lib/android-5.1.jar:$APP_HOME/lib/dx-1.10.jar:$APP_HOME/lib/slf4j-api-1.7.10.jar:$APP_HOME/lib/jadx-core-0.6.1.jar:$APP_HOME/lib/jcommander-1.47.jar:$APP_HOME/lib/logback-classic-1.1.2.jar:$APP_HOME/lib/commons-io-2.4.jar:$APP_HOME/lib/asm-5.0.3.jar:$APP_HOME/lib/annotations-12.0.jar:$APP_HOME/lib/cloning-1.9.2.jar:$APP_HOME/lib/logback-core-1.1.2.jar:$APP_HOME/lib/objenesis-2.1.jar
CLASSPATH=$APP_HOME/lib/jadx-cli-0.7.1.jar:$APP_HOME/lib/jadx-core-0.7.1.jar:$APP_HOME/lib/dx-1.14.jar:$APP_HOME/lib/android-5.1.jar:$APP_HOME/lib/logback-classic-1.2.3.jar:$APP_HOME/lib/slf4j-api-1.7.25.jar:$APP_HOME/lib/jcommander-1.72.jar:$APP_HOME/lib/commons-io-2.6.jar:$APP_HOME/lib/asm-6.0.jar:$APP_HOME/lib/annotations-15.0.jar:$APP_HOME/lib/cloning-1.9.9.jar:$APP_HOME/lib/logback-core-1.2.3.jar:$APP_HOME/lib/objenesis-2.6.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
Expand All @@ -85,7 +89,7 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
Expand Down Expand Up @@ -150,11 +154,19 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And JADX_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $JADX_OPTS
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $JADX_OPTS -classpath "\"$CLASSPATH\"" jadx.cli.JadxCLI "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" jadx.cli.JadxCLI "$@"
exec "$JAVACMD" "$@"
72 changes: 42 additions & 30 deletions src/jadx/bin/jadx-gui
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
## jadx-gui start up script for UN*X
##
##############################################################################

# Add default JVM options here. You can also use JAVA_OPTS and JADX_GUI_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/.." >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null

APP_NAME="jadx-gui"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and JADX_GUI_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-d64" "-Xms512M" "-Xmx4g"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand All @@ -30,6 +48,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
Expand All @@ -40,27 +59,12 @@ case "`uname`" in
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/.." >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-

CLASSPATH=$APP_HOME/lib/jadx-gui-0.6.1.jar:$APP_HOME/lib/android-5.1.jar:$APP_HOME/lib/dx-1.10.jar:$APP_HOME/lib/jfontchooser-1.0.5.jar:$APP_HOME/lib/slf4j-api-1.7.10.jar:$APP_HOME/lib/jadx-core-0.6.1.jar:$APP_HOME/lib/jadx-cli-0.6.1.jar:$APP_HOME/lib/rsyntaxtextarea-2.5.8.jar:$APP_HOME/lib/gson-2.3.1.jar:$APP_HOME/lib/image-viewer-1.2.3.jar:$APP_HOME/lib/commons-io-2.4.jar:$APP_HOME/lib/asm-5.0.3.jar:$APP_HOME/lib/annotations-12.0.jar:$APP_HOME/lib/cloning-1.9.2.jar:$APP_HOME/lib/jcommander-1.47.jar:$APP_HOME/lib/logback-classic-1.1.2.jar:$APP_HOME/lib/objenesis-2.1.jar:$APP_HOME/lib/logback-core-1.1.2.jar
CLASSPATH=$APP_HOME/lib/jadx-gui-0.7.1.jar:$APP_HOME/lib/jfontchooser-1.0.5.jar:$APP_HOME/lib/jadx-cli-0.7.1.jar:$APP_HOME/lib/jadx-core-0.7.1.jar:$APP_HOME/lib/dx-1.14.jar:$APP_HOME/lib/android-5.1.jar:$APP_HOME/lib/logback-classic-1.2.3.jar:$APP_HOME/lib/slf4j-api-1.7.25.jar:$APP_HOME/lib/rsyntaxtextarea-2.6.1.jar:$APP_HOME/lib/gson-2.8.2.jar:$APP_HOME/lib/image-viewer-1.2.3.jar:$APP_HOME/lib/commons-io-2.6.jar:$APP_HOME/lib/asm-6.0.jar:$APP_HOME/lib/annotations-15.0.jar:$APP_HOME/lib/cloning-1.9.9.jar:$APP_HOME/lib/jcommander-1.72.jar:$APP_HOME/lib/objenesis-2.6.jar:$APP_HOME/lib/logback-core-1.2.3.jar

# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
Expand All @@ -85,7 +89,7 @@ location of your Java installation."
fi

# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
Expand Down Expand Up @@ -150,11 +154,19 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And JADX_GUI_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $JADX_GUI_OPTS
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $JADX_GUI_OPTS -classpath "\"$CLASSPATH\"" jadx.gui.JadxGUI "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" jadx.gui.JadxGUI "$@"
exec "$JAVACMD" "$@"
Loading

0 comments on commit fe0bc41

Please sign in to comment.