feat: add proxy template origin field and implement socket utilities for log streaming
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user