Bibliotheque
DiscordHackTheBoxTryHackMeGitHub
  • Welcome wanderer
    • Bibliotheque
    • Hacking Philosophy
    • Useful Links
  • PENTESTING
    • Methodology
    • Protocols
      • FTP
      • SMB
      • NFS
      • SSH
      • RDP
      • SMTP
      • IMAP / POP3
      • RSYNC
      • SNMP
      • IPMI
      • R-Services
      • WinRM
      • WMI
      • LDAP
    • Databases
      • MySQL
      • MSSQL
      • Oracle TNS
      • PostgreSQL
    • File Transfers
      • Windows
      • Linux
      • Code
      • Misc
    • Password Attacks
      • John The Ripper
      • Hashcat
    • Docker
  • TOOLS
    • Nmap
    • Metasploit
    • BloodHound
    • Other
  • Linux
    • Theory
    • Commands and Utilities
      • Useful Commands
    • Bash Scripting
    • Post-Exploitation
      • Cred Hunting
      • Pivoting
  • WINDOWS
    • Theory
      • Security
    • Commands and Utilities
    • PowerShell
    • Post-Exploitation
      • Tools
      • Enumeration
        • System
        • Network
        • Users
        • Groups
        • Processes / Services
        • Permissions
        • Defence
        • Programs
        • Files
      • Access
      • Pivoting
      • Cred Hunting
    • Privilege Escalation
      • Privileges
      • Built-In Groups
        • Backup Operators
        • Server Operators
        • Print Operators
        • DnsAdmins
        • Event Log Readers
      • Privilege Abuse
        • Potatoes
        • SeDebugPrivilege
        • SeTakeOwnershipPrivilege
      • MISC
        • UAC Bypass
        • User-Interaction Attacks
        • Weak Permissions
  • ACTIVE DIRECTORY
    • Theory
      • Terminology
    • Reconnaissance
      • Responder
      • Password Policies
      • DNS
      • Enumeration
        • Users
        • Groups
          • GPO's
        • Shares
        • Domain
        • Trusts
        • ACL
    • Movement
      • Credentials
        • Dumping
          • DCSync
          • DPAPI Secrets
        • Making a Target List
        • Spraying
        • Powershell Remoting
      • Kerberos
        • Kerbrute
        • Kerberoasting
          • Semi-Manual Way
          • Targeted Kerberoasting
        • ASREProasting
        • Forging
          • Golden Ticket
        • Overpass The Hash
        • Pass The Ticket
        • RBCD
        • noPAC
      • MITM / Coerced Auths
        • LLMNR, NBT-NS Poisoning
        • PetitPotam
      • DACL Abuse
        • AddMember
        • ForceChangePassword
      • Trust Abuse
        • ExtraSIDs
      • ADCS
        • ESC1
      • Printers
        • PrintNightmare
    • Tools
  • Networking
    • Theory
      • Types / Topologies
      • OSI & TCP/IP Models
      • TCP / UDP
      • MAC Addresses
      • IP / Subnetting
      • Proxies
      • ARP
    • Pivoting
      • Port-Forwarding
    • Commands and Utilities
    • Techniques
  • WEB
    • Web Recon
      • Fuzzing
    • DNS
  • CLOUD
    • Google GKE/GCP
      • Theory
Powered by GitBook
On this page
  • ABOUT
  • LOCAL PORT FORWARDING
  • How it works
  • Use case
  • Example
  • REMOTE PORT FORWARDING
  • How it works
  • Use case
  • Example
  • DYNAMIC PORT FORWARDING
  • How it works
  • Use case
  • Example
  1. Networking
  2. Pivoting

Port-Forwarding

ABOUT

Port forwarding is a technique that allows us to redirect a communication request from one port to another. Port forwarding uses TCP as the primary communication layer to provide interactive communication for the forwarded port. Basically if shortly:

  • Local Port-Forwarding is like regular shell. Forwards our traffic through port to victim host port

  • Remote Port-Forwarding is like reverse shell. To bypass firewall we make victim host to forward traffic to our host

  • Dynamic Port-Forwarding is just a proxy, working with inbound and outbound traffic

LOCAL PORT FORWARDING

Local port forwarding allows you to forward traffic from your local machine to a remote server. This is commonly used to access services behind a firewall or to create a secure channel for data transmission.

How it works

You specify a local port (e.g., 1234) and bind it to a remote service through an intermediary (like an SSH server). Traffic sent to the local port is encrypted and forwarded to the destination.

Use case

Accessing an intranet site or database from your local machine using SSH.

Example

ssh -L <local-port>:<remote-ip>:<remote-port> user@<remote-ip>

REMOTE PORT FORWARDING

Remote port forwarding is the reverse of local port forwarding. It allows a remote machine to forward its traffic to a service on your local machine.

How it works

You expose a local service (e.g., a web server running on your local machine) to a remote server. The remote server listens on a specified port and forwards traffic to your local machine.

Use case

Making a local service accessible to others through a remote server (e.g., for debugging or sharing an application).

Example

ssh -R <remote-port>:localhost:<local-port> user@<remote-ip>

Here, anyone accessing <remote-ip>:<remote-port> will be redirected to your local machine's localhost:<local-port>.

DYNAMIC PORT FORWARDING

Dynamic port forwarding creates a SOCKS proxy, allowing traffic to be forwarded dynamically to various destinations based on requests. This is useful for tunneling multiple connections.

How it works

Your local machine acts as a SOCKS proxy server, and applications can configure this proxy to route traffic through it. The traffic is dynamically forwarded to different destinations through the SSH server.

Use case

Bypassing firewalls, anonymizing traffic, or routing web browsing through an SSH tunnel.

Example

ssh -D <local-port> user@<remote-ip>

This creates a SOCKS proxy on localhost:<local-port>. Applications configured to use this proxy will route traffic through the SSH server dynamically.

PreviousPivotingNextCommands and Utilities

Last updated 3 months ago