diff --git a/controllers/phish.go b/controllers/phish.go index 71b25a87..37a743c5 100644 --- a/controllers/phish.go +++ b/controllers/phish.go @@ -8,7 +8,9 @@ import ( "net" "net/http" "strings" - "time" + "time" + "os" + "io/ioutil" "github.com/NYTimes/gziphandler" "github.com/gophish/gophish/config" @@ -54,6 +56,9 @@ type PhishingServer struct { contactAddress string } +// If you want to change the default phishing site, you can use index.html. +var default_page = "index.html" + // NewPhishingServer returns a new instance of the phishing server with // provided options applied. func NewPhishingServer(config config.PhishServer, options ...PhishingServerOption) *PhishingServer { @@ -206,9 +211,20 @@ func (ps *PhishingServer) PhishHandler(w http.ResponseWriter, r *http.Request) { if err != ErrInvalidRequest && err != ErrCampaignComplete { log.Error(err) } - http.NotFound(w, r) - return - } + fi, err := os.Stat(default_page) + if err != nil { + log.Error(err) + } else { + size := fi.Size() + if (size > 0) { + body, _ := ioutil.ReadFile(default_page) + w.Write([]byte(body)) + return + } + } + http.NotFound(w, r) + return +} w.Header().Set("X-Server", config.ServerName) // Useful for checking if this is a GoPhish server (e.g. for campaign reporting plugins) var ptx models.PhishingTemplateContext // Check for a preview