Last active
September 26, 2024 11:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Can this be modified, so that it connects to some port on remote server and redirects to some local port ?
Can this be modified, so that it connects to some port on remote server and redirects to some local port ?
- Create listener on remove server port X and forward that to port Y localhost
- 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
ncat supports -k which keep the connection open