- download_cats: Test generate_cats functionality (100% coverage) - keyboard_coop: Test keyboard_listener with mocked pynput (22% coverage) - mock_server: Test mitmproxy request interceptor (100% coverage) - random_jpg: Test JPEG generation with mocked Pillow (100% coverage) - randomize_numbers: Test random_digits functions (99% coverage) - scrape_website: Test scrape_comics with mocked requests (98% coverage) - split: Test text splitting utilities (100% coverage) - tag_divider: Test tag_divider with mock filesystem (44% coverage) - extract_links: Add HTML fixture for tests |
||
|---|---|---|
| .. | ||
| tests | ||
| __init__.py | ||
| mock_server.py | ||
| README.md | ||
| requirements.txt | ||
| run.sh | ||
Simulate Connection Failure
(it takes ≈ 1hr to get it working)
Install: https://mitmproxy.org/ (install it the way they recommend for your OS, for Ubuntu specifically apt version is 4 main versions behind newest version)
Run it using mitmproxy
Run your webbrowser using 127.0.0.1:8080 as proxy
on chromium-based browser it should be enough to do:
google-chrome --proxy-server=127.0.0.1:8080
Run mitmweb
open 127.0.0.1:8081
Click File in upper left corner and then Install Certificates
You should get a list of Windows/Linux/macOS/Firefox with certificates and how to install them
Install certificates using those instructions
important! Go to your browser certificate settings and ensure that:
- mitmproxy certificate is imported
- it is set to trusted
Now all of your network communication should go through mitmproxy, you can verify it by going to 127.0.0.1:8081 and seeing constant flow of requests
What can we do with it?
- Install mitmproxy python library using pip
pip install mitmproxy
- Copy and paste this “hello world”:
from mitmproxy import http
def request(flow: http.HTTPFlow) -> None:
# Only intercept traffic to example.com
if "example.com" in flow.request.host:
flow.response = http.Response.make(
502, # Bad Gateway status code
b"Simulated connection failure",
{"Content-Type": "text/plain"}
)
- Run it:
mitmdump -s mitm_world.py - Go to example.com
- You should see “simulated connection failure” in plain text