mirror of https://github.com/gophish/gophish
Moved creation of URLs to net.URL instances to handle custom paths and parameters. Fixes #969
parent
29555085c0
commit
3d58d8362e
|
@ -9,6 +9,8 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
"net/mail"
|
"net/mail"
|
||||||
|
"net/url"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
|
@ -213,10 +215,20 @@ func (m *MailLog) Generate(msg *gomail.Message) error {
|
||||||
fn = f.Address
|
fn = f.Address
|
||||||
}
|
}
|
||||||
msg.SetAddressHeader("From", f.Address, f.Name)
|
msg.SetAddressHeader("From", f.Address, f.Name)
|
||||||
url, err := buildTemplate(c.URL, r)
|
campaignURL, err := buildTemplate(c.URL, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
phishURL, _ := url.Parse(campaignURL)
|
||||||
|
q := phishURL.Query()
|
||||||
|
q.Set("rid", r.RId)
|
||||||
|
phishURL.RawQuery = q.Encode()
|
||||||
|
|
||||||
|
trackingURL, _ := url.Parse(campaignURL)
|
||||||
|
trackingURL.Path = path.Join(trackingURL.Path, "/track")
|
||||||
|
trackingURL.RawQuery = q.Encode()
|
||||||
|
|
||||||
td := struct {
|
td := struct {
|
||||||
Result
|
Result
|
||||||
URL string
|
URL string
|
||||||
|
@ -225,9 +237,9 @@ func (m *MailLog) Generate(msg *gomail.Message) error {
|
||||||
From string
|
From string
|
||||||
}{
|
}{
|
||||||
r,
|
r,
|
||||||
url + "?rid=" + r.RId,
|
phishURL.String(),
|
||||||
url + "/track?rid=" + r.RId,
|
trackingURL.String(),
|
||||||
"<img alt='' style='display: none' src='" + url + "/track?rid=" + r.RId + "'/>",
|
"<img alt='' style='display: none' src='" + trackingURL.String() + "'/>",
|
||||||
fn,
|
fn,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue