Guest User

Chinks DRM ninebot

a guest
Jul 4th, 2018
171
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.secneo.apkwrapper;
  2.  
  3. import android.app.Application;
  4. import android.content.Context;
  5. import android.content.res.Configuration;
  6. import android.os.Build;
  7. import android.util.ArrayMap;
  8. import android.view.LayoutInflater;
  9. import java.lang.reflect.Field;
  10. import java.lang.reflect.InvocationTargetException;
  11. import java.lang.reflect.Method;
  12. import java.util.Map.Entry;
  13.  
  14. /* compiled from: ApplicationTemplate */
  15. public class ApplicationWrapper extends Application {
  16.     public static Application realApplication = null;
  17.  
  18.     static {
  19.         FilesFileObserver.miui_notify();
  20.         System.loadLibrary("DexHelper");
  21.         if (Helper.PPATH != null) {
  22.             System.load(Helper.PPATH);
  23.         }
  24.     }
  25.  
  26.     protected void attachBaseContext(Context context) {
  27.         super.attachBaseContext(context);
  28.         try {
  29.             realApplication = (Application) getClassLoader().loadClass(Helper.APPNAME).newInstance();
  30.             Helper.attach(realApplication, context);
  31.         } catch (Exception e) {
  32.             realApplication = null;
  33.         }
  34.     }
  35.  
  36.     public void onCreate() {
  37.         super.onCreate();
  38.         try {
  39.             huawei_share();
  40.         } catch (Exception e) {
  41.         }
  42.         if (realApplication != null) {
  43.             Helper.attach(realApplication, null);
  44.             realApplication.onCreate();
  45.             LayoutInflater factory = LayoutInflater.from(getApplicationContext());
  46.             try {
  47.                 Field field = LayoutInflater.class.getDeclaredField("mContext");
  48.                 field.setAccessible(true);
  49.                 field.set(factory, realApplication);
  50.             } catch (Exception e2) {
  51.             }
  52.         }
  53.     }
  54.  
  55.     public void onTerminate() {
  56.         super.onTerminate();
  57.         if (realApplication != null) {
  58.             realApplication.onTerminate();
  59.         }
  60.     }
  61.  
  62.     public void onConfigurationChanged(Configuration newConfig) {
  63.         super.onConfigurationChanged(newConfig);
  64.         if (realApplication != null) {
  65.             realApplication.onConfigurationChanged(newConfig);
  66.         }
  67.     }
  68.  
  69.     public void onLowMemory() {
  70.         super.onLowMemory();
  71.         if (realApplication != null) {
  72.             realApplication.onLowMemory();
  73.         }
  74.     }
  75.  
  76.     public void onTrimMemory(int level) {
  77.         try {
  78.             super.onTrimMemory(level);
  79.             if (realApplication != null) {
  80.                 realApplication.onTrimMemory(level);
  81.             }
  82.         } catch (Exception e) {
  83.         }
  84.     }
  85.  
  86.     public void huawei_share() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
  87.         if (Build.BRAND.equalsIgnoreCase("Huawei") || Build.BRAND.equalsIgnoreCase("Honor")) {
  88.             Class at_cls = Class.forName("android.app.ActivityThread");
  89.             Object ctml_obj = at_cls.getDeclaredMethod("getSystemContext", new Class[0]).invoke(at_cls.getDeclaredMethod("currentActivityThread", new Class[0]).invoke(at_cls, new Object[0]), new Object[0]);
  90.             Field sSharedPrefs_fld = Class.forName("android.app.ContextImpl").getDeclaredField("sSharedPrefs");
  91.             sSharedPrefs_fld.setAccessible(true);
  92.             ArrayMap<String, Object> spr_obj = sSharedPrefs_fld.get(ctml_obj);
  93.             if (!spr_obj.getClass().toString().contains("HashMap") && spr_obj != null && !"{}".endsWith(spr_obj.toString())) {
  94.                 for (Entry entry : ((ArrayMap) spr_obj.get(Helper.PKGNAME)).entrySet()) {
  95.                     Object key = entry.getKey();
  96.                     Object val = entry.getValue();
  97.                     Class SharedPreferencesImpl_cls = val.getClass();
  98.                     Field mMode_filed = SharedPreferencesImpl_cls.getDeclaredField("mMode");
  99.                     mMode_filed.setAccessible(true);
  100.                     Object mMode_value = mMode_filed.get(val);
  101.                     Boolean mMode_value2 = Boolean.valueOf(false);
  102.                     Method loadFDL_mth = SharedPreferencesImpl_cls.getDeclaredMethod("startLoadFromDisk", new Class[0]);
  103.                     loadFDL_mth.setAccessible(true);
  104.                     loadFDL_mth.invoke(val, new Object[0]);
  105.                 }
  106.             }
  107.         }
  108.     }
  109. }
  110. package com.secneo.apkwrapper;
  111.  
  112. public final class BuildConfig {
  113.     public static final boolean DEBUG = false;
  114. }
  115. package com.secneo.apkwrapper;
  116.  
  117. public final class C0000R {
  118.  
  119.     public static final class attr {
  120.     }
  121.  
  122.     public static final class dimen {
  123.         public static final int activity_horizontal_margin = 2130968576;
  124.         public static final int activity_vertical_margin = 2130968577;
  125.     }
  126.  
  127.     public static final class drawable {
  128.         public static final int ic_launcher = 2130837504;
  129.     }
  130.  
  131.     public static final class id {
  132.         public static final int action_settings = 2131230720;
  133.     }
  134.  
  135.     public static final class layout {
  136.         public static final int activity_main = 2130903040;
  137.     }
  138.  
  139.     public static final class menu {
  140.         public static final int main = 2131165184;
  141.     }
  142.  
  143.     public static final class string {
  144.         public static final int action_settings = 2131034113;
  145.         public static final int app_name = 2131034112;
  146.         public static final int hello_world = 2131034114;
  147.     }
  148.  
  149.     public static final class style {
  150.         public static final int AppBaseTheme = 2131099648;
  151.         public static final int AppTheme = 2131099649;
  152.     }
  153. }
  154. package com.secneo.apkwrapper;
  155.  
  156. import android.os.Build.VERSION;
  157. import dalvik.system.DexFile;
  158. import java.io.File;
  159. import java.io.IOException;
  160. import java.lang.reflect.Array;
  161. import java.lang.reflect.Field;
  162. import java.lang.reflect.InvocationTargetException;
  163. import java.lang.reflect.Method;
  164. import java.util.ArrayList;
  165. import java.util.Arrays;
  166. import java.util.Iterator;
  167. import java.util.List;
  168. import java.util.ListIterator;
  169. import java.util.zip.ZipFile;
  170.  
  171. public class DexInstall {
  172.     private static ArrayList<DexFile> oldDexFiles = new ArrayList();
  173.  
  174.     private static final class V14 {
  175.         private V14() {
  176.         }
  177.  
  178.         private static void install(ClassLoader loader, List<File> additionalClassPathEntries, File optimizedDirectory) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, InvocationTargetException, NoSuchMethodException {
  179.             Object dexPathList = DexInstall.findField(loader, "pathList").get(loader);
  180.             DexInstall.expandFieldArray(dexPathList, "dexElements", makeDexElements(dexPathList, new ArrayList(additionalClassPathEntries), optimizedDirectory));
  181.         }
  182.  
  183.         private static Object[] makeDexElements(Object dexPathList, ArrayList<File> files, File optimizedDirectory) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  184.             return (Object[]) DexInstall.findMethod(dexPathList, "makeDexElements", ArrayList.class, File.class).invoke(dexPathList, new Object[]{files, optimizedDirectory});
  185.         }
  186.     }
  187.  
  188.     private static final class V19 {
  189.         private V19() {
  190.         }
  191.  
  192.         private static void install(ClassLoader loader, List<File> additionalClassPathEntries, File optimizedDirectory) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, InvocationTargetException, NoSuchMethodException {
  193.             Object dexPathList = DexInstall.findField(loader, "pathList").get(loader);
  194.             ArrayList<IOException> suppressedExceptions = new ArrayList();
  195.             DexInstall.expandFieldArray(dexPathList, "dexElements", makeDexElements(dexPathList, new ArrayList(additionalClassPathEntries), optimizedDirectory, suppressedExceptions));
  196.             if (suppressedExceptions.size() > 0) {
  197.                 Iterator i$ = suppressedExceptions.iterator();
  198.                 while (i$.hasNext()) {
  199.                     ((IOException) i$.next()).printStackTrace(System.out);
  200.                 }
  201.                 Field suppressedExceptionsField = DexInstall.findField(loader, "dexElementsSuppressedExceptions");
  202.                 IOException[] dexElementsSuppressedExceptions = (IOException[]) suppressedExceptionsField.get(loader);
  203.                 if (dexElementsSuppressedExceptions == null) {
  204.                     dexElementsSuppressedExceptions = (IOException[]) suppressedExceptions.toArray(new IOException[suppressedExceptions.size()]);
  205.                 } else {
  206.                     IOException[] combined = new IOException[(suppressedExceptions.size() + dexElementsSuppressedExceptions.length)];
  207.                     suppressedExceptions.toArray(combined);
  208.                     System.arraycopy(dexElementsSuppressedExceptions, 0, combined, suppressedExceptions.size(), dexElementsSuppressedExceptions.length);
  209.                     dexElementsSuppressedExceptions = combined;
  210.                 }
  211.                 suppressedExceptionsField.set(loader, dexElementsSuppressedExceptions);
  212.             }
  213.         }
  214.  
  215.         private static Object[] makeDexElements(Object dexPathList, ArrayList<File> files, File optimizedDirectory, ArrayList<IOException> suppressedExceptions) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
  216.             Method makeDexElements = null;
  217.             try {
  218.                 makeDexElements = DexInstall.findMethod(dexPathList, "makeDexElements", ArrayList.class, File.class, ArrayList.class);
  219.             } catch (Exception e) {
  220.             }
  221.             if (makeDexElements == null) {
  222.                 try {
  223.                     makeDexElements = DexInstall.findMethod(dexPathList, "makePathElements", List.class, File.class, List.class);
  224.                 } catch (Exception e2) {
  225.                 }
  226.             }
  227.             return (Object[]) makeDexElements.invoke(dexPathList, new Object[]{files, optimizedDirectory, suppressedExceptions});
  228.         }
  229.     }
  230.  
  231.     private static final class V4 {
  232.         private V4() {
  233.         }
  234.  
  235.         private static void install(ClassLoader loader, List<File> additionalClassPathEntries) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, IOException {
  236.             int extraSize = additionalClassPathEntries.size();
  237.             Field pathField = DexInstall.findField(loader, "path");
  238.             StringBuilder path = new StringBuilder((String) pathField.get(loader));
  239.             String[] extraPaths = new String[extraSize];
  240.             File[] extraFiles = new File[extraSize];
  241.             ZipFile[] extraZips = new ZipFile[extraSize];
  242.             DexFile[] extraDexs = new DexFile[extraSize];
  243.             ListIterator<File> iterator = additionalClassPathEntries.listIterator();
  244.             while (iterator.hasNext()) {
  245.                 File additionalEntry = (File) iterator.next();
  246.                 String entryPath = additionalEntry.getAbsolutePath();
  247.                 path.append(':').append(entryPath);
  248.                 int index = iterator.previousIndex();
  249.                 extraPaths[index] = entryPath;
  250.                 extraFiles[index] = additionalEntry;
  251.                 extraZips[index] = new ZipFile(additionalEntry);
  252.                 extraDexs[index] = DexFile.loadDex(entryPath, entryPath + ".dex", 0);
  253.             }
  254.             pathField.set(loader, path.toString());
  255.             DexInstall.expandFieldArray(loader, "mPaths", extraPaths);
  256.             DexInstall.expandFieldArray(loader, "mFiles", extraFiles);
  257.             DexInstall.expandFieldArray(loader, "mZips", extraZips);
  258.             DexInstall.expandFieldArray(loader, "mDexs", extraDexs);
  259.         }
  260.     }
  261.  
  262.     public static void install(ClassLoader loader, String dex_path) {
  263.         try {
  264.             installSecondaryDexes(loader, null, Arrays.asList(new File[]{new File(dex_path)}));
  265.         } catch (Exception ex) {
  266.             ex.printStackTrace(System.out);
  267.         }
  268.     }
  269.  
  270.     public static void install(ClassLoader loader, String dex_path, String dexDir) {
  271.         try {
  272.             installSecondaryDexes(loader, new File(dexDir), Arrays.asList(new File[]{new File(dex_path)}));
  273.         } catch (Exception ex) {
  274.             ex.printStackTrace(System.out);
  275.         }
  276.     }
  277.  
  278.     public static void install(Object dexPathList) {
  279.         try {
  280.             ArrayList<File> additionalClassPathEntries = new ArrayList();
  281.             Field dexElement = findField(dexPathList, "dexElements");
  282.             for (Object element : (Object[]) dexElement.get(dexPathList)) {
  283.                 DexFile dexFile = (DexFile) findField(element, "dexFile").get(element);
  284.                 if (dexFile != null) {
  285.                     additionalClassPathEntries.add(new File(dexFile.getName()));
  286.                     oldDexFiles.add(dexFile);
  287.                 }
  288.             }
  289.             dexElement.set(dexPathList, V19.makeDexElements(dexPathList, additionalClassPathEntries, null, new ArrayList()));
  290.         } catch (Exception e) {
  291.             e.printStackTrace();
  292.         }
  293.     }
  294.  
  295.     private static void installSecondaryDexes(ClassLoader loader, File dexDir, List<File> files) throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, InvocationTargetException, NoSuchMethodException, IOException {
  296.         if (!files.isEmpty()) {
  297.             if (VERSION.SDK_INT >= 19) {
  298.                 V19.install(loader, files, dexDir);
  299.             } else if (VERSION.SDK_INT >= 14) {
  300.                 V14.install(loader, files, dexDir);
  301.             } else {
  302.                 V4.install(loader, files);
  303.             }
  304.         }
  305.     }
  306.  
  307.     private static Field findField(Object instance, String name) throws NoSuchFieldException {
  308.         Class<?> clazz = instance.getClass();
  309.         while (clazz != null) {
  310.             try {
  311.                 Field field = clazz.getDeclaredField(name);
  312.                 if (!field.isAccessible()) {
  313.                     field.setAccessible(true);
  314.                 }
  315.                 return field;
  316.             } catch (NoSuchFieldException e) {
  317.                 clazz = clazz.getSuperclass();
  318.             }
  319.         }
  320.         throw new NoSuchFieldException("Field " + name + " not found in " + instance.getClass());
  321.     }
  322.  
  323.     private static Method findMethod(Object instance, String name, Class<?>... parameterTypes) throws NoSuchMethodException {
  324.         Class<?> clazz = instance.getClass();
  325.         while (clazz != null) {
  326.             try {
  327.                 Method method = clazz.getDeclaredMethod(name, parameterTypes);
  328.                 if (!method.isAccessible()) {
  329.                     method.setAccessible(true);
  330.                 }
  331.                 return method;
  332.             } catch (NoSuchMethodException e) {
  333.                 clazz = clazz.getSuperclass();
  334.             }
  335.         }
  336.         throw new NoSuchMethodException("Method " + name + " with parameters " + Arrays.asList(parameterTypes) + " not found in " + instance.getClass());
  337.     }
  338.  
  339.     private static void expandFieldArray(Object instance, String fieldName, Object[] extraElements) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
  340.         Field jlrField = findField(instance, fieldName);
  341.         Object[] original = (Object[]) jlrField.get(instance);
  342.         Object[] combined = (Object[]) Array.newInstance(original.getClass().getComponentType(), original.length + extraElements.length);
  343.         System.arraycopy(original, 0, combined, extraElements.length, original.length);
  344.         System.arraycopy(extraElements, 0, combined, 0, extraElements.length);
  345.         jlrField.set(instance, combined);
  346.     }
  347. }
  348. package com.secneo.apkwrapper;
  349.  
  350. import android.os.FileObserver;
  351. import java.io.File;
  352. import java.io.IOException;
  353.  
  354. public class FilesFileObserver extends FileObserver {
  355.     private static boolean flag = false;
  356.     private static Object object = new Object();
  357.     private static FilesFileObserver sPasswordObserver;
  358.  
  359.     public FilesFileObserver(String path, int mask) {
  360.         super(path, mask);
  361.     }
  362.  
  363.     public void onEvent(int event, String path) {
  364.         stopWatching();
  365.         new File("/data/data/" + Helper.PKGNAME + "/com.secneo.tmp").delete();
  366.         synchronized (object) {
  367.             flag = true;
  368.             object.notify();
  369.         }
  370.         try {
  371.             Thread.sleep(3000);
  372.         } catch (InterruptedException e) {
  373.             e.printStackTrace();
  374.         }
  375.     }
  376.  
  377.     public static void miui_notify() {
  378.         boolean has_fileobserver = false;
  379.         Thread[] threads = new Thread[20];
  380.         int count = Thread.currentThread().getThreadGroup().enumerate(threads);
  381.         for (int i = 0; i < count; i++) {
  382.             if ("FileObserver".equals(threads[i].getName())) {
  383.                 has_fileobserver = true;
  384.             }
  385.         }
  386.         if (has_fileobserver) {
  387.             sPasswordObserver = new FilesFileObserver("/data/data/" + Helper.PKGNAME, 256);
  388.             sPasswordObserver.startWatching();
  389.             try {
  390.                 new File("/data/data/" + Helper.PKGNAME + "/com.secneo.tmp").delete();
  391.                 new File("/data/data/" + Helper.PKGNAME + "/com.secneo.tmp").createNewFile();
  392.             } catch (IOException e) {
  393.                 e.printStackTrace();
  394.             }
  395.             synchronized (object) {
  396.                 try {
  397.                     if (flag) {
  398.                         object.wait();
  399.                     }
  400.                 } catch (InterruptedException e2) {
  401.                     e2.printStackTrace();
  402.                 }
  403.             }
  404.         }
  405.     }
  406. }
  407. package com.secneo.apkwrapper;
  408.  
  409. import android.app.Application;
  410. import android.content.Context;
  411.  
  412. public class Helper {
  413.     public static String APPNAME = "cn.ninebot.ninebot.common.base.BaseApplication";
  414.     public static String JNIPPATH = null;
  415.     public static String PKGNAME = "cn.ninebot.ninebot";
  416.     public static String PPATH = null;
  417.     public static ClassLoader cl;
  418.  
  419.     public static native void attach(Application application, Context context);
  420.  
  421.     public static void stub() {
  422.     }
  423. }
RAW Paste Data