mirror of https://github.com/gophish/gophish
Update phish.go
parent
2d08befb6b
commit
c021f2165d
|
@ -9,6 +9,8 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"os"
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
"github.com/NYTimes/gziphandler"
|
"github.com/NYTimes/gziphandler"
|
||||||
"github.com/gophish/gophish/config"
|
"github.com/gophish/gophish/config"
|
||||||
|
@ -54,6 +56,9 @@ type PhishingServer struct {
|
||||||
contactAddress string
|
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
|
// NewPhishingServer returns a new instance of the phishing server with
|
||||||
// provided options applied.
|
// provided options applied.
|
||||||
func NewPhishingServer(config config.PhishServer, options ...PhishingServerOption) *PhishingServer {
|
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 {
|
if err != ErrInvalidRequest && err != ErrCampaignComplete {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
http.NotFound(w, r)
|
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
|
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)
|
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
|
var ptx models.PhishingTemplateContext
|
||||||
// Check for a preview
|
// Check for a preview
|
||||||
|
|
Loading…
Reference in New Issue