diff options
author | AlmightyMiau <almightymeow612@gmail.com> | 2024-11-13 10:56:53 -0800 |
---|---|---|
committer | AlmightyMiau <almightymeow612@gmail.com> | 2024-11-13 10:56:53 -0800 |
commit | 40843e35434d56e883655e4377994ac76746b184 (patch) | |
tree | 786c3acc109b4add11c88ca58a534fd19d4e77cb /bitburnerFiles1026/milestones.js | |
parent | 1ca00b3b73a9699e41f81e154cea32934c16de03 (diff) |
Organized scripts into folders
Diffstat (limited to 'bitburnerFiles1026/milestones.js')
-rw-r--r-- | bitburnerFiles1026/milestones.js | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/bitburnerFiles1026/milestones.js b/bitburnerFiles1026/milestones.js deleted file mode 100644 index 856900a..0000000 --- a/bitburnerFiles1026/milestones.js +++ /dev/null @@ -1,133 +0,0 @@ -const HOME = "home"; - -// You have to run this script once per target - -let hacked = []; - -/** @param {NS} ns */ -export async function main(ns) { - - ns.tail(); - ns.moveTail(1650, 725); - ns.resizeTail(250, 100); - - ns.disableLog("disableLog"); - ns.disableLog("clearLog"); - ns.disableLog("sleep"); - ns.disableLog("scan"); - ns.clearLog(); - - const targets = [ - "CSEC", - "avmnite-02h", - "I.I.I.I", - "run4theh111z"//, - // "w0r1d_d43m0n" - ]; - - while (!ns.fileExists("SQLInject.exe")) { - await ns.sleep(12000); - } - for (let i = 0; i < targets.length; i++) { - if (targets[i] == "w0rld_d43m0n") { - while (!ns.singularity.getOwnedAugmentations().includes("The Red Pill")) { - ns.clearLog(); - ns.print("Waiting for red pill"); - await ns.sleep(60000); - } - } - await root(ns, targets[i]); - } -} -function buildRoute(ns, parent, target, route, seen = []) { - //first time we run we need to add the parent to the list of servers we've seen - if (!seen.includes(parent)) { - seen.push(parent); - } - //add to route - route.push(parent); - const children = ns.scan(parent); - for (const child of children) { - if (seen.includes(child)) { - //already checked - continue; - } - seen.push(child); - if (child == target) { - //found target, add it to the route and finish recursion - route.push(child); - return true; - } - if (buildRoute(ns, child, target, route, seen)) { - //target found, finish recursion - return true; - } - else { - //target not found in this branch, remove from route - route.pop(); - } - } - //didn't find target in this route, reset route - route = []; - return false; -} -async function printRoute(ns, route) { - let result = []; - for (const node of route) { - result.push(node); - } - return result; -} -async function root(ns, target) { - if (!ns.hasRootAccess(target)) { - ns.brutessh(target); - ns.ftpcrack(target); - ns.relaysmtp(target); - ns.httpworm(target); - ns.sqlinject(target); - ns.print("Gained root access to ", target); - while (ns.getHackingLevel() < ns.getServerRequiredHackingLevel(target)) { - await ns.sleep(6000); - } - ns.nuke(target); - - ns.singularity.connect(HOME); - await ns.sleep(100); - - let result = []; - let route = []; - - buildRoute(ns, HOME, target, route) - result = await printRoute(ns, route); - - for (let n = 0; n < result.length; n++) { - ns.singularity.connect(result[n]); - await ns.sleep(100); - } - await ns.singularity.installBackdoor(); - ns.singularity.connect(HOME); - } else if (!ns.getServer(target).backdoorInstalled) { - ns.singularity.connect(HOME); - await ns.sleep(100); - - let result = []; - let route = []; - - buildRoute(ns, HOME, target, route) - result = await printRoute(ns, route); - - for (let n = 0; n < result.length; n++) { - ns.singularity.connect(result[n]); - await ns.sleep(100); - } - await ns.singularity.installBackdoor(); - ns.singularity.connect(HOME); - } - hacked.push(target); - ns.clearLog(); - ns.print("Hacked servers: ", ) - for (let j = 0; j < hacked.length; j++) { - ns.print(hacked[j]); - } - return 0; -}
\ No newline at end of file |