Restore a Frida 16-style Python session.create_script() workflow on Frida 17+
Project description
frida-legacy-compat
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) - 旧脚本里的
Java、ObjC、Swift继续可用
仓库地址: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_compat和frida_legacy_compat.patch_frida()都只会给出中英文 warning,不会报错
使用 uv add:
uv add frida-legacy-compat
uv add 'frida-legacy-compat[full]'
兼容性
frida < 17:可安装;import和patch_frida()都只会 warning,并保持 no-op17.0 <= frida < 17.2:可安装;import和patch_frida()都只会 warning,提示需要frida>=17.2,<1817.2 <= frida < 18:支持frida >= 18:可安装;import和patch_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c29f4eca2d39e266649ec9150bee967a643e6f7c34e6cf170dc5b0d29f047b8
|
|
| MD5 |
b8da4b6b21dac325a18e705adb746f02
|
|
| BLAKE2b-256 |
aabf9f6311edff6e44d166767fbd6364fbbeb291f510e4afbafa3f6e75985a29
|
Provenance
The following attestation bundles were made for frida_legacy_compat-1.1.0.tar.gz:
Publisher:
publish.yml on RYF5584/frida-legacy-compat
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
frida_legacy_compat-1.1.0.tar.gz -
Subject digest:
6c29f4eca2d39e266649ec9150bee967a643e6f7c34e6cf170dc5b0d29f047b8 - Sigstore transparency entry: 1613776969
- Sigstore integration time:
-
Permalink:
RYF5584/frida-legacy-compat@711127c1d8eaf5043d9fd8b628223b50c396a9f2 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/RYF5584
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@711127c1d8eaf5043d9fd8b628223b50c396a9f2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file frida_legacy_compat-1.1.0-py3-none-any.whl.
File metadata
- Download URL: frida_legacy_compat-1.1.0-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba555c1bf2447ffe09724aaf880ecd163a35a7c3ffdde420a6d1bfdce1ce2ce2
|
|
| MD5 |
005176c8f61a0151f9b9a6548b114f99
|
|
| BLAKE2b-256 |
c94d1163c0f9fd8404371b1f06763191203b580c18d8d719f532088419cd061b
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
frida_legacy_compat-1.1.0-py3-none-any.whl -
Subject digest:
ba555c1bf2447ffe09724aaf880ecd163a35a7c3ffdde420a6d1bfdce1ce2ce2 - Sigstore transparency entry: 1613777106
- Sigstore integration time:
-
Permalink:
RYF5584/frida-legacy-compat@711127c1d8eaf5043d9fd8b628223b50c396a9f2 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/RYF5584
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@711127c1d8eaf5043d9fd8b628223b50c396a9f2 -
Trigger Event:
release
-
Statement type: