forked from jnfrati/govwa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add client side authentication vulnerability
- Loading branch information
Showing
3 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{{define "template.csa"}} {{template "template.header" .}} {{template "template.sidebar" .}} | ||
<div class="col-md-9"> | ||
<div class="panel panel-primary"> | ||
<div class="panel-heading">Client Side Authentication</div> | ||
<div class="panel-body"> | ||
<div class="pnl"> | ||
<!-- <span class="subheader">SQL Injection Vulnerability</span> --> | ||
<p>Hello json</p> | ||
<p>Verify your account to view full profile:</p> | ||
<div id="alert" style="display: none"></div> | ||
<div class="well"> | ||
<form class="form-inline" id="otpform"> | ||
<div class="form-group"> | ||
<label for="otp" style="color:#428bca;font-family:Open Sans; font-weight:500">Input Your Verfication Code:</label> | ||
<input type="text" class="form-control" name="otp" id="otp"> | ||
<button type="button" id="vrf" class="btn btn-small btn-primary">Verify</button> | ||
</div> | ||
</form> | ||
</div> | ||
<div class="more-info"> | ||
<span>More Info :</span> | ||
<a target="_blank" href="https://api.jquery.com/jquery.post/">https://api.jquery.com/jquery.post/</a> | ||
<a target="_blank" href="https://portswigger.net/burp/help/proxy_gettingstarted">https://portswigger.net/burp/help/proxy_gettingstarted</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{{.js}} | ||
<script> | ||
$("#vrf").on('click', function(){ | ||
var data = $("#otpform").serialize() | ||
url = "{{.url}}verify" | ||
$.post(url,data) | ||
.done(function(res){ | ||
if(res[0].code != 1){ | ||
$("#alert").removeClass("alert alert-success") | ||
$("#alert").addClass("alert alert-danger") | ||
$("#alert").html("<p>Wrong OTP</p>") | ||
$("#alert").show() | ||
$("#alert").delay(2000).fadeOut(); | ||
}else{ | ||
$("#alert").removeClass("alert alert-danger") | ||
$("#alert").addClass("alert alert-success") | ||
$("#alert").html("<p>Account Verified</p>") | ||
$("#alert").show() | ||
//$("#alert").delay(2000).fadeOut(); | ||
} | ||
}) | ||
}); | ||
</script> | ||
{{template "template.footer"}} {{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package csa | ||
|
||
import ( | ||
|
||
"fmt" | ||
"net/http" | ||
"crypto/md5" | ||
"encoding/hex" | ||
|
||
"github.com/julienschmidt/httprouter" | ||
|
||
"govwa/util" | ||
"govwa/user/session" | ||
"govwa/util/middleware" | ||
) | ||
|
||
type XSS struct{ | ||
Name string | ||
} | ||
func New()XSS{ | ||
return XSS{} | ||
} | ||
func (self XSS)SetRouter(r *httprouter.Router){ | ||
mw := middleware.New() | ||
r.GET("/csa", mw.LoggingMiddleware(mw.CapturePanic(mw.AuthCheck(csaHandler)))) | ||
r.POST("/verify", mw.LoggingMiddleware(mw.CapturePanic(mw.AuthCheck(verifyHandler)))) | ||
} | ||
|
||
type JsonRes struct{ | ||
Code int `json:"code"` | ||
} | ||
|
||
func csaHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params){ | ||
s := session.New() | ||
uid := s.GetSession(r, "id") | ||
|
||
data := make(map[string]interface{}) | ||
data["title"] = "Client Side Authentication" | ||
|
||
id := fmt.Sprintf("<script> var uid=%s </script>", uid) | ||
|
||
data["js"] = util.ToHTML(id) | ||
|
||
util.SafeRender(w,r, "template.csa", data) | ||
} | ||
|
||
func verifyHandler(w http.ResponseWriter, r *http.Request, _ httprouter.Params){ | ||
if r.Method == "POST"{ | ||
sotp := "a587cd6bf1e49d2c3928d1f8b86f248b" | ||
otp := r.FormValue("otp") | ||
res := JsonRes{} | ||
if sotp != Md5Sum(otp){ | ||
res.Code = 0 | ||
}else{ | ||
res.Code = 1 | ||
} | ||
util.RenderAsJson(w, res) | ||
} | ||
} | ||
|
||
func Md5Sum(text string) string { | ||
hasher := md5.New() | ||
hasher.Write([]byte(text)) | ||
return hex.EncodeToString(hasher.Sum(nil)) | ||
} |