Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
2,454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,7 @@ | |
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
drupot | ||
*.swp | ||
config.toml |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module github.com/d1str0/Drupot | ||
|
||
require ( | ||
github.com/BurntSushi/toml v0.3.1 | ||
github.com/d1str0/hpfeeds v0.1.1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |