Commit 5088e9af authored by Administrator's avatar Administrator

增加更多api

parent f8c40934
......@@ -14,6 +14,7 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.List;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
......@@ -60,6 +61,29 @@ public class UnPackerToolKit {
autoEnable(false);
}
public interface UnpackEvent {
void onFinish(File file);
}
public static void unpack(UnpackEvent unpackEvent) {
autoEnable();
new Thread("construct-unpack") {
@Override
public void run() {
try {
Thread.sleep(30 * 1000 + new Random().nextInt(2000));
File apkFile = constructUnpackedApkInternal();
if (apkFile == null) {
return;
}
unpackEvent.onFinish(apkFile);
} catch (Exception e) {
Log.e(TAG_UNPACK, "unpack error", e);
}
}
}.start();
}
/**
* 自动开启脱壳组件
*
......@@ -69,7 +93,7 @@ public class UnPackerToolKit {
if (RatelToolKit.processName.equals(RatelToolKit.packageName)) {
RposedHelpers.findAndHookMethod(Activity.class, "onResume", new RC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
protected void afterHookedMethod(MethodHookParam param) {
RatelToolKit.ratelUnpack.enableUnPack(
new File(RatelToolKit.sContext.getFilesDir(), "ratel_unpack"),
dumpMethod
......@@ -174,4 +198,35 @@ public class UnPackerToolKit {
}
return target;
}
/**
* 给定任意class,获取改class的dex数据
*
* @param clazz 任意class
* @return dex内容
*/
public byte[] dumpDex(Class<?> clazz) {
Method[] declaredMethods = clazz.getDeclaredMethods();
if (declaredMethods.length > 0) {
return RatelToolKit.ratelUnpack.methodDex(declaredMethods[0]);
}
Constructor<?>[] declaredConstructors = clazz.getDeclaredConstructors();
if (declaredConstructors.length > 0) {
return RatelToolKit.ratelUnpack.methodDex(declaredConstructors[0]);
}
return null;
}
/**
* 根据一个class名称,搜索对应的dex文件
*
* @param className class名称
* @return 存在重复类的情况下,可能有多条;搜索结果为空的情况下,返回空List
*/
public List<byte[]> searchDex(String className) {
return RatelToolKit.ratelUnpack.findDumpedDex(className);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment