Implemented campaign.URL. Fixed #32

Implemented {{.From}}. Fixed #36
pull/64/head
Jordan Wright 2015-10-22 19:54:01 -05:00
parent 8dcbfed3a3
commit b574fb2741
6 changed files with 24 additions and 12 deletions

View File

@ -25,6 +25,7 @@ type Campaign struct {
Groups []Group `json:"groups,omitempty"` Groups []Group `json:"groups,omitempty"`
Events []Event `json:"timeline,omitemtpy"` Events []Event `json:"timeline,omitemtpy"`
SMTP SMTP `json:"smtp"` SMTP SMTP `json:"smtp"`
URL string `json:"url"`
} }
// ErrCampaignNameNotSpecified indicates there was no template given by the user // ErrCampaignNameNotSpecified indicates there was no template given by the user

View File

@ -20,6 +20,7 @@ function save(){
template:{ template:{
name: $("#template").val() name: $("#template").val()
}, },
url: $("#url").val(),
smtp: { smtp: {
from_address: $("input[name=from]").val(), from_address: $("input[name=from]").val(),
host: $("input[name=host]").val(), host: $("input[name=host]").val(),

View File

@ -19,6 +19,8 @@ function save(idx){
template.name = $("#name").val() template.name = $("#name").val()
template.subject = $("#subject").val() template.subject = $("#subject").val()
template.html = CKEDITOR.instances["html_editor"].getData(); template.html = CKEDITOR.instances["html_editor"].getData();
// Fix the URL Scheme added by CKEditor (until we can remove it from the plugin)
template.html = template.html.replace(/https?:\/\/{{\.URL}}/gi, "{{.URL}}")
template.text = $("#text_editor").val() template.text = $("#text_editor").val()
// Add the attachments // Add the attachments
$.each($("#attachmentsTable").DataTable().rows().data(), function(i, target){ $.each($("#attachmentsTable").DataTable().rows().data(), function(i, target){

View File

@ -144,4 +144,6 @@ var api = {
// Register our moment.js datatables listeners // Register our moment.js datatables listeners
$(document).ready(function(){ $(document).ready(function(){
$.fn.dataTable.moment('MMMM Do YYYY, h:mm:ss a'); $.fn.dataTable.moment('MMMM Do YYYY, h:mm:ss a');
// Setup tooltips
$('[data-toggle="tooltip"]').tooltip()
}); });

View File

@ -68,11 +68,12 @@
<div class="form-group"> <div class="form-group">
<label for="name">Name:</label> <label for="name">Name:</label>
<input type="text" class="form-control" id="name" placeholder="Campaign name" autofocus> <input type="text" class="form-control" id="name" placeholder="Campaign name" autofocus>
<br />
<label class="control-label" for="template">Template:</label> <label class="control-label" for="template">Template:</label>
<input type="text" class="typeahead form-control" placeholder="Template Name" id="template"/> <input type="text" class="typeahead form-control" placeholder="Template Name" id="template"/>
<br> <br>
<br> <label class="control-label" for="url">URL: <i class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="Location of gophish listener (must be reachable by targets!)"></i></label>
<input type="text" class="form-control" placeholder="http://192.168.1.1" id="url"/>
<br/>
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading" role="tab"> <div class="panel-heading" role="tab">
<a role="button" class="collapsed" data-toggle="collapse" href="#smtpPanel" aria-expanded="false" aria-controls="#smtpPanel"> <a role="button" class="collapsed" data-toggle="collapse" href="#smtpPanel" aria-expanded="false" aria-controls="#smtpPanel">

View File

@ -3,12 +3,11 @@ package worker
import ( import (
"bytes" "bytes"
"log" "log"
"net" "net/mail"
"net/smtp" "net/smtp"
"os" "os"
"strings" "strings"
"text/template" "text/template"
"time"
"github.com/jordan-wright/email" "github.com/jordan-wright/email"
"github.com/jordan-wright/gophish/models" "github.com/jordan-wright/gophish/models"
@ -52,24 +51,27 @@ func processCampaign(c *models.Campaign) {
if c.SMTP.Username != "" && c.SMTP.Password != "" { if c.SMTP.Username != "" && c.SMTP.Password != "" {
auth = smtp.PlainAuth("", c.SMTP.Username, c.SMTP.Password, strings.Split(c.SMTP.Host, ":")[0]) auth = smtp.PlainAuth("", c.SMTP.Username, c.SMTP.Password, strings.Split(c.SMTP.Host, ":")[0])
} }
ips, err := net.InterfaceAddrs() f, err := mail.ParseAddress(c.SMTP.FromAddress)
if err != nil { if err != nil {
Logger.Println(err) Logger.Println(err)
} }
for _, i := range ips { ft := f.Name
Logger.Println(i.String()) if ft == "" {
ft = f.Address
} }
for _, t := range c.Results { for _, t := range c.Results {
td := struct { td := struct {
models.Result models.Result
URL string URL string
Tracker string
TrackingURL string TrackingURL string
Tracker string
From string
}{ }{
t, t,
"http://" + ips[0].String() + "?rid=" + t.RId, c.URL + "?rid=" + t.RId,
"<img src='http://" + ips[0].String() + "/track?rid=" + t.RId + "'/>", c.URL + "/track?rid=" + t.RId,
"http://" + ips[0].String() + "/track?rid=" + t.RId, "<img src='" + c.URL + "/track?rid=" + t.RId + "'/>",
ft,
} }
// Parse the templates // Parse the templates
var subjBuff bytes.Buffer var subjBuff bytes.Buffer
@ -118,6 +120,9 @@ func processCampaign(c *models.Campaign) {
Logger.Println(err) Logger.Println(err)
} }
} }
time.Sleep(1) }
err = c.UpdateStatus(models.CAMPAIGN_EMAILS_SENT)
if err != nil {
Logger.Println(err)
} }
} }