Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bitburner script: jormungandr.js
- /** @param {NS} ns */
- export async function main(ns) {
- let branches = ns.scan();
- let validBranches = getValidBranches(ns, branches);
- for (let branch of validBranches) {
- getRootAccess(ns, branch);
- }
- }
- function getValidBranches(ns, branches) {
- let validBranches = [];
- for (let branch of branches) {
- if (branchValid(ns, branch)) {
- validBranches.push(branch);
- }
- }
- return validBranches;
- }
- function branchValid(ns, branch) {
- let hackingLevel = ns.getHackingLevel();
- var retVal = ns.getServerRequiredHackingLevel(branch) <= hackingLevel;
- return retVal;
- }
- function getRootAccess(ns, target) {
- if (!ns.hasRootAccess(target) && openPorts(ns, target)) {
- ns.nuke(target);
- }
- }
- function openPorts(ns, target) {
- let portsRequired = ns.getServerNumPortsRequired(target);
- let portsBroken = 0;
- if (portsRequired == 0) {
- return true;
- } else {
- if (ns.fileExists("BruteSSH.exe", "home") && portsBroken < portsRequired) {
- ns.brutessh(target);
- portsBroken++;
- }
- if (ns.fileExists("FTPCrack.exe", "home") && portsBroken < portsRequired) {
- ns.ftpcrack(target);
- portsBroken++;
- }
- if (ns.fileExists("relaySMTP.exe", "home") && portsBroken < portsRequired) {
- ns.relaysmtp(target);
- portsBroken++;
- }
- if (ns.fileExists("HTTPWorm.exe", "home") && portsBroken < portsRequired) {
- ns.httpworm(target);
- portsBroken++;
- }
- if (ns.fileExists("SQLInject.exe", "home") && portsBroken < portsRequired) {
- ns.sqlinject(target);
- portsBroken++;
- }
- if (portsBroken >= portsRequired) {
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement