StubApplication.java 源代码


package org.uyckjce.game;

import android.app.Application;
import android.app.Instrumentation;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Base64;
import dalvik.system.DexClassLoader;
import java.io.File;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import kotlin.coroutines.jvm.internal.a;
import kotlin.coroutines.jvm.internal.c;

public class StubApplication extends Application {
    public Application a;

    @Override
    public void attachBaseContext(Context context) {
        PackageInfo packageInfo;
        Application application;
        List list;
        String str = "";
        super.attachBaseContext(context);
        Context baseContext = getBaseContext();
        try {
            File a = a.a(baseContext);
            if (a.exists()) {
                AssetManager assetManager = (AssetManager) AssetManager.class.newInstance();
                Method method = AssetManager.class.getMethod(new String(Base64.decode("YWRkQXNzZXRQYXRo", 0)), String.class);
                method.invoke(assetManager, a.getAbsolutePath());
                method.invoke(assetManager, baseContext.getPackageCodePath());
                c cVar = new c(baseContext.getResources(), new Resources(assetManager, baseContext.getResources().getDisplayMetrics(), baseContext.getResources().getConfiguration()));
                Field declaredField = baseContext.getClass().getDeclaredField(new String(Base64.decode("bVJlc291cmNlcw==", 0)));
                declaredField.setAccessible(true);
                declaredField.set(baseContext, cVar);
                Field declaredField2 = baseContext.getClass().getDeclaredField(new String(Base64.decode("bVBhY2thZ2VJbmZv", 0)));
                declaredField2.setAccessible(true);
                Object obj = declaredField2.get(baseContext);
                Field declaredField3 = obj.getClass().getDeclaredField(new String(Base64.decode("bVJlc291cmNlcw==", 0)));
                declaredField3.setAccessible(true);
                declaredField3.set(obj, cVar);
                Field declaredField4 = obj.getClass().getDeclaredField(new String(Base64.decode("bVJlc0Rpcg==", 0)));
                declaredField4.setAccessible(true);
                declaredField4.set(obj, a.getAbsolutePath());
                Field declaredField5 = baseContext.getClass().getDeclaredField(new String(Base64.decode("bVRoZW1l", 0)));
                declaredField5.setAccessible(true);
                declaredField5.set(baseContext, null);
            }
            try {
                packageInfo = getPackageManager().getPackageInfo(getPackageName(), 16384);
            } catch (Exception e) {
                e.printStackTrace();
                packageInfo = null;
            }
            int i = packageInfo == null ? 0 : packageInfo.versionCode;
            try {
                File dir = getDir("payload_odex", 0);
                String absolutePath = dir.getAbsolutePath();
                String format = String.format(Locale.CHINESE, "%s/AppDex_%d.apk", absolutePath, Integer.valueOf(i));
                File file = new File(format);
                if (!file.exists()) {
                    File[] listFiles = dir.listFiles();
                    if (listFiles != null && listFiles.length > 0) {
                        for (File file2 : listFiles) {
                            file2.delete();
                        }
                    }
                    file.createNewFile();
                    a.a(a.a(getApplicationInfo().sourceDir), format);
                }
                WeakReference weakReference = (WeakReference) ((ArrayMap) a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQ=", 0)), a.a(), new String(Base64.decode("bVBhY2thZ2Vz", 0)))).get(getPackageName());
                DexClassLoader dexClassLoader = new DexClassLoader(format, absolutePath, getApplicationInfo().nativeLibraryDir, (ClassLoader) a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuTG9hZGVkQXBr", 0)), weakReference.get(), new String(Base64.decode("bUNsYXNzTG9hZGVy", 0))));
                a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuTG9hZGVkQXBr", 0)), new String(Base64.decode("bUNsYXNzTG9hZGVy", 0)), weakReference.get(), dexClassLoader);
                Thread.currentThread().setContextClassLoader(dexClassLoader);
                try {
                    Bundle bundle = getPackageManager().getApplicationInfo(getPackageName(), 128).metaData;
                    if (bundle != null && bundle.containsKey("APPLICATION_CLASS_NAME")) {
                        str = bundle.getString("APPLICATION_CLASS_NAME");
                    }
                } catch (PackageManager.NameNotFoundException e2) {
                    e2.printStackTrace();
                }
                if (TextUtils.isEmpty(str)) {
                    application = null;
                } else {
                    Object a2 = a.a();
                    Object a3 = a.a(a2);
                    Object a4 = a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQkQXBwQmluZERhdGE=", 0)), a3, "info");
                    ((ApplicationInfo) a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuTG9hZGVkQXBr", 0)), a4, new String(Base64.decode("bUFwcGxpY2F0aW9uSW5mbw==", 0)))).className = str;
                    String str2 = new String(Base64.decode("YW5kcm9pZC5hcHAuTG9hZGVkQXBr", 0));
                    String str3 = new String(Base64.decode("bWFrZUFwcGxpY2F0aW9u", 0));
                    Class<?>[] clsArr = {Boolean.TYPE, Instrumentation.class};
                    Object obj2 = null;
                    Object[] objArr = {Boolean.FALSE, null};
                    try {
                        Method declaredMethod = Class.forName(str2).getDeclaredMethod(str3, clsArr);
                        declaredMethod.setAccessible(true);
                        obj2 = declaredMethod.invoke(a4, objArr);
                    } catch (Exception e3) {
                        e3.printStackTrace();
                    }
                    application = (Application) obj2;
                    if (application != null && (list = (List) a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQkQXBwQmluZERhdGE=", 0)), a3, new String(Base64.decode("cHJvdmlkZXJz", 0)))) != null) {
                        Object[] objArr2 = {application, list};
                        try {
                            Method declaredMethod2 = Class.forName(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQ=", 0))).getDeclaredMethod(new String(Base64.decode("aW5zdGFsbENvbnRlbnRQcm92aWRlcnM=", 0)), Context.class, List.class);
                            declaredMethod2.setAccessible(true);
                            declaredMethod2.invoke(a2, objArr2);
                        } catch (Exception e4) {
                            e4.printStackTrace();
                        }
                        list.clear();
                    }
                }
                this.a = application;
            } catch (Exception e5) {
                throw new RuntimeException(e5);
            }
        } catch (Exception e6) {
            throw new RuntimeException(e6);
        }
    }

    @Override
    public AssetManager getAssets() {
        return super.getAssets();
    }

    @Override
    public Resources getResources() {
        return super.getResources();
    }

    @Override
    public Resources.Theme getTheme() {
        return super.getTheme();
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Application application = this.a;
        if (application == null) {
            return;
        }
        String name = application.getClass().getName();
        Object a = a.a();
        Object a2 = a.a(a);
        a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuTG9hZGVkQXBr", 0)), new String(Base64.decode("bUFwcGxpY2F0aW9u", 0)), a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQkQXBwQmluZERhdGE=", 0)), a2, "info"), application);
        ((ArrayList) a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQ=", 0)), a, new String(Base64.decode("bUFsbEFwcGxpY2F0aW9ucw==", 0)))).remove(a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQ=", 0)), a, new String(Base64.decode("bUluaXRpYWxBcHBsaWNhdGlvbg==", 0))));
        a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQ=", 0)), new String(Base64.decode("bUluaXRpYWxBcHBsaWNhdGlvbg==", 0)), a, application);
        ((ApplicationInfo) a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQkQXBwQmluZERhdGE=", 0)), a2, "appInfo")).className = name;
        Iterator it = ((ArrayMap) a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQ=", 0)), a, new String(Base64.decode("bVByb3ZpZGVyTWFw", 0)))).values().iterator();
        while (it.hasNext()) {
            a.a(new String(Base64.decode("YW5kcm9pZC5jb250ZW50LkNvbnRlbnRQcm92aWRlcg==", 0)), new String(Base64.decode("bUNvbnRleHQ=", 0)), a.a(new String(Base64.decode("YW5kcm9pZC5hcHAuQWN0aXZpdHlUaHJlYWQkUHJvdmlkZXJDbGllbnRSZWNvcmQ=", 0)), it.next(), new String(Base64.decode("bUxvY2FsUHJvdmlkZXI=", 0))), application);
        }
        application.onCreate();
    }
}