Skip to content

Instantly share code, notes, and snippets.

@heathkit
Created May 18, 2022 15:44
Show Gist options
  • Save heathkit/4e174184180314ce436abec20853ad38 to your computer and use it in GitHub Desktop.
Save heathkit/4e174184180314ce436abec20853ad38 to your computer and use it in GitHub Desktop.
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