Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** @param {NS} ns */
- export async function main(ns) {
- // Array of all servers that don't need any ports opened
- // to gain root access. These have 16 GB of RAM
- const servers0Port = ["sigma-cosmetics",
- "joesguns",
- "nectar-net",
- "hong-fang-tea",
- "harakiri-sushi"];
- // Array of all servers that only need 1 port opened
- // to gain root access. These have 32 GB of RAM
- const servers1Port = ["neo-net",
- "zer0",
- "max-hardware",
- "iron-gym"];
- const script_filename = 'early-hack-template.js';
- //const script_ram = 2.6; // GB, Memory usage of original original script.
- const script_ram = ns.getScriptRam(script_filename);
- // Calculate how many threads of the script we can run on a system
- // with 16 and 32 GB of RAM.
- const threads16 = Math.max(1, Math.floor(script_ram / 16) );
- const threads32 = Math.max(1, Math.floor(script_ram / 32) );
- // Copy our scripts onto each server that requires 0 ports
- // to gain root access. Then use nuke() to gain admin access and
- // run the scripts.
- for (let i = 0; i < servers0Port.length; ++i) {
- const serv = servers0Port[i];
- if (ns.scp(script_filename, serv) === false) {
- ns.tprint(`ERROR: copying '${script_filename} to "${serv}"`);
- continue; // Skip to next server in the for loop
- }
- ns.nuke(serv);
- let pid = ns.exec(script_filename, serv, threads16);
- if (pid === 0) {
- ns.tprint(`ERROR: Unable to execute ${script_filename} on "${serv}"`);
- }
- }
- // Wait until we acquire the "BruteSSH.exe" program
- while (!ns.fileExists("BruteSSH.exe")) {
- ns.print("Waiting for BruteSSH.exe to be purchased or created.");
- await ns.sleep(60 * 1000); // 60 secs or 60000 milliseconds
- }
- // Copy our scripts onto each server that requires 1 port
- // to gain root access. Then use brutessh() and nuke()
- // to gain admin access and run the scripts.
- for (let i = 0; i < servers1Port.length; ++i) {
- const serv = servers1Port[i];
- if (ns.scp(script_filename, serv) === false) {
- ns.tprint(`ERROR: copying '${script_filename} to "${serv}"`);
- continue; // Skip to next server in the for loop
- }
- ns.brutessh(serv);
- ns.nuke(serv);
- let pid = ns.exec(script_filename, serv, threads32);
- if (pid === 0) {
- ns.tprint(`ERROR: Unable to execute ${script_filename} on "${serv}"`);
- }
- }
- }
Add Comment
Please, Sign In to add comment