From 6ab1613157a6a5d3eabf9d2fe2adf4699d29a5ba Mon Sep 17 00:00:00 2001 From: Marin Ivanov Date: Sun, 24 Mar 2019 21:45:18 +0200 Subject: Make TCP connection tarpit This first version of the command has support for SSH protocol tarpit. --- ssh.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 ssh.go (limited to 'ssh.go') diff --git a/ssh.go b/ssh.go new file mode 100644 index 0000000..3d43a6c --- /dev/null +++ b/ssh.go @@ -0,0 +1,33 @@ +package main + +import ( + "fmt" + "io" + "io/ioutil" + "math/rand" + "net" + "time" +) + +type empty struct{} + +func sshHandler(conn net.Conn) { + eof := make(chan empty) + go func() { + io.Copy(ioutil.Discard, conn) + eof <- empty{} + }() + + tick := time.Tick(10 * time.Second) + for { + select { + case <-eof: + return + case <-tick: + _, err := fmt.Fprintf(conn, "%x\r\n", rand.Uint32()) + if err != nil { + return + } + } + } +} -- cgit v1.2.3