Security Scanning Tools
当用户提出“执行漏洞扫描”、“扫描网络开放端口”、“评估Web应用程序安全性”、“扫描无线网络”、“检测恶意软件”、“检查云安全”或“评估系统合规性”等要求时,应启用此技能。它提供关于安全扫描工具与方法的全面指导。
Security Scanning Tools
Purpose
Master essential security scanning tools for network discovery, vulnerability assessment, web application testing, wireless security, and compliance validation. This skill covers tool selection, configuration, and practical usage across different scanning categories.
Prerequisites
Required Environment
Required Knowledge
Outputs and Deliverables
Core Workflow
Phase 1: Network Scanning Tools
Nmap (Network Mapper)
Primary tool for network discovery and security auditing:
# Host discovery
nmap -sn 192.168.1.0/24 # Ping scan (no port scan)
nmap -sL 192.168.1.0/24 # List scan (DNS resolution)
nmap -Pn 192.168.1.100 # Skip host discoveryPort scanning techniques
nmap -sS 192.168.1.100 # TCP SYN scan (stealth)
nmap -sT 192.168.1.100 # TCP connect scan
nmap -sU 192.168.1.100 # UDP scan
nmap -sA 192.168.1.100 # ACK scan (firewall detection)Port specification
nmap -p 80,443 192.168.1.100 # Specific ports
nmap -p- 192.168.1.100 # All 65535 ports
nmap -p 1-1000 192.168.1.100 # Port range
nmap --top-ports 100 192.168.1.100 # Top 100 common portsService and OS detection
nmap -sV 192.168.1.100 # Service version detection
nmap -O 192.168.1.100 # OS detection
nmap -A 192.168.1.100 # Aggressive (OS, version, scripts)Timing and performance
nmap -T0 192.168.1.100 # Paranoid (slowest, IDS evasion)
nmap -T4 192.168.1.100 # Aggressive (faster)
nmap -T5 192.168.1.100 # Insane (fastest)NSE Scripts
nmap --script=vuln 192.168.1.100 # Vulnerability scripts
nmap --script=http-enum 192.168.1.100 # Web enumeration
nmap --script=smb-vuln 192.168.1.100 # SMB vulnerabilities
nmap --script=default 192.168.1.100 # Default script setOutput formats
nmap -oN scan.txt 192.168.1.100 # Normal output
nmap -oX scan.xml 192.168.1.100 # XML output
nmap -oG scan.gnmap 192.168.1.100 # Grepable output
nmap -oA scan 192.168.1.100 # All formatsMasscan
High-speed port scanning for large networks:
# Basic scanning
masscan -p80 192.168.1.0/24 --rate=1000
masscan -p80,443,8080 192.168.1.0/24 --rate=10000Full port range
masscan -p0-65535 192.168.1.0/24 --rate=5000Large-scale scanning
masscan 0.0.0.0/0 -p443 --rate=100000 --excludefile exclude.txtOutput formats
masscan -p80 192.168.1.0/24 -oG results.gnmap
masscan -p80 192.168.1.0/24 -oJ results.json
masscan -p80 192.168.1.0/24 -oX results.xmlBanner grabbing
masscan -p80 192.168.1.0/24 --bannersPhase 2: Vulnerability Scanning Tools
Nessus
Enterprise-grade vulnerability assessment:
# Start Nessus service
sudo systemctl start nessusdAccess web interface
https://localhost:8834
Command-line (nessuscli)
nessuscli scan --create --name "Internal Scan" --targets 192.168.1.0/24
nessuscli scan --list
nessuscli scan --launch <scan_id>
nessuscli report --format pdf --output report.pdf <scan_id>Key Nessus features:
OpenVAS (Greenbone)
Open-source vulnerability scanning:
# Install OpenVAS
sudo apt install openvas
sudo gvm-setupStart services
sudo gvm-startAccess web interface (Greenbone Security Assistant)
https://localhost:9392
Command-line operations
gvm-cli socket --xml "<get_version/>"
gvm-cli socket --xml "<get_tasks/>"Create and run scan
gvm-cli socket --xml '
<create_target>
<name>Test Target</name>
<hosts>192.168.1.0/24</hosts>
</create_target>'Phase 3: Web Application Scanning Tools
Burp Suite
Comprehensive web application testing:
# Proxy configuration
Set browser proxy to 127.0.0.1:8080
Import Burp CA certificate for HTTPS
Add target to scope Key modules:
Proxy: Intercept and modify requests
Spider: Crawl web applications
Scanner: Automated vulnerability detection
Intruder: Automated attacks (fuzzing, brute-force)
Repeater: Manual request manipulation
Decoder: Encode/decode data
Comparer: Compare responses Core testing workflow:
OWASP ZAP
Open-source web application scanner:
# Start ZAP
zaproxyAutomated scan from CLI
zap-cli quick-scan https://target.comFull scan
zap-cli spider https://target.com
zap-cli active-scan https://target.comGenerate report
zap-cli report -o report.html -f htmlAPI mode
zap.sh -daemon -port 8080 -config api.key=<your_key>ZAP automation:
# Docker-based scanning
docker run -t owasp/zap2docker-stable zap-full-scan.py \
-t https://target.com -r report.htmlBaseline scan (passive only)
docker run -t owasp/zap2docker-stable zap-baseline.py \
-t https://target.com -r report.htmlNikto
Web server vulnerability scanner:
# Basic scan
nikto -h https://target.comScan specific port
nikto -h target.com -p 8080Scan with SSL
nikto -h target.com -sslMultiple targets
nikto -h targets.txtOutput formats
nikto -h target.com -o report.html -Format html
nikto -h target.com -o report.xml -Format xml
nikto -h target.com -o report.csv -Format csvTuning options
nikto -h target.com -Tuning 123456789 # All tests
nikto -h target.com -Tuning x # Exclude specific testsPhase 4: Wireless Scanning Tools
Aircrack-ng Suite
Wireless network penetration testing:
# Check wireless interface
airmon-ngEnable monitor mode
sudo airmon-ng start wlan0Scan for networks
sudo airodump-ng wlan0monCapture specific network
sudo airodump-ng -c <channel> --bssid <target_bssid> -w capture wlan0monDeauthentication attack
sudo aireplay-ng -0 10 -a <bssid> wlan0monCrack WPA handshake
aircrack-ng -w wordlist.txt -b <bssid> capture.capCrack WEP
aircrack-ng -b <bssid> capture*.capKismet
Passive wireless detection:
# Start Kismet
kismetSpecify interface
kismet -c wlan0Access web interface
http://localhost:2501
Detect hidden networks
Kismet passively collects all beacon frames
including those from hidden SSIDs
Phase 5: Malware and Exploit Scanning
ClamAV
Open-source antivirus scanning:
# Update virus definitions
sudo freshclamScan directory
clamscan -r /path/to/scanScan with verbose output
clamscan -r -v /path/to/scanMove infected files
clamscan -r --move=/quarantine /path/to/scanRemove infected files
clamscan -r --remove /path/to/scanScan specific file types
clamscan -r --include='\.exe$|\.dll$' /path/to/scanOutput to log
clamscan -r -l scan.log /path/to/scanMetasploit Vulnerability Validation
Validate vulnerabilities with exploitation:
# Start Metasploit
msfconsoleDatabase setup
msfdb init
db_statusImport Nmap results
db_import /path/to/nmap_scan.xmlVulnerability scanning
use auxiliary/scanner/smb/smb_ms17_010
set RHOSTS 192.168.1.0/24
runAuto exploitation
vulns # View vulnerabilities
analyze # Suggest exploitsPhase 6: Cloud Security Scanning
Prowler (AWS)
AWS security assessment:
# Install Prowler
pip install prowlerBasic scan
prowler awsSpecific checks
prowler aws -c iam s3 ec2Compliance framework
prowler aws --compliance cis_awsOutput formats
prowler aws -M html json csvSpecific region
prowler aws -f us-east-1Assume role
prowler aws -R arn:aws:iam::123456789012:role/ProwlerRoleScoutSuite (Multi-cloud)
Multi-cloud security auditing:
# Install ScoutSuite
pip install scoutsuiteAWS scan
scout awsAzure scan
scout azure --cliGCP scan
scout gcp --user-accountGenerate report
scout aws --report-dir ./reportsPhase 7: Compliance Scanning
Lynis
Security auditing for Unix/Linux:
# Run audit
sudo lynis audit systemQuick scan
sudo lynis audit system --quickSpecific profile
sudo lynis audit system --profile serverOutput report
sudo lynis audit system --report-file /tmp/lynis-report.datCheck specific section
sudo lynis show profiles
sudo lynis audit system --tests-from-group malwareOpenSCAP
Security compliance scanning:
# List available profiles
oscap info /usr/share/xml/scap/ssg/content/ssg-<distro>-ds.xmlRun scan with profile
oscap xccdf eval --profile xccdf_org.ssgproject.content_profile_pci-dss \
--report report.html \
/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xmlGenerate fix script
oscap xccdf generate fix \
--profile xccdf_org.ssgproject.content_profile_pci-dss \
--output remediation.sh \
/usr/share/xml/scap/ssg/content/ssg-rhel8-ds.xmlPhase 8: Scanning Methodology
Structured scanning approach:
- Define scope and objectives
- Obtain proper authorization
- Select appropriate tools
- Host discovery (Nmap ping sweep)
- Port scanning
- Service enumeration
- Automated scanning (Nessus/OpenVAS)
- Web application scanning (Burp/ZAP)
- Manual verification
- Correlate findings
- Eliminate false positives
- Prioritize by severity
- Document findings
- Provide remediation guidance
- Executive summary
Phase 9: Tool Selection Guide
Choose the right tool for each scenario:
| Scenario | Recommended Tools |
|---|---|
| Network Discovery | Nmap, Masscan |
| Vulnerability Assessment | Nessus, OpenVAS |
| Web App Testing | Burp Suite, ZAP, Nikto |
| Wireless Security | Aircrack-ng, Kismet |
| Malware Detection | ClamAV, YARA |
| Cloud Security | Prowler, ScoutSuite |
| Compliance | Lynis, OpenSCAP |
| Protocol Analysis | Wireshark, tcpdump |
Phase 10: Reporting and Documentation
Generate professional reports:
# Nmap XML to HTML
xsltproc nmap-output.xml -o report.htmlOpenVAS report export
gvm-cli socket --xml '<get_reports report_id="<id>" format_id="<pdf_format>"/>'Combine multiple scan results
Use tools like Faraday, Dradis, or custom scripts
Executive summary template:
1. Scope and methodology
2. Key findings summary
3. Risk distribution chart
4. Critical vulnerabilities
5. Remediation recommendations
6. Detailed technical findings
Quick Reference
Nmap Cheat Sheet
| Scan Type | Command |
|---|---|
| Ping Scan | nmap -sn <target> |
| Quick Scan | nmap -T4 -F <target> |
| Full Scan | nmap -p- <target> |
| Service Scan | nmap -sV <target> |
| OS Detection | nmap -O <target> |
| Aggressive | nmap -A <target> |
| Vuln Scripts | nmap --script=vuln <target> |
| Stealth Scan | nmap -sS -T2 <target> |
Common Ports Reference
| Port | Service |
|---|---|
| 21 | FTP |
| 22 | SSH |
| 23 | Telnet |
| 25 | SMTP |
| 53 | DNS |
| 80 | HTTP |
| 443 | HTTPS |
| 445 | SMB |
| 3306 | MySQL |
| 3389 | RDP |
Constraints and Limitations
Legal Considerations
Technical Limitations
Best Practices
Troubleshooting
Scan Not Detecting Hosts
Solutions:
nmap -Pn or nmap -sn -PS/PA/PUnmap -PS22,80,443Slow Scan Performance
Solutions:
nmap -T4 or -T5--top-ports 100-nWeb Scanner Missing Vulnerabilities
Solutions: