mirror of
https://github.com/yunginnanet/HellPot
synced 2024-06-30 17:50:53 +00:00
gofmt and refine logging
This commit is contained in:
parent
3f75a2c7de
commit
db7f5d7103
18
README.md
18
README.md
@ -32,3 +32,21 @@ Live example: <a href="https://vx-underground.org/wp-login.php" rel="nofollow">D
|
|||||||
|
|
||||||
If the configuration file is missing, the default settings will automatically drop itself in the current working directory as `config.toml`.
|
If the configuration file is missing, the default settings will automatically drop itself in the current working directory as `config.toml`.
|
||||||
|
|
||||||
|
```
|
||||||
|
title = "HellPot"
|
||||||
|
|
||||||
|
[logger]
|
||||||
|
debug = false
|
||||||
|
log_directory = "./logs/"
|
||||||
|
|
||||||
|
[http]
|
||||||
|
bind_addr = "127.0.0.1"
|
||||||
|
bind_port = "8080"
|
||||||
|
# paths to be added to robots.txt that we will respond to
|
||||||
|
paths = [
|
||||||
|
"wp-login.php",
|
||||||
|
"wp-login",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
title = "HellPot"
|
title = "HellPot"
|
||||||
|
|
||||||
[logger]
|
[logger]
|
||||||
debug = false
|
debug = true
|
||||||
log_directory = "./logs/"
|
log_directory = "./logs/"
|
||||||
|
|
||||||
[http]
|
[http]
|
||||||
|
10
http.go
10
http.go
@ -39,6 +39,12 @@ func NewHoneypot(mm MarkovMap, buffsize int) http.HandlerFunc {
|
|||||||
paths = paths + "Disallow: " + p + "\r\n"
|
paths = paths + "Disallow: " + p + "\r\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Debug().
|
||||||
|
Str("UserAgent", r.UserAgent()).
|
||||||
|
Strs("REMOTE_ADDR", r.Header.Values("X-Real-IP")).
|
||||||
|
Strs("PATHS", config.Paths).
|
||||||
|
Msg("SERVE_ROBOTS")
|
||||||
|
|
||||||
if _, err := io.WriteString(w, robotsTxt+paths+"\r\n"); err != nil {
|
if _, err := io.WriteString(w, robotsTxt+paths+"\r\n"); err != nil {
|
||||||
log.Error().Err(err).Msg("SERVE_ROBOTS_ERROR")
|
log.Error().Err(err).Msg("SERVE_ROBOTS_ERROR")
|
||||||
}
|
}
|
||||||
@ -69,13 +75,13 @@ func NewHoneypot(mm MarkovMap, buffsize int) http.HandlerFunc {
|
|||||||
buf := getBuffer()
|
buf := getBuffer()
|
||||||
defer putBuffer(buf)
|
defer putBuffer(buf)
|
||||||
io.WriteString(w, "<HTML>\n<BODY>\n")
|
io.WriteString(w, "<HTML>\n<BODY>\n")
|
||||||
n, err := io.CopyBuffer(w, mm, buf)
|
n, _ := io.CopyBuffer(w, mm, buf)
|
||||||
log.Info().
|
log.Info().
|
||||||
Str("UserAgent", r.UserAgent()).
|
Str("UserAgent", r.UserAgent()).
|
||||||
Interface("URL", r.URL.RequestURI()).
|
Interface("URL", r.URL.RequestURI()).
|
||||||
Strs("REMOTE_ADDR", r.Header.Values("X-Real-IP")).
|
Strs("REMOTE_ADDR", r.Header.Values("X-Real-IP")).
|
||||||
Int64("BYTES", n).
|
Int64("BYTES", n).
|
||||||
Dur("DURATION", time.Since(s)).
|
Dur("DURATION", time.Since(s)).
|
||||||
Err(err).Msg("FINISH")
|
Msg("FINISH")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
main.go
2
main.go
@ -10,10 +10,8 @@ import (
|
|||||||
|
|
||||||
// ascii banners and other aesthetic shit
|
// ascii banners and other aesthetic shit
|
||||||
"HellPot/src/decorate"
|
"HellPot/src/decorate"
|
||||||
|
|
||||||
// bitcask embedded key/value database
|
// bitcask embedded key/value database
|
||||||
//"HellPot/src/casket"
|
//"HellPot/src/casket"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var log zerolog.Logger
|
var log zerolog.Logger
|
||||||
|
@ -169,7 +169,7 @@ func Blueprint() {
|
|||||||
buf, err := ioutil.ReadAll(f)
|
buf, err := ioutil.ReadAll(f)
|
||||||
err2 := Config.ReadConfig(bytes.NewBuffer(buf))
|
err2 := Config.ReadConfig(bytes.NewBuffer(buf))
|
||||||
|
|
||||||
if (err != nil || err2 != nil) {
|
if err != nil || err2 != nil {
|
||||||
println("Error reading specified config file: " + os.Args[i+1])
|
println("Error reading specified config file: " + os.Args[i+1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("config file read fatal error: " + err.Error())
|
panic("config file read fatal error: " + err.Error())
|
||||||
@ -274,7 +274,6 @@ func associate() {
|
|||||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for _, key := range Config.AllKeys() {
|
for _, key := range Config.AllKeys() {
|
||||||
log.Debug().Str("key", key).Msg("LOAD_CONFIG_DIRECTIVE")
|
log.Debug().Str("key", key).Msg("LOAD_CONFIG_DIRECTIVE")
|
||||||
}
|
}
|
||||||
|
@ -26,4 +26,3 @@ func LogInit() {
|
|||||||
multi := zerolog.MultiLevelWriter(zerolog.ConsoleWriter{Out: os.Stderr}, logFile)
|
multi := zerolog.MultiLevelWriter(zerolog.ConsoleWriter{Out: os.Stderr}, logFile)
|
||||||
GlobalLogger = zerolog.New(multi).With().Timestamp().Logger()
|
GlobalLogger = zerolog.New(multi).With().Timestamp().Logger()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user