Added vanguard.js
This commit is contained in:
@ -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];
|
||||
}
|
Reference in New Issue
Block a user