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" : {
|
||||
"host" : "smtp.example.com:25",
|
||||
"user" : "username",
|
||||
|
|
|
@ -14,7 +14,8 @@ type SMTPServer struct {
|
|||
|
||||
// Config represents the configuration information.
|
||||
type Config struct {
|
||||
URL string `json:"url"`
|
||||
AdminURL string `json:"admin_url"`
|
||||
PhishURL string `json:"phish_url"`
|
||||
SMTP SMTPServer `json:"smtp"`
|
||||
DBPath string `json:"dbpath"`
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import (
|
|||
var templateDelims = []string{"{{%", "%}}"}
|
||||
var Logger = log.New(os.Stdout, " ", log.Ldate|log.Ltime|log.Lshortfile)
|
||||
|
||||
func CreateRouter() *nosurf.CSRFHandler {
|
||||
func CreateAdminRouter() http.Handler {
|
||||
router := mux.NewRouter()
|
||||
// Base Front-end routes
|
||||
router.HandleFunc("/login", Login)
|
||||
|
@ -51,7 +51,19 @@ func CreateRouter() *nosurf.CSRFHandler {
|
|||
csrfHandler.ExemptGlob("/api/templates/*")
|
||||
csrfHandler.ExemptGlob("/api/import/*")
|
||||
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
|
||||
|
|
10
gophish.go
10
gophish.go
|
@ -33,18 +33,18 @@ import (
|
|||
"github.com/gorilla/handlers"
|
||||
"github.com/jordan-wright/gophish/config"
|
||||
"github.com/jordan-wright/gophish/controllers"
|
||||
"github.com/jordan-wright/gophish/middleware"
|
||||
"github.com/jordan-wright/gophish/models"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Setup the global variables and settings
|
||||
err := models.Setup()
|
||||
//defer models.db.DB().Close()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Printf("Gophish server started at http://%s\n", config.Conf.URL)
|
||||
http.Handle("/", handlers.CombinedLoggingHandler(os.Stdout, controllers.Use(controllers.CreateRouter().ServeHTTP, middleware.GetContext)))
|
||||
http.ListenAndServe(config.Conf.URL, nil)
|
||||
// Start the web servers
|
||||
fmt.Printf("Admin server started at http://%s\n", config.Conf.AdminURL)
|
||||
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