diff --git a/README.md b/README.md index 745f53c..27b6e0d 100644 --- a/README.md +++ b/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) - [Quick Start](#quick-start) - [Scripts](#scripts) - - [bruteforce.js (WIP)](#bruteforcejs-wip) - [crawler.js](#crawlerjs) - [miner.js](#minerjs) - [network-graph.js](#network-graphjs) - [node-manager.js](#node-managerjs) - [rootkit.js](#rootkitjs) - [update.js](#updatejs) + - [vanguard.js](#vanguardjs) ## Quick Start @@ -179,3 +179,24 @@ Options: -d --device Device to update, defaults to current machine -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 +``` diff --git a/scripts/bruteforce.js b/scripts/bruteforce.js deleted file mode 100644 index 8300b1b..0000000 --- a/scripts/bruteforce.js +++ /dev/null @@ -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]; -} diff --git a/scripts/vanguard.js b/scripts/vanguard.js new file mode 100644 index 0000000..87c13b0 --- /dev/null +++ b/scripts/vanguard.js @@ -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]; +}