23 lines
643 B
Go
23 lines
643 B
Go
package services
|
|
|
|
import (
|
|
"net"
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
func NewLDAPHandler(log LoggerFunc) Handler {
|
|
return func(conn net.Conn) {
|
|
defer conn.Close()
|
|
remote := conn.RemoteAddr().String()
|
|
conn.SetDeadline(time.Now().Add(30 * time.Second))
|
|
buf := make([]byte, 1024)
|
|
n, err := conn.Read(buf)
|
|
if err != nil { return }
|
|
if n > 0 {
|
|
log(Record{Timestamp: Now(), RemoteAddr: remoteIP(remote), RemotePort: remotePort(remote), Service: "ldap", Details: map[string]string{"event":"bind_attempt","request_size":strconv.Itoa(n)}})
|
|
}
|
|
_, _ = conn.Write([]byte{0x30,0x0c,0x02,0x01,0x01,0x61,0x07,0x0a,0x01,0x31,0x04,0x00,0x04,0x00})
|
|
}
|
|
}
|