Skip to content

Instantly share code, notes, and snippets.

@fortuna
Last active May 8, 2023 09:35
Show Gist options
  • Save fortuna/78d2c5c340e47c0f0e06afdeca866421 to your computer and use it in GitHub Desktop.
Save fortuna/78d2c5c340e47c0f0e06afdeca866421 to your computer and use it in GitHub Desktop.
ClientHello splitting in Bash
# Author: Vinicius Fortuna
# Example practical usage at https://github.com/pypi/support/issues/2751#issuecomment-1535248888
mkfifo in.fifo
nc -l localhost 8443 < in.fifo | { dd bs=100 count=1; sleep 0.1; cat; } | nc files.pythonhosted.org 443 > in.fifo &
time curl --connect-to ::localhost:8443 'https://files.pythonhosted.org/packages/84/a9/2bf119f3f9cff1f376f924e39cfae18dec92a1514784046d185731301281/scipy-1.10.1.tar.gz' > /dev/null
@fortuna
Copy link
Author

fortuna commented May 4, 2023

This code is running a local server on port 8443 that intercepts the outgoing flow, splits it on byte 100 using dd, then forwards to files.pythonhosted.org:443. We use in.fifo to connect the two nc commands for the incoming flow.

Here is a diagram of what's going on:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment