mirror of
https://github.com/yunginnanet/HellPot
synced 2024-06-30 01:30:53 +00:00
Merge branch 'main' into development
This commit is contained in:
commit
20c41bebdc
@ -1,15 +1,16 @@
|
|||||||
# HellPot
|
<div align="center">
|
||||||
|
<img src="https://tcp.ac/i/00ctL.gif" alt="HellPot"/>
|
||||||
|
|
||||||
[![GoDoc](https://godoc.org/github.com/yunginnanet/HellPot?status.svg)](https://godoc.org/github.com/yunginnanet/HellPot) [![Go Report Card](https://goreportcard.com/badge/github.com/yunginnanet/HellPot)](https://goreportcard.com/report/github.com/yunginnanet/HellPot) [![IRC](https://img.shields.io/badge/ircd.chat-%23tcpdirect-blue.svg)](ircs://ircd.chat:6697/#tcpdirect) [![Mentioned in Awesome Honeypots](https://awesome.re/mentioned-badge.svg)](https://github.com/paralax/awesome-honeypots)
|
[![GoDoc](https://godoc.org/github.com/yunginnanet/HellPot?status.svg)](https://godoc.org/github.com/yunginnanet/HellPot) [![Go Report Card](https://goreportcard.com/badge/github.com/yunginnanet/HellPot)](https://goreportcard.com/report/github.com/yunginnanet/HellPot) [![IRC](https://img.shields.io/badge/ircd.chat-%23tcpdirect-blue.svg)](ircs://ircd.chat:6697/#tcpdirect) [![Mentioned in Awesome Honeypots](https://awesome.re/mentioned-badge.svg)](https://github.com/paralax/awesome-honeypots)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
HellPot is an endless honeypot based on [Heffalump](https://github.com/carlmjohnson/heffalump) that sends unruly HTTP bots to hell.
|
HellPot is an endless honeypot based on [Heffalump](https://github.com/carlmjohnson/heffalump) that sends unruly HTTP bots to hell.
|
||||||
|
|
||||||
Notably it implements a [toml configuration file](https://github.com/knadh/koanf), has [JSON logging](https://github.com/rs/zerolog), and comes with significant performance gains.
|
Notably it implements a [toml configuration file](https://github.com/knadh/koanf), has [JSON logging](https://github.com/rs/zerolog), and comes with significant performance gains.
|
||||||
|
|
||||||
![Exploding Heffalump](https://tcp.ac/i/H8O9M.gif)
|
|
||||||
|
|
||||||
## Grave Consequences
|
## Grave Consequences
|
||||||
|
|
||||||
Clients (hopefully bots) that disregard `robots.txt` and connect to your instance of HellPot will **suffer eternal consequences**.
|
Clients (hopefully bots) that disregard `robots.txt` and connect to your instance of HellPot will **suffer eternal consequences**.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -24,6 +25,16 @@ var (
|
|||||||
snek = viper.New(".")
|
snek = viper.New(".")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
home, _ = os.UserHomeDir()
|
||||||
|
if home == "" {
|
||||||
|
home = os.Getenv("HOME")
|
||||||
|
}
|
||||||
|
if home == "" {
|
||||||
|
println("WARNING: could not determine home directory")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// exported generic vars
|
// exported generic vars
|
||||||
var (
|
var (
|
||||||
// Trace is the value of our trace (extra verbose) on/off toggle as per the current configuration.
|
// Trace is the value of our trace (extra verbose) on/off toggle as per the current configuration.
|
||||||
@ -41,8 +52,13 @@ var (
|
|||||||
func writeConfig() string {
|
func writeConfig() string {
|
||||||
prefConfigLocation, _ := os.UserConfigDir()
|
prefConfigLocation, _ := os.UserConfigDir()
|
||||||
|
|
||||||
|
if prefConfigLocation == "" {
|
||||||
|
home, _ = os.UserHomeDir()
|
||||||
|
prefConfigLocation = filepath.Join(home, ".config", Title)
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := os.Stat(prefConfigLocation); os.IsNotExist(err) {
|
if _, err := os.Stat(prefConfigLocation); os.IsNotExist(err) {
|
||||||
if err = os.MkdirAll(prefConfigLocation, 0o750); err != nil {
|
if err = os.MkdirAll(prefConfigLocation, 0o750); err != nil && !errors.Is(err, os.ErrExist) {
|
||||||
println("error writing new config: " + err.Error())
|
println("error writing new config: " + err.Error())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -92,25 +108,31 @@ func Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if chosen == "" && uconf != "" {
|
if chosen == "" && uconf != "" {
|
||||||
|
_ = os.MkdirAll(filepath.Join(uconf, Title), 0750)
|
||||||
chosen = filepath.Join(uconf, Title, "config.toml")
|
chosen = filepath.Join(uconf, Title, "config.toml")
|
||||||
}
|
}
|
||||||
|
|
||||||
if chosen == "" {
|
if chosen == "" {
|
||||||
|
pwd, _ := os.Getwd()
|
||||||
if _, err := os.Stat("./config.toml"); err == nil {
|
if _, err := os.Stat("./config.toml"); err == nil {
|
||||||
chosen = "./config.toml"
|
chosen = "./config.toml"
|
||||||
|
} else {
|
||||||
|
if _, err := os.Stat(filepath.Join(pwd, "config.toml")); err == nil {
|
||||||
|
chosen = filepath.Join(pwd, "config.toml")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if chosen == "" {
|
loadErr := snek.Load(file.Provider(chosen), toml.Parser())
|
||||||
|
|
||||||
|
if chosen == "" || loadErr != nil {
|
||||||
println("No configuration file found, writing new configuration file...")
|
println("No configuration file found, writing new configuration file...")
|
||||||
chosen = writeConfig()
|
chosen = writeConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
Filename = chosen
|
Filename = chosen
|
||||||
|
|
||||||
if err := snek.Load(file.Provider(chosen), toml.Parser()); err != nil {
|
if loadErr = snek.Load(file.Provider(chosen), toml.Parser()); loadErr != nil {
|
||||||
println("Error opening specified config file: " + chosen)
|
fmt.Println("failed to load default config file: ", loadErr.Error())
|
||||||
println(err.Error())
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -20,10 +21,10 @@ var (
|
|||||||
|
|
||||||
func prepLogDir() {
|
func prepLogDir() {
|
||||||
logDir = snek.String("logger.directory")
|
logDir = snek.String("logger.directory")
|
||||||
if err := os.MkdirAll(logDir, 0750); err != nil {
|
if logDir == "" {
|
||||||
println("cannot create log directory: " + logDir + "(" + err.Error() + ")")
|
logDir = filepath.Join(home, ".local", "share", Title, "logs")
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
_ = os.MkdirAll(logDir, 0750)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartLogger instantiates an instance of our zerolog loggger so we can hook it in our main package.
|
// StartLogger instantiates an instance of our zerolog loggger so we can hook it in our main package.
|
||||||
|
Loading…
Reference in New Issue
Block a user