aboutsummaryrefslogtreecommitdiff
path: root/ssh.go
diff options
context:
space:
mode:
authorMarin Ivanov <[email protected]>2019-03-24 21:45:18 +0200
committerMarin Ivanov <[email protected]>2019-03-24 21:45:18 +0200
commit6ab1613157a6a5d3eabf9d2fe2adf4699d29a5ba (patch)
tree37d916734789e97096a78d907fd0046dfa349e82 /ssh.go
parent317163b27c1b16687a1473b6b40e743a83964f6a (diff)
Make TCP connection tarpit
This first version of the command has support for SSH protocol tarpit.
Diffstat (limited to 'ssh.go')
-rw-r--r--ssh.go33
1 files changed, 33 insertions, 0 deletions
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
+ }
+ }
+ }
+}