diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c902e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/build +/.gradle +/.idea +local.properties diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e587010 --- /dev/null +++ b/build.gradle @@ -0,0 +1,78 @@ +buildscript { + + repositories { + mavenCentral() + google() + maven { + url "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0' + } +} + +allprojects { + repositories { + mavenCentral() + google() + maven { + url "https://plugins.gradle.org/m2/" + } + } +} + +apply plugin: 'java-library' +apply plugin: 'com.github.johnrengelman.shadow' + +def appVersion = '1.0.1' +def appName = 'apk2gradle' + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.google.code.gson:gson:2.8.9' + implementation 'org.yaml:snakeyaml:1.21' +} + +jar { + manifest { + attributes 'Implementation-Title': appName, + 'Implementation-Version': appVersion, + 'Main-Class': 'com.mosect.a2g.Apk2Gradle' + } +} + +shadowJar { + archiveBaseName = appName + archiveClassifier = 'beta' + archiveVersion = appVersion +} + +task outputProject { + dependsOn('shadowJar') + setGroup('build') + + File targetDir = new File(buildDir, "apk2gradle-${appVersion}") + outputs.dir(targetDir) + doLast { + def t = tasks.findByName('shadowJar') + t.outputs.files.each { + File jar = it + + targetDir.deleteDir() + targetDir.mkdirs() + copy { + from(file('data')) + into(targetDir) + } + copy { + from(jar) + into(targetDir) + } + new File(targetDir, jar.name).renameTo(new File(targetDir, 'apk2gradle.jar')) + } + } +} + +sourceCompatibility = "1.8" +targetCompatibility = "1.8" diff --git a/data/apktool.jar b/data/apktool.jar new file mode 100644 index 0000000..53d723d Binary files /dev/null and b/data/apktool.jar differ diff --git a/data/config.json b/data/config.json new file mode 100644 index 0000000..db71682 --- /dev/null +++ b/data/config.json @@ -0,0 +1,7 @@ +{ + "java": "java", + "apktool": "apktool.jar", + "template": "template", + "cache": "cache", + "dex2jar": "dex-tools/d2j-dex2jar.bat" +} \ No newline at end of file diff --git a/data/dex-tools/LICENSE.txt b/data/dex-tools/LICENSE.txt new file mode 100644 index 0000000..6b0b127 --- /dev/null +++ b/data/dex-tools/LICENSE.txt @@ -0,0 +1,203 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/data/dex-tools/NOTICE.txt b/data/dex-tools/NOTICE.txt new file mode 100644 index 0000000..12d3193 --- /dev/null +++ b/data/dex-tools/NOTICE.txt @@ -0,0 +1,11 @@ +dex2jar - Tools to work with android .dex and java .class files +Copyright (c) 2009-2014 Panxiaobo + +contributors + - Bob Pan + - HyperSpeeed + - Enea Stanzani + - t3stwhat + - paulhooijenga + - yyjdelete + - jcmdev0 diff --git a/data/dex-tools/bin/dex-tools b/data/dex-tools/bin/dex-tools new file mode 100644 index 0000000..5a0f981 --- /dev/null +++ b/data/dex-tools/bin/dex-tools @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## dex-tools start up script for UN*X +## +############################################################################## + +# 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="dex-tools" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and DEX_TOOLS_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/lib/dex-tools-2.2-SNAPSHOT.jar:$APP_HOME/lib/dex-translator-2.2-SNAPSHOT.jar:$APP_HOME/lib/dx-27.0.3.jar:$APP_HOME/lib/d2j-smali-2.2-SNAPSHOT.jar:$APP_HOME/lib/d2j-jasmin-2.2-SNAPSHOT.jar:$APP_HOME/lib/dex-writer-2.2-SNAPSHOT.jar:$APP_HOME/lib/d2j-base-cmd-2.2-SNAPSHOT.jar:$APP_HOME/lib/dex-reader-2.2-SNAPSHOT.jar:$APP_HOME/lib/dex-ir-2.2-SNAPSHOT.jar:$APP_HOME/lib/asm-debug-all-5.0.3.jar:$APP_HOME/lib/antlr4-4.5.jar:$APP_HOME/lib/antlr4-runtime-4.5.jar:$APP_HOME/lib/antlr-3.5.2.jar:$APP_HOME/lib/ST4-4.0.8.jar:$APP_HOME/lib/antlr-runtime-3.5.2.jar:$APP_HOME/lib/dex-reader-api-2.2-SNAPSHOT.jar:$APP_HOME/lib/org.abego.treelayout.core-1.0.1.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +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 + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $DEX_TOOLS_OPTS -classpath "\"$CLASSPATH\"" com.googlecode.dex2jar.tools.BaseCmd "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/data/dex-tools/bin/dex-tools.bat b/data/dex-tools/bin/dex-tools.bat new file mode 100644 index 0000000..372b868 --- /dev/null +++ b/data/dex-tools/bin/dex-tools.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem dex-tools startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME%.. + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and DEX_TOOLS_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\lib\dex-tools-2.2-SNAPSHOT.jar;%APP_HOME%\lib\dex-translator-2.2-SNAPSHOT.jar;%APP_HOME%\lib\dx-27.0.3.jar;%APP_HOME%\lib\d2j-smali-2.2-SNAPSHOT.jar;%APP_HOME%\lib\d2j-jasmin-2.2-SNAPSHOT.jar;%APP_HOME%\lib\dex-writer-2.2-SNAPSHOT.jar;%APP_HOME%\lib\d2j-base-cmd-2.2-SNAPSHOT.jar;%APP_HOME%\lib\dex-reader-2.2-SNAPSHOT.jar;%APP_HOME%\lib\dex-ir-2.2-SNAPSHOT.jar;%APP_HOME%\lib\asm-debug-all-5.0.3.jar;%APP_HOME%\lib\antlr4-4.5.jar;%APP_HOME%\lib\antlr4-runtime-4.5.jar;%APP_HOME%\lib\antlr-3.5.2.jar;%APP_HOME%\lib\ST4-4.0.8.jar;%APP_HOME%\lib\antlr-runtime-3.5.2.jar;%APP_HOME%\lib\dex-reader-api-2.2-SNAPSHOT.jar;%APP_HOME%\lib\org.abego.treelayout.core-1.0.1.jar + + +@rem Execute dex-tools +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %DEX_TOOLS_OPTS% -classpath "%CLASSPATH%" com.googlecode.dex2jar.tools.BaseCmd %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable DEX_TOOLS_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%DEX_TOOLS_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/data/dex-tools/d2j-apk-sign.bat b/data/dex-tools/d2j-apk-sign.bat new file mode 100644 index 0000000..9500725 --- /dev/null +++ b/data/dex-tools/d2j-apk-sign.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.ApkSign %* diff --git a/data/dex-tools/d2j-apk-sign.sh b/data/dex-tools/d2j-apk-sign.sh new file mode 100644 index 0000000..343db7e --- /dev/null +++ b/data/dex-tools/d2j-apk-sign.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.ApkSign" "$@" diff --git a/data/dex-tools/d2j-asm-verify.bat b/data/dex-tools/d2j-asm-verify.bat new file mode 100644 index 0000000..d3af84e --- /dev/null +++ b/data/dex-tools/d2j-asm-verify.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.AsmVerify %* diff --git a/data/dex-tools/d2j-asm-verify.sh b/data/dex-tools/d2j-asm-verify.sh new file mode 100644 index 0000000..e39308e --- /dev/null +++ b/data/dex-tools/d2j-asm-verify.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.AsmVerify" "$@" diff --git a/data/dex-tools/d2j-baksmali.bat b/data/dex-tools/d2j-baksmali.bat new file mode 100644 index 0000000..cc35dfb --- /dev/null +++ b/data/dex-tools/d2j-baksmali.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.d2j.smali.BaksmaliCmd %* diff --git a/data/dex-tools/d2j-baksmali.sh b/data/dex-tools/d2j-baksmali.sh new file mode 100644 index 0000000..d82dde3 --- /dev/null +++ b/data/dex-tools/d2j-baksmali.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.d2j.smali.BaksmaliCmd" "$@" diff --git a/data/dex-tools/d2j-class-version-switch.bat b/data/dex-tools/d2j-class-version-switch.bat new file mode 100644 index 0000000..8ca328c --- /dev/null +++ b/data/dex-tools/d2j-class-version-switch.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.ClassVersionSwitch %* diff --git a/data/dex-tools/d2j-class-version-switch.sh b/data/dex-tools/d2j-class-version-switch.sh new file mode 100644 index 0000000..f540539 --- /dev/null +++ b/data/dex-tools/d2j-class-version-switch.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.ClassVersionSwitch" "$@" diff --git a/data/dex-tools/d2j-decrypt-string.bat b/data/dex-tools/d2j-decrypt-string.bat new file mode 100644 index 0000000..409cd27 --- /dev/null +++ b/data/dex-tools/d2j-decrypt-string.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.DecryptStringCmd %* diff --git a/data/dex-tools/d2j-decrypt-string.sh b/data/dex-tools/d2j-decrypt-string.sh new file mode 100644 index 0000000..fa5d20d --- /dev/null +++ b/data/dex-tools/d2j-decrypt-string.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.DecryptStringCmd" "$@" diff --git a/data/dex-tools/d2j-dex-recompute-checksum.bat b/data/dex-tools/d2j-dex-recompute-checksum.bat new file mode 100644 index 0000000..e5967a4 --- /dev/null +++ b/data/dex-tools/d2j-dex-recompute-checksum.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.DexRecomputeChecksum %* diff --git a/data/dex-tools/d2j-dex-recompute-checksum.sh b/data/dex-tools/d2j-dex-recompute-checksum.sh new file mode 100644 index 0000000..03802a5 --- /dev/null +++ b/data/dex-tools/d2j-dex-recompute-checksum.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.DexRecomputeChecksum" "$@" diff --git a/data/dex-tools/d2j-dex-weaver.bat b/data/dex-tools/d2j-dex-weaver.bat new file mode 100644 index 0000000..94cbaa2 --- /dev/null +++ b/data/dex-tools/d2j-dex-weaver.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.DexWeaverCmd %* diff --git a/data/dex-tools/d2j-dex-weaver.sh b/data/dex-tools/d2j-dex-weaver.sh new file mode 100644 index 0000000..91e13aa --- /dev/null +++ b/data/dex-tools/d2j-dex-weaver.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.DexWeaverCmd" "$@" diff --git a/data/dex-tools/d2j-dex2jar.bat b/data/dex-tools/d2j-dex2jar.bat new file mode 100644 index 0000000..5a8fd33 --- /dev/null +++ b/data/dex-tools/d2j-dex2jar.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.Dex2jarCmd %* diff --git a/data/dex-tools/d2j-dex2jar.sh b/data/dex-tools/d2j-dex2jar.sh new file mode 100644 index 0000000..18a3698 --- /dev/null +++ b/data/dex-tools/d2j-dex2jar.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.Dex2jarCmd" "$@" diff --git a/data/dex-tools/d2j-dex2smali.bat b/data/dex-tools/d2j-dex2smali.bat new file mode 100644 index 0000000..cc35dfb --- /dev/null +++ b/data/dex-tools/d2j-dex2smali.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.d2j.smali.BaksmaliCmd %* diff --git a/data/dex-tools/d2j-dex2smali.sh b/data/dex-tools/d2j-dex2smali.sh new file mode 100644 index 0000000..d82dde3 --- /dev/null +++ b/data/dex-tools/d2j-dex2smali.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.d2j.smali.BaksmaliCmd" "$@" diff --git a/data/dex-tools/d2j-jar-access.bat b/data/dex-tools/d2j-jar-access.bat new file mode 100644 index 0000000..01db81d --- /dev/null +++ b/data/dex-tools/d2j-jar-access.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.JarAccessCmd %* diff --git a/data/dex-tools/d2j-jar-access.sh b/data/dex-tools/d2j-jar-access.sh new file mode 100644 index 0000000..dad0e42 --- /dev/null +++ b/data/dex-tools/d2j-jar-access.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.JarAccessCmd" "$@" diff --git a/data/dex-tools/d2j-jar-weaver.bat b/data/dex-tools/d2j-jar-weaver.bat new file mode 100644 index 0000000..14ee1ce --- /dev/null +++ b/data/dex-tools/d2j-jar-weaver.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.JarWeaverCmd %* diff --git a/data/dex-tools/d2j-jar-weaver.sh b/data/dex-tools/d2j-jar-weaver.sh new file mode 100644 index 0000000..22195d8 --- /dev/null +++ b/data/dex-tools/d2j-jar-weaver.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.JarWeaverCmd" "$@" diff --git a/data/dex-tools/d2j-jar2dex.bat b/data/dex-tools/d2j-jar2dex.bat new file mode 100644 index 0000000..1ab1c64 --- /dev/null +++ b/data/dex-tools/d2j-jar2dex.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.Jar2Dex %* diff --git a/data/dex-tools/d2j-jar2dex.sh b/data/dex-tools/d2j-jar2dex.sh new file mode 100644 index 0000000..f4c493a --- /dev/null +++ b/data/dex-tools/d2j-jar2dex.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.Jar2Dex" "$@" diff --git a/data/dex-tools/d2j-jar2jasmin.bat b/data/dex-tools/d2j-jar2jasmin.bat new file mode 100644 index 0000000..47fdae1 --- /dev/null +++ b/data/dex-tools/d2j-jar2jasmin.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.d2j.jasmin.Jar2JasminCmd %* diff --git a/data/dex-tools/d2j-jar2jasmin.sh b/data/dex-tools/d2j-jar2jasmin.sh new file mode 100644 index 0000000..4d21a6a --- /dev/null +++ b/data/dex-tools/d2j-jar2jasmin.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.d2j.jasmin.Jar2JasminCmd" "$@" diff --git a/data/dex-tools/d2j-jasmin2jar.bat b/data/dex-tools/d2j-jasmin2jar.bat new file mode 100644 index 0000000..a3d6da3 --- /dev/null +++ b/data/dex-tools/d2j-jasmin2jar.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.d2j.jasmin.Jasmin2JarCmd %* diff --git a/data/dex-tools/d2j-jasmin2jar.sh b/data/dex-tools/d2j-jasmin2jar.sh new file mode 100644 index 0000000..fcf107e --- /dev/null +++ b/data/dex-tools/d2j-jasmin2jar.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.d2j.jasmin.Jasmin2JarCmd" "$@" diff --git a/data/dex-tools/d2j-smali.bat b/data/dex-tools/d2j-smali.bat new file mode 100644 index 0000000..ee02fe1 --- /dev/null +++ b/data/dex-tools/d2j-smali.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.d2j.smali.SmaliCmd %* diff --git a/data/dex-tools/d2j-smali.sh b/data/dex-tools/d2j-smali.sh new file mode 100644 index 0000000..f16ff7c --- /dev/null +++ b/data/dex-tools/d2j-smali.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.d2j.smali.SmaliCmd" "$@" diff --git a/data/dex-tools/d2j-std-apk.bat b/data/dex-tools/d2j-std-apk.bat new file mode 100644 index 0000000..2787a55 --- /dev/null +++ b/data/dex-tools/d2j-std-apk.bat @@ -0,0 +1,21 @@ +@echo off + +REM +REM dex2jar - Tools to work with android .dex and java .class files +REM Copyright (c) 2009-2013 Panxiaobo +REM +REM Licensed under the Apache License, Version 2.0 (the "License"); +REM you may not use this file except in compliance with the License. +REM You may obtain a copy of the License at +REM +REM http://www.apache.org/licenses/LICENSE-2.0 +REM +REM Unless required by applicable law or agreed to in writing, software +REM distributed under the License is distributed on an "AS IS" BASIS, +REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +REM See the License for the specific language governing permissions and +REM limitations under the License. +REM + +REM call d2j_invoke.bat to setup java environment +@"%~dp0d2j_invoke.bat" com.googlecode.dex2jar.tools.StdApkCmd %* diff --git a/data/dex-tools/d2j-std-apk.sh b/data/dex-tools/d2j-std-apk.sh new file mode 100644 index 0000000..2a422c0 --- /dev/null +++ b/data/dex-tools/d2j-std-apk.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "com.googlecode.dex2jar.tools.StdApkCmd" "$@" diff --git a/data/dex-tools/d2j_invoke.bat b/data/dex-tools/d2j_invoke.bat new file mode 100644 index 0000000..d38d727 --- /dev/null +++ b/data/dex-tools/d2j_invoke.bat @@ -0,0 +1,13 @@ +REM better invocation scripts for windows from lanchon, release in public domain. thanks! +REM https://code.google.com/p/dex2jar/issues/detail?id=192 + +setlocal enabledelayedexpansion + +set LIB=%~dp0lib + +set CP= +for %%X in ("%LIB%"\*.jar) do ( + set CP=!CP!%%X; +) + +java -Xms512m -Xmx2048m -cp "%CP%" %* diff --git a/data/dex-tools/d2j_invoke.sh b/data/dex-tools/d2j_invoke.sh new file mode 100644 index 0000000..4ef1ffb --- /dev/null +++ b/data/dex-tools/d2j_invoke.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# +# dex2jar - Tools to work with android .dex and java .class files +# Copyright (c) 2009-2013 Panxiaobo +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# copy from $Tomcat/bin/startup.sh +# resolve links - $0 may be a softlink +PRG="$0" +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 +PRGDIR=`dirname "$PRG"` +# + +_classpath="." +if [ `uname -a | grep -i -c cygwin` -ne 0 ]; then # Cygwin, translate the path + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath};`cygpath -w ${k}`" + done +else + for k in "$PRGDIR"/lib/*.jar + do + _classpath="${_classpath}:${k}" + done +fi + +java -Xms512m -Xmx2048m -classpath "${_classpath}" "$@" diff --git a/data/dex-tools/lib/ST4-4.0.8.jar b/data/dex-tools/lib/ST4-4.0.8.jar new file mode 100644 index 0000000..144828b Binary files /dev/null and b/data/dex-tools/lib/ST4-4.0.8.jar differ diff --git a/data/dex-tools/lib/antlr-3.5.2.jar b/data/dex-tools/lib/antlr-3.5.2.jar new file mode 100644 index 0000000..12b6140 Binary files /dev/null and b/data/dex-tools/lib/antlr-3.5.2.jar differ diff --git a/data/dex-tools/lib/antlr-runtime-3.5.2.jar b/data/dex-tools/lib/antlr-runtime-3.5.2.jar new file mode 100644 index 0000000..d48e3e8 Binary files /dev/null and b/data/dex-tools/lib/antlr-runtime-3.5.2.jar differ diff --git a/data/dex-tools/lib/antlr4-4.5.jar b/data/dex-tools/lib/antlr4-4.5.jar new file mode 100644 index 0000000..a20a536 Binary files /dev/null and b/data/dex-tools/lib/antlr4-4.5.jar differ diff --git a/data/dex-tools/lib/antlr4-runtime-4.5.jar b/data/dex-tools/lib/antlr4-runtime-4.5.jar new file mode 100644 index 0000000..924fcce Binary files /dev/null and b/data/dex-tools/lib/antlr4-runtime-4.5.jar differ diff --git a/data/dex-tools/lib/asm-debug-all-5.0.3.jar b/data/dex-tools/lib/asm-debug-all-5.0.3.jar new file mode 100644 index 0000000..c531dea Binary files /dev/null and b/data/dex-tools/lib/asm-debug-all-5.0.3.jar differ diff --git a/data/dex-tools/lib/d2j-base-cmd-2.2-SNAPSHOT.jar b/data/dex-tools/lib/d2j-base-cmd-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..fd43ab6 Binary files /dev/null and b/data/dex-tools/lib/d2j-base-cmd-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/d2j-jasmin-2.2-SNAPSHOT.jar b/data/dex-tools/lib/d2j-jasmin-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..372fa50 Binary files /dev/null and b/data/dex-tools/lib/d2j-jasmin-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/d2j-smali-2.2-SNAPSHOT.jar b/data/dex-tools/lib/d2j-smali-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..fec6a91 Binary files /dev/null and b/data/dex-tools/lib/d2j-smali-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/dex-ir-2.2-SNAPSHOT.jar b/data/dex-tools/lib/dex-ir-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..968e9d8 Binary files /dev/null and b/data/dex-tools/lib/dex-ir-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/dex-reader-2.2-SNAPSHOT.jar b/data/dex-tools/lib/dex-reader-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..ad84eda Binary files /dev/null and b/data/dex-tools/lib/dex-reader-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/dex-reader-api-2.2-SNAPSHOT.jar b/data/dex-tools/lib/dex-reader-api-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..266a0cf Binary files /dev/null and b/data/dex-tools/lib/dex-reader-api-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/dex-tools-2.2-SNAPSHOT.jar b/data/dex-tools/lib/dex-tools-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..d1a5b84 Binary files /dev/null and b/data/dex-tools/lib/dex-tools-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/dex-translator-2.2-SNAPSHOT.jar b/data/dex-tools/lib/dex-translator-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..5973bff Binary files /dev/null and b/data/dex-tools/lib/dex-translator-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/dex-writer-2.2-SNAPSHOT.jar b/data/dex-tools/lib/dex-writer-2.2-SNAPSHOT.jar new file mode 100644 index 0000000..23a475a Binary files /dev/null and b/data/dex-tools/lib/dex-writer-2.2-SNAPSHOT.jar differ diff --git a/data/dex-tools/lib/dx-27.0.3.jar b/data/dex-tools/lib/dx-27.0.3.jar new file mode 100644 index 0000000..023b8da Binary files /dev/null and b/data/dex-tools/lib/dx-27.0.3.jar differ diff --git a/data/dex-tools/lib/open-source-license.txt b/data/dex-tools/lib/open-source-license.txt new file mode 100644 index 0000000..e8669c5 --- /dev/null +++ b/data/dex-tools/lib/open-source-license.txt @@ -0,0 +1,67 @@ +==== dx-*.jar +Apache 2.0 http://www.apache.org/licenses/LICENSE-2.0.html + + +==== antlr-*.jar +[The BSD License] +Copyright (c) 2003-2007, Terence Parr +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. +* Neither the name of the author nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + + +==== asm-*.jar + + ASM: a very small and fast Java bytecode manipulation framework + Copyright (c) 2000-2005 INRIA, France Telecom + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the copyright holders nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/data/dex-tools/lib/org.abego.treelayout.core-1.0.1.jar b/data/dex-tools/lib/org.abego.treelayout.core-1.0.1.jar new file mode 100644 index 0000000..2350adc Binary files /dev/null and b/data/dex-tools/lib/org.abego.treelayout.core-1.0.1.jar differ diff --git a/data/template/app/build.gradle b/data/template/app/build.gradle new file mode 100644 index 0000000..d5294f4 --- /dev/null +++ b/data/template/app/build.gradle @@ -0,0 +1,32 @@ +plugins { + id 'com.android.application' +} + +android { + compileSdk __COMPILE_SDK__ + + defaultConfig { + applicationId __APPLICATION_ID__ + minSdk __MIN_SDK__ + targetSdk __TARGET__SDK__ + versionCode __VERSION_CODE__ + versionName __VERSION_NAME__ + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) +} + +apply from: file('build2.gradle') diff --git a/data/template/app/build2.gradle b/data/template/app/build2.gradle new file mode 100644 index 0000000..b097980 --- /dev/null +++ b/data/template/app/build2.gradle @@ -0,0 +1,274 @@ +import org.w3c.dom.Document +import org.w3c.dom.Element + +import javax.xml.parsers.DocumentBuilderFactory + +dependencies { + if (file('original/classes.jar').exists()) { + compileOnly files('original/classes.jar') + } + if (file('original/unknown.jar').exists()) { + implementation files('original/unknown.jar') + } +} + +def readXml = { File file -> + return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file) +} + +android { + aaptOptions { + File publicTxtFile = new File(buildDir, 'public.txt') + if (!publicTxtFile.exists()) { + // 产生public.txt + if (!publicTxtFile.parentFile.exists()) publicTxtFile.parentFile.mkdirs() + publicTxtFile.text = '' + } + File publicXmlFile = file('src/main/res/values/public.xml') + if (publicXmlFile.exists()) { + Document manifest = readXml(file('src/main/AndroidManifest.xml')) + def packName = manifest.getDocumentElement().getAttribute("package") + Document publicXml = readXml(publicXmlFile) + def list = publicXml.getDocumentElement().getElementsByTagName("public") + if (list.getLength() > 0) { + for (i in 0.. + if (!outDir.exists()) { + outDir.mkdirs() + } + javaexec { + def baksmali = rootProject.file('gradle/baksmali.jar') + main = '-jar' + args = [ + baksmali.getAbsolutePath(), 'd', + '--bcp', '""', '-l', + '-o', outDir.absolutePath, dexFile.absolutePath + ] + } +} + +def dumpDexDir = { File dir, File outDir -> + def files = dir.listFiles() + def result = [] + files.each { + if (it.name ==~ '^classes[0-9]?.dex$') { + def smaliDir = new File(outDir, it.name.replace('.', '_')) + dumpDex(it, smaliDir) + result.add(smaliDir) + } + } + return result +} + +def readSmali = { File file -> + println "readSmali: ${file}" + def result = [ + members: [], + methods: [:], + fields : [:], + ] + def method = null + def lines = file.readLines() + lines.each { String line -> + boolean handled + if (method) { + handled = true + method.lines.add(line) + if (line ==~ '^\\s*\\.end\\s+method\\s*$') { + method = null + } + } else { + if (line ==~ '^\\s*\\.method\\s+.+\\(\\S*\\)\\S+.*$') { + def ss = line.split('\\s') + def name = null + for (def si = ss.length - 1; si >= 0; si--) { + String s = ss[si] + if (s.contains('(')) { + name = s + break + } + } + if (name) { + method = [ + type : 'method', + name : name, + lines: [], + ] + result.methods[method.name] = method + result.members.add(method) + handled = true + } else { + handled = false + } + } else if (line ==~ '^\\s*\\.field\\s+.+:\\S+.*$') { + def ss = line.split('\\s') + def name = null + for (def si = ss.length - 1; si >= 0; si--) { + String s = ss[si] + if (s.contains(':')) { + name = s.split(':')[0] + break + } + } + if (name) { + def obj = [ + type: 'field', + line: line, + name: name, + ] + result.members.add(obj) + result.fields[obj.name] = obj + handled = true + } else { + handled = false + } + } else { + handled = false + } + } + if (!handled) { + def obj = [ + type: 'line', + line: line, + ] + result.members.add(obj) + } + } + return result +} + +def margeSmali = { File from, File to -> + println "mergeSmali: ${from} >>> ${to}" + def fromSmali = readSmali(from) + def toSmali = readSmali(to) + fromSmali.methods.each { + def method = toSmali.methods[it.key] + if (method) { + method.lines = it.value.lines + } else { + // 新增方法 + toSmali.members.add(it.value) + } + } + fromSmali.fields.each { + def field = toSmali.fields[it.key] + if (field) { + field.line = it.value.line + } else { + // 新增字段 + toSmali.members.add(it.value) + } + } + + def lines = [] + toSmali.members.each { + switch (it.type) { + case 'line': + case 'field': + lines.add(it.line) + break + case 'method': + lines.addAll(it.lines) + break + } + } + to.text = '' + lines.each { + to.append(it) + to.append('\n') + } +} + +def putSmaliFile = { File file, def classPath, def outSmaliList -> + println "putSmaliFile: ${classPath}" + File mainDir = null + for (File smaliDir : outSmaliList) { + if (smaliDir.name == 'classes_dex') { + mainDir = smaliDir + } + File outFile = new File(smaliDir, classPath) + if (outFile.exists()) { + margeSmali(file, outFile) + } + } + // 新增的smali,复制smali + if (mainDir) { + File outFile = new File(mainDir, classPath) + if (!outFile.parentFile.exists()) outFile.parentFile.mkdirs() + outFile.text = file.text + } +} + +def createDex = { File smaliDir, File outFile -> + println "createDex: ${smaliDir} >>> ${outFile}" + if (!outFile.parentFile.exists()) outFile.parentFile.mkdirs() + javaexec { + def smali = rootProject.file('gradle/smali.jar') + main = "-jar" + args = [ + smali.getAbsolutePath(), + 'a', '-o', outFile.getAbsolutePath(), + smaliDir.getAbsolutePath() + ] + } +} + +// 合并dex +tasks.whenTaskAdded { + Task cur = it + if (cur.name ==~ '^mergeDex\\S+') { + cur.doLast { + def variantName = cur.variantName + cur.outputs.files.each { + // 生成新的smali + def newSmaliList = dumpDexDir(it, new File(buildDir, "smali/${variantName}/_new")) + + // 生产久的smali + def oldSmaliList = dumpDexDir(file('original'), new File(buildDir, "smali/${variantName}/_old")) + + // 合并smali + newSmaliList.each { File dir -> + def files = fileTree(dir) + files.each { File file -> + if (file.name ==~ '^\\S+.smali$') { + String path = dir.relativePath(file) + putSmaliFile(file, path, oldSmaliList) + } + } + } + + // 生成dex + File dexDir = new File(buildDir, "dex/${variantName}") + oldSmaliList.each { + def dexName = it.name.replace('_', '.') + File dexFile = new File(dexDir, dexName) + createDex(it, dexFile) + } + + // 覆盖dex + it.listFiles().each { + if (it.name ==~ 'classes[0-9]*.dex') { + it.delete() + } + } + def dir = it + copy { + from(dexDir) + into(dir) + } + } + } + } +} diff --git a/data/template/build.gradle b/data/template/build.gradle new file mode 100644 index 0000000..2106b82 --- /dev/null +++ b/data/template/build.gradle @@ -0,0 +1,17 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + google() + mavenCentral() + } + dependencies { + classpath "com.android.tools.build:gradle:7.0.2" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} \ No newline at end of file diff --git a/data/template/gradle.properties b/data/template/gradle.properties new file mode 100644 index 0000000..e69de29 diff --git a/data/template/gradle/baksmali.jar b/data/template/gradle/baksmali.jar new file mode 100644 index 0000000..56ddffe Binary files /dev/null and b/data/template/gradle/baksmali.jar differ diff --git a/data/template/gradle/smali.jar b/data/template/gradle/smali.jar new file mode 100644 index 0000000..5321692 Binary files /dev/null and b/data/template/gradle/smali.jar differ diff --git a/data/template/gradle/wrapper/gradle-wrapper.jar b/data/template/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/data/template/gradle/wrapper/gradle-wrapper.jar differ diff --git a/data/template/gradle/wrapper/gradle-wrapper.properties b/data/template/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..a5ee518 --- /dev/null +++ b/data/template/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Nov 22 15:36:29 CST 2021 +distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +distributionPath=wrapper/dists +zipStorePath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME diff --git a/data/template/settings.gradle b/data/template/settings.gradle new file mode 100644 index 0000000..55f9286 --- /dev/null +++ b/data/template/settings.gradle @@ -0,0 +1,10 @@ +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { + google() + mavenCentral() + maven { url 'https://www.jitpack.io' } + jcenter() // Warning: this repository is going to shut down soon + } +} +include ':app' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..e708b1c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..da9702f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..4f906e0 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# 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="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +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 + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/java/com/mosect/a2g/Apk2Gradle.java b/src/main/java/com/mosect/a2g/Apk2Gradle.java new file mode 100644 index 0000000..2ed9d43 --- /dev/null +++ b/src/main/java/com/mosect/a2g/Apk2Gradle.java @@ -0,0 +1,278 @@ +package com.mosect.a2g; + +import com.google.gson.Gson; + +import org.w3c.dom.Document; +import org.yaml.snakeyaml.Yaml; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.jar.Manifest; + +public class Apk2Gradle { + + private static final String TAG = "A2G"; + + private static Manifest readManifest() { + try { + Enumeration resources = Apk2Gradle.class.getClassLoader() + .getResources("META-INF/MANIFEST.MF"); + while (resources.hasMoreElements()) { + try { + return new Manifest(resources.nextElement().openStream()); + } catch (IOException ignored) { + } + } + } catch (IOException ignored) { + } + return null; + } + + private static void printHelp() { + String version = "1.0.0"; + Manifest manifest = readManifest(); + if (null != manifest) { + String v = manifest.getMainAttributes().getValue("Implementation-Version"); + if (null != v) version = v; + } + System.out.println("apk2gradle"); + System.out.println("version: " + version); + System.out.println("author: mosect.com"); + System.out.println("web: http://www.msoect.com"); + System.out.println("github: https://github.com/Mosect"); + System.out.println(); + System.out.println("Usage: "); + System.out.println("java -jar apk2gradle.jar [output_dir_path]"); + System.out.println("Sample: "); + System.out.println("java -jar apk2gradle.jar export my.apk out_dir"); + System.out.println("java -jar apk2gradle.jar e my.apk out_dir"); + System.out.println("java -jar apk2gradle.jar -e my.apk out_dir"); + System.out.println("java -jar apk2gradle.jar /e my.apk"); + } + + public static void main(String[] args) { + if (null == args || args.length == 0) { + printHelp(); + return; + } + String action = args[0].toLowerCase(); + switch (action) { + case "-e": + case "--e": + case "e": + case "export": + case "/e": + if (args.length == 1) { + System.err.println("Missing apk file path arg."); + printHelp(); + System.exit(1); + return; + } + break; + case "help": + case "-h": + case "--h": + case "/?": + case "?": + case "--help": + printHelp(); + return; + default: + System.err.println("Unsupported action: " + action); + printHelp(); + System.exit(1); + return; + } + + Config config = readConfig(); + + File cacheDir = new File(config.cache); + File templateDir = new File(config.template); + File apktoolFile = new File(config.apktool); + + File apkFile = new File(args[1]); + String outName = apkFile.getName().replace(".", "_") + "_a2g"; + File outDir = new File(args.length > 2 ? args[2] : outName); + + // dump apk + LogUtils.i(TAG, "dump apk"); + File apkDir = new File(cacheDir, "apk-" + System.currentTimeMillis()); + boolean dumpOk = exec(new ProcessBuilder( + config.java, "-jar", apktoolFile.getAbsolutePath(), + "d", "-s", "-o", apkDir.getAbsolutePath(), apkFile.getAbsolutePath() + )); + if (dumpOk) { + if (outDir.exists()) IOUtils.delete(outDir); + outDir.mkdirs(); + // copy template files + LogUtils.i(TAG, "copy template files"); + IOUtils.copy(templateDir, outDir); + + // load project env + Map apktoolYml = new Yaml().loadAs( + IOUtils.loadFile(new File(apkDir, "apktool.yml")), + Map.class + ); + String minSdk = get(apktoolYml, "sdkInfo", "minSdkVersion"); + String targetSdk = get(apktoolYml, "sdkInfo", "targetSdkVersion"); + if (TextUtils.empty(targetSdk)) targetSdk = minSdk; + String versionName = get(apktoolYml, "versionInfo", "versionName"); + String versionCode = get(apktoolYml, "versionInfo", "versionCode"); + Document manifest = IOUtils.readDocument(new File(apkDir, "AndroidManifest.xml")); + String packageName = manifest.getDocumentElement().getAttribute("package"); + String compileSdk = manifest.getDocumentElement().getAttribute("platformBuildVersionCode"); + if (TextUtils.empty(compileSdk)) compileSdk = targetSdk; + manifest.getDocumentElement().removeAttribute("platformBuildVersionCode"); + manifest.getDocumentElement().removeAttribute("platformBuildVersionName"); + + // modify build.gradle + LogUtils.i(TAG, "modify build.gradle"); + Map buildEnv = new HashMap<>(); + buildEnv.put("__COMPILE_SDK__", compileSdk); + buildEnv.put("__APPLICATION_ID__", string(packageName)); + buildEnv.put("__MIN_SDK__", minSdk); + buildEnv.put("__TARGET__SDK__", targetSdk); + buildEnv.put("__VERSION_CODE__", versionCode); + buildEnv.put("__VERSION_NAME__", string(versionName)); + modifyBuildGradle(new File(outDir, "app/build.gradle"), buildEnv); + + File mainDir = new File(outDir, "app/src/main"); + mainDir.mkdirs(); + // create AndroidManifest.xml + LogUtils.i(TAG, "create AndroidManifest.xml"); + IOUtils.saveDocument(new File(mainDir, "AndroidManifest.xml"), manifest); + // copy res + LogUtils.i(TAG, "copy res"); + IOUtils.copy(new File(apkDir, "res"), new File(mainDir, "res")); + // copy assets + LogUtils.i(TAG, "copy assets"); + IOUtils.copy(new File(apkDir, "assets"), new File(mainDir, "assets")); + + File originalDir = new File(outDir, "app/original"); + originalDir.mkdirs(); + // create classes.jar + LogUtils.i(TAG, "create classes.jar"); + File classesJar = new File(originalDir, "classes.jar"); + exec(new ProcessBuilder(config.dex2jar, + "-o", classesJar.getAbsolutePath(), apkFile.getAbsolutePath())); + // create unknown.jar + LogUtils.i(TAG, "create unknown.jar"); + IOUtils.zipDir(new File(apkDir, "unknown"), new File(originalDir, "unknown.jar")); + // copy dex files + LogUtils.i(TAG, "copy dex files"); + copyDexFiles(apkDir, originalDir); + } + + LogUtils.i(TAG, "result: " + dumpOk); + // 清理缓存 + IOUtils.delete(apkDir); + if (!dumpOk) { + System.exit(1); + } + } + + private static void copyDexFiles(File apkDir, File outDir) { + File[] files = apkDir.listFiles(); + if (null != files && files.length > 0) { + for (File f : files) { + if (f.getName().matches("^classes[0-9]*.dex$")) { + File dst = new File(outDir, f.getName()); + IOUtils.copy(f, dst); + } + } + } + } + + private static String string(String str) { + return String.format("'%s'", str); + } + + private static void modifyBuildGradle(File file, Map env) { + List lines = IOUtils.readFileLines(file); + List text = new ArrayList<>(lines.size()); + for (String line : lines) { + for (Map.Entry entry : env.entrySet()) { + line = line.replace(entry.getKey(), entry.getValue()); + } + text.add(line); + } + IOUtils.saveLines(file, text); + } + + @SuppressWarnings("unchecked") + private static T get(Object data, String... keys) { + if (data instanceof Map) { + Map cur = (Map) data; + Object result = null; + for (String key : keys) { + result = cur.get(key); + if (result instanceof Map) { + cur = (Map) result; + } + } + return (T) result; + } + return null; + } + + private static Config readConfig() { + Config config = null; + File file = new File("config.json"); + if (file.exists()) { + String data = IOUtils.loadFile(file); + if (TextUtils.notEmpty(data)) { + config = new Gson().fromJson(data, Config.class); + } + } + if (null == config) config = new Config(); + + if (TextUtils.empty(config.java)) config.java = "java"; + if (TextUtils.empty(config.apktool)) config.apktool = "apktool.jar"; + if (TextUtils.empty(config.cache)) config.cache = "cache"; + if (TextUtils.empty(config.template)) config.template = "template"; + if (TextUtils.empty(config.dex2jar)) config.dex2jar = "dex-tools/d2j-dex2jar.bat"; + return config; + } + + private static boolean exec(ProcessBuilder builder) { + StringBuilder stringBuilder = new StringBuilder(); + for (String str : builder.command()) { + stringBuilder.append(str).append(' '); + } + LogUtils.i(TAG, "exec: " + stringBuilder); + try { + Process process = builder.start(); + InputStream error = process.getErrorStream(); + Thread thread = new Thread(() -> { + InputStreamReader isr = new InputStreamReader(error); + BufferedReader reader = new BufferedReader(isr); + String line; + try { + while ((line = reader.readLine()) != null) { + LogUtils.e(TAG, line); + } + } catch (IOException e) { + e.printStackTrace(); + } + IOUtils.close(reader); + IOUtils.close(isr); + IOUtils.close(error); + }); + thread.start(); + int code = process.waitFor(); + if (code == 0) return true; + } catch (Exception e) { + e.printStackTrace(); + } + return false; + } +} diff --git a/src/main/java/com/mosect/a2g/Config.java b/src/main/java/com/mosect/a2g/Config.java new file mode 100644 index 0000000..22e3b70 --- /dev/null +++ b/src/main/java/com/mosect/a2g/Config.java @@ -0,0 +1,10 @@ +package com.mosect.a2g; + +public class Config { + + public String java; + public String apktool; + public String template; + public String cache; + public String dex2jar; +} diff --git a/src/main/java/com/mosect/a2g/IOUtils.java b/src/main/java/com/mosect/a2g/IOUtils.java new file mode 100644 index 0000000..e9d14f6 --- /dev/null +++ b/src/main/java/com/mosect/a2g/IOUtils.java @@ -0,0 +1,253 @@ +package com.mosect.a2g; + +import org.w3c.dom.Document; +import org.xml.sax.InputSource; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.Closeable; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +public final class IOUtils { + + private IOUtils() { + } + + public static String load(InputStream is) { + try (ByteArrayOutputStream temp = new ByteArrayOutputStream()) { + byte[] buffer = new byte[1024]; + int len; + while ((len = is.read(buffer)) > 0) { + temp.write(buffer, 0, len); + } + return temp.toString("UTF-8"); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String loadFile(File file) { + if (file.exists()) { + try (FileInputStream fis = new FileInputStream(file);) { + return load(fis); + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } + + public static String loadRes(String name) { + InputStream is = IOUtils.class.getResourceAsStream(name); + if (null != is) { + String result = load(is); + close(is); + return result; + } + return null; + } + + public static boolean save(File file, String data) { + File dir = file.getParentFile(); + if (null != dir && !dir.exists()) { + if (!dir.mkdirs()) { + return false; + } + } + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(data.getBytes(StandardCharsets.UTF_8)); + fos.flush(); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public static void close(Closeable closeable) { + if (null != closeable) { + try { + closeable.close(); + } catch (IOException ignored) { + } + } + } + + public static boolean delete(File file) { + if (file.isDirectory()) { + File[] files = file.listFiles(); + if (null != files && files.length > 0) { + for (File f : files) { + String name = f.getName(); + if (".".equals(name) || "..".equals(name)) continue; + delete(f); + } + } + } + return file.delete(); + } + + public static List readLines(InputStream is) { + List lines = new ArrayList<>(); + try (InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8); + BufferedReader reader = new BufferedReader(isr)) { + String line; + while ((line = reader.readLine()) != null) { + lines.add(line); + } + } catch (Exception e) { + e.printStackTrace(); + } + return lines; + } + + public static List readFileLines(File file) { + try (FileInputStream fis = new FileInputStream(file)) { + return readLines(fis); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static List readResLines(String name) { + InputStream is = IOUtils.class.getResourceAsStream(name); + if (null != is) { + List lines = readLines(is); + close(is); + return lines; + } + return null; + } + + public static void saveLines(File file, List lines) { + try (FileOutputStream fos = new FileOutputStream(file); + OutputStreamWriter osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8); + BufferedWriter writer = new BufferedWriter(osw)) { + if (null != lines) { + for (String line : lines) { + writer.write(line); + writer.newLine(); + } + } + writer.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void copy(File src, File dst) { + copy(new byte[1024], src, dst); + } + + private static void copy(byte[] buffer, File src, File dst) { + if (src.exists()) { + if (dst.exists()) { + delete(dst); + } + File parentFile = dst.getParentFile(); + if (null != parentFile && !parentFile.exists()) { + parentFile.mkdirs(); + } + if (src.isFile()) { + try (FileInputStream fis = new FileInputStream(src); + FileOutputStream fos = new FileOutputStream(dst)) { + int len; + while ((len = fis.read(buffer)) > 0) { + fos.write(buffer, 0, len); + } + fos.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (src.isDirectory()) { + dst.mkdir(); + File[] files = src.listFiles(); + if (null != files && files.length > 0) { + for (File f : files) { + if (".".equals(f.getName()) || "..".equals(f.getName())) continue; + + File fd = new File(dst, f.getName()); + copy(buffer, f, fd); + } + } + } + } + } + + public static Document readDocument(File file) { + try (FileInputStream fis = new FileInputStream(file); + InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8)) { + return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(isr)); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static void saveDocument(File file, Document document) { + try { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "YES"); + transformer.setOutputProperty(OutputKeys.ENCODING, "utf-8"); + transformer.transform(new DOMSource(document), new StreamResult(file)); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void zipDir(File dir, File out) { + if (dir.isDirectory()) { + try (FileOutputStream fos = new FileOutputStream(out)) { + ZipOutputStream zos = new ZipOutputStream(fos, StandardCharsets.UTF_8); + putChildrenToZip(dir, "", zos, new byte[1024]); + zos.flush(); + zos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + private static void putChildrenToZip(File dir, String path, ZipOutputStream zos, byte[] buffer) throws IOException { + File[] files = dir.listFiles(); + if (null != files && files.length > 0) { + for (File f : files) { + String name = f.getName(); + if (".".equals(name) || "..".equals(name)) continue; + String curPath = path + "/" + name; + zos.putNextEntry(new ZipEntry(curPath)); + if (f.isDirectory()) { + putChildrenToZip(f, curPath, zos, buffer); + } else { + int len; + try (FileInputStream fis = new FileInputStream(f)) { + while ((len = fis.read(buffer)) > 0) { + zos.write(buffer, 0, len); + } + } + } + } + } + } +} diff --git a/src/main/java/com/mosect/a2g/LogUtils.java b/src/main/java/com/mosect/a2g/LogUtils.java new file mode 100644 index 0000000..fa197b1 --- /dev/null +++ b/src/main/java/com/mosect/a2g/LogUtils.java @@ -0,0 +1,38 @@ +package com.mosect.a2g; + +import java.io.PrintStream; +import java.text.SimpleDateFormat; +import java.util.Date; + +public final class LogUtils { + + private final static Impl impl = new Impl(); + + private LogUtils() { + } + + public synchronized static void i(String tag, String msg) { + impl.print(System.out, tag, msg); + } + + public synchronized static void e(String tag, String msg) { + impl.print(System.err, tag, msg); + } + + static class Impl { + + final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + Impl() { + } + + void print(PrintStream stream, String tag, String msg) { + stream.print(dateFormat.format(new Date())); + stream.print(" : "); + stream.print(tag); + stream.print(" : "); + stream.print(msg); + stream.println(); + } + } +} diff --git a/src/main/java/com/mosect/a2g/TextUtils.java b/src/main/java/com/mosect/a2g/TextUtils.java new file mode 100644 index 0000000..6ee9674 --- /dev/null +++ b/src/main/java/com/mosect/a2g/TextUtils.java @@ -0,0 +1,15 @@ +package com.mosect.a2g; + +public final class TextUtils { + + private TextUtils() { + } + + public static boolean empty(CharSequence cs) { + return null == cs || cs.length() == 0; + } + + public static boolean notEmpty(CharSequence cs) { + return !empty(cs); + } +}