chore: auto-commit (1 archivos)

- web_proxy

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-02 22:25:59 +02:00
parent b8ed53d468
commit 6e094dce97
+20 -5
View File
@@ -47,6 +47,8 @@ DEFAULT_PORT=8080
DEFAULT_OUT="$HOME/captures"
DEFAULT_ROTATE=20
DEFAULT_WEB_PORT=8081
DEFAULT_MAX_MB=2048 # tope de tamaño del directorio de capturas (MB); 0 = sin limite
DEFAULT_MAX_DAYS=7 # antiguedad maxima de una captura (dias); 0 = sin limite
MITMDUMP_BIN="$(command -v mitmdump 2>/dev/null || echo "$HOME/.local/bin/mitmdump")"
MITMWEB_BIN="$(command -v mitmweb 2>/dev/null || echo "$HOME/.local/bin/mitmweb")"
@@ -72,13 +74,15 @@ conf_get() {
}
conf_write() {
local port="$1" out="$2" rotate="$3" web_port="${4:-}" web_pass="${5:-}"
local port="$1" out="$2" rotate="$3" web_port="${4:-}" web_pass="${5:-}" max_mb="${6:-}" max_days="${7:-}"
cat > "$CONFFILE" <<EOF
PORT=$port
OUT=$out
ROTATE=$rotate
WEB_PORT=$web_port
WEB_PASS=$web_pass
MAX_MB=$max_mb
MAX_DAYS=$max_days
EOF
}
@@ -179,10 +183,14 @@ cmd_status() {
out="$(conf_get OUT "$DEFAULT_OUT")"
rotate="$(conf_get ROTATE "$DEFAULT_ROTATE")"
local max_mb max_days
max_mb="$(conf_get MAX_MB "$DEFAULT_MAX_MB")"
max_days="$(conf_get MAX_DAYS "$DEFAULT_MAX_DAYS")"
info "web_proxy — estado"
info " home: $WEB_PROXY_HOME"
info " capturas: $out"
info " rotacion: cada ${rotate} min"
info " retencion: max ${max_mb} MB, max ${max_days} dias"
local pid
if pid="$(running_pid)"; then
@@ -379,18 +387,22 @@ cmd_ca() {
# expone una UI web en vivo (estilo Burp/ZAP) ademas de capturar a disco; sin
# --web usa mitmdump headless.
cmd_install_service() {
local port out rotate enable_linger="no" web="no" web_port web_pass
local port out rotate enable_linger="no" web="no" web_port web_pass max_mb max_days
port="$(conf_get PORT "$DEFAULT_PORT")"
out="$(conf_get OUT "$DEFAULT_OUT")"
rotate="$(conf_get ROTATE "$DEFAULT_ROTATE")"
web_port="$(conf_get WEB_PORT "$DEFAULT_WEB_PORT")"
web_pass="$(conf_get WEB_PASS "")"
max_mb="$(conf_get MAX_MB "$DEFAULT_MAX_MB")"
max_days="$(conf_get MAX_DAYS "$DEFAULT_MAX_DAYS")"
[[ -n "$(conf_get WEB_PORT "")" ]] && web="yes"
while [[ $# -gt 0 ]]; do
case "$1" in
--port) port="$2"; shift 2 ;;
--out) out="$2"; shift 2 ;;
--rotate-min) rotate="$2"; shift 2 ;;
--max-mb) max_mb="$2"; shift 2 ;;
--max-days) max_days="$2"; shift 2 ;;
--web) web="yes"; shift ;;
--web-port) web="yes"; web_port="$2"; shift 2 ;;
--web-password) web="yes"; web_pass="$2"; shift 2 ;;
@@ -408,12 +420,13 @@ cmd_install_service() {
[[ -z "$web_pass" ]] && web_pass="webproxy"
fi
local retention="--set max_total_mb=$max_mb --set max_age_days=$max_days"
local bin="$MITMDUMP_BIN" exec_line
if [[ "$web" == "yes" ]]; then
bin="$MITMWEB_BIN"
exec_line="$MITMWEB_BIN --no-web-open-browser --web-host 127.0.0.1 --web-port $web_port --set web_password=$web_pass -s $ADDON_PATH --set rotate_min=$rotate --set capture_dir=$out --set exclude_hosts=127.0.0.1:$web_port,localhost:$web_port --listen-port $port"
exec_line="$MITMWEB_BIN --no-web-open-browser --web-host 127.0.0.1 --web-port $web_port --set web_password=$web_pass -s $ADDON_PATH --set rotate_min=$rotate --set capture_dir=$out --set exclude_hosts=127.0.0.1:$web_port,localhost:$web_port $retention --listen-port $port"
else
exec_line="$MITMDUMP_BIN -s $ADDON_PATH --set rotate_min=$rotate --set capture_dir=$out --listen-port $port"
exec_line="$MITMDUMP_BIN -s $ADDON_PATH --set rotate_min=$rotate --set capture_dir=$out $retention --listen-port $port"
fi
if [[ ! -x "$bin" ]]; then
err "$(basename "$bin") no encontrado. Instala con: uv tool install mitmproxy"
@@ -429,7 +442,8 @@ cmd_install_service() {
mkdir -p "$SYSTEMD_USER_DIR" "$out"
conf_write "$port" "$out" "$rotate" \
"$([[ "$web" == "yes" ]] && echo "$web_port")" \
"$([[ "$web" == "yes" ]] && echo "$web_pass")"
"$([[ "$web" == "yes" ]] && echo "$web_pass")" \
"$max_mb" "$max_days"
cat > "$SYSTEMD_USER_DIR/$SERVICE_NAME" <<EOF
[Unit]
@@ -465,6 +479,7 @@ EOF
if service_active; then
ok "Servicio instalado y ACTIVO en 127.0.0.1:$port."
info " capturas -> $out (rotacion cada ${rotate} min)"
info " retencion -> max ${max_mb} MB, max ${max_days} dias (borra las mas viejas al rotar)"
if [[ "$web" == "yes" ]]; then
ok " UI viva -> http://127.0.0.1:$web_port (registros en tiempo real)"
info " UI login -> deja el usuario vacio, password: $web_pass"