A replacement for fail2ban that doesn't fuck around.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
dentata/cmd/landmine/main.go

68 lines
1.1 KiB

package main
import (
"fmt"
"net"
"log"
"sync"
"syscall"
)
func handleConnection(conn net.Conn) {
defer conn.Close()
addr := conn.RemoteAddr()
fmt.Println("Connect from", addr.Network(), addr.String())
// send explosion notice to dentata
report, err := net.Dial("tcp","127.0.0.1:9001")
if err != nil { panic(err) }
defer report.Close()
report.Write([]byte(addr.String()))
}
func listener(addr string) {
server, err := net.Listen("tcp", addr)
if err != nil { panic(err) }
for {
conn, err := server.Accept()
if err != nil {
log.Println("ACCEPT ERROR", err)
} else {
go handleConnection(conn)
}
}
}
func ChrootJailLOL() {
err := syscall.Chdir("tmp")
if err != nil { panic(err) }
err = syscall.Chroot(".")
if err != nil { panic(err) }
err = syscall.Setuid(1000)
if err != nil { panic(err) }
syscall.Setgid(1000)
if err != nil { panic(err) }
}
func main() {
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Go(func () {
listener(fmt.Sprintf("0.0.0.0:%d", 8000 + i))
})
}
//BUG: ain't no way this works, learn to do it right
ChrootJailLOL()
wg.Wait()
}