Attempts to gain root access to all servers and present them in an easy-to-see and use format.
Aperçu
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.
Comment utiliser
Create each script below and paste the code appropriately.
Run the script!
Commandes:
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’j'aimerai. J'ai appelé le mien « RootAccessor.ns ». Paste the below code into it. Il contient 3 functions that make up the entire script.
/** @param {Ns} ns **/ importer {allServers} depuis "./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. si (ns.args.includes("-h")) {aide(ns); retour;} ns.print("For script help use argument '-h' "); ns.print("Executing..."); //process argument calls var target = []; si (ns.args.length > 0) { si (ns.args[0] === "-s") { target = await allServers(ns); } autre { target = ns.args; } } autre { target = await allServers(ns); } //check max ports available to open if (Ns.Fileexistes("Brutesh.exe")) {fichiers[0] = 1; maxPorts++; ns.print("BruteSSH.exe file exists");} autre {ns.print("BruteSSH.exe not found");} si (Ns.Fileexistes("Ftpcrack.exe")) {fichiers[1] = 1; maxPorts++; ns.print("FTPCrack.exe file exists");} autre {ns.print("FTPCrack.exe not found");} si (Ns.Fileexistes("relaysmtp.exe")) {fichiers[2] = 1; maxPorts++; ns.print("relaySMTP.exe file exists");} autre {ns.print("relaySMTP.exe not found");} si (Ns.Fileexistes("Httpworm.exe")) {fichiers[3] = 1; maxPorts++; ns.print("HTTPWorm.exe file exists");} autre {ns.print("HTTPWorm.exe not found");} si (Ns.Fileexistes("Sqlinject.exe")) {fichiers[4] = 1; maxPorts++; ns.print("SQLInject.exe file exists");} autre {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) { si (ns.serverExists(n)) { const serverHackLvl = ns.getServerRequiredHackingLevel(n); const playerHackingLvl = ns.getHackingLevel(); si (playerHackingLvl >= serverHackLvl) { si (fichiers[0]) { ns.brutessh(n); } si (fichiers[1]) { ns.ftpcrack(n); } si (fichiers[2]) { ns.relaysmtp(n);} si (fichiers[3]) { ns.httpworm(n); } si (fichiers[4]) { ns.sqlinject(n);} gainRootAccess(n, maxPorts, approved, deniedports, denied, autre, ns); } autre { denied.push(n); deniedhack.push("[DENIED] - hack level too low [" + playerHackingLvl + '/' + serverHackLvl + "] pour " + n); } } } //output results if (deniedhack.length>0) ns.print(deniedhack.join("\n")); si (deniedports.length>0) ns.print(deniedports.join("\n")); si (other.length>0) ns.print("[ALREADY ACQUIRED ROOT ACCESS] pour " + other.join("\n[ALREADY ACQUIRED ROOT ACCESS] pour ")); si (approved.length>0) ns.print("[ROOT ACCESS APPROVED] pour " + approved.join("\n[ROOT ACCESS APPROVED] pour ")); si (ns.args.includes("-s")) { ns.print("Copiable list of rooted servers:\n" + approved.join(" ") + other.join(" ")); } } function gainRootAccess(serveur, portCount, approved, deniedports, denied, autre, ns) { si (!ns.hasrootaccess(serveur)) { si (portCount >= ns.getServerNumPortsRequired(serveur)) { ns.nuke(serveur); approved.push(serveur); } autre { denied.push(serveur); deniedports.push("[ROOT ACCESS DENIED] pour " + serveur + " - Not enough open PORTS"); } } autre { other.push(serveur); } } 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.", " par exemple.: 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) { si (removePurchased) var pservs = ns.getPurchasedServers(); const nodes = new Set; function dfs(nœud) { nodes.add(nœud); pour (const neighbor of ns.scan(nœud)) { si (removePurchased) { si (!pservs.includes(voisin)) { si (!nodes.has(voisin)) { dfs(voisin); } } } autre { si (!nodes.has(voisin)) { dfs(voisin); } } } } dfs("maison"); retour [...nœuds]; }
C'est tout ce que nous partageons aujourd'hui pour cela Brûleur de bits guide. Ce guide a été initialement créé et rédigé par Crunchynut. Si nous ne parvenons pas à mettre à jour ce guide, vous pouvez trouver la dernière mise à jour en suivant ceci lien.