hook逆向autojs离线Dex加密的app(四)

本文涉及的产品
密钥管理服务KMS,1000个密钥,100个凭据,1个月
简介: hook逆向autojs离线Dex加密的app(四)

脚本源码位于_c_script_0方法体内

//
// Decompiled by Jadx - 706ms
//
package org.autojs.autojspro.gen;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.NativeFunction;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.optimizer.OptRuntime;
public class _7a9076d6d94e62c13d641aa71f19ae8e extends NativeFunction implements Script {
    private int _id = 0;
    public _7a9076d6d94e62c13d641aa71f19ae8e() {
    }
    public static void main(String[] strArr) {
        OptRuntime.main(new _7a9076d6d94e62c13d641aa71f19ae8e(), strArr);
    }
    public final Object call(Context context, Scriptable scriptable, Scriptable scriptable2, Object[] objArr) {
        return !ScriptRuntime.hasTopCall(context) ? ScriptRuntime.doTopCall(this, context, scriptable, scriptable2, objArr, false) : _c_script_0(this, context, scriptable, scriptable2, objArr);
    }
    public final Object exec(Context context, Scriptable scriptable) {
        return call(context, scriptable, scriptable, (Object[]) null);
    }
    public String getFunctionName() {
        return "";
    }
    public int getLanguageVersion() {
        return 200;
    }
    public int getParamAndVarCount() {
        return 1;
    }
    public int getParamCount() {
        return 0;
    }
    public boolean getParamOrVarConst(int i) {
        return false;
    }
    public String getParamOrVarName(int i) {
        return "info";
    }
    private static Object _c_script_0(_7a9076d6d94e62c13d641aa71f19ae8e _7a9076d6d94e62c13d641aa71f19ae8e, Context context, Scriptable scriptable, Scriptable scriptable2, Object[] objArr) {
        ScriptRuntime.initScript(_7a9076d6d94e62c13d641aa71f19ae8e, scriptable2, context, scriptable, false);
        Object obj = Undefined.instance;
        ScriptRuntime.addInstructionCount(context, 1);
        ScriptRuntime.addInstructionCount(context, 1);
        ScriptRuntime.setName(ScriptRuntime.bind(context, scriptable, "info"), "yashu", context, scriptable, "info");
        Object callName = OptRuntime.callName(new Object[]{ScriptRuntime.name(context, scriptable, "info")}, "toastLog", context, scriptable);
        ScriptRuntime.addInstructionCount(context, 63);
        return callName;
    }
}


重点是

ScriptRuntime.setName(ScriptRuntime.bind(context, scriptable, "info"), "yashu", context, scriptable, "info");
Object callName = OptRuntime.callName(new Object[]{ScriptRuntime.name(context, scriptable, "info")}, "toastLog", context, scriptable);


这两行代码里的陌生单词就是

  • ScriptRuntime
  • OptRuntime
  • scriptable


ScriptRuntime

