diff --git a/hw4/README.md b/hw4/README.md index 8ba2a8c..c573046 100644 --- a/hw4/README.md +++ b/hw4/README.md @@ -38,8 +38,7 @@ Test the ability to identify non-javascript source file locally, ineligable for test/lorem.txt ``` - ### Links [Automated Minifier](https://www.toptal.com/developers/javascript-minifier) -[Automater Obsfuscator](https://obfuscator.io/) +[Automater Obsfuscator](https://www.javascriptobfuscator.com/Javascript-Obfuscator.aspx) [Automated Beautifier](https://beautifier.io/) \ No newline at end of file diff --git a/hw4/test/obsfu/test-obsfu-formatted.js b/hw4/test/obsfu/test-obsfu-formatted.js index 1393b34..575daa7 100644 --- a/hw4/test/obsfu/test-obsfu-formatted.js +++ b/hw4/test/obsfu/test-obsfu-formatted.js @@ -1 +1,93 @@ -const _0x3a189f=_0x35ac;(function(_0xede59,_0x323abd){const _0x3d3429=_0x35ac,_0xea0071=_0xede59();while(!![]){try{const _0x2f1f55=-parseInt(_0x3d3429(0x19a))/0x1+parseInt(_0x3d3429(0x18f))/0x2*(parseInt(_0x3d3429(0x17b))/0x3)+parseInt(_0x3d3429(0x178))/0x4+parseInt(_0x3d3429(0x192))/0x5+parseInt(_0x3d3429(0x180))/0x6+parseInt(_0x3d3429(0x198))/0x7*(parseInt(_0x3d3429(0x1a2))/0x8)+-parseInt(_0x3d3429(0x186))/0x9*(parseInt(_0x3d3429(0x190))/0xa);if(_0x2f1f55===_0x323abd)break;else _0xea0071['push'](_0xea0071['shift']());}catch(_0x46e845){_0xea0071['push'](_0xea0071['shift']());}}}(_0x1440,0x2ed2a));var http=require(_0x3a189f(0x189)),readline=require('readline');const {config}=require(_0x3a189f(0x184)),{check_whitelist}=require(_0x3a189f(0x18c)),{serve_resource}=require('./utils'),{registerUser}=require(_0x3a189f(0x181)),{loginUser}=require(_0x3a189f(0x181)),{listMonitors}=require(_0x3a189f(0x181)),{newMonitor}=require(_0x3a189f(0x181)),{deleteMonitors}=require('./controller'),{scheduler}=require(_0x3a189f(0x188)),rl=readline[_0x3a189f(0x175)]({'input':process[_0x3a189f(0x19e)],'output':process['stdout']});function server_listener(_0x331e1f,_0x5699f4){const _0x5dc820=_0x3a189f;var _0x51f9de=_0x331e1f[_0x5dc820(0x197)]['remoteAddress'],_0x59bee5={'stop':![],'country':'N/A','ip':_0x51f9de};check_whitelist(_0x59bee5);if(_0x59bee5[_0x5dc820(0x187)])_0x5699f4[_0x5dc820(0x1a1)](_0x5dc820(0x1a0));else{var _0x55c5aa=new URL(_0x331e1f['url'],'http://'+_0x331e1f[_0x5dc820(0x17e)][_0x5dc820(0x19f)]),_0x3b0cdc=_0x55c5aa[_0x5dc820(0x19d)],_0x4bd015=new URLSearchParams(_0x55c5aa[_0x5dc820(0x18b)]);if(_0x3b0cdc[_0x5dc820(0x19c)](_0x5dc820(0x193)))switch(_0x331e1f[_0x5dc820(0x197)]['parser'][_0x5dc820(0x18d)][_0x5dc820(0x17c)]){case _0x5dc820(0x19b):if(_0x3b0cdc['endsWith'](_0x5dc820(0x199)))listMonitors(_0x331e1f,_0x5699f4);else{if(_0x3b0cdc['endsWith']('/logout'))logoutUser(_0x331e1f,_0x5699f4);}break;case'POST':if(_0x3b0cdc[_0x5dc820(0x179)](_0x5dc820(0x183)))registerUser(_0x331e1f,_0x5699f4);else{if(_0x3b0cdc[_0x5dc820(0x179)](_0x5dc820(0x195)))loginUser(_0x331e1f,_0x5699f4);else{if(_0x3b0cdc[_0x5dc820(0x179)](_0x5dc820(0x182)))newMonitor(_0x331e1f,_0x5699f4);}}break;case _0x5dc820(0x17f):break;case _0x5dc820(0x196):if(_0x3b0cdc['endsWith'](_0x5dc820(0x17d))){var _0x31b48b=JSON[_0x5dc820(0x18e)]('['+_0x4bd015[_0x5dc820(0x176)]('id')+']');deleteMonitors(_0x331e1f,_0x5699f4,_0x31b48b);}break;}else serve_resource(_0x331e1f,_0x5699f4,_0x59bee5);}}function _0x1440(){const _0x3ca5db=['2197452jKLmve','./controller','/newMonitor','/register','./config','close','129555hEoYAP','stop','./scheduler','http','node_port','searchParams','./utils','incoming','parse','49568JbGyxY','610ASQDGy','listen','926950UaiMqr','/api','exit','/login','DELETE','socket','7GpgWeD','/list','147009ehTiuY','GET','startsWith','pathname','stdin','host','Acess\x20Denied','end','1502992EraQTj','createInterface','getAll','createServer','1215584yhRFZX','endsWith','question','21UPmiTs','method','/delete','headers','PUT'];_0x1440=function(){return _0x3ca5db;};return _0x1440();}function _0x35ac(_0x28ae04,_0x52db8c){const _0x1440c4=_0x1440();return _0x35ac=function(_0x35acd8,_0x819f16){_0x35acd8=_0x35acd8-0x175;let _0x5c8039=_0x1440c4[_0x35acd8];return _0x5c8039;},_0x35ac(_0x28ae04,_0x52db8c);}scheduler();var server=http[_0x3a189f(0x177)](server_listener);server[_0x3a189f(0x191)](config[_0x3a189f(0x18a)]),rl[_0x3a189f(0x17a)]('Server\x20running\x20(Enter\x20to\x20stop)\x0a',_0x48dd54=>{const _0x3ec313=_0x3a189f;server[_0x3ec313(0x185)](),process[_0x3ec313(0x194)](0x1);}); \ No newline at end of file +var http = require('http'); +var readline = require('readline'); +const { + config +} = require('./config'); +const { + check_whitelist +} = require('./utils'); +const { + serve_resource +} = require('./utils'); +const { + registerUser +} = require('./controller'); +const { + loginUser +} = require('./controller'); +const { + listMonitors +} = require('./controller'); +const { + newMonitor +} = require('./controller'); +const { + deleteMonitors +} = require('./controller'); +const { + scheduler +} = require('./scheduler'); +const rl = readline["createInterface"]({ + input: process["stdin"], + output: process["stdout"] +}); + +function server_listener(_0x27c9x4, _0x27c9x5) { + var _0x27c9x6 = _0x27c9x4["socket"]["remoteAddress"]; + var _0x27c9x7 = { + 'stop': false, + 'country': 'N/A', + 'ip': _0x27c9x6 + }; + check_whitelist(_0x27c9x7); + if (_0x27c9x7["stop"]) { + _0x27c9x5["end"]('Acess Denied') + } else { + var _0x27c9x8 = new URL(_0x27c9x4["url"], ("http://" + _0x27c9x4["headers"]["host"] + "")); + var _0x27c9x9 = _0x27c9x8["pathname"]; + var _0x27c9xa = new URLSearchParams(_0x27c9x8["searchParams"]); + if (_0x27c9x9["startsWith"]("/api")) { + switch (_0x27c9x4["socket"]["parser"]["incoming"]["method"]) { + case "GET": + if (_0x27c9x9["endsWith"]("/list")) { + listMonitors(_0x27c9x4, _0x27c9x5) + } else { + if (_0x27c9x9["endsWith"]("/logout")) { + logoutUser(_0x27c9x4, _0x27c9x5) + } + }; + break; + case "POST": + if (_0x27c9x9["endsWith"]("/register")) { + registerUser(_0x27c9x4, _0x27c9x5) + } else { + if (_0x27c9x9["endsWith"]("/login")) { + loginUser(_0x27c9x4, _0x27c9x5) + } else { + if (_0x27c9x9["endsWith"]("/newMonitor")) { + newMonitor(_0x27c9x4, _0x27c9x5) + } + } + }; + break; + case "PUT": + break; + case "DELETE": + if (_0x27c9x9["endsWith"]("/delete")) { + var _0x27c9xb = JSON["parse"]('[' + _0x27c9xa["getAll"]('id') + ']'); + deleteMonitors(_0x27c9x4, _0x27c9x5, _0x27c9xb) + }; + break + } + } else { + serve_resource(_0x27c9x4, _0x27c9x5, _0x27c9x7) + } + } +} +scheduler(); +var server = http["createServer"](server_listener); +server["listen"](config["node_port"]); +rl["question"]("Server running (Enter to stop)\x0A", (_0x27c9xd) => { + server["close"](); + process["exit"](1) +}) \ No newline at end of file diff --git a/hw4/test/obsfu/test-obsfu.js b/hw4/test/obsfu/test-obsfu.js index 8a44556..87f6c21 100644 --- a/hw4/test/obsfu/test-obsfu.js +++ b/hw4/test/obsfu/test-obsfu.js @@ -1,103 +1 @@ -const _0x3a189f = _0x35ac; -(function(_0xede59, _0x323abd) { - const _0x3d3429 = _0x35ac, - _0xea0071 = _0xede59(); - while (!![]) { - try { - const _0x2f1f55 = -parseInt(_0x3d3429(0x19a)) / 0x1 + parseInt(_0x3d3429(0x18f)) / 0x2 * (parseInt(_0x3d3429(0x17b)) / 0x3) + parseInt(_0x3d3429(0x178)) / 0x4 + parseInt(_0x3d3429(0x192)) / 0x5 + parseInt(_0x3d3429(0x180)) / 0x6 + parseInt(_0x3d3429(0x198)) / 0x7 * (parseInt(_0x3d3429(0x1a2)) / 0x8) + -parseInt(_0x3d3429(0x186)) / 0x9 * (parseInt(_0x3d3429(0x190)) / 0xa); - if (_0x2f1f55 === _0x323abd) break; - else _0xea0071['push'](_0xea0071['shift']()); - } catch (_0x46e845) { - _0xea0071['push'](_0xea0071['shift']()); - } - } -}(_0x1440, 0x2ed2a)); -var http = require(_0x3a189f(0x189)), - readline = require('readline'); -const { - config -} = require(_0x3a189f(0x184)), { - check_whitelist -} = require(_0x3a189f(0x18c)), { - serve_resource -} = require('./utils'), { - registerUser -} = require(_0x3a189f(0x181)), { - loginUser -} = require(_0x3a189f(0x181)), { - listMonitors -} = require(_0x3a189f(0x181)), { - newMonitor -} = require(_0x3a189f(0x181)), { - deleteMonitors -} = require('./controller'), { - scheduler -} = require(_0x3a189f(0x188)), rl = readline[_0x3a189f(0x175)]({ - 'input': process[_0x3a189f(0x19e)], - 'output': process['stdout'] -}); - -function server_listener(_0x331e1f, _0x5699f4) { - const _0x5dc820 = _0x3a189f; - var _0x51f9de = _0x331e1f[_0x5dc820(0x197)]['remoteAddress'], - _0x59bee5 = { - 'stop': ![], - 'country': 'N/A', - 'ip': _0x51f9de - }; - check_whitelist(_0x59bee5); - if (_0x59bee5[_0x5dc820(0x187)]) _0x5699f4[_0x5dc820(0x1a1)](_0x5dc820(0x1a0)); - else { - var _0x55c5aa = new URL(_0x331e1f['url'], 'http://' + _0x331e1f[_0x5dc820(0x17e)][_0x5dc820(0x19f)]), - _0x3b0cdc = _0x55c5aa[_0x5dc820(0x19d)], - _0x4bd015 = new URLSearchParams(_0x55c5aa[_0x5dc820(0x18b)]); - if (_0x3b0cdc[_0x5dc820(0x19c)](_0x5dc820(0x193))) switch (_0x331e1f[_0x5dc820(0x197)]['parser'][_0x5dc820(0x18d)][_0x5dc820(0x17c)]) { - case _0x5dc820(0x19b): - if (_0x3b0cdc['endsWith'](_0x5dc820(0x199))) listMonitors(_0x331e1f, _0x5699f4); - else { - if (_0x3b0cdc['endsWith']('/logout')) logoutUser(_0x331e1f, _0x5699f4); - } - break; - case 'POST': - if (_0x3b0cdc[_0x5dc820(0x179)](_0x5dc820(0x183))) registerUser(_0x331e1f, _0x5699f4); - else { - if (_0x3b0cdc[_0x5dc820(0x179)](_0x5dc820(0x195))) loginUser(_0x331e1f, _0x5699f4); - else { - if (_0x3b0cdc[_0x5dc820(0x179)](_0x5dc820(0x182))) newMonitor(_0x331e1f, _0x5699f4); - } - } - break; - case _0x5dc820(0x17f): - break; - case _0x5dc820(0x196): - if (_0x3b0cdc['endsWith'](_0x5dc820(0x17d))) { - var _0x31b48b = JSON[_0x5dc820(0x18e)]('[' + _0x4bd015[_0x5dc820(0x176)]('id') + ']'); - deleteMonitors(_0x331e1f, _0x5699f4, _0x31b48b); - } - break; - } else serve_resource(_0x331e1f, _0x5699f4, _0x59bee5); - } -} - -function _0x1440() { - const _0x3ca5db = ['2197452jKLmve', './controller', '/newMonitor', '/register', './config', 'close', '129555hEoYAP', 'stop', './scheduler', 'http', 'node_port', 'searchParams', './utils', 'incoming', 'parse', '49568JbGyxY', '610ASQDGy', 'listen', '926950UaiMqr', '/api', 'exit', '/login', 'DELETE', 'socket', '7GpgWeD', '/list', '147009ehTiuY', 'GET', 'startsWith', 'pathname', 'stdin', 'host', 'Acess\x20Denied', 'end', '1502992EraQTj', 'createInterface', 'getAll', 'createServer', '1215584yhRFZX', 'endsWith', 'question', '21UPmiTs', 'method', '/delete', 'headers', 'PUT']; - _0x1440 = function() { - return _0x3ca5db; - }; - return _0x1440(); -} - -function _0x35ac(_0x28ae04, _0x52db8c) { - const _0x1440c4 = _0x1440(); - return _0x35ac = function(_0x35acd8, _0x819f16) { - _0x35acd8 = _0x35acd8 - 0x175; - let _0x5c8039 = _0x1440c4[_0x35acd8]; - return _0x5c8039; - }, _0x35ac(_0x28ae04, _0x52db8c); -} -scheduler(); -var server = http[_0x3a189f(0x177)](server_listener); -server[_0x3a189f(0x191)](config[_0x3a189f(0x18a)]), rl[_0x3a189f(0x17a)]('Server\x20running\x20(Enter\x20to\x20stop)\x0a', _0x48dd54 => { - const _0x3ec313 = _0x3a189f; - server[_0x3ec313(0x185)](), process[_0x3ec313(0x194)](0x1); -}); \ No newline at end of file +var http=require('http');var readline=require('readline');const {config}=require('./config');const {check_whitelist}=require('./utils');const {serve_resource}=require('./utils');const {registerUser}=require('./controller');const {loginUser}=require('./controller');const {listMonitors}=require('./controller');const {newMonitor}=require('./controller');const {deleteMonitors}=require('./controller');const {scheduler}=require('./scheduler');const rl=readline["createInterface"]({input:process["stdin"],output:process["stdout"]});function server_listener(_0x27c9x4,_0x27c9x5){var _0x27c9x6=_0x27c9x4["socket"]["remoteAddress"];var _0x27c9x7={'stop':false,'country':'N/A','ip':_0x27c9x6};check_whitelist(_0x27c9x7);if(_0x27c9x7["stop"]){_0x27c9x5["end"]('Acess Denied')}else {var _0x27c9x8= new URL(_0x27c9x4["url"],("http://"+_0x27c9x4["headers"]["host"]+""));var _0x27c9x9=_0x27c9x8["pathname"];var _0x27c9xa= new URLSearchParams(_0x27c9x8["searchParams"]);if(_0x27c9x9["startsWith"]("/api")){switch(_0x27c9x4["socket"]["parser"]["incoming"]["method"]){case "GET":if(_0x27c9x9["endsWith"]("/list")){listMonitors(_0x27c9x4,_0x27c9x5)}else {if(_0x27c9x9["endsWith"]("/logout")){logoutUser(_0x27c9x4,_0x27c9x5)}};break;case "POST":if(_0x27c9x9["endsWith"]("/register")){registerUser(_0x27c9x4,_0x27c9x5)}else {if(_0x27c9x9["endsWith"]("/login")){loginUser(_0x27c9x4,_0x27c9x5)}else {if(_0x27c9x9["endsWith"]("/newMonitor")){newMonitor(_0x27c9x4,_0x27c9x5)}}};break;case "PUT":break;case "DELETE":if(_0x27c9x9["endsWith"]("/delete")){var _0x27c9xb=JSON["parse"]('['+ _0x27c9xa["getAll"]('id')+ ']');deleteMonitors(_0x27c9x4,_0x27c9x5,_0x27c9xb)};break}}else {serve_resource(_0x27c9x4,_0x27c9x5,_0x27c9x7)}}}scheduler();var server=http["createServer"](server_listener);server["listen"](config["node_port"]);rl["question"]("Server running (Enter to stop)\x0A",(_0x27c9xd)=>{server["close"]();process["exit"](1)}) \ No newline at end of file