feat: add proxy template origin field and implement socket utilities for log streaming

This commit is contained in:
gabdevele
2026-05-07 10:54:57 +02:00 Unverified
parent 53dcdafdb1
commit 354ec150bc
32 changed files with 1681 additions and 1214 deletions
@@ -0,0 +1,37 @@
id: http-block-command-injection-markers
name: Block command injection markers
protocol: http
description: Rejects obvious shell metacharacters and command-substitution markers.
category: http
family: web-hardening
tags:
- command-injection
- web
- block
action: block
summary: Rejects obvious shell metacharacters and command-substitution markers.
behavior: Scans URL and body for shell-style injection markers, logs the first hit,
and drops the client connection.
source_url: https://docs.mitmproxy.org/stable/addons/examples/
code: |
import logging
from mitmproxy import http
BLOCKED_MARKERS = (";", "&&", "||", "$(", "`", "|sh", "|bash")
def request(flow: http.HTTPFlow) -> None:
body = flow.request.get_text(strict=False)
haystack = "\n".join(
[flow.request.pretty_url, body]
).lower()
for marker in BLOCKED_MARKERS:
if marker in haystack:
logging.warning(
"[http-block-command-injection-markers] blocked marker=%r url=%s",
marker,
flow.request.pretty_url,
)
flow.kill()
return