mirror of https://github.com/gophish/gophish
Added http handler for phishing endpoint - Will add content soon
Updated config.go to reflect the new changespull/24/head
parent
f3ddb7074a
commit
0f603e6501
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"url" : "localhost:3333",
|
"admin_url" : "127.0.0.1:3333",
|
||||||
|
"phish_url" : "0.0.0.0:80",
|
||||||
"smtp" : {
|
"smtp" : {
|
||||||
"host" : "smtp.example.com:25",
|
"host" : "smtp.example.com:25",
|
||||||
"user" : "username",
|
"user" : "username",
|
||||||
|
|
|
@ -14,9 +14,10 @@ type SMTPServer struct {
|
||||||
|
|
||||||
// Config represents the configuration information.
|
// Config represents the configuration information.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
URL string `json:"url"`
|
AdminURL string `json:"admin_url"`
|
||||||
SMTP SMTPServer `json:"smtp"`
|
PhishURL string `json:"phish_url"`
|
||||||
DBPath string `json:"dbpath"`
|
SMTP SMTPServer `json:"smtp"`
|
||||||
|
DBPath string `json:"dbpath"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var Conf Config
|
var Conf Config
|
||||||
|
|
|
@ -18,7 +18,7 @@ import (
|
||||||
var templateDelims = []string{"{{%", "%}}"}
|
var templateDelims = []string{"{{%", "%}}"}
|
||||||
var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile)
|
var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile)
|
||||||
|
|
||||||
func CreateRouter() *nosurf.CSRFHandler {
|
func CreateAdminRouter() http.Handler {
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
// Base Front-end routes
|
// Base Front-end routes
|
||||||
router.HandleFunc("/login", Login)
|
router.HandleFunc("/login", Login)
|
||||||
|
@ -51,7 +51,19 @@ func CreateRouter() *nosurf.CSRFHandler {
|
||||||
csrfHandler.ExemptGlob("/api/templates/*")
|
csrfHandler.ExemptGlob("/api/templates/*")
|
||||||
csrfHandler.ExemptGlob("/api/import/*")
|
csrfHandler.ExemptGlob("/api/import/*")
|
||||||
csrfHandler.ExemptGlob("/static/*")
|
csrfHandler.ExemptGlob("/static/*")
|
||||||
return csrfHandler
|
return Use(csrfHandler.ServeHTTP, mid.GetContext)
|
||||||
|
}
|
||||||
|
|
||||||
|
//CreateEndpointRouter creates the router that handles phishing connections.
|
||||||
|
func CreatePhishingRouter() http.Handler {
|
||||||
|
router := mux.NewRouter()
|
||||||
|
router.PathPrefix("/static").Handler(http.FileServer(http.Dir("./static/endpoint/")))
|
||||||
|
router.HandleFunc("/{path:.*}", PhishHandler)
|
||||||
|
return router
|
||||||
|
}
|
||||||
|
|
||||||
|
func PhishHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Write([]byte("It Works!"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use allows us to stack middleware to process the request
|
// Use allows us to stack middleware to process the request
|
||||||
|
|
12
gophish.go
12
gophish.go
|
@ -33,18 +33,18 @@ import (
|
||||||
"github.com/gorilla/handlers"
|
"github.com/gorilla/handlers"
|
||||||
"github.com/jordan-wright/gophish/config"
|
"github.com/jordan-wright/gophish/config"
|
||||||
"github.com/jordan-wright/gophish/controllers"
|
"github.com/jordan-wright/gophish/controllers"
|
||||||
"github.com/jordan-wright/gophish/middleware"
|
|
||||||
"github.com/jordan-wright/gophish/models"
|
"github.com/jordan-wright/gophish/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
//Setup the global variables and settings
|
// Setup the global variables and settings
|
||||||
err := models.Setup()
|
err := models.Setup()
|
||||||
//defer models.db.DB().Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Gophish server started at http://%s\n", config.Conf.URL)
|
// Start the web servers
|
||||||
http.Handle("/", handlers.CombinedLoggingHandler(os.Stdout, controllers.Use(controllers.CreateRouter().ServeHTTP, middleware.GetContext)))
|
fmt.Printf("Admin server started at http://%s\n", config.Conf.AdminURL)
|
||||||
http.ListenAndServe(config.Conf.URL, nil)
|
go http.ListenAndServe(config.Conf.AdminURL, handlers.CombinedLoggingHandler(os.Stdout, controllers.CreateAdminRouter()))
|
||||||
|
fmt.Printf("Phishing server started at http://%s\n", config.Conf.PhishURL)
|
||||||
|
http.ListenAndServe(config.Conf.PhishURL, handlers.CombinedLoggingHandler(os.Stdout, controllers.CreatePhishingRouter()))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue