A secure remote client/server terminal, written in Golang. Intended as a test-bed for experimental key exchanges and symmetric session crypto. Integrated traffic chaffing.
Go to file
Russ Magee b0f614f82e Tunnel keepalives from client implemented. If client dies/exits unexpectedly the server
tunnel will disconnect from rport in a timely manner.

Signed-off-by: Russ Magee <rmagee@gmail.com>
2018-11-11 22:46:39 -08:00
herradurakex Moved HerraduraKEx-specific LICENSE files into component subdir 2018-10-10 22:35:49 -07:00
hkexnet Tunnel keepalives from client implemented. If client dies/exits unexpectedly the server 2018-11-11 22:46:39 -08:00
hkexpasswd -hkexpasswd: now can add new users 2018-09-07 20:56:42 -07:00
hkexsh Tunnel keepalives from client implemented. If client dies/exits unexpectedly the server 2018-11-11 22:46:39 -08:00
hkexshd Tunnels working again to basic level w/o re-connect or re-dial 2018-11-01 18:52:01 -07:00
logger Pushed logging into sub-package to preserve windows client build 2018-10-26 16:05:01 -07:00
spinsult Updates to main Makefile (and added spinsult Makefile) 2018-07-04 23:07:09 -07:00
CODE_OF_CONDUCT.md Added clause 11a. to cover crypto regs 2018-10-19 11:50:17 -07:00
CODE_OF_MERIT.md Added clause 11a. to cover crypto regs 2018-10-19 11:56:09 -07:00
LICENSE.mit Added hkexnet to LICENSE file 2018-10-10 22:37:25 -07:00
Makefile Pushed logging into sub-package to preserve windows client build 2018-10-26 16:05:01 -07:00
README.md Updated README.md for new CryptMTv1 cipher 2018-10-24 00:31:32 -07:00
TODO.txt Update TODO - ~/.hkexsh_id 2018-10-08 23:42:09 -07:00
consts.go Bump version 2018-10-21 20:32:57 -07:00
cp.cmd Continuing groundwork for cp mode - refactor main client code into shell/copy subroutines; -r option 2018-08-06 22:29:51 -07:00
hkexauth.go Added validation user actually exists on system 2018-10-03 22:31:35 -07:00
hkexsession.go GenAuthToken() now uses client-supplied ConnHost 2018-09-14 01:13:14 -07:00
termmode_unix.go MSYS+mintty support; pkg renaming to hkexsh 2018-04-04 15:43:27 -07:00
termmode_windows.go MSYS+mintty support; pkg renaming to hkexsh 2018-04-04 15:43:27 -07:00

README.md

HKExSh

'hkexsh' (HerraduraKyberEx shell) is a golang implementation of a simple remote shell client and server, similar in role to ssh, offering encrypted interactive and non-interactive sessions as well as file copying.

The client and server programs (hkexsh and hkexshd) use a mostly drop-in replacement for golang's standard golang/pkg/net facilities (net.Dial(), net.Listen(), net.Accept() and the net.Conn type), which automatically negotiate keying material for 'secure' sockets, using one of a selectable set of experimental key exchange (KEX) or key encapsulation mechanisms (KEM).

Currently supported exchanges are:

Currently supported session encryption and hmac algorithms:

One can simply replace calls to net.Dial() with hkex.Dial(), and likewise net.Listen() with hkex.Listen(), to obtain connections (hkex.Conn) conforming to the basic net.Conn interface. Upon Dial(), the HerraduraKEx key exchange is initiated (whereby client and server independently derive the same keying material).

Above the hkex.Conn layer, the server and client apps in this repository (server/hkexshd and client/hkexsh) negotiate session settings (cipher/hmac algorithms, interactive/non-interactive, etc.) to be used for further communication.

Packets are subject to random padding, and (optionally) the client and server channels can both send chaff packets at random defineable intervals to help thwart analysis of session activity (especially for interactive shell sessions).

