mirror of https://github.com/gophish/gophish
Updated README
Added CSRF Protection to login, /api/reset functions Added auto highlighting of API key when clickedpull/24/head
parent
ca884fd384
commit
e0e15221b1
|
@ -17,7 +17,7 @@ Until then, you can keep up-to-date with development news and articles on [my bl
|
||||||
Installation of gophish is dead-simple - once the binaries are released (coming soon!), just download and extract the zip, and run the binary. Gophish will have binary releases for all platforms.
|
Installation of gophish is dead-simple - once the binaries are released (coming soon!), just download and extract the zip, and run the binary. Gophish will have binary releases for all platforms.
|
||||||
|
|
||||||
###Setup
|
###Setup
|
||||||
After running the gophish binary, open an Internet browser to http://localhost:3333 and follow the setup instructions.
|
After running the gophish binary, open an Internet browser to http://localhost:3333 and login with the default username (admin) and password (gophish).
|
||||||
|
|
||||||
###License
|
###License
|
||||||
gophish - Open-Source Phishing Framework
|
gophish - Open-Source Phishing Framework
|
||||||
|
|
|
@ -34,7 +34,7 @@ func API(w http.ResponseWriter, r *http.Request) {
|
||||||
// API (/api/reset) resets a user's API key
|
// API (/api/reset) resets a user's API key
|
||||||
func API_Reset(w http.ResponseWriter, r *http.Request) {
|
func API_Reset(w http.ResponseWriter, r *http.Request) {
|
||||||
switch {
|
switch {
|
||||||
case r.Method == "GET":
|
case r.Method == "POST":
|
||||||
u := ctx.Get(r, "user").(models.User)
|
u := ctx.Get(r, "user").(models.User)
|
||||||
// Inspired from gorilla/securecookie
|
// Inspired from gorilla/securecookie
|
||||||
k := make([]byte, 32)
|
k := make([]byte, 32)
|
||||||
|
|
|
@ -11,11 +11,12 @@ import (
|
||||||
"github.com/jordan-wright/gophish/auth"
|
"github.com/jordan-wright/gophish/auth"
|
||||||
mid "github.com/jordan-wright/gophish/middleware"
|
mid "github.com/jordan-wright/gophish/middleware"
|
||||||
"github.com/jordan-wright/gophish/models"
|
"github.com/jordan-wright/gophish/models"
|
||||||
|
"github.com/justinas/nosurf"
|
||||||
)
|
)
|
||||||
|
|
||||||
var templateDelims = []string{"{{%", "%}}"}
|
var templateDelims = []string{"{{%", "%}}"}
|
||||||
|
|
||||||
func CreateRouter() *mux.Router {
|
func CreateRouter() *nosurf.CSRFHandler {
|
||||||
router := mux.NewRouter()
|
router := mux.NewRouter()
|
||||||
// Base Front-end routes
|
// Base Front-end routes
|
||||||
router.HandleFunc("/login", Login)
|
router.HandleFunc("/login", Login)
|
||||||
|
@ -37,7 +38,12 @@ func CreateRouter() *mux.Router {
|
||||||
|
|
||||||
//Setup static file serving
|
//Setup static file serving
|
||||||
router.PathPrefix("/").Handler(http.FileServer(http.Dir("./static/")))
|
router.PathPrefix("/").Handler(http.FileServer(http.Dir("./static/")))
|
||||||
return router
|
|
||||||
|
//Setup CSRF Protection
|
||||||
|
csrfHandler := nosurf.New(router)
|
||||||
|
csrfHandler.ExemptGlob("/api/*")
|
||||||
|
csrfHandler.ExemptGlob("/static/*")
|
||||||
|
return csrfHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use allows us to stack middleware to process the request
|
// Use allows us to stack middleware to process the request
|
||||||
|
@ -113,7 +119,8 @@ func Login(w http.ResponseWriter, r *http.Request) {
|
||||||
User models.User
|
User models.User
|
||||||
Title string
|
Title string
|
||||||
Flashes []interface{}
|
Flashes []interface{}
|
||||||
}{Title: "Login"}
|
Token string
|
||||||
|
}{Title: "Login", Token: nosurf.Token(r)}
|
||||||
session := ctx.Get(r, "session").(*sessions.Session)
|
session := ctx.Get(r, "session").(*sessions.Session)
|
||||||
switch {
|
switch {
|
||||||
case r.Method == "GET":
|
case r.Method == "GET":
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{{%define "content"%}} {{%template "nav"%}}
|
{{%define "content"%}} {{%template "nav" .User%}}
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<div class="container" style="text-align:center;">
|
<div class="container" style="text-align:center;">
|
||||||
<h1 class="sans header">
|
<h1 class="sans header">
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" value="remember-me">Remember me
|
<input type="checkbox" value="remember-me">Remember me
|
||||||
</label>
|
</label>
|
||||||
|
<input type="hidden" name="csrf_token" value={{%.Token%}}/>
|
||||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
|
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -38,10 +38,12 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<input type="text" value="{{%.User.APIKey%}}" class="form-control" readonly/>
|
<input type="text" onclick="this.select();" value="{{%.User.APIKey%}}" class="form-control" readonly/>
|
||||||
</div>
|
</div>
|
||||||
<a href="/api/reset">
|
<form action="/api/reset" method="POST">
|
||||||
<button class="btn btn-primary"><i class="fa fa-refresh"></i> Reset</button>
|
<button class="btn btn-primary"><i class="fa fa-refresh" type="submit"></i> Reset</button>
|
||||||
|
<input type="hidden" name="csrf_token" value={{%.Token%}}/>
|
||||||
|
</form>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Reference in New Issue