FDex2 core code MainHook

tags: Shelling

package com.ppma.xposed;
 
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Method;
 
import de.robv.android.xposed.IXposedHookLoadPackage;
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 de.robv.android.xposed.callbacks.XC_LoadPackage;
 
public class MainHook implements IXposedHookLoadPackage {
 
    XSharedPreferences xsp;
    Class Dex;
    Method Dex_getBytes;
    Method getDex;
    String packagename;
 
 
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        xsp = new XSharedPreferences("com.ppma.appinfo", "User");
        xsp.makeWorldReadable();
        xsp.reload();
        initRefect();
        packagename = xsp.getString("packagename", null);
        XposedBridge.log ( "setting package name:" + packagename);
        if ((!lpparam.packageName.equals(packagename))||packagename==null) {
                         XposedBridge.log ( "current or inconsistent package and the package name called empty set");
            return;
        }
                 XposedBridge.log ( "target package name:" + lpparam.packageName);
        String str = "java.lang.ClassLoader";
        String str2 = "loadClass";
 
        XposedHelpers.findAndHookMethod(str, lpparam.classLoader, str2, String.class, Boolean.TYPE, new XC_MethodHook() {
            protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                super.afterHookedMethod(param);
                Class cls = (Class) param.getResult();
                if (cls == null) {
                    //XposedBridge.log("cls == null");
                    return;
                }
                String name = cls.getName();
                                 XposedBridge.log ( "current class name:" + name);
                byte[] bArr = (byte[]) Dex_getBytes.invoke(getDex.invoke(cls, new Object[0]), new Object[0]);
                if (bArr == null) {
                                         XposedBridge.log ( "data is empty: return");
                    return;
                }
                                 XposedBridge.log ( "start writing data");
                String dex_path = "/data/data/" + packagename + "/" + packagename + "_" + bArr.length + ".dex";
                XposedBridge.log(dex_path);
                File file = new File(dex_path);
                if (file.exists()) return;
                writeByte(bArr, file.getAbsolutePath());
            }
            } );
    }
 
    public void initRefect() {
        try {
            Dex = Class.forName("com.android.dex.Dex");
            Dex_getBytes = Dex.getDeclaredMethod("getBytes", new Class[0]);
            getDex = Class.forName("java.lang.Class").getDeclaredMethod("getDex", new Class[0]);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
 
    }
 
    public  void writeByte(byte[] bArr, String str) {
        try {
            OutputStream outputStream = new FileOutputStream(str);
            outputStream.write(bArr);
            outputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
                         XposedBridge.log ( "Failed to write file");
        }
    }
}

 

Intelligent Recommendation

Jasper report core code

Without a configuration file, the configuration is done by a colleague. Chinese output seems to be a bit problematic, but it is generally implemented....

Handler core code analysis

1 Looper.prepare 2 new Handler() 3 Get the message 4 Send a message 5 response handler handlerMessage...

Spring core source code

ClassUtils. IdGenerator It has 3 implementation classes, SimpleIdGenerator, JdkIdGenerator, AlternativeJdkIdGenerator CollectionUtils: ConcurrencyThrottleSupport: Control concurrency, visible Concurre...

AI core code

PTA 04: (ladder race)AI core code First, the topic This question requires you to implement a simple version of the AI ​​English Q&A program. The rules are: Regardless of what the user says, first ...

More Recommendation

jQuery source code - core

I recently spent some time looking at the source code of jQuery. The following part is my extraction of the core part of the source code. This will give a clearer picture of the structure of jQuery it...

javaWeb core code

Article directory 1, global exception handling 2, the comment function is implemented 3, grab the coupon code 3, hase service 4, permission interception Create a business Consumption kafka core code 1...

TextField search core code

Core search code Search for markedTextRange and then perform network loading based on the search time period...

Debug .NET CORE code

Foreword Core has also been used for a long time, and found that many small partners do not know how to debug the core code. As you can imagine, when you used mvc, you don't need to release the code. ...

AJAX core code

AJAX core code is only 4 steps Create AJAX core object XMLHttpRequest (built-in browser, can be used directly) Registration callback function Open the browser and server channel Send an AJAX request T...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top