Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

whattheslime/NetGo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetGo

Basic implementation of ncat in GO language.

     ___       ___       ___       ___       ___   
    /\__\     /\  \     /\  \     /\  \     /\  \  
   /:| _|_   /::\  \    \:\  \   /::\  \   /::\  \ 
  /::|/\__\ /::\:\__\   /::\__\ /:/\:\__\ /:/\:\__\
  \/|::/  / \:\:\/__/  /:/\/__/ \:\:\/__/ \:\/:/  /
    |:/  /   \:\/__/   \/__/     \::/  /   \::/  / 
    \/__/     \/__/               \/__/     \/__/  

Features

Flags Implemented Description
-b, --broker No Enable connection brokering mode
-d <time>, --delay <time> No Wait between read/writes
-e <command>, --exec <command> Yes Executes the given command
-h, --help Yes Display help screen
-k, --keep-open Yes Accept multiple connections in listen mode
-l, --listen Yes Bind and listen for incoming connections
-m <number>, --max-conns <number> Yes Maximum simultaneous connections (default: 50)
-n, --nodns No Do not resolve hostnames via DNS
-u, --udp No Use UDP instead of default TCP
-v, --verbose No Set verbosity level
-w, --wait <time> No Connect timeout
-x <proxy>, --proxy <proxy> Yes Specify address of http or socks5 host to proxy through
(HTTP proxy works only with CONNECT method)
--send Yes Only send data, ignoring received and quit on EOF
(Print md5 checksum)
--recv Yes Only receive data, never send anything and quit on EOF
(Print md5 checksum)
--tls Yes Connect or listen with TLS
--tls-cert Yes Specify TLS certificate file (PEM) for listening
--tls-key Yes Specify TLS private key (PEM) for listening
--version Yes Display version information and exit

Install

  1. Get the project:

    git clone [email protected]:WhatTheSlime/NetGo.git
    cd NetGo
  2. Compile the project:

    • For Linux and Windows:

      make
    • For Linux:

      make linux
    • For Windows:

      make windows
    • For MacOS:

      make darwin
  3. (Optional) Package binaries using upx

    upx --best build/*
  4. Use it:

    cd build
    ./netgo -h

Port Forwarding Tips

Execute commands on a target using an intermediate host (Proxy Jump)

Consider following network configuration:

+--------+     +--------+     +--------+
| Host 1 |     | Host 2 |     | Host 3 |
|--------| --> |--------| --> |--------|
| Start  |     |  Jump  |     | Target |
+--------+     +--------+     +--------+

Connect from host1 to host3 using host2:

Equivalent to ssh -J host2:2000 host3 -p 3000

  1. Start listener on host3:

    ./netgo -l 3000 -e /bin/bash
  2. Start port forwarder on host2:

    ./netgo -l 2000 -e './netgo host3 3000'
  3. Connect to host2 from host1:

    ./netgo host2 2000

Local Port Forwarding

Consider following network configuration:

+--------+                   +--------------------+
| Host 1 |     One way       |       Host 2       |
|--------| -- connection --> |--------------------|
| Client |                   | Local HTTP service |
+--------+                   +--------------------+

Forward local port host1:8001 to the host2:8002 HTTP service:

Equivalent to ssh host2 -p 1337 -NL 127.0.0.1:8001:127.0.0.1:8002

  1. Start a local HTTP service on host2:

    python3 -m http.server -b 127.0.0.1 8002
  2. Start listener + forwarder on host2:

    ./netgo -l 1337 -e './netgo 127.0.0.1 8002'
  3. Start listener + forwarder on host1:

    ./netgo -l 8001 -e './netgo host2 1337'
  4. Access to host2 local HTTP service from host1:

    curl http://127.0.0.1:8001

Remote Port Forwarding

Consider following network configuration:

+--------------------+                   +--------+
|       Host 1       |     One way       | Host 2 |
|--------------------| -- connection --> |--------|
| Local HTTP service |                   | Client |
+--------------------+                   +--------+

Forward a remote port host2:8002 to the host1:8001 HTTP service:

Equivalent to ssh host2 -p 1337 -NR 127.0.0.1:8002:127.0.0.1:8001

  1. Start an HTTP service on host1:

    python3 -m http.server -b 127.0.0.1 8001
  2. Start forwarder + listener on host2:

    ./netgo -l 1337 -e './netgo -l 127.0.0.1 8002'
  3. Start client + forwarder on host1:

    ./netgo host2 1337 -e './netgo 127.0.0.1 8001'
  4. Access to host1 local HTTP service from host2:

    curl http://127.0.0.1:8002

References

About

A basic implementation of ncat in go language

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published