FRida In The Middle
fritm is a minimalist, cross-platform (tested on macOS and Windows)
network reverse engineering framework written in Python.
fritm-hook allows you to easily hook the
connect()
function with frida to redirect all traffic
from a target application.
You can then use the builtin server written in Python to initiate a Man-in-the-middle attack.
Even if you don't want to use Python, you can use the fritm-hook
command to redirect the traffic to your application and implement the
simple lecture of the HTTP CONNECT header.
Installation
pip install fritm
Usage
Hook the process:
fritm-hook PROCESS_NAME_OR_PID -p PORT # (default 8080)
Or create a new one:
fritm-spawn PATH_TO_COMMAND -p PORT # (default 8080)
Launch a proxy server in Python:
import select
from fritm import start_proxy_server
def dumb_callback(soClient, soServer):
"""Forwards all the traffic between the two sockets
"""
conns = [soClient, soServer]
other = {soClient: soServer, soServer: soClient}
active = True
try:
while active:
rlist, wlist, xlist = select.select(conns, [], conns)
if xlist or not rlist:
break
for r in rlist:
data = r.recv(8192)
if not data:
active = False
break
other[r].sendall(data)
finally:
for c in conns:
c.close()
httpd = start_proxy_server(dumb_callback)
Now, all the traffic will go through your application. You can modify anything on the fly.
How does it work?
Hooking with fritm.hook(process, port, filter)
- attach to the target process
- intercept the calls to
connect() - replace the target IP address by 127.0.0.1 and the port with the chosen one
- execute the
connect()function with the local IP - just before returning, send the HTTP CONNECT method with the original IP and port
fritm.spawn_and_hook(process, port) launches the process and ensures
it is hooked from the beginning.
MITM with fritm.start_proxy_server(callback, port, filter)
- Launch a local server that listens for connections on the given port
- Upon receiving a new connection from the hooked client, read the IP and port of the server from the HTTP CONNECT header
- Open a new socket to the server
- Call
callback(socket_to_client, socket_to_server)
filter usage
When specified, filter allows you to not redirect some connections.
It is a javascript expression that can use the variables sa_family,
addr and port.
A good value is sa_family == 2 (corresponds to AF_INET aka ipv4), but
for unknown reasons sa_family is 0 on Windows.
Differences with mitmproxy
- mitmproxy doesn't use function hooking, it intercepts all the traffic from your browser or computer
- mitmproxy only works for HTTP traffic, whereas fritm works with any TCP traffic.
Differences with proxychains / proxychains-ng
fritm-spawnis intented as simplified and cross-platform version of proxychains.fritm-hookcan attach to an already running process.- proxychains is not cross-platform and hard to install, whereas fritm is cross-platform and simple to install.
- proxychains uses a config file whereas
fritm-spawnonly takes two arguments - fritm includes a HTTP proxy server (that is also able to communicate with proxychains)
- proxychains can handle a lot of different proxy types (SOCKS4, SOCKS5, HTTPS) with a lot of options (e.g. for authentification)
- proxychains can chain multiple proxies
- proxychains handles any proxy address whereas
fritm-spawndefaults to localhost. However, if anyone needs it for remote addresses, post an issue and I'll implement it.
Current limitations
- Some Windows user faced issues that I couldn't reproduce
- fritm will fail on IPv6 addresses, but it should not be hard to fix (I just don't happen to have any application that uses an IPv6 address to test).
Metadata
Release files for fritm 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fritm-0.4.1.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fritm-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / fritm-0.4.1.tar.gz
| Download URL | fritm-0.4.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0682044310b8464e0c5645eb66d1fcf035f3286ff26c8de53c4c0cbcd0ce2011
|
|
BLAKE2b-256 checksum How to use checksums |
9138d3a7576762e293155bf62d3b551afe9fbfbcb6b98055d0e60365b815b492
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|
Release files / fritm-0.4.1-py3-none-any.whl
| Download URL | fritm-0.4.1-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af8270471a821b84ff48b7355f343401f13b9aec48939f1a80d8a3cf251bcffb
|
|
BLAKE2b-256 checksum How to use checksums |
d292d1b21c9e74f57026dccede612bbbf210bcfdca6bb926520678589470790d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|
Security for fritm 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.