Comments (3)
跟其它的没区别,只是对bitmap的处理你要用java模拟实现
from unidbg.
package com.kuaishou;
import cn.banny.unidbg.Module;
import cn.banny.unidbg.arm.ARMEmulator;
import cn.banny.unidbg.file.FileIO;
import cn.banny.unidbg.file.IOResolver;
import cn.banny.unidbg.linux.android.AndroidARMEmulator;
import cn.banny.unidbg.linux.android.AndroidResolver;
import cn.banny.unidbg.linux.android.dvm.*;
import cn.banny.unidbg.memory.Memory;
import java.io.*;
public class KpgDecoder extends AbstractJni implements IOResolver {
private static final String APP_PACKAGE_NAME = "com.smile.gifmaker";
private final ARMEmulator emulator;
private final VM vm;
private final DvmClass KpgUtil;
private static final String APK_PATH = "src/test/resources/app/kuaishou.apk";
private final Module module;
private KpgDecoder() throws IOException {
emulator = new AndroidARMEmulator(APP_PACKAGE_NAME);
emulator.getSyscallHandler().addIOResolver(this);
System.out.println("== init ===");
final Memory memory = emulator.getMemory();
memory.setLibraryResolver(new AndroidResolver(19));
memory.setCallInitFunction();
vm = emulator.createDalvikVM(new File(APK_PATH));
vm.setJni(this);
DalvikModule dm = vm.loadLibrary("kpg", false);
dm.callJNI_OnLoad(emulator);
module = dm.getModule();
KpgUtil = vm.resolveClass("com/kwai/sdk/libkpg/KpgUtil");
}
public static void main(String[] args) {
try {
File file = new File("D:\\test.kpg");
InputStream in = new FileInputStream(file);
b test = parseKpgHeader(in);
InputStream in2 = new FileInputStream(file);
byte[] kWVCPayLoad = getKWVCPayLoad(in2, test);
KpgDecoder kpgDecoder = new KpgDecoder();
kpgDecoder.decode(kWVCPayLoad,test);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private void decode(byte[] kWVCPayLoad,b bVar){
Number ret = KpgUtil.callStaticJniMethod(emulator, "native_decode([BIII)[I",
vm.addLocalObject(new ByteArray(kWVCPayLoad)), bVar.d, bVar.a, bVar.b);
long hash = ret.intValue() & 0xffffffffL;
StringObject obj = vm.getObject(hash);
vm.deleteLocalRefs();
System.out.println(obj.getValue());
}
public static b parseKpgHeader(InputStream inputStream) {
byte[] bArr = new byte[4];
try {
b bVar = new b();
inputStream.read(bArr);
if (compare(bArr, "RIFF")) {
bVar.c = getInt(inputStream);
inputStream.read(bArr);
if (compare(bArr, "KPGB")) {
int i = 0;
while (i < bVar.c - 4) {
inputStream.read(bArr);
i += 4;
int i2 = getInt(inputStream);
i += 4;
if (compare(bArr, "KWVC")) {
bVar.a = getInt(inputStream);
i += 4;
bVar.b = getInt(inputStream);
i += 4;
bVar.d = i2 - 8;
bVar.e = i + 12;
break;
}
inputStream.skip((long) i2);
i += i2;
}
if (i < bVar.c) {
try {
inputStream.close();
} catch (IOException e) {
}
return bVar;
} else {
try {
inputStream.close();
return null;
} catch (IOException e2) {
return null;
}
}
} else {
try {
inputStream.close();
return null;
} catch (IOException e22) {
return null;
}
}
} else {
try {
inputStream.close();
return null;
} catch (IOException e222) {
return null;
}
}
} catch (IOException e2222) {
try {
inputStream.close();
return null;
} catch (IOException e22222) {
return null;
}
} catch (Throwable th) {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e222222) {
}
}
}
return null;
}
private static boolean compare(byte[] bArr, String str) {
if (bArr.length != str.length()) {
return false;
}
for (int i = 0; i < bArr.length; i++) {
if (str.charAt(i) != bArr[i]) {
return false;
}
}
return true;
}
private static int getInt(InputStream inputStream) throws IOException {
return (((byte) inputStream.read()) & 255) | (((((byte) inputStream.read()) << 8) & 65280) | (((((byte) inputStream.read()) << 16) & 16711680) | ((((byte) inputStream.read()) << 24) & -16777216)));
}
public static byte[] getKWVCPayLoad(InputStream inputStream, b bVar) {
byte[] bArr = new byte[bVar.d];
try {
inputStream.skip((long) bVar.e);
if (inputStream.read(bArr) == bVar.d) {
return bArr;
}
throw new IllegalArgumentException(String.format("getKWVCPayLoad fail, can not read enough bytes of kwvcPayloadLen:%d", new Object[]{Integer.valueOf(bVar.d)}));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Override
public FileIO resolve(File workDir, String pathname, int oflags) {
return null;
}
@Override
public DvmObject callObjectMethodV(BaseVM vm, DvmObject dvmObject, String signature, VaList vaList) {
switch (signature) {
case "com/yxcorp/gifshow/App->getPackageName()Ljava/lang/String;":
return new StringObject(vm, APP_PACKAGE_NAME);
case "com/yxcorp/gifshow/App->getPackageManager()Landroid/content/pm/PackageManager;":
return vm.resolveClass("android/content/pm/PackageManager").newObject(null);
}
return super.callObjectMethodV(vm, dvmObject, signature, vaList);
}
public static class b {
public int a;
public int b;
public int c;
public int d;
public int e;
}
}
test.kpg在这
test.zip
为啥这个会报[swscaler @ 0x804e290] No accelerated colorspace conversion found from yuv420p to bgra.
from unidbg.
更新最新代码即可支持
from unidbg.
Related Issues (20)
- 有没有大佬知道java/lang/String->toCharArray()[C该怎么补啊?求解
- BackendException on CallObjectMethodV
- 大佬们,看看 这种怎么补啊 "android/os/Parcel->setDataPosition(I)V"
- libopenjdk.so
- 需要api文档 HOT 1
- 最新版代码32位好像不支持Unicorn2Factory? HOT 1
- dump模拟执行时候发现的错误
- 怎么重写读取目录下所有文件的io HOT 1
- 调用问题
- 运行报错DalvikVM64$128.handle,怎么解决呀 HOT 2
- 小白的第一个unidbg
- 运行其他示例正常,运行anjuke示例报错了,用了unidbg-0.9.7 HOT 3
- 请问,如何补GetStringCritical jni 方法呢
- 补了环境还是报错 WARN [com.github.unidbg.linux.ARM64SyscallHandler] (ARM64SyscallHandler:405) - handleInterrupt intno=2, NR=0, svcNumber=0x107, PC=unidbg@0xfffe0104 java.lang.UnsupportedOperationException at com.github.unidbg.linux.android.dvm.DalvikVM64$8.handle(DalvikVM64.java:168) HOT 1
- com.github.unidbg.arm.backend.BackendException: dvmObject="two", dvmClass=class java/lang/String, jmethodID=unidbg@0xffffffffd6cb375b HOT 11
- 执行结果返回空JNIEnv->SetByteArrayRegion([B@0x, 0, 0, unidbg@0xbffff6b1) was called from RX@0x400d55dc[libfekit.so]0xd55dc
- unidbg-boot-server报错,求大佬帮看看
- 怎样移除断点
- 大佬们这个环境要咋补呢,init方法它没得返回值,必然会调用callVoidMethod这个方法,这个方法只有一个出路就是抛出异常 HOT 1
- 系统调用找不到,提示127,怎么解决呀。0.9。7版本 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unidbg.