Skip to content

Instantly share code, notes, and snippets.

@calaveraInfo
Last active September 26, 2024 11:37
Show Gist options
  • Save calaveraInfo/01691146a54df985acc523a71aecf93f to your computer and use it in GitHub Desktop.
Save calaveraInfo/01691146a54df985acc523a71aecf93f to your computer and use it in GitHub Desktop.
How to create extremely simple (http) reverse proxy using netcat (nmap flavor) and a named pipe
mkfifo reply
ncat -kl 8765 < reply | ncat 127.0.0.1 4567 > reply # listens on port 8765 and redirects to localhost:4567. Runs until C-c.
rm reply # cleanup after end
@snimavat
Copy link

snimavat commented Feb 7, 2024

Can this be modified, so that it connects to some port on remote server and redirects to some local port ?

@Isanderthul
Copy link

Can this be modified, so that it connects to some port on remote server and redirects to some local port ?

  1. Create listener on remove server port X and forward that to port Y localhost
  2. on your computer create a reverse shell from server port Y to your local port Z below allow_incoming.sh making remote server 9026 to go to local port 9001
#!/bin/bash

# SERVER_IP: this is the publicly available server
SERVER_IP='test.example.com'

# SERVER_PORT: the port you want to connect to remote
SERVER_PORT='9026'

# LOCAL_IP: the IP of the local server
LOCAL_IP='127.0.0.1'

# LOCAL_PORT: The local port to forward the data to
LOCAL_PORT='9001' 

echo "forwarding $SERVER_IP:$SERVER_PORT to $LOCAL_IP:$LOCAL_PORT"

ssh -i ~/.ssh/KeyToUse -N -T -R 0.0.0.0:$SERVER_PORT:$LOCAL_IP:$LOCAL_PORT root@$SERVER_IP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment