Update phish.go

pull/2683/head
Eren Şimşek 2022-12-04 06:27:45 +03:00 committed by GitHub
parent 2d08befb6b
commit c021f2165d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 4 deletions

View File

@ -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,6 +211,17 @@ 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)
} }
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) http.NotFound(w, r)
return return
} }