package org.mozilla.javascript;
import com.google.android.material.shadow.ShadowDrawableWrapper;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.mozilla.javascript.NativeIterator;
import org.mozilla.javascript.TopLevel;
import org.mozilla.javascript.typedarrays.NativeArrayBuffer;
import org.mozilla.javascript.typedarrays.NativeDataView;
import org.mozilla.javascript.v8dtoa.DoubleConversion;
import org.mozilla.javascript.v8dtoa.FastDtoa;
import org.mozilla.javascript.xml.XMLLib;
import org.mozilla.javascript.xml.XMLObject;
import p015d.p019b.p047c.p048a.C1556a;
public class ScriptRuntime {
    public static final Class<?> BooleanClass = Kit.classOrNull("java.lang.Boolean");
    public static final Class<?> ByteClass = Kit.classOrNull("java.lang.Byte");
    public static final Class<?> CharacterClass = Kit.classOrNull("java.lang.Character");
    public static final Class<?> ClassClass = Kit.classOrNull("java.lang.Class");
    public static final Class<?> ContextClass = Kit.classOrNull("org.mozilla.javascript.Context");
    public static final Class<?> ContextFactoryClass = Kit.classOrNull("org.mozilla.javascript.ContextFactory");
    private static final String DEFAULT_NS_TAG = "__default_namespace__";
    public static final Class<?> DateClass = Kit.classOrNull("java.util.Date");
    public static final Class<?> DoubleClass = Kit.classOrNull("java.lang.Double");
    public static final int ENUMERATE_ARRAY = 2;
    public static final int ENUMERATE_ARRAY_NO_ITERATOR = 5;
    public static final int ENUMERATE_KEYS = 0;
    public static final int ENUMERATE_KEYS_NO_ITERATOR = 3;
    public static final int ENUMERATE_VALUES = 1;
    public static final int ENUMERATE_VALUES_IN_ORDER = 6;
    public static final int ENUMERATE_VALUES_NO_ITERATOR = 4;
    public static final Class<?> FloatClass = Kit.classOrNull("java.lang.Float");
    public static final Class<?> FunctionClass = Kit.classOrNull("org.mozilla.javascript.Function");
    public static final Class<?> IntegerClass = Kit.classOrNull("java.lang.Integer");
    private static final Object LIBRARY_SCOPE_KEY = "LIBRARY_SCOPE";
    public static final Class<?> LongClass = Kit.classOrNull("java.lang.Long");
    public static final double NaN;
    public static final Double NaNobj;
    public static final Class<?> NumberClass = Kit.classOrNull("java.lang.Number");
    public static final Class<?> ObjectClass = Kit.classOrNull("java.lang.Object");
    public static Locale ROOT_LOCALE = new Locale("");
    public static final Class<Scriptable> ScriptableClass = Scriptable.class;
    public static final Class<?> ScriptableObjectClass = Kit.classOrNull("org.mozilla.javascript.ScriptableObject");
    public static final Class<?> ShortClass = Kit.classOrNull("java.lang.Short");
    public static final Class<?> StringClass = Kit.classOrNull("java.lang.String");
    public static final Object[] emptyArgs = new Object[0];
    public static final String[] emptyStrings = new String[0];
    public static MessageProvider messageProvider = new DefaultMessageProvider();
    public static final double negativeZero = Double.longBitsToDouble(Long.MIN_VALUE);
    ...
}    


OptRuntime

package org.mozilla.javascript.optimizer;
import com.google.android.material.shadow.ShadowDrawableWrapper;
import org.mozilla.javascript.ArrowFunction;
import org.mozilla.javascript.Callable;
import org.mozilla.javascript.ConsString;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextAction;
import org.mozilla.javascript.ContextFactory;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.JavaScriptException;
import org.mozilla.javascript.NativeFunction;
import org.mozilla.javascript.NativeGenerator;
import org.mozilla.javascript.NativeIterator;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
public final class OptRuntime extends ScriptRuntime {
    public static final Double minusOneObj = new Double(-1.0d);
    public static final Double oneObj = new Double(1.0d);
    public static final Double zeroObj = new Double((double) ShadowDrawableWrapper.COS_45);
    public static class GeneratorState {
        public static final String CLASS_NAME = "org/mozilla/javascript/optimizer/OptRuntime$GeneratorState";
        public static final String resumptionPoint_NAME = "resumptionPoint";
        public static final String resumptionPoint_TYPE = "I";
        public static final String thisObj_NAME = "thisObj";
        public static final String thisObj_TYPE = "Lorg/mozilla/javascript/Scriptable;";
        public Object[] localsState;
        public int maxLocals;
        public int maxStack;
        public int resumptionPoint;
        public Object[] stackState;
        public Scriptable thisObj;
        public GeneratorState(Scriptable scriptable, int i, int i2) {
            this.thisObj = scriptable;
            this.maxLocals = i;
            this.maxStack = i2;
        }
    }
    public static Object add(double d, Object obj) {
        if (obj instanceof Scriptable) {
            obj = ((Scriptable) obj).getDefaultValue(null);
        }
        return !(obj instanceof CharSequence) ? wrapDouble(ScriptRuntime.toNumber(obj) + d) : new ConsString(ScriptRuntime.toString(d), (CharSequence) obj);
    }
    public static Object add(Object obj, double d) {
        if (obj instanceof Scriptable) {
            obj = ((Scriptable) obj).getDefaultValue(null);
        }
        return !(obj instanceof CharSequence) ? wrapDouble(ScriptRuntime.toNumber(obj) + d) : new ConsString((CharSequence) obj, ScriptRuntime.toString(d));
    }
    public static Function bindThis(NativeFunction nativeFunction, Context context, Scriptable scriptable, Scriptable scriptable2) {
        return new ArrowFunction(context, scriptable, nativeFunction, scriptable2);
    }
    public static Object call0(Callable callable, Scriptable scriptable, Context context, Scriptable scriptable2) {
        return callable.call(context, scriptable2, scriptable, ScriptRuntime.emptyArgs);
    }
    public static Object call1(Callable callable, Scriptable scriptable, Object obj, Context context, Scriptable scriptable2) {
        return callable.call(context, scriptable2, scriptable, new Object[]{obj});
    }
    public static Object call2(Callable callable, Scriptable scriptable, Object obj, Object obj2, Context context, Scriptable scriptable2) {
        return callable.call(context, scriptable2, scriptable, new Object[]{obj, obj2});
    }
    public static Object callN(Callable callable, Scriptable scriptable, Object[] objArr, Context context, Scriptable scriptable2) {
        return callable.call(context, scriptable2, scriptable, objArr);
    }
    public static Object callName(Object[] objArr, String str, Context context, Scriptable scriptable) {
        return ScriptRuntime.getNameFunctionAndThis(str, context, scriptable).call(context, scriptable, ScriptRuntime.lastStoredScriptable(context), objArr);
    }
    public static Object callName0(String str, Context context, Scriptable scriptable) {
        return ScriptRuntime.getNameFunctionAndThis(str, context, scriptable).call(context, scriptable, ScriptRuntime.lastStoredScriptable(context), ScriptRuntime.emptyArgs);
    }
    public static Object callProp0(Object obj, String str, Context context, Scriptable scriptable) {
        return ScriptRuntime.getPropFunctionAndThis(obj, str, context, scriptable).call(context, scriptable, ScriptRuntime.lastStoredScriptable(context), ScriptRuntime.emptyArgs);
    }
    public static Object callSpecial(Context context, Callable callable, Scriptable scriptable, Object[] objArr, Scriptable scriptable2, Scriptable scriptable3, int i, String str, int i2) {
        return ScriptRuntime.callSpecial(context, callable, scriptable, objArr, scriptable2, scriptable3, i, str, i2);
    }
    public static Scriptable createNativeGenerator(NativeFunction nativeFunction, Scriptable scriptable, Scriptable scriptable2, int i, int i2) {
        return new NativeGenerator(scriptable, nativeFunction, new GeneratorState(scriptable2, i, i2));
    }
    private static int[] decodeIntArray(String str, int i) {
        if (i != 0) {
            if (str.length() == (i * 2) + 1 || str.charAt(0) == 1) {
                int[] iArr = new int[i];
                for (int i2 = 0; i2 != i; i2++) {
                    int i3 = (i2 * 2) + 1;
                    iArr[i2] = str.charAt(i3 + 1) | (str.charAt(i3) << 16);
                }
                return iArr;
            }
            throw new IllegalArgumentException();
        } else if (str == null) {
            return null;
        } else {
            throw new IllegalArgumentException();
        }
    }
    @Deprecated
    public static Object elemIncrDecr(Object obj, double d, Context context, int i) {
        return elemIncrDecr(obj, d, context, ScriptRuntime.getTopCallScope(context), i);
    }
    public static Object elemIncrDecr(Object obj, double d, Context context, Scriptable scriptable, int i) {
        return ScriptRuntime.elemIncrDecr(obj, new Double(d), context, scriptable, i);
    }
    public static String encodeIntArray(int[] iArr) {
        if (iArr == null) {
            return null;
        }
        int length = iArr.length;
        char[] cArr = new char[((length * 2) + 1)];
        cArr[0] = 1;
        for (int i = 0; i != length; i++) {
            int i2 = iArr[i];
            int i3 = (i * 2) + 1;
            cArr[i3] = (char) (i2 >>> 16);
            cArr[i3 + 1] = (char) i2;
        }
        return new String(cArr);
    }
    public static Object[] getGeneratorLocalsState(Object obj) {
        GeneratorState generatorState = (GeneratorState) obj;
        if (generatorState.localsState == null) {
            generatorState.localsState = new Object[generatorState.maxLocals];
        }
        return generatorState.localsState;
    }
    public static Object[] getGeneratorStackState(Object obj) {
        GeneratorState generatorState = (GeneratorState) obj;
        if (generatorState.stackState == null) {
            generatorState.stackState = new Object[generatorState.maxStack];
        }
        return generatorState.stackState;
    }
    public static void initFunction(NativeFunction nativeFunction, int i, Scriptable scriptable, Context context) {
        ScriptRuntime.initFunction(context, scriptable, nativeFunction, i, false);
    }
    public static void main(final Script script, final String[] strArr) {
        ContextFactory.getGlobal().call(new ContextAction() {
            /* class org.mozilla.javascript.optimizer.OptRuntime.C34141 */
            @Override // org.mozilla.javascript.ContextAction
            public Object run(Context context) {
                ScriptableObject global = ScriptRuntime.getGlobal(context);
                String[] strArr = strArr;
                Object[] objArr = new Object[strArr.length];
                System.arraycopy(strArr, 0, objArr, 0, strArr.length);
                global.defineProperty("arguments", context.newArray(global, objArr), 2);
                script.exec(context, global);
                return null;
            }
        });
    }
    public static Scriptable newArrayLiteral(Object[] objArr, String str, int i, Context context, Scriptable scriptable) {
        return ScriptRuntime.newArrayLiteral(objArr, decodeIntArray(str, i), context, scriptable);
    }
    public static Object newObjectSpecial(Context context, Object obj, Object[] objArr, Scriptable scriptable, Scriptable scriptable2, int i) {
        return ScriptRuntime.newSpecial(context, obj, objArr, scriptable, i);
    }
    public static Object[] padStart(Object[] objArr, int i) {
        Object[] objArr2 = new Object[(objArr.length + i)];
        System.arraycopy(objArr, 0, objArr2, i, objArr.length);
        return objArr2;
    }
    public static void throwStopIteration(Object obj) {
        throw new JavaScriptException(NativeIterator.getStopIterationObject((Scriptable) obj), "", 0);
    }
    public static Double wrapDouble(double d) {
        if (d == ShadowDrawableWrapper.COS_45) {
            if (1.0d / d > ShadowDrawableWrapper.COS_45) {
                return zeroObj;
            }
        } else if (d == 1.0d) {
            return oneObj;
        } else {
            if (d == -1.0d) {
                return minusOneObj;
            }
            if (d != d) {
                return ScriptRuntime.NaNobj;
            }
        }
        return new Double(d);
    }
}


