Attempts to gain root access to all servers and present them in an easy-to-see and use format.
Visão geral
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.
Como usar
Create each script below and paste the code appropriately.
Run the script!
Comandos:
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
“-é” 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. Ele contém 3 functions that make up the entire script.
/** @param {NS} ns **/ importar {allServers} de "./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. se (ns.args.includes("-h")) {ajuda(ns); retornar;} ns.print("For script help use argument '-h' "); ns.print("Executing..."); //process argument calls var target = []; se (ns.args.length > 0) { se (ns.args[0] === "-é") { target = await allServers(ns); } outro { target = ns.args; } } outro { target = await allServers(ns); } //check max ports available to open if (ns.fileExists("BruteSSH.exe")) {arquivos[0] = 1; maxPorts++; ns.print("BruteSSH.exe file exists");} outro {ns.print("BruteSSH.exe not found");} se (ns.fileExists("FTPCrack.exe")) {arquivos[1] = 1; maxPorts++; ns.print("FTPCrack.exe file exists");} outro {ns.print("FTPCrack.exe not found");} se (ns.fileExists("relaySMTP.exe")) {arquivos[2] = 1; maxPorts++; ns.print("relaySMTP.exe file exists");} outro {ns.print("relaySMTP.exe not found");} se (ns.fileExists("HTTPWorm.exe")) {arquivos[3] = 1; maxPorts++; ns.print("HTTPWorm.exe file exists");} outro {ns.print("HTTPWorm.exe not found");} se (ns.fileExists("SQLInject.exe")) {arquivos[4] = 1; maxPorts++; ns.print("SQLInject.exe file exists");} outro {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) { se (ns.serverExists(n)) { const serverHackLvl = ns.getServerRequiredHackingLevel(n); const playerHackingLvl = ns.getHackingLevel(); se (playerHackingLvl >= serverHackLvl) { se (arquivos[0]) { ns.brutessh(n); } se (arquivos[1]) { ns.ftpcrack(n); } se (arquivos[2]) { ns.relaysmtp(n);} se (arquivos[3]) { ns.httpworm(n); } se (arquivos[4]) { ns.sqlinject(n);} gainRootAccess(n, maxPorts, approved, deniedports, denied, outro, ns); } outro { denied.push(n); deniedhack.push("[DENIED] - hack level too low [" + playerHackingLvl + '/' + serverHackLvl + "] para " + n); } } } //output results if (deniedhack.length>0) ns.print(deniedhack.join("\n")); se (deniedports.length>0) ns.print(deniedports.join("\n")); se (other.length>0) ns.print("[ALREADY ACQUIRED ROOT ACCESS] para " + other.join("\n[ALREADY ACQUIRED ROOT ACCESS] para ")); se (approved.length>0) ns.print("[ROOT ACCESS APPROVED] para " + approved.join("\n[ROOT ACCESS APPROVED] para ")); se (ns.args.includes("-é")) { ns.print("Copiable list of rooted servers:\n" + approved.join(" ") + other.join(" ")); } } function gainRootAccess(servidor, portCount, approved, deniedports, denied, outro, ns) { se (!ns.hasRootAccess(servidor)) { se (portCount >= ns.getServerNumPortsRequired(servidor)) { ns.nuke(servidor); approved.push(servidor); } outro { denied.push(servidor); deniedports.push("[ROOT ACCESS DENIED] para " + servidor + " - Not enough open PORTS"); } } outro { other.push(servidor); } } 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.", " por exemplo: 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) { se (removePurchased) var pservs = ns.getPurchasedServers(); const nodes = new Set; function dfs(nó) { nodes.add(nó); para (const neighbor of ns.scan(nó)) { se (removePurchased) { se (!pservs.includes(vizinho)) { se (!nodes.has(vizinho)) { dfs(vizinho); } } } outro { se (!nodes.has(vizinho)) { dfs(vizinho); } } } } dfs("lar"); retornar [...nós]; }
Isso é tudo o que estamos compartilhando hoje para isso Bitburner guia. Este guia foi originalmente criado e escrito por Crunchynut. Caso não atualizemos este guia, você pode encontrar a atualização mais recente seguindo este link.