forked from bmax121/BudHook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a693a45
Showing
98 changed files
with
3,308 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild |
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 26 | ||
defaultConfig { | ||
applicationId "com.bmax.budhook" | ||
minSdkVersion 21 | ||
targetSdkVersion 26 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'com.android.support:appcompat-v7:26.1.0' | ||
implementation 'com.android.support.constraint:constraint-layout:1.1.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'com.android.support.test:runner:1.0.1' | ||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' | ||
compile project(path: ':library') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# https://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
app/src/androidTest/java/com/bmax/budhook/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.bmax.budhook; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="https://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() throws Exception { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.bmax.budhook", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="https://schemas.android.com/apk/res/android" | ||
package="com.bmax.budhook"> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
<activity android:name=".MainActivity"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package com.bmax.budhook; | ||
|
||
import android.Manifest; | ||
import android.content.pm.PackageManager; | ||
import android.support.v4.app.ActivityCompat; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.Button; | ||
|
||
import java.lang.reflect.Method; | ||
|
||
import bmax.budhook.BudHelpers; | ||
import dalvik.system.DexClassLoader; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
public static final String TAG = "budhook"; | ||
|
||
private static final int REQUEST_EXTERNAL_STORAGE = 1; | ||
private static String[] PERMISSIONS_STORAGE = { | ||
Manifest.permission.READ_EXTERNAL_STORAGE, | ||
Manifest.permission.WRITE_EXTERNAL_STORAGE}; | ||
|
||
|
||
private Button btn_test ; | ||
private Button btn_hook ; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
btn_hook = (Button) findViewById(R.id.btn_hook); | ||
btn_test = (Button) findViewById(R.id.btn_test); | ||
|
||
int permission = ActivityCompat.checkSelfPermission(this, | ||
Manifest.permission.READ_EXTERNAL_STORAGE); | ||
|
||
if (permission != PackageManager.PERMISSION_GRANTED) { | ||
//如果应用程序没有权限,则会提示用户授予权限 | ||
ActivityCompat.requestPermissions(this, PERMISSIONS_STORAGE, | ||
REQUEST_EXTERNAL_STORAGE); | ||
} | ||
|
||
|
||
|
||
BudHelpers.init(getBaseContext()); | ||
|
||
|
||
ClassLoader classLoader = getClassLoader(); | ||
|
||
final DexClassLoader dexClassLoader = new DexClassLoader("/sdcard/appplugin-debug.apk", | ||
getCodeCacheDir().getAbsolutePath(), null, classLoader); | ||
|
||
Log.d(TAG,dexClassLoader.toString()); | ||
|
||
btn_hook.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
|
||
try { | ||
Class demo = Class.forName("bmax.budhook.demo.BudHookDemo", true, dexClassLoader); | ||
|
||
Method startHook = demo.getMethod("startHook",ClassLoader.class); | ||
|
||
startHook.invoke(null,getClassLoader()); | ||
|
||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
}); | ||
|
||
btn_test.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
runTestFun(MainActivity.this); | ||
} | ||
}); | ||
|
||
} | ||
|
||
public static void runTestFun(MainActivity thiz){ | ||
|
||
|
||
test1(1,2,'c'); | ||
|
||
|
||
long ret = thiz.test2("test2 arg1","test2 arg2","test2 arg3","test2 arg4","test2 arg5",new TestClass("constructor test")); | ||
Log.d(TAG,"test2 ret" + Long.toString(ret)); | ||
|
||
try { | ||
thiz.test3("def"); | ||
} catch (Throwable e) { | ||
Log.d(TAG,e.toString()); | ||
} | ||
} | ||
|
||
public static void test1(int arg1,double arg2,char arg3){ | ||
Log.d(TAG,"arg1:" + arg1 + " arg2:" + arg2 +" arg3:" + arg3); | ||
} | ||
|
||
public long test2(String arg1,String arg2,String arg3,String arg4,String arg5,TestClass arg6){ | ||
|
||
return 1111; | ||
} | ||
|
||
public void test3(Object a) throws Exception{ | ||
Log.d(TAG,"origin call test3" ); | ||
throw new Exception("origin exception"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.bmax.budhook; | ||
|
||
import android.util.Log; | ||
|
||
/** | ||
* Created by bmax on 2018/4/13. | ||
*/ | ||
|
||
public class TestClass { | ||
|
||
public TestClass(String s){ | ||
Log.d("budhook","origin call constructor"); | ||
} | ||
@Override | ||
public String toString(){ | ||
return "origin TestClass toString()"; | ||
} | ||
} |
Oops, something went wrong.