scriptable

package org.mozilla.javascript;
public interface Scriptable {
    public static final Object NOT_FOUND = UniqueTag.NOT_FOUND;
    void delete(int i);
    void delete(String str);
    Object get(int i, Scriptable scriptable);
    Object get(String str, Scriptable scriptable);
    String getClassName();
    Object getDefaultValue(Class<?> cls);
    Object[] getIds();
    Scriptable getParentScope();
    Scriptable getPrototype();
    boolean has(int i, Scriptable scriptable);
    boolean has(String str, Scriptable scriptable);
    boolean hasInstance(Scriptable scriptable);
    void put(int i, Scriptable scriptable, Object obj);
    void put(String str, Scriptable scriptable, Object obj);
    void setParentScope(Scriptable scriptable);
    void setPrototype(Scriptable scriptable);
}


未完待续

相关文章
|
3月前
|
JavaScript 前端开发 安全
VUE——APP,后端,前端三端AES加密解密
VUE——APP,后端,前端三端AES加密解密
137 0
|
安全 数据安全/隐私保护 Python
Crack App | 某赢+ 二手车 App 登录参数加密逻辑分析
Crack App | 某赢+ 二手车 App 登录参数加密逻辑分析
102 0
|
Dart 安全 数据安全/隐私保护
Crack App | 某都市魔幻 FM 请求参数 sign 的加密分析
Crack App | 某都市魔幻 FM 请求参数 sign 的加密分析
119 0
|
6月前
|
数据安全/隐私保护
基于AutoJs实现的薅羊毛App专业版源码大分享---更新啦
基于AutoJs实现的薅羊毛App专业版源码大分享---更新啦
175 0
|
6月前
|
存储 缓存 JavaScript
基于AutoJs实现的薅羊毛App专业版源码大分享
基于AutoJs实现的薅羊毛App专业版源码大分享
150 0
|
6月前
|
算法 Java 数据安全/隐私保护
Android App开发之利用JNI实现加密和解密操作实战(附源码 简单易懂)
Android App开发之利用JNI实现加密和解密操作实战(附源码 简单易懂)
315 0
|
6月前
|
XML 数据库 数据安全/隐私保护
Android App规范处理中版本设置、发布模式、给数据集SQLite加密的讲解及使用(附源码 超详细必看)
Android App规范处理中版本设置、发布模式、给数据集SQLite加密的讲解及使用(附源码 超详细必看)
75 0
|
Java 数据安全/隐私保护 Android开发
app逆向实战强化篇——破解某安卓APP请求加密参数
app逆向实战强化篇——破解某安卓APP请求加密参数
|
算法 Java 数据安全/隐私保护
Crack App | yrx App 对抗赛第二、第三题加密签名对抗
Crack App | yrx App 对抗赛第二、第三题加密签名对抗
119 0
|
安全 数据安全/隐私保护 Python
Crack App | 某新闻 app 注册 token 加密逻辑分析
Crack App | 某新闻 app 注册 token 加密逻辑分析