仰望星辰工作室

miaopanel

miaopanel/ scripts/repro-sensitive.sh 1.0 KB · 28 行 原始文件
1#!/usr/bin/env bash
2# Prove whether the sensitive-path rule blocks files that actually exist.
3set -uo pipefail
4ROOT=/www/wwwroot/demo
5mkdir -p "$ROOT/.well-known" "$ROOT/blog" "$ROOT/docs" "$ROOT/download"
6printf 'zip-demo' > "$ROOT/download/app.zip"
7printf 'pkg-demo' > "$ROOT/download/pkg.tar.gz"
8printf 'security-contact' > "$ROOT/.well-known/security.txt"
9printf 'guide' > "$ROOT/blog/phpmyadmin-guide"
10printf 'dump' > "$ROOT/docs/app.sql"
11printf '<?php echo 1;' > "$ROOT/wp-login.php"
12printf 'body{}' > "$ROOT/style.css"
13
14H='Host: demo.test'
15req() {
16 printf '%-38s -> %s\n' "$1" "$(curl -s -o /dev/null -w '%{http_code}' -H "$H" "http://127.0.0.1$1")"
17}
18req /style.css
19req /download/app.zip
20req /download/pkg.tar.gz
21req /.well-known/security.txt
22req /blog/phpmyadmin-guide
23req /docs/app.sql
24req /wp-login.php
25
26rm -rf "$ROOT/.well-known/security.txt" "$ROOT/blog/phpmyadmin-guide" \
27 "$ROOT/docs/app.sql" "$ROOT/wp-login.php" "$ROOT/download" "$ROOT/style.css"
28rmdir "$ROOT/.well-known" "$ROOT/blog" "$ROOT/docs" 2>/dev/null || true