Created
May 18, 2022 15:44
-
-
Save heathkit/4e174184180314ce436abec20853ad38 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let servers = []; | |
/** @param {NS} ns */ | |
export async function main(ns) { | |
ns.disableLog("ALL") | |
let previousHost = ns.args[0]; | |
ns.printf("Previous host: %s", previousHost); | |
let currentHost = ns.getHostname(); | |
ns.tail() | |
await scan(ns, currentHost); | |
ns.write("servers.txt", JSON.stringify(servers), "w") | |
} | |
async function scan(ns, currentHost, previousHost) { | |
let hosts = ns.scan(currentHost); | |
for (let host of hosts) { | |
if (host === previousHost) continue; | |
if (host === "darkweb") continue; | |
if (host.includes("pserv-")) continue; | |
servers.push(host); | |
ns.print(`${host} (${previousHost})`) | |
if (!ns.hasRootAccess(host) && (ns.getServerRequiredHackingLevel(host) <= ns.getHackingLevel())) { | |
try { | |
await ns.brutessh(host); | |
await ns.ftpcrack(host); | |
await ns.relaysmtp(host); | |
await ns.httpworm(host); | |
} catch {} | |
try { | |
await ns.nuke(host); | |
ns.print(`Nuking: ${host}`) | |
} catch { | |
ns.print(`FAIL: ${host}`) | |
} | |
} | |
await scan(ns, host, currentHost) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment