Intercept Network Traffic Transparently
This guide will walk you through enabling lueur's stealth mode to capture network traffic without modifying your application.
Info
This feature is only available on Linux as it relies on a kernel advanaced capability called ebpf.
Prerequisites
-
Install lueur
If you haven’t installed lueur yet, follow the installation instructions.
Capture HTTPS Traffic
-
Start the proxy in stealth mode with a normal distribution latency
lueur run \ --stealth \ # (1)! --capture-process curl \ # (2)! --with-latency \ # (3)! --latency-mean 300 \ --latency-stddev 40
- Enable stealth mode
- Stealth mode will focus only on processes named
curl
- Enable the latency fault support
-
Send traffic
curl \ -4 \ # (1)! -I \ # (2)! -o /dev/null -s \ # (3)! -w "Connected IP: %{remote_ip}\nTotal time: %{time_total}s\n" \ # (4)! https://www.google.com
- lueur can only intercept IPv4 traffic
- Let's only focus on a HEAD request for brevety
- Discard any returned output
- Display statistics about the call
Apply Latency to a PostgreSQL Connection
-
Install lueur's ebpf dependencies
Follow the procedure to install the eBPF programs on your machine.
-
Start a local PostgreSQL server using a container
docker run \ --name demo-db \ # (1)! -e POSTGRES_USER=demo \ # (2)! -e POSTGRES_PASSWORD=demo \ # (3)! -e POSTGRES_DB=demo \ # (4)! --rm -it \ # (5)! -p 5432:5432 \ # (6)! postgres
- Name of the container, useful to identify and delete it later on
- Default basic user named {demo}
- Password set to {demo} for the user {demo}
- Default database name
- Release all resources once we stop the container
- Expose the database port onto the host
-
Start the proxy in stealth mode with a normal distribution latency
lueur run \ --stealth \ # (1)! --capture-process curl \ # (2)! --with-latency \ # (3)! --latency-mean 300 \ --latency-stddev 40
- Enable stealth mode
- Stealth mode will focus only on processes named
curl
- Enable the latency fault support
-
Communicate with your PostgreSQL server
First, install
uv
to run the demonstration script below. Follow the instructions from the uv documentation.Let's use the following basic Python script:
connect-to-pgsql.pyimport time import psycopg def query_database_server_time(url: str) -> None: start = time.time() with psycopg.Connection.connect(url) as conn: # (1)! cur = conn.execute("select now()") print(cur.fetchone()[0]) print(f"Time taken {time.time() - start}") if __name__ == "__main__": connection_url = "postgresql://demo:demo@localhost:5432/demo" # (2)! query_database_server_time(connection_url)
- We are using a context manager which closes the connection automatically
- This should reflect the address of your PostgreSQL database
Run the script using
uv
.- Use uv to run the script with the required dependency
- Install the required dependency on the fly. Here the psycopg driver
This should output something such as:
- This shows the impact of the latency injected by lueur into the exchange
Info
We use
uv
to ease the management of the Python environment for this particular script. When we run the script this way, the actual process executing the script is indeedpython
. This is why lueur captures the network traffic from thepython
process, not fromuv
.