Skip to content

Commit

Permalink
Added api key
Browse files Browse the repository at this point in the history
  • Loading branch information
domwhewell-sage committed May 8, 2024
1 parent 701f1fe commit b943171
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
24 changes: 7 additions & 17 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,13 @@ Email Address - {{ .Email }}
IP Address - {{ .Address }}
User Agent - {{ .UserAgent }}`

var defaultgraphqlTemplate = `mutation InsertGophishLog (
$oplog: bigint!, $sourceIp: String, $tool: String,
$userContext: String, $description: String, $output: String,
$comments: String
) {
insert_oplogEntry(objects: {
oplog: $oplog,
sourceIp: $sourceIp,
tool: $tool,
userContext: $userContext,
description: $description,
output: $output,
comments: $comments
}) {
returning { id }
var defaultgraphqlTemplate = `mutation InsertGophishLog ($oplog: bigint!, $sourceIp: String, $tool: String, $userContext: String, $description: String, $output: String, $comments: String) {
insert_oplogEntry(objects: {oplog: $oplog, sourceIp: $sourceIp, tool: $tool, userContext: $userContext, description: $description, comments: $comments, output: $output}) {
returning {
id
}
}
}`
}`

func init() {
viper.SetConfigName("config")
Expand Down Expand Up @@ -107,7 +97,7 @@ func validateConfig() {
continue
}
if profile == "ghostwriter" {
ghostwriterConfigs := []string{"ghostwriter.graphql_endpoint", "ghostwriter.api_key"}
ghostwriterConfigs := []string{"ghostwriter.graphql_endpoint", "ghostwriter.api_key", "ghostwriter.oplog_id"}
checkKeysExist(ghostwriterConfigs...)
log.Infof("Using Ghostwriter sending profile. Will send messages to %s", viper.GetString("ghostwriter.graphql_endpoint"))
continue
Expand Down
2 changes: 2 additions & 0 deletions sending_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ func sendEmail(subject, body string) error {

func sendGraphql(data ghostwriter_oplog_entry) error {
url := viper.GetString("ghostwriter.graphql_endpoint")
api_key := viper.GetString("ghostwriter.api_key")
query := viper.GetString("graphql_default_query")
oplog_id := viper.GetInt("ghostwriter.oplog_id")
client := graphql.NewClient(url)

req := graphql.NewRequest(query)
req.Header.Set("Authorization", "Bearer "+api_key)
req.Var("oplog", oplog_id)
req.Var("sourceIp", data.SourceIp)
req.Var("tool", "gophish")
Expand Down

0 comments on commit b943171

Please sign in to comment.