Attempts to gain root access to all servers and present them in an easy-to-see and use format.
Descripción general
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.
Cómo utilizar
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
«-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. contiene 3 functions that make up the entire script.
/** @param {Ns} ns **/ import {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. si (ns.args.includes("-h")) {ayuda(ns); devolver;} 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); } demás { target = ns.args; } } demás { target = await allServers(ns); } //check max ports available to open if (ns.fileExists("BruteSSH.exe")) {archivos[0] = 1; maxPorts++; ns.print("BruteSSH.exe file exists");} demás {ns.print("BruteSSH.exe not found");} si (ns.fileExists("FTPCrack.exe")) {archivos[1] = 1; maxPorts++; ns.print("FTPCrack.exe file exists");} demás {ns.print("FTPCrack.exe not found");} si (ns.fileExists("relaySMTP.exe")) {archivos[2] = 1; maxPorts++; ns.print("relaySMTP.exe file exists");} demás {ns.print("relaySMTP.exe not found");} si (ns.fileExists("HTTPWorm.exe")) {archivos[3] = 1; maxPorts++; ns.print("HTTPWorm.exe file exists");} demás {ns.print("HTTPWorm.exe not found");} si (ns.fileExists("SQLInject.exe")) {archivos[4] = 1; maxPorts++; ns.print("SQLInject.exe file exists");} demás {ns.print("SQLInject.exe not found");} ns.print("Maximum ports able to open: [" + maxPorts + "]\norte"); //open all ports and attempt root access for (const n of target) { si (ns.serverExists(norte)) { const serverHackLvl = ns.getServerRequiredHackingLevel(norte); const playerHackingLvl = ns.getHackingLevel(); si (playerHackingLvl >= serverHackLvl) { si (archivos[0]) { ns.brutessh(norte); } si (archivos[1]) { ns.ftpcrack(norte); } si (archivos[2]) { ns.relaysmtp(norte);} si (archivos[3]) { ns.httpworm(norte); } si (archivos[4]) { ns.sqlinject(norte);} gainRootAccess(norte, maxPorts, approved, deniedports, denied, otro, ns); } demás { denied.push(norte); deniedhack.push("[DENIED] - hack level too low [" + playerHackingLvl + '/' + serverHackLvl + "] para " + norte); } } } //output results if (deniedhack.length>0) ns.print(deniedhack.join("\norte")); si (deniedports.length>0) ns.print(deniedports.join("\norte")); si (other.length>0) ns.print("[ALREADY ACQUIRED ROOT ACCESS] para " + other.join("\norte[ALREADY ACQUIRED ROOT ACCESS] para ")); si (approved.length>0) ns.print("[ROOT ACCESS APPROVED] para " + approved.join("\norte[ROOT ACCESS APPROVED] para ")); si (ns.args.includes("-s")) { ns.print("Copiable list of rooted servers:\norte" + approved.join(" ") + other.join(" ")); } } function gainRootAccess(servidor, portCount, approved, deniedports, denied, otro, ns) { si (!ns.hasRootAccess(servidor)) { si (portCount >= ns.getServerNumPortsRequired(servidor)) { ns.nuke(servidor); approved.push(servidor); } demás { denied.push(servidor); deniedports.push("[ROOT ACCESS DENIED] para " + servidor + " - Not enough open PORTS"); } } demás { other.push(servidor); } } function help(ns) { const text = [ "<========================HELP=====================>\norte", "- Script takes in [norte] arguments or none at all.", " [norte]: server names that you wish to be rooted.", " p.ej.: 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("\norte")); }
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(nodo) { nodes.add(nodo); para (const neighbor of ns.scan(nodo)) { si (removePurchased) { si (!pservs.includes(neighbor)) { si (!nodes.has(neighbor)) { dfs(neighbor); } } } demás { si (!nodes.has(neighbor)) { dfs(neighbor); } } } } dfs("hogar"); devolver [...nodos]; }
Eso es todo lo que estamos compartiendo hoy para este Quemador de bits guía. Esta guía fue originalmente creada y escrita por Crunchynut. En caso de que no actualicemos esta guía, puede encontrar la última actualización siguiendo este enlace.