NOTE: THIS PROJECT IS EXPERIMENTAL. Due to the experimental nature of the HerraduraKEx and Kyber IND-CCA-2 algorithms, this package SHOULD BE USED WITH CAUTION and should DEFINITELY NOT be used for any sensitive applications. USE AT YOUR OWN RISK. NO WARRANTY OR CLAIM OF FITNESS FOR PURPOSE IS IMPLIED.

HERRADURA KEX

As of this time (Oct 2018) no verdict by acknowledged 'crypto experts' as to the level of security of the HerraduraKEx algorithm for purposes of session key exchange over an insecure channel has been rendered. It is hoped that experts in the field will analyze the algorithm and determine if it is indeed a suitable one for use in situations where Diffie-Hellman or other key exchange algorithms are currently utilized.

KYBER IND-CCA-2 KEM

As of this time (Oct 2018) Kyber is one of the candidate algorithms submitted to the NIST post-quantum cryptography project. The authors recommend using it in "... so-called hybrid mode in combination with established "pre-quantum" security; for example in combination with elliptic-curve Diffie-Hellman." THIS PROJECT DOES NOT DO THIS, for purposes of simplicity of code and to evaluate the algorithm in operation by itself (again, THIS PROJECT IS EXPERIMENTAL.)

Finally, within the hkexpasswd/ directory is a password-setting utility using its own user/password file distinct from the system /etc/passwd, which is used by the hkexshd server to authenticate clients.

Dependencies:

Get source code

  • $ go get -u blitter.com/go/hkexsh
  • $ cd $GOPATH/src/blitter.com/go/hkexsh
  • $ go build ./... # install all dependent go pkgs

To build

  • $ cd $GOPATH/src/blitter.com/go/hkexsh
  • $ make clean all

To set accounts & passwords:

  • $ sudo touch /etc/hkexsh.passwd
  • $ sudo hkexpasswd/hkexpasswd -u joebloggs
  • $ <enter a password, enter again to confirm>

Running Clent and Server

In separate shells A and B:

  • [A]$ cd hkexshd && sudo ./hkexshd & # add -d for debugging

Interactive shell

  • [B]$ cd hkexsh && ./hkexsh joebloggs@host-or-ip # add -d for debugging

One-shot command

  • [B]$ cd hkexsh && ./hkexsh -x "ls /tmp" joebloggs@host-or-ip

WARNING WARNING WARNING: the -d debug flag will echo passwords to the log/console!

NOTE if running client (hkexsh) with -d, one will likely need to run 'reset' afterwards to fix up the shell tty afterwards, as stty echo may not be restored if client crashes or is interrupted.

Setting up an 'authtoken' for scripted (password-free) logins

Use the -g option of hkexsh to request a token from the remote server, which will return a hostname:token string. Place this string into $HOME/.hkexsh_id to allow logins without entering a password (obviously, $HOME/.hkexsh_id on both server and client $HOME for the user should not be world-readable.)

File Copying using hkexcp

hkexcp is a symlink to hkexsh, and the binary checks its own filename to determine whether it is being invoked in 'shell' or 'copy' mode. Refer to the '-h' output for differences in accepted options.

General remote syntax is: user@server:[/]src-or-dest-path If no leading / is specified in src-or-dest-path, it is assumed to be relative to $HOME of the remote user. File operations are all performed as the remote user, so account permissions apply as expected.

Local (client) to remote (server) copy:

  • cd hkexsh && ./hkexcp fileA /some/where/fileB /some/where/else/dirC joebloggs@host-or-ip:remoteDir

Remote (server) to local (client) copy:

  • cd hekxsh && ./hkexcp joebloggs@host-or-ip:/remoteDirOrFile /some/where/local/Dir

NOTE: Renaming while copying is NOT supported (ie., like cp's 'cp /foo/bar/fileA ./fileB). Put another way, the destination (whether local or remote) is ALWAYS a dir.

hkexcp uses tar with gzip compression (ala a 'tarpipe') under the hood, sending tar data over the hkex encrypted channel. Use the -d flag on client or server to see the generated tar commandlines if you're curious.