diff options
| author | Marin Ivanov <[email protected]> | 2019-03-24 21:45:18 +0200 |
|---|---|---|
| committer | Marin Ivanov <[email protected]> | 2019-03-24 21:45:18 +0200 |
| commit | 6ab1613157a6a5d3eabf9d2fe2adf4699d29a5ba (patch) | |
| tree | 37d916734789e97096a78d907fd0046dfa349e82 /ssh.go | |
| parent | 317163b27c1b16687a1473b6b40e743a83964f6a (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.go | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -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 + } + } + } +} |
