Rootkit will skip rooting if it already has it to save time

This commit is contained in:
Zakary Timson 2022-03-20 09:01:52 -04:00
parent 86158da1b2
commit 65050fb619
2 changed files with 27 additions and 32 deletions

View File

@ -218,7 +218,7 @@ Options:
``` ```
### [rootkit.js](./scripts/rootkit.js) ### [rootkit.js](./scripts/rootkit.js)
**RAM:** 4.75 GB - 4.90 GB <small>(depending on un-commented programs)</small> **RAM:** 4.80 GB - 4.95 GB <small>(depending on un-commented programs)</small>
Automatically gain root on a target machine. A file can also be uploaded & executed. Automatically gain root on a target machine. A file can also be uploaded & executed.

View File

@ -36,36 +36,29 @@ export async function main(ns) {
ns.tprint('==================================================='); ns.tprint('===================================================');
} }
// Check if we already have root
if(ns.hasRootAccess(args['device'])) {
if(!args['silent']) ns.tprint('Root: Skipped');
} else {
let spacer = false; let spacer = false;
const sleep = 750;
try { try {
// Run exploits // Run exploits
ns.brutessh(args['device']); ns.brutessh(args['device']);
if(!args['silent']) { if(!args['silent']) {
await slowPrint(ns, `Attacking over SSH (${args['device']}:22)...`, 0.5, 1.5); await slowPrint(ns, `Attacking over SSH (${args['device']}:22)...`, 0.5, 1.5);
await ns.sleep(sleep);
spacer = true; spacer = true;
} }
ns.ftpcrack(args['device']); ns.ftpcrack(args['device']);
if(!args['silent']) { if(!args['silent']) await slowPrint(ns, `Attacking over FTP (${args['device']}:24)...`, 0.5, 1.5);
await slowPrint(ns, `Attacking over FTP (${args['device']}:24)...`, 0.5, 1.5);
await ns.sleep(sleep);
}
ns.relaysmtp(args['device']); ns.relaysmtp(args['device']);
if(!args['silent']) { if(!args['silent']) await slowPrint(ns, `Attacking over SMTP (${args['device']}:25)...`, 0.5, 1.5);
await slowPrint(ns, `Attacking over SMTP (${args['device']}:25)...`, 0.5, 1.5);
await ns.sleep(sleep);
}
} catch { } catch {
} finally { } finally {
try { try {
// Attempt root // Attempt root
if(spacer) ns.tprint(''); if(spacer) ns.tprint('');
ns.nuke(args['device']) ns.nuke(args['device']);
if(!args['silent']) { if(!args['silent']) ns.tprint(`Root: Success!`);
ns.tprint(`Root: Success!`);
ns.tprint('');
}
} catch { } catch {
if(!args['silent']) { if(!args['silent']) {
ns.tprint(`Root: Failed`); ns.tprint(`Root: Failed`);
@ -74,6 +67,8 @@ export async function main(ns) {
ns.exit(); ns.exit();
} }
} }
}
ns.tprint('');
if(args['script']) { if(args['script']) {
// Detect script dependencies & copy everything to target // Detect script dependencies & copy everything to target