mimic README

The project's README from github.com/littledivy/mimic. As one markdown file: README.md.

mimic

Intercept any app, then call it from Python like a library.

from hinge_client import Hinge

acc = Hinge()                 # reuses your captured session
recs = acc.get_recommendations()
acc.like(subject_id, comment="hi lol")

You don't write hinge_client.py. mimic captures your own app traffic and an AI generates the client from it.

How it works

Most apps authenticate every request with the same bundle of values: a bearer token, some device ids, a session id, cookies. They're stable across calls. Capture them once from a real request you made, and you can replay them on new requests to the same API.

capture traffic   ->   extract auth   ->   generate client
  (mitmproxy)         (mimic.Session)      (claude reads the
                                            captured endpoints)

The generated client is plain Python on top of mimic.App, and you edit it like any other file. It gives you named methods, body templates, and the multi-step call chaining mobile APIs tend to need (fetch a token in one call, spend it in the next).

Install

sh install.sh

Installs uv if you don't have it, then mimic in an isolated tool env. mitmproxy isn't a separate install; mimic launches it via uvx on first record. (Manual: uv tool install mimic-client.)

mimic doctor                    # confirm proxy + claude are ready

Use it (iPhone)

mimic record                    # starts the proxy, prints the iPhone steps

record fills in your Mac's LAN IP and walks you through it:

  1. iPhone -> Wi-Fi -> Configure Proxy -> Manual -> <your-mac-ip>:8080
  2. Safari -> http://mitm.it -> install the Apple profile
  3. Settings -> General -> About -> Certificate Trust Settings -> turn on full trust for mitmproxy. This step is easy to miss and nothing works without it.
  4. open the app, use it normally

Then:

mimic hosts                     # list captured hosts; pick your API host
mimic learn  prod-api.hingeaws.net    # see the endpoints mimic saw
mimic gen    prod-api.hingeaws.net    # generate hinge_client.py

Then from hinge_client import Hinge; Hinge().get_recommendations().

The library

Three ways to build a session by hand, if you don't want codegen:

from mimic import Session

Session.from_mitm("prod-api.hingeaws.net")        # pull auth from mitmweb
Session.from_curl(open("copied.txt").read())      # paste "Copy as cURL" from devtools
Session(base_url="https://x.com", headers={...})  # explicit

.get(path), .post(path, json=...), and the other common HTTP verb helpers return parsed JSON and raise requests.HTTPError for failed responses. If your token rotates, a 401 on an idempotent request triggers one re-pull from mitmweb and a retry. Non-idempotent requests are not retried unless you explicitly pass refresh=True.

Capture backends

Limitations

Two auth schemes get in the way, for different reasons:

If mimic hosts shows the app's API host, you're good.

Ethics

Use it on your own accounts and data. It replays your session; it is not a tool for accessing anyone else's. Respect each app's terms of service.

License

MIT, see LICENSE. Provided as-is, no warranty. Use on your own accounts and data; you are responsible for complying with each app's terms.

mimic (littledivy/mimic)

Searching Database…

2.9K ·GitHub
这是什么?mimic 会拦截任何应用(移动端或网页端)的流量,并把它转换成一个可以像库一样调用的纯 Python 客户端——你只需捕获一个真实请求,AI 就会为你生成具名方法,而不必手写。
它是命令行工具、Python 库,还是两者都是?两者都是:mimic 命令行工具负责录制流量并生成客户端文件,生成的文件是构建在 mimic.App 之上的纯 Python 代码,你可以像普通模块一样导入和编辑。
如何安装 mimic 并开始捕获流量?安装程序会在你没有 uv 时先装好 uv,并把 mimic 安装到隔离的工具环境中(也可以手动运行 `uv tool install mimic-client`);第一次录制时会通过 uvx 自动启动 mitmproxy,因此不需要单独安装 mitmproxy。
录制之前需要自己安装 mitmproxy 吗?不需要——首次录制时 mimic 会通过 uvx 帮你启动 mitmproxy,你只需把 iPhone 的代理设置指向你的 Mac,并信任 mitmproxy 证书。
对于使用证书固定或轮换 DPoP 令牌的应用,mimic 还有效吗?证书固定(银行应用、Instagram)会导致捕获失败,因为应用会拒绝 mitmproxy 证书,但 mimic 自带一个基于 Frida 的“去固定”绕过方案。DPoP / 发送方约束令牌则是死路一条:每个请求都携带由一把从未离开设备的密钥签名的新鲜证明,因此捕获到的请求根本无法重放。
网页应用的流量也能捕获吗,还是只支持 iOS?iOS 应用默认通过 mitmproxy,但网页应用可以完全跳过代理:在开发者工具中把请求复制为 cURL 放进 Session.fromcurl(),或者从浏览器的 Network 标签页导出 HAR 文件,再用 mimic 处理它。
用 mimic 指向任意应用的流量合适吗?mimic 的用途是在自己的账号上重放你自己的会话,而不是访问别人的数据,同时你应当遵守各应用的服务条款。
如果我的认证令牌在会话中途轮换了会怎样?幂等请求返回 401 时,会自动从 mitmweb 重新拉取一次并重试。非幂等请求(如 POST)只有在你显式传入 refresh=True 时才会重试。
我可以不用 AI 代码生成,手动构建客户端吗?可以——mimic.App 暴露了 .get()、.post() 等 HTTP 动词辅助方法,它们返回解析后的 JSON,失败时抛出 requests.HTTPError,因此你可以在不生成任何代码的情况下手动组装会话。
`mimic unpin` 是做什么的?它为使用证书固定的应用设置一个基于 Frida 的绕过方案,让 mitmproxy 证书能够被信任,流量也就能被看到并捕获。
为什么要用 mimic 而不是自己逆向 API?大多数移动端 API 在各次调用间复用同一组稳定的凭据(bearer token、设备 ID、会话 ID);mimic 从一个真实请求中一次性捕获这些内容,再让 AI 生成具名方法和多步调用链,省去了手动逆向的工作。
What are similar projects?captcha-api, httpx, frida, bettercap, httpx, evilginx2, badnotes, ipatool
Creator
littledivy
Size
0.1 MB
Stars
2.9K
Updated
CommitJul 26
Age
3mo
Commits · 90 Days