βοΈNetsh Port Forwarding
π Module Overview
Purpose: Native Windows port forwarding using built-in tools Tool: netsh.exe - Windows network configuration utility Technique: IPv4-to-IPv4 port proxy forwarding Advantage: No external tools required (living off the land) Scenario: Windows workstation as pivot to internal network
1. Introduction to Windows Netsh
What is Netsh?
Full Name: Network Shell (netsh.exe)
Type: Built-in Windows command-line utility
Purpose: Network configuration and management
Location:
C:\Windows\System32\netsh.exeAvailability: Present on all Windows systems
Privileges: Requires administrator privileges for port forwarding
Netsh Capabilities
Finding routes - network path discovery
Viewing firewall configuration - Windows Firewall management
Adding proxies - proxy server configuration
Creating port forwarding rules - IPv4-to-IPv4 forwarding
Network interface management - adapter configuration
Netsh vs Other Windows Tools
Tool
Type
Availability
Configuration
Stealth
Netsh
Built-in
Always present
Command-line
High (legitimate tool)
Plink
External
PuTTY required
SSH-based
Medium (admin tool)
PowerShell
Built-in
Windows 7+
Script-based
High (native)
SSH
External
Windows 10+
SSH tunneling
Medium (newer feature)
Network Topology Example
2. Basic Netsh Port Forwarding
IPv4-to-IPv4 Port Proxy
Creating Port Forward Rule
Verifying Port Forward
Understanding the Configuration
Listen Address: 10.129.15.150 (Windows 10 pivot host)
Listen Port: 8080 (accessible from attack host)
Connect Address: 172.16.5.25 (internal Windows server)
Connect Port: 3389 (RDP service)
3. Practical Implementation
Step 1: Access Windows Pivot Host
Step 2: Create Port Forward Rule
Step 3: Verify Configuration
Step 4: Test Port Forward
4. Advanced Netsh Configurations
Multiple Port Forwards
Different Interface Binding
IPv6 Support
5. HTB Academy Lab Exercise
Lab Challenge
"Using the concepts covered in this section, take control of the DC (172.16.5.19) using xfreerdp by pivoting through the Windows 10 target host. Submit the approved contact's name found inside the 'VendorContacts.txt' file located in the 'Approved Vendors' folder on Victor's desktop (victor's credentials: victor:pass@123)."
Complete Solution Steps
Step 1: Connect to Windows 10 Pivot
Step 2: Configure Netsh Port Forward
Step 3: Test Port Forward
Step 4: Connect to DC through Port Forward
Step 5: Navigate to File Location
Step 6: Submit Answer
Expected File Path: C:\Users\victor\Desktop\Approved Vendors\VendorContacts.txt
6. Troubleshooting Netsh Issues
Common Problems
Access Denied Errors
Port Already in Use
Connection Refused
Firewall Blocking
7. Management and Cleanup
Listing Port Forwards
Deleting Port Forwards
Persistent Configuration
8. Security Considerations
Operational Security (OPSEC)
Legitimate Tool - netsh.exe is standard Windows utility
Administrative Logs - commands logged in Windows Event Log
Persistent Rules - forwards survive reboots (good for persistence)
Firewall Integration - works with Windows Firewall
Process Visibility - no additional processes required
Detection Risks
Command Line Auditing - PowerShell/CMD logging may capture commands
Event Log Entries - Windows Security log may record configuration changes
Network Monitoring - unusual port listeners detectable
Registry Changes - port proxy rules stored in registry
Forensic Artifacts - commands may be recoverable from memory/disk
Registry Storage
9. Integration with Other Techniques
Netsh + SSH Tunneling
Netsh + Meterpreter
PowerShell Integration
10. Advanced Scenarios
Multi-Hop Pivoting
Service-Specific Forwarding
Load Balancing Simulation
11. Comparison with Other Windows Tools
Netsh vs Windows Alternatives
Tool
Complexity
Persistence
Admin Required
Stealth
Netsh
Low
High (persistent)
Yes
High
PowerShell
Medium
Low (script-based)
Depends
Medium
Windows Firewall
High
High
Yes
High
IIS URL Rewrite
High
High
Yes
Medium
When to Use Netsh
β Windows environment with admin access β Persistent forwarding needed across reboots β Simple port forwarding requirements β Living off the land approach preferred β No external tools can be installed
When NOT to Use Netsh
β No admin privileges available β Complex routing requirements β Cross-platform compatibility needed β Temporary forwarding only (creates persistent rules) β Stealth operation (logged extensively)
12. Best Practices
Operational Guidelines
Test locally first - verify connectivity before deployment
Use non-standard ports - avoid common port detection
Document configurations - track created port forwards
Clean up after use - remove forwards when done
Monitor connections - watch for unexpected traffic
Security Recommendations
Minimize exposure time - create forwards only when needed
Use specific bind addresses - avoid 0.0.0.0 when possible
Implement access controls - Windows Firewall rules
Monitor event logs - watch for detection indicators
Rotate ports regularly - vary port usage patterns
Performance Considerations
Limit concurrent forwards - avoid resource exhaustion
Monitor bandwidth usage - track network utilization
Consider connection limits - Windows has TCP connection limits
Optimize for target services - tune for specific protocols
Test under load - verify performance with multiple connections
References
HTB Academy: Pivoting, Tunneling & Port Forwarding - Page 11
Microsoft Netsh Documentation: Official Netsh Reference
Netsh Portproxy: Port Proxy Commands
Windows Network Security: Security Considerations
SANS Windows Pivoting: Windows Lateral Movement Techniques
Last updated