Attempts to gain root access to all servers and present them in an easy-to-see and use format.
Обзор
This script gets all servers, opens all ports possible, and attempts to gain root access, all while presenting the user with easy-to-read and useful information.
Как использовать
Create each script below and paste the code appropriately.
Run the script!
Команды:
run RootAccessor.ns
Runs the script against all servers. Displays results.
run RootAccessor.ns -h
brings up the help menu for the script. The script does not process any further if it contains “-час” as an argument.
run RootAccessor.ns -s
lists all servers with root access as a space-separated list if users want to utilize them as arguments in other scripts.
run RootAccessor.ns joesguns n00dles max-hardware
attempts to gain root access on target servers (each argument is a server name).
run RootAccessor.ns joesguns n00dles max-hardware -s
run RootAccessor.ns -s joesguns n00dles max-hardware
run RootAccessor.ns joesguns n00dles -s max-hardware
“-с” can be added as an argument at any time.
RootAccessor.ns Script
Create a new script with whatever name you’d like. I called mine “RootAccessor.ns”. Paste the below code into it. Он содержит 3 functions that make up the entire script.
/** @парам {НС} нс **/ импорт {allServers} от "./lib-getServers.ns"; экспортировать асинхронную функцию main(нс) { var approved = []; var deniedhack = []; var deniedports = []; var denied = []; var other = []; var files = [0, 0, 0, 0, 0]; var maxPorts = 0; //suppress all default log messages ns.tail(); ns.disableLog('ВСЕ'); ns.clearLog(); //check for help argument. если (ns.args.includes("-час")) {помощь(нс); возвращаться;} нс.принт("For script help use argument '-h' "); нс.принт("Executing..."); //process argument calls var target = []; если (ns.args.length > 0) { если (ns.args[0] === "-с") { target = await allServers(нс); } еще { target = ns.args; } } еще { target = await allServers(нс); } //check max ports available to open if (NS.FileExists("Brutessh.exe")) {файлы[0] = 1; maxPorts++; нс.принт("BruteSSH.exe file exists");} еще {нс.принт("BruteSSH.exe not found");} если (NS.FileExists("Ftpcrack.exe")) {файлы[1] = 1; maxPorts++; нс.принт("FTPCrack.exe file exists");} еще {нс.принт("FTPCrack.exe not found");} если (NS.FileExists("RELAYSMTP.EXE")) {файлы[2] = 1; maxPorts++; нс.принт("relaySMTP.exe file exists");} еще {нс.принт("relaySMTP.exe not found");} если (NS.FileExists("Httpworm.exe")) {файлы[3] = 1; maxPorts++; нс.принт("HTTPWorm.exe file exists");} еще {нс.принт("HTTPWorm.exe not found");} если (NS.FileExists("Sqlinject.exe")) {файлы[4] = 1; maxPorts++; нс.принт("SQLInject.exe file exists");} еще {нс.принт("SQLInject.exe not found");} нс.принт("Maximum ports able to open: [" + maxPorts + "]\н"); //open all ports and attempt root access for (const n of target) { если (ns.serverExists(н)) { const serverHackLvl = ns.getServerRequiredHackingLevel(н); const playerHackingLvl = ns.getHackingLevel(); если (playerHackingLvl >= serverHackLvl) { если (файлы[0]) { ns.brutessh(н); } если (файлы[1]) { ns.ftpcrack(н); } если (файлы[2]) { ns.reelaysmtp(н);} если (файлы[3]) { ns.httpworm(н); } если (файлы[4]) { ns.sqlinject(н);} gainRootAccess(н, maxPorts, approved, deniedports, denied, другой, нс); } еще { denied.push(н); deniedhack.push("[DENIED] - hack level too low [" + playerHackingLvl + '/' + serverHackLvl + "] для " + н); } } } //output results if (deniedhack.length>0) нс.принт(deniedhack.join("\н")); если (deniedports.length>0) нс.принт(deniedports.join("\н")); если (other.length>0) нс.принт("[ALREADY ACQUIRED ROOT ACCESS] для " + other.join("\н[ALREADY ACQUIRED ROOT ACCESS] для ")); если (approved.length>0) нс.принт("[ROOT ACCESS APPROVED] для " + approved.join("\н[ROOT ACCESS APPROVED] для ")); если (ns.args.includes("-с")) { нс.принт("Copiable list of rooted servers:\н" + approved.join(" ") + other.join(" ")); } } function gainRootAccess(сервер, portCount, approved, deniedports, denied, другой, нс) { если (!ns.hasrootaccess(сервер)) { если (portCount >= ns.getServerNumPortsRequired(сервер)) { Ns.wull(сервер); approved.push(сервер); } еще { denied.push(сервер); deniedports.push("[ROOT ACCESS DENIED] для " + сервер + " - Not enough open PORTS"); } } еще { other.push(сервер); } } function help(нс) { const text = [ "<========================HELP=====================>\н", "- Script takes in [Н] arguments or none at all.", " [Н]: server names that you wish to be rooted.", " например: run rootAccessor.ns n00dles joesguns zer0\n", "- No args will attempt root access on all servers\n", "- include argument '-s' as an argument to print", " copiable list of all rooted servers\n", "<=================================================>" ]; нс.принт(text.join("\н")); }
lib-getServers.ns Script
Create a new script named “lib-getServers.ns” and paste the below helper function.
/** @парам {НС} нс **/ export function allServers(нс, removePurchased=true) { если (removePurchased) var pservs = ns.getPurchasedServers(); const nodes = new Set; function dfs(узел) { nodes.add(узел); для (const neighbor of ns.scan(узел)) { если (removePurchased) { если (!pservs.includes(сосед)) { если (!nodes.has(сосед)) { dfs(сосед); } } } еще { если (!nodes.has(сосед)) { dfs(сосед); } } } } dfs("дом"); возвращаться [...узлы]; }
Это все, чем мы делимся сегодня для этого. Битбернер гид. Это руководство было первоначально создано и написано Crunchynut. На случай, если нам не удастся обновить это руководство, вы можете найти последнее обновление, следуя этому связь.