File: rtfm.js

package info (click to toggle)
bettercap-caplets 0%2Bgit20240106-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,028 kB
  • sloc: javascript: 2,112; sh: 29; makefile: 8; python: 1
file content (24 lines) | stat: -rw-r--r-- 854 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function onRequest(req, res) {
    req.Path = req.Path.replace('-you-did-not-rtfm', '');
}

function onResponse(req, res) {
    if (res.ContentType.indexOf("text/html") == 0) {
        var body = res.ReadBody();
        res.Body = body.replace(
            /\.(jpg|jpeg|png|gif|bmp)/gi,
            '-you-did-not-rtfm.$1'
        );
    }
    else if (res.ContentType.indexOf("image/jpeg") != -1) {
        headers = res.Headers.split("\r\n");
        for (var i = 0; i < headers.length; i++) {
            header_name = headers[i].replace(/:.*/, "");
            res.RemoveHeader(header_name);
        }
        res.SetHeader("Connection", "close");
        res.Status  = 200;
        res.Body    = readFile("/usr/share/bettercap/caplets/www/rtfm_cat.jpg");
        log("RTFM! " + req.Hostname + req.Path + ( req.Query ? "?" + req.Query : ''));
    }
}