Skip to main content

Restore a Frida 16-style Python session.create_script() workflow on Frida 17+

Project description

frida-legacy-compat

Repository GitHub stars

默认中文 | English

frida-legacy-compat 是一个面向 Frida 17+ 的 Python 兼容层,用来把 Frida 16 风格的 session.create_script() 注入体验尽量恢复回来。

这个库就是专门用来解决 Frida 17.0.0 以上版本中,使用 Python API 执行旧版 JS 脚本时常见的 bridge 报错问题,例如:

{'type': 'error', 'description': "ReferenceError: 'Java' is not defined", 'stack': "ReferenceError: 'Java' is not defined\n at (/script1.js:3)"}

Frida 17 以后,旧版 bridge 默认不再跟随原来的 plain JS 工作流一起可用,很多场景需要改成 TypeScript/ESM 编译,或者额外下载 bridge,使用成本明显变高。

这个库的目标很直接:

  • 安装一次
  • 多加一行 import frida_legacy_compat
  • 显式调用 frida_legacy_compat.patch_frida()
  • 继续直接把旧版 JS 字符串传给 session.create_script(source)
  • 旧脚本里的 JavaObjCSwift 继续可用

仓库地址:https://github.com/RYF5584/frida-legacy-compat

特性

  • 显式调用后 patch frida.core.Session.create_script()
  • 自动识别旧版 bridge 脚本并按需编译
  • 自动安装所需 bridge 包
  • 不需要 Node.js
  • 根据 frida.__version__ 自动选择默认 bridge profile

安装

本项目已发布到 PyPI,可直接通过 PyPI 安装: https://pypi.org/project/frida-legacy-compat/

pip install frida-legacy-compat

如果希望同时安装 frida

pip install 'frida-legacy-compat[full]'

说明:

  • 本库安装时不限制 frida 版本
  • 推荐范围为 frida>=17.2,<18
  • 如果当前 frida 版本不满足,import frida_legacy_compatfrida_legacy_compat.patch_frida() 都只会给出中英文 warning,不会报错

使用 uv add

uv add frida-legacy-compat
uv add 'frida-legacy-compat[full]'

兼容性

  • frida < 17:可安装;importpatch_frida() 都只会 warning,并保持 no-op
  • 17.0 <= frida < 17.2:可安装;importpatch_frida() 都只会 warning,提示需要 frida>=17.2,<18
  • 17.2 <= frida < 18:支持
  • frida >= 18:可安装;importpatch_frida() 都只会 warning,提示当前不在已验证范围内

快速开始

import frida
import frida_legacy_compat

frida_legacy_compat.patch_frida()

device = frida.get_usb_device()
session = device.attach("com.example.app")
source = """
Java.perform(function () {
  var Activity = Java.use("android.app.Activity");
  console.log(Activity);
});
"""

script = session.create_script(source)
script.load()

CLI

frida-legacy -U -f com.example.app -l agent.js

文档

注意事项

  • 第一次运行可能会慢一点,因为 bridge 包会按需安装
  • 已编译的 Frida bundle 会被自动识别并直接透传
  • 当前兼容入口是 Session.create_script()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frida_legacy_compat-1.1.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

frida_legacy_compat-1.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file frida_legacy_compat-1.1.0.tar.gz.

File metadata

  • Download URL: frida_legacy_compat-1.1.0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for frida_legacy_compat-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6c29f4eca2d39e266649ec9150bee967a643e6f7c34e6cf170dc5b0d29f047b8
MD5 b8da4b6b21dac325a18e705adb746f02
BLAKE2b-256 aabf9f6311edff6e44d166767fbd6364fbbeb291f510e4afbafa3f6e75985a29

See more details on using hashes here.

Provenance

The following attestation bundles were made for frida_legacy_compat-1.1.0.tar.gz:

Publisher: publish.yml on RYF5584/frida-legacy-compat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file frida_legacy_compat-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for frida_legacy_compat-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba555c1bf2447ffe09724aaf880ecd163a35a7c3ffdde420a6d1bfdce1ce2ce2
MD5 005176c8f61a0151f9b9a6548b114f99
BLAKE2b-256 c94d1163c0f9fd8404371b1f06763191203b580c18d8d719f532088419cd061b

See more details on using hashes here.

Provenance

The following attestation bundles were made for frida_legacy_compat-1.1.0-py3-none-any.whl:

Publisher: publish.yml on RYF5584/frida-legacy-compat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page