Added vanguard.js
This commit is contained in:
parent
d04d9d3b99
commit
b19d4fe501
23
README.md
23
README.md
@ -6,13 +6,13 @@ These scripts are for playing the [open source](https://github.com/danielyxie/bi
|
|||||||
- [Table of Contents](#table-of-contents)
|
- [Table of Contents](#table-of-contents)
|
||||||
- [Quick Start](#quick-start)
|
- [Quick Start](#quick-start)
|
||||||
- [Scripts](#scripts)
|
- [Scripts](#scripts)
|
||||||
- [bruteforce.js (WIP)](#bruteforcejs-wip)
|
|
||||||
- [crawler.js](#crawlerjs)
|
- [crawler.js](#crawlerjs)
|
||||||
- [miner.js](#minerjs)
|
- [miner.js](#minerjs)
|
||||||
- [network-graph.js](#network-graphjs)
|
- [network-graph.js](#network-graphjs)
|
||||||
- [node-manager.js](#node-managerjs)
|
- [node-manager.js](#node-managerjs)
|
||||||
- [rootkit.js](#rootkitjs)
|
- [rootkit.js](#rootkitjs)
|
||||||
- [update.js](#updatejs)
|
- [update.js](#updatejs)
|
||||||
|
- [vanguard.js](#vanguardjs)
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
@ -179,3 +179,24 @@ Options:
|
|||||||
-d --device Device to update, defaults to current machine
|
-d --device Device to update, defaults to current machine
|
||||||
-h --help Display this help message
|
-h --help Display this help message
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### [vanguard.js](./scripts/vanguard.js)
|
||||||
|
**RAM:** 1.90 GB
|
||||||
|
|
||||||
|
Weaken the device indefinitely.
|
||||||
|
```
|
||||||
|
[home ~/scripts]> run /scripts/vanguard.js --help
|
||||||
|
Running script with 1 thread(s), pid 1 and args: ["--help"].
|
||||||
|
/scripts/vanguard.js:
|
||||||
|
|
||||||
|
Weaken the device indefinitely.
|
||||||
|
|
||||||
|
Usage: run vanguard.js [OPTIONS] [DEVICE]
|
||||||
|
run vanguard.js --help
|
||||||
|
|
||||||
|
DEVICE Device to weaken, defaults to the current machine
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-l --limit Limit the number of times to run
|
||||||
|
-h --help Display this help message
|
||||||
|
```
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
export async function main(ns) {
|
|
||||||
ns.disableLog('ALL');
|
|
||||||
const TARGET = ns.args[0];
|
|
||||||
const SECURITY = ns.getServerMinSecurityLevel(TARGET);
|
|
||||||
let security, once = true;
|
|
||||||
|
|
||||||
do {
|
|
||||||
security = ns.getServerSecurityLevel(TARGET);
|
|
||||||
if(once) {
|
|
||||||
ns.print('===================================================');
|
|
||||||
ns.print(`🔐 Bruteforcing: ${TARGET}`);
|
|
||||||
ns.print('===================================================');
|
|
||||||
ns.print(`Security: ${Math.round(security * 100) / 100}/${SECURITY}`);
|
|
||||||
ns.print('===================================================');
|
|
||||||
once = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ns.print(`Attacking ⚔️...`);
|
|
||||||
const w = await ns.weaken(TARGET);
|
|
||||||
ns.print(`Security: ${w} (${Math.round((security - w) * 100) / 100}/${SECURITY})`);
|
|
||||||
} while (security > SECURITY);
|
|
||||||
ns.print('Complete!');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function autocomplete(data) {
|
|
||||||
return [...data.servers];
|
|
||||||
}
|
|
54
scripts/vanguard.js
Normal file
54
scripts/vanguard.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import {ArgError, ArgParser} from './scripts/lib/arg-parser';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Weaken the device indefinitely.
|
||||||
|
* @params ns {NS} - BitBurner API
|
||||||
|
*/
|
||||||
|
export async function main(ns) {
|
||||||
|
// Setup
|
||||||
|
ns.disableLog('ALL');
|
||||||
|
let args, counter = 0, orgSecurity, security;
|
||||||
|
const historyLength = 17;
|
||||||
|
const messageHistory = Array(historyLength).fill('');
|
||||||
|
const argParser = new ArgParser('vanguard.js', 'Weaken the device indefinitely.', null, [
|
||||||
|
{name: 'device', desc: 'Device to weaken, defaults to the current machine', optional: true, default: ns.getHostname(), type: 'string'},
|
||||||
|
{name: 'limit', desc: 'Limit the number of times to run', flags: ['-l', '--limit'], default: Infinity, type: 'num'}
|
||||||
|
]);
|
||||||
|
try {
|
||||||
|
args = argParser.parse(ns.args);
|
||||||
|
orgSecurity = security = ns.getServerSecurityLevel(args['device']);
|
||||||
|
} catch(err) {
|
||||||
|
if(err instanceof ArgError) return ns.tprint(argParser.help(err.message));
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print header with logs
|
||||||
|
* @param message - message to append to logs
|
||||||
|
*/
|
||||||
|
function log(message) {
|
||||||
|
ns.clearLog();
|
||||||
|
ns.print('===================================================');
|
||||||
|
ns.print(`Vanguard: ${args['device']}`);
|
||||||
|
ns.print('===================================================');
|
||||||
|
ns.print(`Security: ${security}/${orgSecurity}`);
|
||||||
|
ns.print('===================================================');
|
||||||
|
if(message != null) messageHistory.push(message);
|
||||||
|
messageHistory.splice(0, messageHistory.length - historyLength);
|
||||||
|
messageHistory.forEach(m => ns.print(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run
|
||||||
|
log();
|
||||||
|
do {
|
||||||
|
security = ns.getServerSecurityLevel(args['device']);
|
||||||
|
log(`Attacking...`);
|
||||||
|
log(await ns.weaken(args['device']));
|
||||||
|
counter++;
|
||||||
|
} while (counter < args['limit']);
|
||||||
|
ns.print('Complete!');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function autocomplete(data) {
|
||||||
|
return [...data.servers];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user