Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log more event types #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ base_url: https://10.0.0.15:3333
profiles:
- slack
- email
# Enables notifications for each of the webhook events https://docs.getgophish.com/user-guide/documentation/webhooks. Options are `email_error`, `email_sent`, `email_opened`, `clicked_link`, `submitted_data` and `email_reported`.
events:
- email_error
- email_sent
- email_opened
- clicked_link
- submitted_data
- email_reported

# Slack Profile
slack:
Expand Down
12 changes: 11 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import (
"github.com/spf13/viper"
)

var defaultErrorTemplate = `Email ID - {{ .ID }}`

var defaultSentTemplate = `Email ID - {{ .ID }}`

var defaultClickedTemplate = `Email ID - {{ .ID }}
Email Address - {{ .Email }}
IP Address - {{ .Address }}
Expand All @@ -22,6 +26,8 @@ Email Address - {{ .Email }}
IP Address - {{ .Address }}
User Agent - {{ .UserAgent }}`

var defaultReportedTemplate = `Email ID - {{ .ID }}`

var defaultgraphqlTemplate = `mutation InsertGophishLog ($oplog: bigint!, $sourceIp: String, $tool: String, $userContext: String, $description: String, $output: String, $comments: String, $extraFields: jsonb!) {
insert_oplogEntry(objects: {oplog: $oplog, sourceIp: $sourceIp, tool: $tool, userContext: $userContext, description: $description, comments: $comments, output: $output, extraFields: $extraFields}) {
returning {
Expand Down Expand Up @@ -53,11 +59,15 @@ func setDefaults() {
viper.SetDefault("ip_query_base", "https://whatismyipaddress.com/ip/")
viper.SetDefault("listen_port", "9999")
viper.SetDefault("webhook_path", "/webhook")
viper.SetDefault("email_error_sending_template", defaultErrorTemplate)
viper.SetDefault("email_sent_template", defaultSentTemplate)
viper.SetDefault("email_send_click_template", defaultClickedTemplate)
viper.SetDefault("email_submitted_credentials_template", defaultSubmittedCredentailsTemplate)
viper.SetDefault("email_default_email_open_template", defaultEmailOpenedTemplate)
viper.SetDefault("email_reported_template", defaultReportedTemplate)
viper.SetDefault("graphql_default_query", defaultgraphqlTemplate)
viper.SetDefault("profiles", []string{"slack"})
viper.SetDefault("events", []string{"email_opened", "clicked_link", "submitted_data"})
}

func setLogLevel() {
Expand All @@ -77,7 +87,7 @@ func validateConfig() {
}
}

globalConfigs := []string{"secret", "profiles"}
globalConfigs := []string{"secret", "profiles", "events"}
checkKeysExist(globalConfigs...)

profiles := viper.GetStringSlice("profiles")
Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ func handler(w http.ResponseWriter, r *http.Request) {
return
}

sender, err := senderDispatch(response.Message, response, []byte(response.Details))
var details []byte
if response.Details != nil {
details = []byte(*response.Details)
}

sender, err := senderDispatch(response.Message, response, details)
if err != nil {
log.Error(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
Loading