Skip to content

Commit

Permalink
Initial honeypot code.
Browse files Browse the repository at this point in the history
  • Loading branch information
d1str0 committed Feb 22, 2019
1 parent 14f2486 commit fe164fc
Show file tree
Hide file tree
Showing 6 changed files with 2,454 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -10,3 +10,7 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

drupot
*.swp
config.toml
2,346 changes: 2,346 additions & 0 deletions CHANGELOG-7.63.txt

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions config.toml.example
@@ -0,0 +1,21 @@
# Drupot Configuration File


# Port to server the honeypot webserver on.
# Note: Ports under 1024 require sudo.
HttpServerPort = 80

# Allows you to choose which changelog file to return to spoof different versions.
# Always served as "CHANGELOG.txt"
DrupalChangelogFilepath = "CHANGELOG-7.63.txt"

# Meta data to be provided with each request phoned home
HpfeedsMeta = "Drupal scan event detected"

[hpfeeds]
Host = "hpfeeds.example.com"
Port = 10000
Ident = "drupot"
Auth = "drupot"
Channel = "drupot.events"

6 changes: 6 additions & 0 deletions go.mod
@@ -0,0 +1,6 @@
module github.com/d1str0/Drupot

require (
github.com/BurntSushi/toml v0.3.1
github.com/d1str0/hpfeeds v0.1.1
)
4 changes: 4 additions & 0 deletions go.sum
@@ -0,0 +1,4 @@
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/d1str0/hpfeeds v0.1.1 h1:ni3FrwJNbJ149hTms2W219lRdg7OC7Tpaj0VLdEoV/c=
github.com/d1str0/hpfeeds v0.1.1/go.mod h1:Vz6oY+o+BF++pu8d/Aj9fjeVWMTGQjOIi2Ow/2+kLSY=
73 changes: 73 additions & 0 deletions main.go
@@ -0,0 +1,73 @@
package main

import (
"flag"
"fmt"
"log"

"github.com/BurntSushi/toml"
"github.com/d1str0/hpfeeds"
)

type Config struct {
StartPort int
EndPort int
ExcludedPorts []int
HpfConfig *HpfConfig `toml:"hpfeeds"`
}

// Config for Hpfeeds publishing
type HpfConfig struct {
Host string
Port int
Ident string
Auth string
Channel string
}

func main() {
fmt.Println("///- Running WhiteNoise")

// Load config file
var configFilename string
var logFilename string
flag.StringVar(&configFilename, "c", "config.toml", "load given config file")
flag.StringVar(&logFilename, "l", "", "log file to write to")

flag.Parse()

fmt.Printf("//- Loading config file: %s\n", configFilename)
c := loadConfig(configFilename)
if c.HpfConfig != nil {
hpc := c.HpfConfig
fmt.Printf("/- Connecting to hpfeeds server: %s\n", hpc.Host)
fmt.Printf("/-\tPort: %d\n", hpc.Port)
fmt.Printf("/-\tIdent: %s\n", hpc.Ident)
fmt.Printf("/-\tAuth: %s\n", hpc.Auth)
fmt.Printf("/-\tChannel: %s\n", hpc.Channel)

client := hpfeeds.NewClient(hpc.Host, hpc.Port, hpc.Ident, hpc.Auth)
err := client.Connect()
if err != nil {
log.Fatalf("Error connecting to hpfeeds server: %s\n", err.Error())
}

publish := make(chan []byte)
client.Publish(hpc.Channel, publish)
publish <- []byte("test")
}

if logFilename != "" {
fmt.Printf("//- Logging to file: %s\n", logFilename)
}

}

func loadConfig(filename string) *Config {
var c Config
_, err := toml.DecodeFile(filename, &c)
if err != nil {
log.Fatalf("Unable to parse config file: %s\n", err.Error())
}
return &c
}

0 comments on commit fe164fc

Please sign in to comment.