Attempts to gain root access to all servers and present them in an easy-to-see and use format.
Przegląd
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.
Jak używać
Create each script below and paste the code appropriately.
Run the script!
Polecenia:
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 “-H” 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
“-S” 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. Zawiera 3 functions that make up the entire script.
/** @param {NS} ns **/ import {allServers} z "./lib-getServers.ns"; export async function main(ns) { 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('ALL'); ns.clearLog(); //check for help argument. Jeśli (ns.args.includes("-H")) {pomoc(ns); powrót;} ns.print("For script help use argument '-h' "); ns.print("Executing..."); //process argument calls var target = []; Jeśli (ns.args.length > 0) { Jeśli (ns.args[0] === "-S") { target = await allServers(ns); } w przeciwnym razie { target = ns.args; } } w przeciwnym razie { target = await allServers(ns); } //check max ports available to open if (ns.fileExists("BruteSSH.exe")) {akta[0] = 1; maxPorts++; ns.print("BruteSSH.exe file exists");} w przeciwnym razie {ns.print("BruteSSH.exe not found");} Jeśli (ns.fileExists("FTPCrack.exe")) {akta[1] = 1; maxPorts++; ns.print("FTPCrack.exe file exists");} w przeciwnym razie {ns.print("FTPCrack.exe not found");} Jeśli (ns.fileExists("relaySMTP.exe")) {akta[2] = 1; maxPorts++; ns.print("relaySMTP.exe file exists");} w przeciwnym razie {ns.print("relaySMTP.exe not found");} Jeśli (ns.fileExists("HTTPWorm.exe")) {akta[3] = 1; maxPorts++; ns.print("HTTPWorm.exe file exists");} w przeciwnym razie {ns.print("HTTPWorm.exe not found");} Jeśli (ns.fileExists("SQLInject.exe")) {akta[4] = 1; maxPorts++; ns.print("SQLInject.exe file exists");} w przeciwnym razie {ns.print("SQLInject.exe not found");} ns.print("Maximum ports able to open: [" + maxPorts + "]\N"); //open all ports and attempt root access for (const n of target) { Jeśli (ns.serverExists(N)) { const serverHackLvl = ns.getServerRequiredHackingLevel(N); const playerHackingLvl = ns.getHackingLevel(); Jeśli (playerHackingLvl >= serverHackLvl) { Jeśli (akta[0]) { ns.brutessh(N); } Jeśli (akta[1]) { ns.ftpcrack(N); } Jeśli (akta[2]) { ns.relaysmtp(N);} Jeśli (akta[3]) { ns.httpworm(N); } Jeśli (akta[4]) { ns.sqlinject(N);} gainRootAccess(N, maxPorts, approved, deniedports, denied, Inny, ns); } w przeciwnym razie { denied.push(N); deniedhack.push("[DENIED] - hack level too low [" + playerHackingLvl + '/' + serverHackLvl + "] Do " + N); } } } //output results if (deniedhack.length>0) ns.print(deniedhack.join("\N")); Jeśli (deniedports.length>0) ns.print(deniedports.join("\N")); Jeśli (other.length>0) ns.print("[ALREADY ACQUIRED ROOT ACCESS] Do " + other.join("\N[ALREADY ACQUIRED ROOT ACCESS] Do ")); Jeśli (approved.length>0) ns.print("[ROOT ACCESS APPROVED] Do " + approved.join("\N[ROOT ACCESS APPROVED] Do ")); Jeśli (ns.args.includes("-S")) { ns.print("Copiable list of rooted servers:\N" + approved.join(" ") + other.join(" ")); } } function gainRootAccess(serwer, portCount, approved, deniedports, denied, Inny, ns) { Jeśli (!ns.hasRootAccess(serwer)) { Jeśli (portCount >= ns.getServerNumPortsRequired(serwer)) { ns.nuke(serwer); approved.push(serwer); } w przeciwnym razie { denied.push(serwer); deniedports.push("[ROOT ACCESS DENIED] Do " + serwer + " - Not enough open PORTS"); } } w przeciwnym razie { other.push(serwer); } } function help(ns) { const text = [ "<========================HELP=====================>\N", "- Script takes in [N] arguments or none at all.", " [N]: server names that you wish to be rooted.", " np.: 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", "<=================================================>" ]; ns.print(text.join("\N")); }
lib-getServers.ns Script
Create a new script named “lib-getServers.ns” and paste the below helper function.
/** @param {NS} ns **/ export function allServers(ns, removePurchased=true) { Jeśli (removePurchased) var pservs = ns.getPurchasedServers(); const nodes = new Set; function dfs(węzeł) { nodes.add(węzeł); Do (const neighbor of ns.scan(węzeł)) { Jeśli (removePurchased) { Jeśli (!pservs.includes(neighbor)) { Jeśli (!nodes.has(neighbor)) { dfs(neighbor); } } } w przeciwnym razie { Jeśli (!nodes.has(neighbor)) { dfs(neighbor); } } } } dfs("home"); powrót [...węzły]; }
To wszystko, co dzisiaj udostępniamy w tym celu Bitburnera przewodnik. Ten przewodnik został pierwotnie stworzony i napisany przez Crunchynut. Na wypadek, gdybyśmy nie zaktualizowali tego przewodnika, możesz znaleźć najnowszą aktualizację, postępując zgodnie z tym połączyć.