βš™οΈ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.exe

  • Availability: Present on all Windows systems

  • Privileges: Requires administrator privileges for port forwarding

Netsh Capabilities

  1. Finding routes - network path discovery

  2. Viewing firewall configuration - Windows Firewall management

  3. Adding proxies - proxy server configuration

  4. Creating port forwarding rules - IPv4-to-IPv4 forwarding

  5. 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)

  1. Legitimate Tool - netsh.exe is standard Windows utility

  2. Administrative Logs - commands logged in Windows Event Log

  3. Persistent Rules - forwards survive reboots (good for persistence)

  4. Firewall Integration - works with Windows Firewall

  5. Process Visibility - no additional processes required

Detection Risks

  1. Command Line Auditing - PowerShell/CMD logging may capture commands

  2. Event Log Entries - Windows Security log may record configuration changes

  3. Network Monitoring - unusual port listeners detectable

  4. Registry Changes - port proxy rules stored in registry

  5. 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

  1. Test locally first - verify connectivity before deployment

  2. Use non-standard ports - avoid common port detection

  3. Document configurations - track created port forwards

  4. Clean up after use - remove forwards when done

  5. Monitor connections - watch for unexpected traffic

Security Recommendations

  1. Minimize exposure time - create forwards only when needed

  2. Use specific bind addresses - avoid 0.0.0.0 when possible

  3. Implement access controls - Windows Firewall rules

  4. Monitor event logs - watch for detection indicators

  5. Rotate ports regularly - vary port usage patterns

Performance Considerations

  1. Limit concurrent forwards - avoid resource exhaustion

  2. Monitor bandwidth usage - track network utilization

  3. Consider connection limits - Windows has TCP connection limits

  4. Optimize for target services - tune for specific protocols

  5. Test under load - verify performance with multiple connections


References

Last updated