\# .TH gs-netcat 1 "08 October 2020" "1.0" "gs-netcat man page" .Dd October 08, 2020 .Dt GS-NETCAT 1 .Os .Sh NAME .Nm gs-netcat .Nd transfer data, forward traffic and execute commands on a remote host. Securely. .Sh SYNOPSIS .Nm gs-netcat .Op Fl rlgvqwCTSDiu .Op Fl s Ar secret .Op Fl k Ar keyfile .Op Fl L Ar logfile .Op Fl d Ar IP .Op Fl p Ar port .Op Fl e Ar cmd .Sh DESCRIPTION The .Nm utility is a re-implementation of netcat. It allows two or more users to establish a secure TCP connection with each other in a scenario where all users are behind NAT/Firewall and would not be able to connect to each other directly. Typically a connection between one workstation and another workstation on a different Local Area Network. .Pp It uses the Global Socket Relay Network (GSRN) instead of direct TCP connections. Neither workstation needs to open a port in their firewall or accept incoming TCP connections. .Pp The connection is end-2-end encrypted using SRP (RFC 5054) with AES-256 and a 4096 Prime. The GSRN sees only the encrypted traffic. .Pp Common uses include: .Pp .Bl -bullet -offset indent -compact .It simple TCP proxies .It PTY shell .It File transfer .It a SOCKS ProxyCommand for .Xr ssh 1 .It and much, much more. .El .Pp .Sh OPTIONS .Bl -tag -width Ds .It Fl C Disable encryption and use clear-text instead. Use with caution. .It Fl d Ar ip Destination IPv4 address for port forwarding. .It Fl D Daemon & Watchdog mode. Start .Nm as a background process and restart if killed. .It Fl e Ar cmd Execute command and send output to the connected client. Needs -l. .It Fl g Generate a secure random password and output it to standard output. .It Fl i Interactive login shell. The server spawns a true PTY login shell. The client acts as a true PTY client (with Ctrl-C etc working). The client can terminate the session by typing 'Ctrl-e q' at any time or by typing 'exit'. The server supports multiple clients at the same time. .It Fl k Ar file A file containing the password. .It Fl l Server/Listening mode. The default mode is client. .It Fl L Ar file Log file [default: standard out] .It Fl p Ar port Port to listen on or to forward traffic to [1-65535]. .It Fl q Quiet mode. Do not output any warnings or errors. .It Fl r Receive-only. Do not send any data. Terminate when no more data is available for reading. .It Fl s Ar secret A password chosen by the user. Both users need to use the same password to connect. .It Fl S Act as a SOCKS4/4a/5 server. The server acts as a SOCKS4/4a/5 proxy. It allows multiple .Nm clients to (securely) relay traffic via the server. Needs -l. .It Fl T Use TOR. The .Nm tool will connect via TOR to the GSRN. This requires TOR to be installed and running. The IP and PORT of the TOR server can be set using environment variables. .It Fl t Connect to the GSRN (only) and check if the peer is listening. Do not connect the peer. .It Fl u Use UDP instead of TCP for port forwarding. Needs -p. .It Fl v Prints status messages. Use -vv to be more verbose and -vvv to be insanely verbose. .It Fl w Client to wait for the listening server to become available. .El .Sh CONSOLE The interactive login shell ( .Ar -i ) has a command console. Pressing 'Ctrl-e c' (e for EEEElite) opens the command console. The command console displays the following information: .Pp .Bl -bullet -offset indent -compact .It Latency (in milliseconds) to the remote host .It Warning when a user logs into the system or becomes active .It Data throughput .It File transfer logs .El Type 'help' for a list of available commands. .Sh FILETRANSFER File transfer is available from the command console. Files are transferred with the permission and modification timestamp unchanged. Partially transferred files are re-started where the transfer was left off. The 'put' command is used for uploading: .Dl put foobar.txt .Dl put $HOME/foobar.txt .Dl put /tmp/*.log .Dl put $(find . -type f -name '*.c') (The above example shows Shell Variable substitution and word expansion) It is possible to limit the amount of path information that is sent as implied directories for each path you specify. You can insert a dot and a slash into the source path, like this: .Dl put /foo/./bar/baz.c That would create /tmp/bar/baz.c on the remote machine. The 'get' command is used for downloading: .Dl get foobar.txt .Dl get $(find /var/./ -name '*.log') Transferring a directory automatically transfers all files and directories within that directory (recursively): .Dl get /var/log .Dl get / The first command transfers all directories and files in /var/log/*. The latter command transfers the entire filesystem. Multiple get/put commands can be scheduled at the same time. .Sh EXAMPLES .Nm Example 1 - Listen for a new connection using the password 'MySecret': .Dl $ gs-netcat -s MySecret -l .Pp Connect with client using the same password: .Dl $ gs-netcat -s MySecret .Pp .Nm Example 2 - spawn a PTY login shell when a client connects: .Dl $ gs-netcat -s MySecret -l -i .Pp Log in to server's interactive shell: .Dl $ gs-netcat -s MySecret -i .Pp Log in via TOR: .Dl $ gs-netcat -s MySecret -i -T .Pp Log in via a Socks5 Proxy: .Dl $ export GSOCKET_SOCKS_IP=127.0.0.1 .Dl $ export GSOCKET_SOCKS_PORT=1080 .Dl $ gs-netcat -s MySecret -i -T .Pp .Nm Example 3 - Execute a command when a client connects: .Dl $ gs-netcat -s MySecret -l -e 'echo hello world; id; exit' .Pp Connect client to the server: .Dl $ gs-netcat -s MySecret .Pp .Nm Example 4 - Pipe data from client to server: .Dl $ gs-netcat -s MySecret -l -r >warez.tar.gz .Pp Client to read 'warez.tar.gz' and pipe it to the server. .Dl $ gs-netcat -s MySecret