Rootkit will skip rooting if it already has it to save time
This commit is contained in:
parent
86158da1b2
commit
65050fb619
@ -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.
|
||||||
|
|
||||||
|
@ -36,44 +36,39 @@ export async function main(ns) {
|
|||||||
ns.tprint('===================================================');
|
ns.tprint('===================================================');
|
||||||
}
|
}
|
||||||
|
|
||||||
let spacer = false;
|
// Check if we already have root
|
||||||
const sleep = 750;
|
if(ns.hasRootAccess(args['device'])) {
|
||||||
try {
|
if(!args['silent']) ns.tprint('Root: Skipped');
|
||||||
// Run exploits
|
} else {
|
||||||
ns.brutessh(args['device']);
|
let spacer = false;
|
||||||
if(!args['silent']) {
|
|
||||||
await slowPrint(ns, `Attacking over SSH (${args['device']}:22)...`, 0.5, 1.5);
|
|
||||||
await ns.sleep(sleep);
|
|
||||||
spacer = true;
|
|
||||||
}
|
|
||||||
ns.ftpcrack(args['device']);
|
|
||||||
if(!args['silent']) {
|
|
||||||
await slowPrint(ns, `Attacking over FTP (${args['device']}:24)...`, 0.5, 1.5);
|
|
||||||
await ns.sleep(sleep);
|
|
||||||
}
|
|
||||||
ns.relaysmtp(args['device']);
|
|
||||||
if(!args['silent']) {
|
|
||||||
await slowPrint(ns, `Attacking over SMTP (${args['device']}:25)...`, 0.5, 1.5);
|
|
||||||
await ns.sleep(sleep);
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
} finally {
|
|
||||||
try {
|
try {
|
||||||
// Attempt root
|
// Run exploits
|
||||||
if(spacer) ns.tprint('');
|
ns.brutessh(args['device']);
|
||||||
ns.nuke(args['device'])
|
|
||||||
if(!args['silent']) {
|
if(!args['silent']) {
|
||||||
ns.tprint(`Root: Success!`);
|
await slowPrint(ns, `Attacking over SSH (${args['device']}:22)...`, 0.5, 1.5);
|
||||||
ns.tprint('');
|
spacer = true;
|
||||||
}
|
}
|
||||||
|
ns.ftpcrack(args['device']);
|
||||||
|
if(!args['silent']) await slowPrint(ns, `Attacking over FTP (${args['device']}:24)...`, 0.5, 1.5);
|
||||||
|
ns.relaysmtp(args['device']);
|
||||||
|
if(!args['silent']) await slowPrint(ns, `Attacking over SMTP (${args['device']}:25)...`, 0.5, 1.5);
|
||||||
} catch {
|
} catch {
|
||||||
if(!args['silent']) {
|
} finally {
|
||||||
ns.tprint(`Root: Failed`);
|
try {
|
||||||
ns.tprint('');
|
// Attempt root
|
||||||
|
if(spacer) ns.tprint('');
|
||||||
|
ns.nuke(args['device']);
|
||||||
|
if(!args['silent']) ns.tprint(`Root: Success!`);
|
||||||
|
} catch {
|
||||||
|
if(!args['silent']) {
|
||||||
|
ns.tprint(`Root: Failed`);
|
||||||
|
ns.tprint('');
|
||||||
|
}
|
||||||
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user