new: http proxy can now be scripted with js files

This commit is contained in:
evilsocket 2018-01-07 22:51:18 +01:00
parent 5b209890c1
commit 98d1a028ed
12 changed files with 345 additions and 124 deletions

View file

@ -0,0 +1,42 @@
// called when script is loaded
function onLoad() {
console.log( "PROXY SCRIPT LOADED" );
}
// called before a request is proxied
function onRequest(req, res) {
if( req.Path == "/test-page" ){
res.Status = 200;
res.ContentType = "text/html";
res.Headers = "Server: bettercap-ng\r\n" +
"Connection: close";
res.Body = "<html>" +
"<head>" +
"<title>Test Page</title>" +
"</head>" +
"<body>" +
"<div align=\"center\">Hello world from bettercap-ng!</div>" +
"</body>" +
"</html>";
res.Updated();
}
}
// called after a request is proxied and there's a response
function onResponse(req, res) {
if( res.Status == 404 ){
res.ContentType = "text/html";
res.Headers = "Server: bettercap-ng\r\n" +
"Connection: close";
res.Body = "<html>" +
"<head>" +
"<title>Test 404 Page</title>" +
"</head>" +
"<body>" +
"<div align=\"center\">Custom 404 from bettercap-ng.</div>" +
"</body>" +
"</html>";
res.Updated();
}
}