用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/CyberStrikeus/CyberStrike --skill wstg-conf-09命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | wstg-conf-09 |
| description | Test File Permission |
| category | configuration |
| owasp_id | WSTG-CONF-09 |
| version | 1.0.0 |
| author | cyberstrike-official |
| tags | ["misconfiguration","hardening","server","wstg","conf"] |
| tech_stack | ["php","java","asp","nodejs"] |
| cwe_ids | ["CWE-434"] |
| chains_with | [] |
| prerequisites | [] |
| severity_boost | {} |
WSTG-CONF-09
Test File Permission
Incorrect file permissions can expose sensitive data, allow unauthorized modifications, or enable code execution. This test examines file and directory permissions to identify overly permissive settings that could be exploited by attackers. Proper file permissions are a critical component of defense-in-depth security.
# List permissions in web directory
ls -la /var/www/html/
# Recursive listing
ls -laR /var/www/html/
# Using namei for path permissions
namei -l /var/www/html/config/database.php
# Find world-writable files
find /var/www/html -perm -0002 -type f
# Find world-writable directories
find /var/www/html -perm -0002 -type d
find /var/www/html -perm -4000 - f
find /var/www/html -user root - f
# Configuration files
ls -la /var/www/html/config/
ls -la /var/www/html/.env
ls -la /var/www/html/wp-config.php
# Should be readable only by web server user
# Recommended: 640 or 600
# Log files
ls -la /var/log/apache2/
ls -la /var/log/nginx/
# Database files
ls -la /var/lib/mysql/
# Upload directories should not allow execution
ls -la /var/www/html/uploads/
ls -la /var/www/html/media/
ls -la /var/www/html/files/
# Check for executable files in upload dirs
find /var/www/html/uploads -type f \( -name "*.php" -o -name "*.sh" -o -name "*.pl" \)
# List permissions
icacls C:\inetpub\wwwroot\
# Recursive
icacls C:\inetpub\wwwroot\ /T
# Check specific file
icacls C:\inetpub\wwwroot\web.config
# Try to access sensitive files via web
curl -s https://target.com/.htaccess
curl -s https://target.com/web.config
curl -s https://target.com/config/database.yml
curl -s https://target.com/.env
# Check for directory listing
curl -s https://target.com/uploads/
curl -s https://target.com/config/
curl -s https://target.com/logs/
| Tool | Description | Usage |
|---|---|---|
| ls | List files | ls -la /path |
| namei | Path permissions | namei -l /path/to/file |
| find | Find files | find /path -perm mode |
| stat | File status | stat /path/to/file |
| getfacl | ACL permissions | getfacl /path/to/file |
| Tool | Description |
|---|---|
| icacls | Display/modify ACLs |
| AccessChk | Sysinternals tool |
| AccessEnum | Permission enumeration |
| Tool | Description |
|---|---|
| Lynis | Security auditing |
| Linux Exploit Suggester | Permission checks |
#!/bin/bash
WEBROOT=${1:-"/var/www/html"}
echo "=== FILE PERMISSION AUDIT ==="
echo "Web Root: $WEBROOT"
echo ""
# World-writable files
echo "[+] World-writable files:"
find "$WEBROOT" -perm -0002 -type f 2>/dev/null
# World-writable directories
echo ""
echo "[+] World-writable directories:"
find "$WEBROOT" -perm -0002 -type d 2>/dev/null
# SUID files
echo ""
echo "[+] SUID files:"
find "$WEBROOT" -perm -4000 -type f 2>/dev/null
# Config files with loose permissions
echo ""
echo "[+] Config files with permissions > 640:"
find "$WEBROOT" -name "*.conf" -o -name "*.config" -o -name "*.ini" -o -name "*.env" 2>/dev/null | while read file; do
perms=$(stat -c %a "$file" 2>/dev/null)
if [ "$perms" -gt 640 ]; then
echo "$file: $perms"
fi
done
# PHP files in upload directories
echo ""
echo "[+] PHP files in upload directories:"
for dir in uploads files media documents; do
find "$WEBROOT/$dir" -name "*.php" 2>/dev/null
done
echo ""
echo "[+] Audit complete"
# Web files (read-only)
find /var/www/html -type f -exec chmod 644 {} \;
# Directories (read + execute)
find /var/www/html -type d -exec chmod 755 {} \;
# Configuration files (restrictive)
chmod 640 /var/www/html/config/*.php
chmod 640 /var/www/html/.env
# Upload directories (no execution)
chmod 755 /var/www/html/uploads
# Use .htaccess to prevent PHP execution
# Set ownership
chown -R www-data:www-data /var/www/html
# Files: 644 (rw-r--r--)
find /var/www/html -type f -exec chmod 644 {} \;
# Directories: 755 (rwxr-xr-x)
find /var/www/html -type d -exec chmod 755 {} \;
# Config files: 640 (rw-r-----)
chmod 640 /var/www/html/config/*
chmod 640 /var/www/html/.env
chmod 640 /var/www/html/wp-config.php
# Private keys: 600 (rw-------)
chmod 600 /var/www/html/keys/*
chmod 600 ~/.ssh/id_rsa
# Set permissions
chmod 755 /var/www/html/uploads
# Apache - Prevent PHP execution
# Create /var/www/html/uploads/.htaccess
echo "php_flag engine off" > /var/www/html/uploads/.htaccess
# Or use FilesMatch
cat > /var/www/html/uploads/.htaccess << 'EOF'
<FilesMatch "\.(php|phtml|php3|php4|php5|php7|phps|phar)$">
Require all denied
</FilesMatch>
EOF
# Nginx - Prevent PHP execution in uploads
location ~* /uploads/.*\.php$ {
deny all;
}
# Logs readable only by root/admin
chmod 640 /var/log/apache2/*
chmod 640 /var/log/nginx/*
# Owned by root
chown root:adm /var/log/apache2/*
| Finding | CVSS | Severity |
|---|---|---|
| World-writable config file | 9.8 | Critical |
| Executable in upload dir | 9.8 | Critical |
| World-readable credentials | 7.5 | High |
| Overly permissive directories | 5.3 | Medium |
| CWE ID | Title | Description |
|---|---|---|
| CWE-732 | Incorrect Permission Assignment for Critical Resource | Improper file permissions |
| CWE-276 | Incorrect Default Permissions | Default permissions too permissive |
| CWE-284 | Improper Access Control | Access control failure |
[ ] Web directory permissions reviewed
[ ] Configuration file permissions checked
[ ] Sensitive files restricted (600/640)
[ ] Upload directories checked
[ ] No PHP files in upload directories
[ ] Log file permissions verified
[ ] World-writable files identified
[ ] SUID/SGID files reviewed
[ ] Ownership verified
[ ] Remediation recommendations provided