Skip to content

Commit

Permalink
msic
Browse files Browse the repository at this point in the history
  • Loading branch information
coderstory committed Dec 14, 2020
1 parent 9e89670 commit 8100a9b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,5 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'eu.chainfire:libsuperuser:1.0.0.201704021214'
compileOnly 'de.robv.android.xposed:api:82'
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="toolkit.coderstory.com.toolkit">
package="com.coderstory.toolkit">

<application
android:allowBackup="true"
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/toolkit/coderstory/CorePatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

import android.content.pm.Signature;

import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage;

Expand All @@ -23,11 +25,16 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage {
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam loadPackageParam) throws IllegalAccessException, InvocationTargetException, InstantiationException {

if (("android".equals(loadPackageParam.packageName)) && (loadPackageParam.processName.equals("android"))) {
File file = (File) XposedHelpers.getObjectField(prefs, "mFile");
XposedBridge.log("file"+file.getAbsolutePath());
XposedBridge.log("downgrade" + prefs.getBoolean("downgrade", true));
XposedBridge.log("authcreak" + prefs.getBoolean("authcreak", true));
XposedBridge.log("digestCreak" + prefs.getBoolean("digestCreak", true));
// 允许降级
if (prefs.getBoolean("downgrade", false)) {
if (prefs.getBoolean("downgrade", true)) {
hookAllMethods("com.android.server.pm.PackageManagerService", loadPackageParam.classLoader, "checkDowngrade", XC_MethodReplacement.returnConstant(null));
}
if (prefs.getBoolean("authcreak", false)) {
if (prefs.getBoolean("authcreak", true)) {
// apk内文件修改后 digest校验会失败
hookAllMethods("android.util.jar.StrictJarVerifier", loadPackageParam.classLoader, "verifyMessageDigest", XC_MethodReplacement.returnConstant(true));
hookAllMethods("android.util.jar.StrictJarVerifier", loadPackageParam.classLoader, "verify", XC_MethodReplacement.returnConstant(true));
Expand Down Expand Up @@ -82,7 +89,7 @@ public void afterHookedMethod(MethodHookParam methodHookParam) throws Throwable
}
});
}
if (prefs.getBoolean("digestCreak", false)) {
if (prefs.getBoolean("digestCreak", true)) {
//New package has a different signature
//处理覆盖安装但签名不一致
Class<?> signingDetails = XposedHelpers.findClass("android.content.pm.PackageParser.SigningDetails", loadPackageParam.classLoader);
Expand Down
25 changes: 13 additions & 12 deletions app/src/main/java/toolkit/coderstory/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
package toolkit.coderstory;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Base64;
import android.util.Log;
import android.view.View;
import android.widget.Switch;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import com.coderstory.toolkit.R;

import java.io.File;
import java.lang.reflect.Field;

import eu.chainfire.libsuperuser.Shell;
import toolkit.coderstory.com.toolkit.R;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -61,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {
});

((Switch) $(R.id.authcreak)).setChecked(getPrefs().getBoolean("authcreak", true));
((Switch) $(R.id.digestCreak)).setChecked(getPrefs().getBoolean("digestCreak", false));
((Switch) $(R.id.digestCreak)).setChecked(getPrefs().getBoolean("digestCreak", true));
((Switch) $(R.id.downgrade)).setChecked(getPrefs().getBoolean("downgrade", true));
((Switch) $(R.id.hideicon)).setChecked(getPrefs().getBoolean("hideIcon", false));

Expand Down Expand Up @@ -97,7 +89,16 @@ protected SharedPreferences.Editor getEditor() {
}

protected SharedPreferences getPrefs() {
SharedPreferences prefs = getSharedPreferences("conf.xml", Context.MODE_PRIVATE);
SharedPreferences prefs = getSharedPreferences("conf", Context.MODE_PRIVATE);
try {
Field mfile = Class.forName("android.app.SharedPreferencesImpl").getDeclaredField("mFile");
mfile.setAccessible(true);
File file = (File) mfile.get(prefs);
Log.d("xxxxx",file.getAbsolutePath());

} catch (NoSuchFieldException | IllegalAccessException | ClassNotFoundException e) {
e.printStackTrace();
}
return prefs;
}
}
6 changes: 4 additions & 2 deletions app/src/main/java/toolkit/coderstory/XposedHelper.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package toolkit.coderstory;


import com.coderstory.toolkit.BuildConfig;

import java.util.Set;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XSharedPreferences;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
import toolkit.coderstory.com.toolkit.BuildConfig;



public class XposedHelper {
protected XSharedPreferences prefs = new XSharedPreferences("com.coderstory.toolkit", "config");
protected XSharedPreferences prefs = new XSharedPreferences("com.coderstory.toolkit", "conf");

{
prefs.makeWorldReadable();
Expand Down

0 comments on commit 8100a9b

Please sign in to comment.