netcat using netstack userspace library

Related tags

netkat
Overview

netkat

netcat version using raw sockets to avoid iptables and/or other OS filtering mechanisms.

Install

make build

Usage

It requires root privileges:

sudo ./bin/netkat
Usage: nk [options] [hostname] [port]

  -debug
        Debug
  -interface string
        Specify interface to use. Default interface with default route
  -listen
        Bind and listen for incoming connections
  -source-port int
        Specify source port to use
  -udp
        Use UDP instead of default TCP

Docker image

It can be used as a container image, based in alpine:

docker run -it --privileged aojea/netkat:latest 192.168.68.1 80
2021/05/31 21:29:42 Using source address 172.17.0.2/16
2021/05/31 21:29:42 Creating raw socket
2021/05/31 21:29:42 Adding ebpf ingress filter on interface eth0
2021/05/31 21:29:42 filter {LinkIndex: 99, Handle: 0:1, Parent: ffff:fff2, Priority: 0, Protocol: 3}
2021/05/31 21:29:42 Creating user TCP/IP stack
2021/05/31 21:29:42 Dialing ...
2021/05/31 21:29:42 Connection established

Development

netkat uses the gvisor userspace TCP/IP stack "netstack"

It creates a RAW socket attached to the interface with the route to the destination IP, attaching a BPF filter for the traffic mathing the connection parameters specified as arguments.

It also creates an ingress queue and attaches an eBPF filter, to drop the traffic of the connection directed to the RAW socket, preventing that the host stack drops the connection.

Issues
  • Crash because of TUN/TAP do not support ebpf

    Crash because of TUN/TAP do not support ebpf

    ./netkat -listen -debug x.x.x.x 1234
    2021/06/03 16:29:38 routes {Ifindex: 5 Dst: x.x.x.x/32 Src: y.y.y.y Gw: <nil> Flags: [] Table: 254}
    2021/06/03 16:29:38 Creating raw socket
    2021/06/03 16:29:38 Adding ebpf ingress filter on interface zzzzzzz
    2021/06/03 16:29:38 failed to load objects: field Ingress: program _ingress: map .rodata: map create: read- and write-only maps not supported (requires >= v5.2)
    
    opened by sbilly 1
  • add  TCP listen

    add TCP listen

    Add listen options

    It needs some refactoring

    • [x] add tests
    • [x] bpf and ebpf filter, we don't know the source ip and port
    • [x] variables doesn't match now
    • [ ] UDP listener, I can't find it in gvisor
    opened by aojea 0
  • Reorganise code

    Reorganise code

    just move functions with same scope to a different file so it is easier to read

    opened by aojea 0
  • add short flags

    add short flags

    implement short flags

    opened by aojea 0
Releases(v0.1.0)
  • v0.1.0(Jun 4, 2021)

  • 0.0.1(Jun 2, 2021)

    Client TCP connect mode only.

    Dockerfile aojea/netkat:0.0.1

    
                        ┌─────────┐                  ┌─────────────┐
    ┌───────┐           │         │                  │             │
    │netkat ├───────────┼─────────┼──────────────────►             │
    └───────┘           ├─────────┤                  │             │
                        │         │                  │             │
                        │         │                  │             │
                        ├─────────┤                  │             │
     ┌───────┐          │         │                  │             │
     │  nc   ├──────────►         │                  │             │
     └───────┘          ┌─────────┤                  │             │
                        │         │                  └─────────────┘
                        │         │
                        └─────────┘
    
    
    Source code(tar.gz)
    Source code(zip)
    netkat(7.56 MB)
Owner
Antonio Ojea
The network is reliable. Latency is zero, Bandwidth is infinite, ..
Antonio Ojea
Mutual TLS encryption TCP proxy with golang

mtls-tcp-proxy Mutual Authentication TLS encryption TCP proxy with golang Why? I created this because of sometimes, it is not possible for us to estab

Habibie Faried 3 May 19, 2021
eBPF library for Go based on Linux libbpf

libbpfgo libbpfgo is a Go library for working with Linux's eBPF. It was created for Tracee, our open source Runtime Security and eBPF tracing tools wr

Aqua Security 48 Jun 9, 2021
Extensible network application framework inspired by netty

GO-NETTY 中文介绍 Introduction go-netty is heavily inspired by netty Feature Extensible transport support, default support TCP, UDP, QUIC, KCP, Websocket

The Go-Netty Project 207 May 26, 2021
Library to work with eBPF programs from Go

Go eBPF A nice and convenient way to work with eBPF programs / perf events from Go. Requirements Go 1.10+ Linux Kernel 4.15+ Supported eBPF features e

Dropbox 705 Jun 14, 2021
🚥 Yet another pinger: A high-performance ICMP ping implementation build on top of BPF technology.

yap Yet-Another-Pinger: A high-performance ICMP ping implementation build on top of BPF technology. yap uses the gopacket library to receive and handl

dongdong 28 May 31, 2021
Pusher Channels HTTP API library for Go

Pusher Channels HTTP Go Library The Golang library for interacting with the Pusher Channels HTTP API. This package lets you trigger events to your cli

Pusher 162 Jun 7, 2021
Glue - Robust Go and Javascript Socket Library (Alternative to Socket.io)

Glue - Robust Go and Javascript Socket Library Glue is a real-time bidirectional socket library. It is a clean, robust and efficient alternative to so

DesertBit 9.3k Jun 2, 2021
grobotstxt is a native Go port of Google's robots.txt parser and matcher library.

grobotstxt grobotstxt is a native Go port of Google's robots.txt parser and matcher C++ library. Direct function-for-function conversion/port Preserve

Jim Smart 895 May 30, 2021
grpc-http1: A gRPC via HTTP/1 Enabling Library for Go

grpc-http1: A gRPC via HTTP/1 Enabling Library for Go This library enables using all the functionality of a gRPC server even if it is exposed behind a

StackRox 53 Jun 3, 2021
Secure-by-default HTTP servers in Go.

go-safeweb DISCLAIMER: This is not an officially supported Google product. go-safeweb is a collection of libraries for writing secure-by-default HTTP

Google 417 Jun 14, 2021
A library to simplify writing applications using TCP sockets to stream protobuff messages

BuffStreams Streaming Protocol Buffers messages over TCP in Golang What is BuffStreams? BuffStreams is a set of abstraction over TCPConns for streamin

Sean Kelly 244 May 12, 2021
Command-line tool and library for Windows remote command execution in Go

WinRM for Go Note: if you're looking for the winrm command-line tool, this has been splitted from this project and is available at winrm-cli This is a

Brice Figureau 312 Jun 10, 2021
Fluux XMPP is a Go XMPP library, focusing on simplicity, simple automation, and IoT.

Fluux XMPP is a Go XMPP library, focusing on simplicity, simple automation, and IoT. The goal is to make simple to write simple XMPP client

Fluux 243 Jun 5, 2021
DNS library in Go

Alternative (more granular) approach to a DNS library Less is more. Complete and usable DNS library. All Resource Records are supported, including the

Miek Gieben 5.6k Jun 15, 2021