├── Demo
├── .gitignore
├── .idea
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── runConfigurations.xml
├── app
│ ├── .gitignore
│ ├── app-release.apk
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── demon
│ │ │ └── demo
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── demon
│ │ │ │ └── demo
│ │ │ │ ├── GlideUtil.java
│ │ │ │ ├── ImageActivity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── MyApplication.java
│ │ │ │ └── NetStateReceiver.java
│ │ └── res
│ │ │ ├── layout
│ │ │ ├── activity_image.xml
│ │ │ └── activity_main.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── demon
│ │ └── demo
│ │ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── DexShellTool
├── .idea
│ ├── encodings.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── workspace.xml
├── DexShellTool.iml
├── force
│ ├── classes.dex
│ ├── demo.apk
│ └── shell.dex
├── out
│ └── production
│ │ └── DexShellTool
│ │ └── DexShellTool.class
└── src
│ └── DexShellTool.java
├── MyUnshell
├── .gitignore
├── .idea
│ ├── compiler.xml
│ ├── copyright
│ │ └── profiles_settings.xml
│ ├── encodings.xml
│ ├── gradle.xml
│ ├── inspectionProfiles
│ │ ├── Project_Default.xml
│ │ └── profiles_settings.xml
│ ├── misc.xml
│ ├── modules.xml
│ └── runConfigurations.xml
├── app
│ ├── .gitignore
│ ├── app-release.apk
│ ├── build.gradle
│ ├── proguard-rules.pro
│ └── src
│ │ ├── androidTest
│ │ └── java
│ │ │ └── demon
│ │ │ └── myunshell
│ │ │ └── ExampleInstrumentedTest.java
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── demon
│ │ │ │ └── myunshell
│ │ │ │ ├── ProxyApplication.java
│ │ │ │ └── RefInvoke.java
│ │ └── res
│ │ │ ├── layout
│ │ │ ├── activity_image.xml
│ │ │ └── activity_main.xml
│ │ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ │ └── values
│ │ │ ├── colors.xml
│ │ │ ├── strings.xml
│ │ │ └── styles.xml
│ │ └── test
│ │ └── java
│ │ └── demon
│ │ └── myunshell
│ │ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
├── README.md
└── Tools
├── DeMon.jks
├── shell.apk
├── shelldemo.apk
├── sign.bat
└── 说明.txt
/Demo/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/Demo/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Demo/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Demo/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/Demo/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Demo/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Demo/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Demo/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/Demo/app/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/app-release.apk
--------------------------------------------------------------------------------
/Demo/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.1"
6 | defaultConfig {
7 | applicationId "demon.demo"
8 | minSdkVersion 16
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:26.+'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | compile 'com.github.bumptech.glide:glide:3.6.1'
31 | }
32 |
--------------------------------------------------------------------------------
/Demo/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/Demo/app/src/androidTest/java/demon/demo/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package demon.demo;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("demon.demo", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Demo/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Demo/app/src/main/java/demon/demo/GlideUtil.java:
--------------------------------------------------------------------------------
1 | package demon.demo;
2 |
3 | import android.content.Context;
4 | import android.widget.ImageView;
5 |
6 | import com.bumptech.glide.Glide;
7 |
8 | /**
9 | * Created by DeMon on 2017/10/17.
10 | */
11 |
12 | public class GlideUtil {
13 |
14 | /**
15 | * 根据图片url将图片显示在img控件上
16 | *
17 | * @param context 所属的Context
18 | * @param url 图片url
19 | * @param img ImageView控件
20 | */
21 | public static void setImage(Context context, String url, ImageView img) {
22 | Glide.with(context).load(url).dontAnimate().fitCenter().placeholder(R.mipmap.ic_launcher_round).into(img);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Demo/app/src/main/java/demon/demo/ImageActivity.java:
--------------------------------------------------------------------------------
1 | package demon.demo;
2 |
3 | import android.content.IntentFilter;
4 | import android.net.ConnectivityManager;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.widget.ImageView;
8 |
9 | public class ImageActivity extends AppCompatActivity {
10 |
11 |
12 | private NetStateReceiver receiver = new NetStateReceiver();
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_image);
18 |
19 | IntentFilter filter = new IntentFilter();
20 | filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
21 | registerReceiver(receiver, filter);
22 | receiver.onReceive(this, null);
23 |
24 | ImageView image = (ImageView) findViewById(R.id.image);
25 | GlideUtil.setImage(this, "http://omuzv9mvf.bkt.clouddn.com/D.png", image);
26 | }
27 |
28 | @Override
29 | protected void onDestroy() {
30 | super.onDestroy();
31 | this.unregisterReceiver(receiver);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Demo/app/src/main/java/demon/demo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package demon.demo;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.TextView;
10 |
11 |
12 | public class MainActivity extends AppCompatActivity {
13 |
14 |
15 | @Override
16 | protected void onCreate(Bundle savedInstanceState) {
17 | super.onCreate(savedInstanceState);
18 | setContentView(R.layout.activity_main);
19 |
20 | TextView text = (TextView) findViewById(R.id.text);
21 | text.setText("当前包名为:" + getAppInfo());
22 |
23 | Button button = (Button) findViewById(R.id.button);
24 | button.setOnClickListener(new View.OnClickListener() {
25 | @Override
26 | public void onClick(View view) {
27 | startActivity(new Intent(MainActivity.this, ImageActivity.class));
28 | }
29 | });
30 | }
31 |
32 |
33 | /**
34 | * 获取当前包名
35 | *
36 | * @return
37 | */
38 | private String getAppInfo() {
39 | try {
40 | String pkName = this.getPackageName();
41 | return pkName;
42 | } catch (Exception e) {
43 | }
44 | return null;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Demo/app/src/main/java/demon/demo/MyApplication.java:
--------------------------------------------------------------------------------
1 | package demon.demo;
2 |
3 | import android.app.Application;
4 | import android.util.Log;
5 |
6 | public class MyApplication extends Application {
7 |
8 | @Override
9 | public void onCreate() {
10 | super.onCreate();
11 | Log.i("demo", "apk onCreate:" + this);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/Demo/app/src/main/java/demon/demo/NetStateReceiver.java:
--------------------------------------------------------------------------------
1 | package demon.demo;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.net.ConnectivityManager;
8 | import android.net.NetworkInfo;
9 |
10 | /**
11 | * Created by DeMon on 2017/10/17.
12 | */
13 |
14 | public class NetStateReceiver extends BroadcastReceiver {
15 |
16 | @Override
17 | public void onReceive(final Context context, Intent arg) {
18 | ConnectivityManager manager = (ConnectivityManager) context.
19 | getSystemService(Context.CONNECTIVITY_SERVICE);
20 | if (manager != null) {
21 | NetworkInfo gprs = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
22 | NetworkInfo wifi = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
23 | if (!gprs.isConnected() && !wifi.isConnected()) {
24 | AlertDialog.Builder ab = new AlertDialog.Builder(context);
25 | ab.setTitle("网络不可用");
26 | ab.setMessage("请检查网络状态!");
27 | ab.create().show();
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/Demo/app/src/main/res/layout/activity_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
--------------------------------------------------------------------------------
/Demo/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/Demo/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/Demo/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Demo
3 |
4 |
--------------------------------------------------------------------------------
/Demo/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Demo/app/src/test/java/demon/demo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package demon.demo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/Demo/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/Demo/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/Demo/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Demo/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/Demo/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Oct 18 08:24:28 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/Demo/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/Demo/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/Demo/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/DexShellTool/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/DexShellTool/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/DexShellTool/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/DexShellTool/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Android
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 | 1508229714273
397 |
398 |
399 | 1508229714273
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 | 1.8
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
--------------------------------------------------------------------------------
/DexShellTool/DexShellTool.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/DexShellTool/force/classes.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/DexShellTool/force/classes.dex
--------------------------------------------------------------------------------
/DexShellTool/force/demo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/DexShellTool/force/demo.apk
--------------------------------------------------------------------------------
/DexShellTool/force/shell.dex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/DexShellTool/force/shell.dex
--------------------------------------------------------------------------------
/DexShellTool/out/production/DexShellTool/DexShellTool.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/DexShellTool/out/production/DexShellTool/DexShellTool.class
--------------------------------------------------------------------------------
/DexShellTool/src/DexShellTool.java:
--------------------------------------------------------------------------------
1 | import java.io.*;
2 | import java.security.MessageDigest;
3 | import java.security.NoSuchAlgorithmException;
4 | import java.util.zip.Adler32;
5 |
6 | /**
7 | * Created by DeMon on 2017/10/17.
8 | */
9 | public class DexShellTool {
10 | /**
11 | * @param args
12 | */
13 | public static void main(String[] args) {
14 | // TODO Auto-generated method stub
15 | try {
16 | File payloadSrcFile = new File("force/demo.apk"); //需要加壳的程序
17 | System.out.println("apk size:"+payloadSrcFile.length());
18 | File unShellDexFile = new File("force/shell.dex"); //解壳dex
19 | byte[] payloadArray = encrpt(readFileBytes(payloadSrcFile));//以二进制形式读出apk,并进行加密处理//对源Apk进行加密操作
20 | byte[] unShellDexArray = readFileBytes(unShellDexFile);//以二进制形式读出dex
21 | int payloadLen = payloadArray.length;
22 | int unShellDexLen = unShellDexArray.length;
23 | int totalLen = payloadLen + unShellDexLen +4;//多出4字节是存放长度的。
24 | byte[] newdex = new byte[totalLen]; // 申请了新的长度
25 | //添加解壳代码
26 | System.arraycopy(unShellDexArray, 0, newdex, 0, unShellDexLen);//先拷贝dex内容
27 | //添加加密后的解壳数据
28 | System.arraycopy(payloadArray, 0, newdex, unShellDexLen, payloadLen);//再在dex内容后面拷贝apk的内容
29 | //添加解壳数据长度
30 | System.arraycopy(intToByte(payloadLen), 0, newdex, totalLen-4, 4);//最后4为长度
31 | //修改DEX file size文件头
32 | fixFileSizeHeader(newdex);
33 | //修改DEX SHA1 文件头
34 | fixSHA1Header(newdex);
35 | //修改DEX CheckSum文件头
36 | fixCheckSumHeader(newdex);
37 |
38 | String str = "force/classes.dex";
39 | File file = new File(str);
40 | if (!file.exists()) {
41 | file.createNewFile();
42 | }
43 |
44 | FileOutputStream localFileOutputStream = new FileOutputStream(str);
45 | localFileOutputStream.write(newdex);
46 | localFileOutputStream.flush();
47 | localFileOutputStream.close();
48 |
49 |
50 | } catch (Exception e) {
51 | e.printStackTrace();
52 | }
53 | }
54 |
55 | //直接返回数据,读者可以添加自己加密方法
56 | private static byte[] encrpt(byte[] srcdata){
57 | for(int i = 0;i= 0; i--) {
93 | b[i] = (byte) (number % 256);
94 | number >>= 8;
95 | }
96 | return b;
97 | }
98 |
99 | /**
100 | * 修改dex头 sha1值
101 | * @param dexBytes
102 | * @throws NoSuchAlgorithmException
103 | */
104 | private static void fixSHA1Header(byte[] dexBytes)
105 | throws NoSuchAlgorithmException {
106 | MessageDigest md = MessageDigest.getInstance("SHA-1");
107 | md.update(dexBytes, 32, dexBytes.length - 32);//从32为到结束计算sha--1
108 | byte[] newdt = md.digest();
109 | System.arraycopy(newdt, 0, dexBytes, 12, 20);//修改sha-1值(12-31)
110 | //输出sha-1值,可有可无
111 | String hexstr = "";
112 | for (int i = 0; i < newdt.length; i++) {
113 | hexstr += Integer.toString((newdt[i] & 0xff) + 0x100, 16)
114 | .substring(1);
115 | }
116 | System.out.println(hexstr);
117 | }
118 |
119 | /**
120 | * 修改dex头 file_size值
121 | * @param dexBytes
122 | */
123 | private static void fixFileSizeHeader(byte[] dexBytes) {
124 | //新文件长度
125 | byte[] newfs = intToByte(dexBytes.length);
126 | System.out.println(Integer.toHexString(dexBytes.length));
127 | byte[] refs = new byte[4];
128 | //高位在前,低位在前掉个个
129 | for (int i = 0; i < 4; i++) {
130 | refs[i] = newfs[newfs.length - 1 - i];
131 | System.out.println(Integer.toHexString(newfs[i]));
132 | }
133 | System.arraycopy(refs, 0, dexBytes, 32, 4);//修改(32-35)
134 | }
135 |
136 |
137 | /**
138 | * 以二进制读出文件内容
139 | * @param file
140 | * @return
141 | * @throws IOException
142 | */
143 | private static byte[] readFileBytes(File file) throws IOException {
144 | byte[] arrayOfByte = new byte[1024];
145 | ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
146 | FileInputStream fis = new FileInputStream(file);
147 | while (true) {
148 | int i = fis.read(arrayOfByte);
149 | if (i != -1) {
150 | localByteArrayOutputStream.write(arrayOfByte, 0, i);
151 | } else {
152 | return localByteArrayOutputStream.toByteArray();
153 | }
154 | }
155 | }
156 | }
157 |
--------------------------------------------------------------------------------
/MyUnshell/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/MyUnshell/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MyUnshell/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/MyUnshell/app/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/app-release.apk
--------------------------------------------------------------------------------
/MyUnshell/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "26.0.1"
6 | defaultConfig {
7 | applicationId "demon.myunshell"
8 | minSdkVersion 16
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:26.+'
28 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
29 | testCompile 'junit:junit:4.12'
30 | }
31 |
--------------------------------------------------------------------------------
/MyUnshell/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/MyUnshell/app/src/androidTest/java/demon/myunshell/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package demon.myunshell;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("demon.myunshell", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/java/demon/myunshell/ProxyApplication.java:
--------------------------------------------------------------------------------
1 | package demon.myunshell;
2 |
3 | import java.io.BufferedInputStream;
4 | import java.io.ByteArrayInputStream;
5 | import java.io.ByteArrayOutputStream;
6 | import java.io.DataInputStream;
7 | import java.io.File;
8 | import java.io.FileInputStream;
9 | import java.io.FileOutputStream;
10 | import java.io.IOException;
11 | import java.lang.ref.WeakReference;
12 | import java.lang.reflect.Method;
13 | import java.util.ArrayList;
14 | import java.util.HashMap;
15 | import java.util.Iterator;
16 | import java.util.zip.ZipEntry;
17 | import java.util.zip.ZipInputStream;
18 |
19 | import android.app.Application;
20 | import android.app.Instrumentation;
21 | import android.content.Context;
22 | import android.content.pm.ApplicationInfo;
23 | import android.content.pm.PackageManager;
24 | import android.content.pm.PackageManager.NameNotFoundException;
25 | import android.content.res.AssetManager;
26 | import android.content.res.Resources;
27 | import android.content.res.Resources.Theme;
28 | import android.os.Bundle;
29 | import android.util.ArrayMap;
30 | import android.util.Log;
31 | import dalvik.system.DexClassLoader;
32 |
33 | public class ProxyApplication extends Application{
34 | private static final String appkey = "APPLICATION_CLASS_NAME";
35 | private String apkFileName;
36 | private String odexPath;
37 | private String libPath;
38 |
39 | //这是context 赋值
40 | @Override
41 | protected void attachBaseContext(Context base) {
42 | super.attachBaseContext(base);
43 | try {
44 | //创建两个文件夹payload_odex,payload_lib 私有的,可写的文件目录
45 | File odex = this.getDir("demo_odex", MODE_PRIVATE);
46 | File libs = this.getDir("demo_lib", MODE_PRIVATE);
47 | odexPath = odex.getAbsolutePath();
48 | libPath = libs.getAbsolutePath();
49 | apkFileName = odex.getAbsolutePath() + "/shelldemo.apk";
50 | File dexFile = new File(apkFileName);
51 | Log.i("demo", "apk size:"+dexFile.length());
52 | if (!dexFile.exists())
53 | {
54 | dexFile.createNewFile(); //在payload_odex文件夹内,创建payload.apk
55 | // 读取程序classes.dex文件
56 | byte[] dexdata = this.readDexFileFromApk();
57 |
58 | // 分离出解壳后的apk文件已用于动态加载
59 | this.splitPayLoadFromDex(dexdata);
60 | }
61 | // 配置动态加载环境
62 | Object currentActivityThread = RefInvoke.invokeStaticMethod(
63 | "android.app.ActivityThread", "currentActivityThread",
64 | new Class[] {}, new Object[] {});//获取主线程对象 http://blog.csdn.net/myarrow/article/details/14223493
65 | String packageName = this.getPackageName();//当前apk的包名
66 | //下面两句不是太理解
67 | ArrayMap mPackages = (ArrayMap) RefInvoke.getFieldOjbect(
68 | "android.app.ActivityThread", currentActivityThread,
69 | "mPackages");
70 | WeakReference wr = (WeakReference) mPackages.get(packageName);
71 | //创建被加壳apk的DexClassLoader对象 加载apk内的类和本地代码(c/c++代码)
72 | DexClassLoader dLoader = new DexClassLoader(apkFileName, odexPath,
73 | libPath, (ClassLoader) RefInvoke.getFieldOjbect(
74 | "android.app.LoadedApk", wr.get(), "mClassLoader"));
75 | //base.getClassLoader(); 是不是就等同于 (ClassLoader) RefInvoke.getFieldOjbect()? 有空验证下//?
76 | //把当前进程的DexClassLoader 设置成了被加壳apk的DexClassLoader ----有点c++中进程环境的意思~~
77 | RefInvoke.setFieldOjbect("android.app.LoadedApk", "mClassLoader",
78 | wr.get(), dLoader);
79 |
80 | Log.i("demo","classloader:"+dLoader);
81 |
82 |
83 | } catch (Exception e) {
84 | Log.i("demo", "error:"+Log.getStackTraceString(e));
85 | e.printStackTrace();
86 | }
87 | }
88 |
89 | @Override
90 | public void onCreate() {
91 | {
92 | //loadResources(apkFileName);
93 |
94 | Log.i("demo", "onCreate");
95 | // 如果源应用配置有Appliction对象,则替换为源应用Applicaiton,以便不影响源程序逻辑。
96 | String appClassName = null;
97 | try {
98 | ApplicationInfo ai = this.getPackageManager()
99 | .getApplicationInfo(this.getPackageName(),
100 | PackageManager.GET_META_DATA);
101 | Bundle bundle = ai.metaData;
102 | if (bundle != null && bundle.containsKey("APPLICATION_CLASS_NAME")) {
103 | appClassName = bundle.getString("APPLICATION_CLASS_NAME");//className 是配置在xml文件中的。
104 | } else {
105 | Log.i("demo", "have no application class name");
106 | return;
107 | }
108 | } catch (NameNotFoundException e) {
109 | Log.i("demo", "error:"+Log.getStackTraceString(e));
110 | e.printStackTrace();
111 | }
112 | //有值的话调用该Applicaiton
113 | Object currentActivityThread = RefInvoke.invokeStaticMethod(
114 | "android.app.ActivityThread", "currentActivityThread",
115 | new Class[] {}, new Object[] {});
116 | Object mBoundApplication = RefInvoke.getFieldOjbect(
117 | "android.app.ActivityThread", currentActivityThread,
118 | "mBoundApplication");
119 | Object loadedApkInfo = RefInvoke.getFieldOjbect(
120 | "android.app.ActivityThread$AppBindData",
121 | mBoundApplication, "info");
122 | //把当前进程的mApplication 设置成了null
123 | RefInvoke.setFieldOjbect("android.app.LoadedApk", "mApplication",
124 | loadedApkInfo, null);
125 | Object oldApplication = RefInvoke.getFieldOjbect(
126 | "android.app.ActivityThread", currentActivityThread,
127 | "mInitialApplication");
128 | //http://www.codeceo.com/article/android-context.html
129 | ArrayList mAllApplications = (ArrayList) RefInvoke
130 | .getFieldOjbect("android.app.ActivityThread",
131 | currentActivityThread, "mAllApplications");
132 | mAllApplications.remove(oldApplication);//删除oldApplication
133 |
134 | ApplicationInfo appinfo_In_LoadedApk = (ApplicationInfo) RefInvoke
135 | .getFieldOjbect("android.app.LoadedApk", loadedApkInfo,
136 | "mApplicationInfo");
137 | ApplicationInfo appinfo_In_AppBindData = (ApplicationInfo) RefInvoke
138 | .getFieldOjbect("android.app.ActivityThread$AppBindData",
139 | mBoundApplication, "appInfo");
140 | appinfo_In_LoadedApk.className = appClassName;
141 | appinfo_In_AppBindData.className = appClassName;
142 | Application app = (Application) RefInvoke.invokeMethod(
143 | "android.app.LoadedApk", "makeApplication", loadedApkInfo,
144 | new Class[] { boolean.class, Instrumentation.class },
145 | new Object[] { false, null });//执行 makeApplication(false,null)
146 | RefInvoke.setFieldOjbect("android.app.ActivityThread",
147 | "mInitialApplication", currentActivityThread, app);
148 |
149 |
150 | ArrayMap mProviderMap = (ArrayMap) RefInvoke.getFieldOjbect(
151 | "android.app.ActivityThread", currentActivityThread,
152 | "mProviderMap");
153 | Iterator it = mProviderMap.values().iterator();
154 | while (it.hasNext()) {
155 | Object providerClientRecord = it.next();
156 | Object localProvider = RefInvoke.getFieldOjbect(
157 | "android.app.ActivityThread$ProviderClientRecord",
158 | providerClientRecord, "mLocalProvider");
159 | RefInvoke.setFieldOjbect("android.content.ContentProvider",
160 | "mContext", localProvider, app);
161 | }
162 |
163 | Log.i("demo", "app:"+app);
164 |
165 | app.onCreate();
166 | }
167 | }
168 |
169 | /**
170 | * 释放被加壳的apk文件,so文件
171 | * @param
172 | * @throws IOException
173 | */
174 | private void splitPayLoadFromDex(byte[] apkdata) throws IOException {
175 | int ablen = apkdata.length;
176 | //取被加壳apk的长度 这里的长度取值,对应加壳时长度的赋值都可以做些简化
177 | byte[] dexlen = new byte[4];
178 | System.arraycopy(apkdata, ablen - 4, dexlen, 0, 4);
179 | ByteArrayInputStream bais = new ByteArrayInputStream(dexlen);
180 | DataInputStream in = new DataInputStream(bais);
181 | int readInt = in.readInt();
182 | System.out.println(Integer.toHexString(readInt));
183 | byte[] newdex = new byte[readInt];
184 | //把被加壳apk内容拷贝到newdex中
185 | System.arraycopy(apkdata, ablen - 4 - readInt, newdex, 0, readInt);
186 | //这里应该加上对于apk的解密操作,若加壳是加密处理的话
187 | //?
188 |
189 | //对源程序Apk进行解密
190 | newdex = decrypt(newdex);
191 |
192 | //写入apk文件
193 | File file = new File(apkFileName);
194 | try {
195 | FileOutputStream localFileOutputStream = new FileOutputStream(file);
196 | localFileOutputStream.write(newdex);
197 | localFileOutputStream.close();
198 | } catch (IOException localIOException) {
199 | throw new RuntimeException(localIOException);
200 | }
201 |
202 | //分析被加壳的apk文件
203 | ZipInputStream localZipInputStream = new ZipInputStream(
204 | new BufferedInputStream(new FileInputStream(file)));
205 | while (true) {
206 | ZipEntry localZipEntry = localZipInputStream.getNextEntry();//不了解这个是否也遍历子目录,看样子应该是遍历的
207 | if (localZipEntry == null) {
208 | localZipInputStream.close();
209 | break;
210 | }
211 | //取出被加壳apk用到的so文件,放到 libPath中(data/data/包名/payload_lib)
212 | String name = localZipEntry.getName();
213 | if (name.startsWith("lib/") && name.endsWith(".so")) {
214 | File storeFile = new File(libPath + "/"
215 | + name.substring(name.lastIndexOf('/')));
216 | storeFile.createNewFile();
217 | FileOutputStream fos = new FileOutputStream(storeFile);
218 | byte[] arrayOfByte = new byte[1024];
219 | while (true) {
220 | int i = localZipInputStream.read(arrayOfByte);
221 | if (i == -1)
222 | break;
223 | fos.write(arrayOfByte, 0, i);
224 | }
225 | fos.flush();
226 | fos.close();
227 | }
228 | localZipInputStream.closeEntry();
229 | }
230 | localZipInputStream.close();
231 |
232 |
233 | }
234 |
235 | /**
236 | * 从apk包里面获取dex文件内容(byte)
237 | * @return
238 | * @throws IOException
239 | */
240 | private byte[] readDexFileFromApk() throws IOException {
241 | ByteArrayOutputStream dexByteArrayOutputStream = new ByteArrayOutputStream();
242 | ZipInputStream localZipInputStream = new ZipInputStream(
243 | new BufferedInputStream(new FileInputStream(
244 | this.getApplicationInfo().sourceDir)));
245 | while (true) {
246 | ZipEntry localZipEntry = localZipInputStream.getNextEntry();
247 | if (localZipEntry == null) {
248 | localZipInputStream.close();
249 | break;
250 | }
251 | if (localZipEntry.getName().equals("classes.dex")) {
252 | byte[] arrayOfByte = new byte[1024];
253 | while (true) {
254 | int i = localZipInputStream.read(arrayOfByte);
255 | if (i == -1)
256 | break;
257 | dexByteArrayOutputStream.write(arrayOfByte, 0, i);
258 | }
259 | }
260 | localZipInputStream.closeEntry();
261 | }
262 | localZipInputStream.close();
263 | return dexByteArrayOutputStream.toByteArray();
264 | }
265 |
266 |
267 | // //直接返回数据,读者可以添加自己解密方法
268 | private byte[] decrypt(byte[] srcdata) {
269 | for(int i=0;i
2 |
8 |
9 |
13 |
14 |
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ShellDemo
3 |
4 |
--------------------------------------------------------------------------------
/MyUnshell/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MyUnshell/app/src/test/java/demon/myunshell/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package demon.myunshell;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/MyUnshell/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/MyUnshell/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/MyUnshell/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/MyUnshell/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/MyUnshell/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Oct 17 17:02:04 CST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/MyUnshell/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/MyUnshell/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/MyUnshell/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Shell
2 |
3 | Android Apk加壳技术实战详解的相关代码。原文连接:
4 |
5 |
6 | 目录结构说明:
7 | 1.Demo:源apk,需要加密的demo.apk. Android Studio工程。
8 | 2.DexShellTool:dex文件加密工具,IDEA Java工程。
9 | 3.MyUnshell:壳程序,即shell.apk. Android Studio工程。
10 | 4.Tools:Apk重新签名工具及说明。
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Tools/DeMon.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Tools/DeMon.jks
--------------------------------------------------------------------------------
/Tools/shell.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Tools/shell.apk
--------------------------------------------------------------------------------
/Tools/shelldemo.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Tools/shelldemo.apk
--------------------------------------------------------------------------------
/Tools/sign.bat:
--------------------------------------------------------------------------------
1 | jarsigner -verbose -keystore DeMon.jks -storepass 123456 -keypass 123456 -sigfile CERT -digestalg SHA1 -sigalg MD5withRSA -signedjar shelldemo.apk shell.apk key
--------------------------------------------------------------------------------
/Tools/说明.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iDeMonnnnnn/Shell/dd3ba2ebfdb488596fcf5c1e96c51888f572b1fa/Tools/说明.txt
--------------------------------------------------------------------------------