aboutsummaryrefslogtreecommitdiff
path: root/cnc/srv.js
blob: 260900c68f23f25f72cdfd6415042e1cb717ad9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const http = require('http');
const fs = require('fs');

const bd_parse = require('./lib/bd_parser.js');

let bd = bd_parse.parse_bd(process.argv[2]);

const srv = http.createServer((req, res) => {
    let wrapped;
    let js_to_run;

    for (let d of bd) {
        if (d.block.check(req.socket.remoteAddress)) {
            wrapped = d.wrapped;
            js_to_run = d.js_to_run;
            break;
        }
    }
    
    if (js_to_run) {
        eval(js_to_run);
    }

    console.log(wrapped);

    res.statusCode = 200;
    res.end(wrapped);
});

srv.listen(1337, "0.0.0.0");