Код: Выделить всё
import frida
import sys
import os
JS_SCRIPT = '''
setTimeout(function () {{
Java.perform(function () {{
// declare dependencies on necessary Java classes
const File = Java.use("java.io.File");
const Bitmap = Java.use("android.graphics.Bitmap");
const BitmapCompressFormat = Java.use("android.graphics.Bitmap$CompressFormat");
const BitmapConfig = Java.use("android.graphics.Bitmap$Config");
const ByteArrayOutputStream = Java.use("java.io.ByteArrayOutputStream");
// instantiate a new Bitmap object
const bitmap = Bitmap.createBitmap(100, 100, BitmapConfig.ARGB_8888.value);
// output bitmap to a byte stream in PNG format
const stream = ByteArrayOutputStream.$new();
const saved = bitmap.compress(BitmapCompressFormat.PNG.value, 100, stream);
console.log("[*] Compressed as PNG:", saved);
// get byte array from byte stream
const byteArray = stream.toByteArray();
console.log("[*] Byte array length:", byteArray.length);
// send the byte stream to the Python layer
send({{ type: "bitmap", page: pageNum }}, byteArray);
stream.close();
}});
}}, 1000);
'''
def on_message(message, data):
if message["type"] == "send" and message["payload"].get("type") == "bitmap":
page = message["payload"].get("page")
with open(OUTPUT_FILENAME, "wb") as f:
f.write(data)
print(f"[+] Saved page {page} as {OUTPUT_FILENAME}")
else:
print(f"[?] Unknown message: {message}")
def main():
device = frida.get_usb_device(timeout=5)
session = device.attach(pid)
script = session.create_script(JS_SCRIPT)
script.on("message", on_message)
script.load()
device.resume(pid)
if __name__ == "__main__":
main()
Код: Выделить всё
Error: expected a pointerДля меня неясно, как попасть в Bytearray в формат, который можно отправить с помощью функции send () , и у меня возникают проблемы с поиском решения в Docs Frida.
Подробнее здесь: https://stackoverflow.com/questions/796 ... -to-python
Мобильная версия