const http = require('http'), purl = require('url'), fs = require('fs'); const hostname = process.argv[2]; const port = process.argv[3]; var results = [], limit = 100, counter = 0; var commands = [{ InformationType: 6, Data: null, }, {} ], ccounter = 0; const server = http.createServer((req, res) => { var irHeaders = req.headers; var irMethod = req.method; var irUrl = req.url; var body = []; req.on('error', function(err){ console.log(err.stack); }).on('data', function(chunk){ body.push(chunk); }).on('end', function(){ body = Buffer.concat(body).toString(); var surl = purl.parse(irUrl, true); if(surl.pathname == "/chrome.htm" || surl.pathname == "/opera.htm" || surl.pathname == "/firefox.htm"){ res.writeHead(200, { "Content-Type": "text/html; charset=UTF-8", "Cache-Control": "no-cache" }); try{ fs.createReadStream("." + surl.pathname).pipe(res);}catch(e){} }else if(surl.pathname == "/chrome.htm/_4884_.html" || surl.pathname == "/opera.htm/_4884_.html"){ res.writeHead(200, { "Content-Type": "text/html; charset=UTF-8", "Cache-Control": "no-cache" }); try{ fs.createReadStream("./" + surl.pathname.split("/")[1]).pipe(res);}catch(e){} }else if(surl.pathname == "/WebUI"){ res.writeHead(200, { "Content-Type": "text/html; charset=UTF-8", "Cache-Control": "no-cache" }); try{ fs.createReadStream("./chrome.htm").pipe(res);}catch(e){} }else if(surl.pathname == "/firefox_guretv.htm"){ res.writeHead(200, { "Content-Type": "text/html; charset=UTF-8", "Cache-Control": "no-cache" }); try{ fs.createReadStream("./" + surl.pathname.split("/")[1]).pipe(res);}catch(e){} }else if(surl.pathname.startsWith("/scripts/")){ res.writeHead(200, { "Content-Type": "application/javascript", "Cache-Control": "no-cache", "Access-Control-Allow-Origin": "*" }); try{ fs.createReadStream("." + surl.pathname).pipe(res);}catch(e){} }else if(surl.pathname.startsWith("/css/")) { res.writeHead(200, { "Content-Type": "text/css", "Cache-Control": "no-cache" }); try{ fs.createReadStream("." + surl.pathname).pipe(res); }catch(e){ console.log("Error", e); } }else if(surl.pathname == "/WebUI/getCommand") { res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-cache" }); try{ res.end(JSON.stringify(commands[ccounter++])) }catch(e){ console.log("Error", e); } }else{ res.end(); } }); }); server.listen(port, hostname, () => { console.log(`Server running at http://${hostname}:${port}/`); }); //Homepage function getHomePage(browser){ return ` Main page

Execute arbitrary script

Various content are loaded within this page