系统与软件更新
sudo apt update && sudo apt upgrade (Debian/Ubuntu) 或 sudo yum update (RHEL/CentOS)apache2 -v 或 nginx -vphp -v最小化服务原则
systemctl list-units --type=service --state=runningsudo systemctl disable <service_name>防火墙配置
sudo ufw statussudo iptables -L -n -vapache
Options -Indexesapache
ServerSignature Off
ServerTokens Prodnginx
server_tokens off;nginx
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
return 405;
}bash
docker pull owasp/zap2docker-stable
docker run -it owasp/zap2docker-stable zap-cli quick-scan -s xss,sqli --spider -r http://your-target.comNikto
bash
nikto -h http://your-target.com -output nikto_scan_results.html
Nmap NSE脚本
bash
nmap --script http-vuln* -p 80,443 your-target.com
认证与授权
hydra或burp intruder输入验证
sqlmap -u "http://target.com/api?user=1" --risk=3 --level=5<script>alert(1)</script>等payload业务逻辑漏洞
其他安全风险
Access-Control-Allow-OriginWeb应用防火墙
sudo apt install libapache2-mod-security2日志监控
持续安全
npm audit或pip-auditbash
zap-cli report -o security_report.html -f html漏洞修复优先级矩阵:
验证修复:
通过以上系统化的安全审核和漏洞扫描流程,可以显著提升Linux服务器上Web接口的安全性,降低被攻击风险。