mimic: intercept any iOS app, AI-generate a Python client · littledivy/mimic@3361c2a · GitHub
Skip to content

Commit 3361c2a

Browse files
committed
mimic: intercept any iOS app, AI-generate a Python client
Capture your own session with mitmproxy, reuse your real auth, and let claude -p write an ergonomic client from the captured endpoints. - Session/App runtime with mitm + cURL sources and token auto-refresh - CLI: record / doctor / hosts / learn / gen - one-command install via uv; mitmproxy launched on demand via uvx - MIT licensed, own-accounts-only framing
0 parents  commit 3361c2a

12 files changed

Lines changed: 751 additions & 0 deletions

File tree

‎.gitignore‎

Lines changed: 6 additions & 0 deletions

‎LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Divy Srivastava
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# mimic
2+
3+
Intercept any app, then call it from Python like a library.
4+
5+
```python
6+
from hinge_client import Hinge
7+
8+
acc = Hinge() # reuses your captured session — no keys to wire up
9+
recs = acc.get_recommendations()
10+
acc.like(subject_id, comment="empty pools are so peaceful lol")
11+
```
12+
13+
You never wrote `hinge_client.py`. mimic watched your own app traffic and an AI
14+
wrote the client for you.
15+
16+
## How it works
17+
18+
Every app authenticates each request with a stable bundle — a bearer token,
19+
device ids, a session id, cookies. Capture that once from a real request **you**
20+
made, and you can craft new calls the server can't tell apart from the real app.
21+
22+
```
23+
capture your traffic ─▶ extract your reusable auth ─▶ AI writes the client
24+
(mitmproxy) (mimic.Session) (claude reads the
25+
captured endpoints)
26+
```
27+
28+
The generated client is plain, editable Python on top of `mimic.App`. It gets
29+
the ergonomic parts right — named methods, body templates, and the multi-step
30+
chaining mobile APIs need (fetch a token here, spend it there).
31+
32+
## Install (one command)
33+
34+
```bash
35+
sh install.sh
36+
```
37+
38+
Installs [`uv`](https://astral.sh/uv) if you don't have it, then mimic in an
39+
isolated tool env. No separate mitmproxy install — mimic launches it for you via
40+
`uvx` on first `record`. (Manual: `uv tool install mimic-client`.)
41+
42+
```bash
43+
mimic doctor # confirm proxy + claude are ready
44+
```
45+
46+
## Use it (iPhone)
47+
48+
```bash
49+
mimic record # starts the proxy, prints the exact iPhone steps
50+
```
51+
52+
`record` walks you through it and auto-fills your Mac's LAN IP:
53+
54+
1. iPhone → Wi-Fi → Configure Proxy → Manual → `<your-mac-ip>:8080`
55+
2. Safari → `http://mitm.it` → install the Apple profile
56+
3. **Settings → General → About → Certificate Trust Settings → turn on full
57+
trust for mitmproxy** — the step everyone forgets
58+
4. open the app, use it normally
59+
60+
Then:
61+
62+
```bash
63+
mimic hosts # list captured hosts; pick your API host
64+
mimic learn prod-api.hingeaws.net # see the endpoints mimic saw
65+
mimic gen prod-api.hingeaws.net # AI writes hinge_client.py
66+
```
67+
68+
Then `from hinge_client import Hinge; Hinge().get_recommendations()`.
69+
70+
## The library
71+
72+
Three ways to build a session by hand, if you don't want codegen:
73+
74+
```python
75+
from mimic import Session
76+
77+
Session.from_mitm("prod-api.hingeaws.net") # pull auth from mitmweb
78+
Session.from_curl(open("copied.txt").read()) # paste "Copy as cURL" from devtools
79+
Session(base_url="https://x.com", headers={...}) # explicit
80+
```
81+
82+
`.get(path)` / `.post(path, json=...)` return parsed JSON and auto-refresh your
83+
token from mitmweb if it rotates (a `401`/`403` triggers one re-pull + retry).
84+
85+
## Capture backends
86+
87+
- **mitmproxy** — iOS apps (the default). mimic reads its JSON flow API and runs
88+
it for you via `uvx`, so there's nothing extra to install.
89+
- **cURL / paste** — anything with a web version. `Copy as cURL` in devtools →
90+
`Session.from_curl(text)`. No proxy, no cert.
91+
92+
**Certificate pinning** (banking, Instagram) defeats a plain proxy, so pinned
93+
apps aren't supported. Plenty of apps aren't pinned and just work — if
94+
`mimic hosts` shows the app's API host, you're set.
95+
96+
## Ethics
97+
98+
Use it on **your own** accounts and data. It replays *your* session; it is not a
99+
tool for accessing anyone else's. Respect each app's terms of service.
100+
101+
## License
102+
103+
MIT — see [LICENSE](LICENSE). Provided as-is, no warranty. Use on your own
104+
accounts and data; you are responsible for complying with each app's terms.

‎install.sh‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env sh
2+
# One-command install for mimic. Installs uv if missing, then mimic (isolated).
3+
set -e
4+
5+
if ! command -v uv >/dev/null 2>&1; then
6+
echo "installing uv…"
7+
curl -LsSf https://astral.sh/uv/install.sh | sh
8+
export PATH="$HOME/.local/bin:$PATH"
9+
fi
10+
11+
# Install from the current directory if run inside the repo, else from PyPI.
12+
if [ -f "pyproject.toml" ] && grep -q 'name = "mimic-client"' pyproject.toml 2>/dev/null; then
13+
uv tool install . --reinstall
14+
else
15+
uv tool install mimic-client --reinstall
16+
fi
17+
18+
echo
19+
echo "installed. next:"
20+
echo " mimic doctor # check setup"
21+
echo " mimic record # start capture, follow the iPhone steps"

‎mimic/__init__.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""mimic — intercept any app, then call it from Python like a library.
2+
3+
from mimic import Session, App
4+
5+
Capture your own session with mitmproxy, and mimic reuses your real auth so the
6+
server can't tell your script from the app. Point it at a host and let the AI
7+
write an ergonomic client: `mimic gen <host>`.
8+
"""
9+
from .session import App, Session
10+
11+
__all__ = ["Session", "App"]
12+
__version__ = "0.1.0"

‎mimic/cli.py‎

Lines changed: 186 additions & 0 deletions

0 commit comments

Comments
 (0)