From a76a95b3005fa1b14a3b1229be92494c7bd85582 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 17 Sep 2021 09:27:00 +0200 Subject: [PATCH] Log country --- honeypot/server.go | 9 ++++++++- version.go | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/honeypot/server.go b/honeypot/server.go index ee4b430..a08a2d5 100644 --- a/honeypot/server.go +++ b/honeypot/server.go @@ -6,6 +6,7 @@ import ( "net" "os" "time" + "unicode/utf8" gossh "golang.org/x/crypto/ssh" @@ -90,11 +91,17 @@ func (hs *HoneypotServer) passwordHandler(ctx ssh.Context, password string) bool ConnectionUUID: sessUUID, } country := hs.LookupCountry(la.RemoteIP) + if utf8.RuneCountInString(country) > 2 { + hs.Logger.Warnw("Too many characters in country", "country", country, "runecount", utf8.RuneCountInString(country)) + country = "??" + } + la.Country = country hs.Logger.Infow("Login attempt", "remote_ip", la.RemoteIP.String(), "username", la.Username, - "password", la.Password) + "password", la.Password, + "country", la.Country) if err := hs.attemptStore.AddAttempt(&la); err != nil { hs.Logger.Warnw("Error adding attempt to store", "error", err) diff --git a/version.go b/version.go index 56a1314..e84afe6 100644 --- a/version.go +++ b/version.go @@ -5,7 +5,7 @@ import ( "runtime" ) -var Version = "v0.1.8" +var Version = "v0.1.9" var Build string func FullVersion() string {