Updated crawler to support more flags
This commit is contained in:
parent
de7eb3bc4f
commit
a76ab24efb
31
README.md
31
README.md
@ -10,7 +10,7 @@ These scripts are for playing the [open source](https://github.com/danielyxie/bi
|
|||||||
- [connect.js](#connectjs)
|
- [connect.js](#connectjs)
|
||||||
- [copy.js](#copyjs)
|
- [copy.js](#copyjs)
|
||||||
- [crawler.js](#crawlerjs)
|
- [crawler.js](#crawlerjs)
|
||||||
- [find-target.js](#besttargetjs)
|
- [find-target.js](#findtargetjs)
|
||||||
- [hacknet-manager.js](#hacknet-managerjs)
|
- [hacknet-manager.js](#hacknet-managerjs)
|
||||||
- [miner.js](#minerjs)
|
- [miner.js](#minerjs)
|
||||||
- [network-graph.js](#network-graphjs)
|
- [network-graph.js](#network-graphjs)
|
||||||
@ -20,21 +20,25 @@ These scripts are for playing the [open source](https://github.com/danielyxie/bi
|
|||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Download the update script in-game
|
# Download the update script in-game & run it
|
||||||
wget https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/update.js scripts/update.js
|
wget https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/update.js scripts/update.js
|
||||||
|
run scripts/update.js # Repeat to pull the latest
|
||||||
|
|
||||||
# Run the update script (Repeat this to pull this repository in the future)
|
# View the network
|
||||||
run scripts/update.js
|
run scripts/network-graph.js --verbose
|
||||||
|
run scripts/netowkr-graph.js --verbose --filter CSEC # Find path to a specific device
|
||||||
|
|
||||||
# Start the node manager with 8 nodes
|
# Start the node manager & cap it at 8 nodes
|
||||||
run scripts/node-manager.js 8
|
run scripts/node-manager.js 8
|
||||||
|
|
||||||
# Chain the crawler, rootkit & miner to hack everything on the network
|
# Chain the crawler & rootkit to root all devices on the network
|
||||||
alias hackAll="run scripts/crawler.js /scripts/rootkit.js {{TARGET}} /scripts/miner.js"
|
run scripts/crawler.js --not-rooted --local /scripts/rootkit.js {{TARGET}}
|
||||||
hackAll
|
|
||||||
|
|
||||||
# Identify & install a backdoor on CSEC
|
# Find the most profitable server & use the crawler to deploy miners on the network targeting it
|
||||||
run scripts/network-graph.js -f CSEC
|
run scripts/find-target.js # Output: n00dles
|
||||||
|
run scriipts/crawler.js --rooted /scripts/miner.js n00dles
|
||||||
|
|
||||||
|
# Install backdoor on CSEC
|
||||||
run scripts/rootkit.js CSEC
|
run scripts/rootkit.js CSEC
|
||||||
run scripts/connect.js CSEC
|
run scripts/connect.js CSEC
|
||||||
backdoor
|
backdoor
|
||||||
@ -115,11 +119,14 @@ Usage: run crawler.js [OPTIONS] SCRIPT [ARGS]...
|
|||||||
Options:
|
Options:
|
||||||
-c --cpu Number of CPU threads to use with script
|
-c --cpu Number of CPU threads to use with script
|
||||||
-d --depth Depth to scan to, defaults to 3
|
-d --depth Depth to scan to, defaults to 3
|
||||||
-l --level Exclude targets with higher hack level, defaults to current hack level
|
-k --kill Kill all scripts running on device
|
||||||
|
--level Exclude targets with higher hack level, defaults to current hack level
|
||||||
|
-l --local Execute on current machine otherwise execute on remote device
|
||||||
-r --rooted Filter to devices that have been rooted
|
-r --rooted Filter to devices that have been rooted
|
||||||
-n --not-rooted Filter to devices that have not been rooted
|
-n --not-rooted Filter to devices that have not been rooted
|
||||||
-p --ports Exclude targets with too many closed ports
|
-p --ports Exclude targets with too many closed ports
|
||||||
-s --silent Suppress program output
|
-s --silent Suppress program output
|
||||||
|
-v --verbose Display the device names in the final report
|
||||||
-h --help Display this help message
|
-h --help Display this help message
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -210,7 +217,7 @@ Usage: run network-graph.js [OPTIONS] [DEVICE]
|
|||||||
DEVICE Point to start scan from, defaults to current machine
|
DEVICE Point to start scan from, defaults to current machine
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-d --depth Depth to scan to, defaults is 3
|
-d --depth Depth to scan to
|
||||||
-f --filter Filter to device matching name
|
-f --filter Filter to device matching name
|
||||||
-e --regex Filter to devices matching pattern
|
-e --regex Filter to devices matching pattern
|
||||||
-r --rooted Filter to devices that have been rooted
|
-r --rooted Filter to devices that have been rooted
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {ArgError, ArgParser} from '/scripts/lib/arg-parser';
|
import {ArgError, ArgParser} from '/scripts/lib/arg-parser';
|
||||||
import {scanNetwork} from '/scripts/lib/utils';
|
import {copyWithDependencies, scanNetwork} from '/scripts/lib/utils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BitBurner autocomplete
|
* BitBurner autocomplete
|
||||||
@ -20,20 +20,24 @@ export async function main(ns) {
|
|||||||
const argParser = new ArgParser('crawler.js', 'Search the network for targets to execute a script against.', null, [
|
const argParser = new ArgParser('crawler.js', 'Search the network for targets to execute a script against.', null, [
|
||||||
{name: 'script', desc: 'Script to copy & execute', type: 'string'},
|
{name: 'script', desc: 'Script to copy & execute', type: 'string'},
|
||||||
{name: 'args', desc: 'Arguments for script. Forward the current target with: {{TARGET}}', optional: true, extras: true, type: 'string'},
|
{name: 'args', desc: 'Arguments for script. Forward the current target with: {{TARGET}}', optional: true, extras: true, type: 'string'},
|
||||||
{name: 'cpu', desc: 'Number of CPU threads to use with script', flags: ['-c', '--cpu'], default: 1, type: 'num'},
|
{name: 'cpu', desc: 'Number of CPU threads to use with script', flags: ['-c', '--cpu'], type: 'num'},
|
||||||
{name: 'depth', desc: 'Depth to scan to, defaults to 3', flags: ['-d', '--depth'], default: Infinity, type: 'num'},
|
{name: 'depth', desc: 'Depth to scan to, defaults to 3', flags: ['-d', '--depth'], default: Infinity, type: 'num'},
|
||||||
{name: 'level', desc: 'Exclude targets with higher hack level, defaults to current hack level', flags: ['-l', '--level'], default: ns.getHackingLevel(), type: 'num'},
|
{name: 'kill', desc: 'Kill all scripts running on device', flags: ['-k', '--kill'], type: 'bool'},
|
||||||
|
{name: 'level', desc: 'Exclude targets with higher hack level, defaults to current hack level', flags: ['--level'], default: ns.getHackingLevel(), type: 'num'},
|
||||||
|
{name: 'remoteExec', desc: 'Copy script to remote device & run there', flags: ['-e', '--remote-exec'], type: 'bool'},
|
||||||
{name: 'rooted', desc: 'Filter to devices that have been rooted', flags: ['-r', '--rooted'], type: 'bool'},
|
{name: 'rooted', desc: 'Filter to devices that have been rooted', flags: ['-r', '--rooted'], type: 'bool'},
|
||||||
{name: 'notRooted', desc: 'Filter to devices that have not been rooted', flags: ['-n', '--not-rooted'], type: 'bool'},
|
{name: 'notRooted', desc: 'Filter to devices that have not been rooted', flags: ['-n', '--not-rooted'], type: 'bool'},
|
||||||
{name: 'ports', desc: 'Exclude targets with too many closed ports', flags: ['-p', '--ports'], default: Infinity, type: 'num'},
|
{name: 'ports', desc: 'Exclude targets with too many closed ports', flags: ['-p', '--ports'], default: Infinity, type: 'num'},
|
||||||
{name: 'silent', desc: 'Suppress program output', flags: ['-s', '--silent'], type: 'bool'}
|
{name: 'silent', desc: 'Suppress program output', flags: ['-s', '--silent'], type: 'bool'},
|
||||||
|
{name: 'verbose', desc: 'Display the device names in the final report', flags: ['-v', '--verbose'], type: 'bool'},
|
||||||
], true);
|
], true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Run
|
// Run
|
||||||
|
const localhost = ns.getHostname();
|
||||||
const args = argParser.parse(ns.args);
|
const args = argParser.parse(ns.args);
|
||||||
const [devices, network] = scanNetwork(ns);
|
const [devices, network] = scanNetwork(ns);
|
||||||
let complete = 0, failed = 0, skipped = 0;
|
let complete = [], failed = [], skipped = [];
|
||||||
for(let device of devices) {
|
for(let device of devices) {
|
||||||
// Check root status if needed
|
// Check root status if needed
|
||||||
const rooted = ns.hasRootAccess(device);
|
const rooted = ns.hasRootAccess(device);
|
||||||
@ -42,31 +46,47 @@ export async function main(ns) {
|
|||||||
|
|
||||||
// Skip invalid devices
|
// Skip invalid devices
|
||||||
if(device == 'home' || args['level'] < ns.getServerRequiredHackingLevel(device) || args['ports'] < ns.getServerNumPortsRequired(device)) {
|
if(device == 'home' || args['level'] < ns.getServerRequiredHackingLevel(device) || args['ports'] < ns.getServerNumPortsRequired(device)) {
|
||||||
skipped++;
|
skipped.push(device);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start script
|
// Start script
|
||||||
|
if(args['kill']) ns.killall(device);
|
||||||
const scriptArgs = args['args'].map(arg => arg.toUpperCase() == '{{TARGET}}' ? device : arg);
|
const scriptArgs = args['args'].map(arg => arg.toUpperCase() == '{{TARGET}}' ? device : arg);
|
||||||
const pid = ns.run(args['script'], args['cpu'], ...scriptArgs);
|
const [totalRam, usedRam] = ns.getServerRam(args['remoteExec'] ? device : localhost);
|
||||||
|
const threads = args['cpu'] || ~~((totalRam - usedRam) / ns.getScriptRam(args['script'], localhost)) || 1;
|
||||||
|
if(args['remoteExec']) await copyWithDependencies(ns, args['script'], device);
|
||||||
|
const pid = ns.exec(args['script'], args['remoteExec'] ? device : localhost, threads, ...scriptArgs);
|
||||||
if(pid == 0) {
|
if(pid == 0) {
|
||||||
failed++;
|
failed.push(device);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for script to finish
|
// Wait for script to finish if local
|
||||||
while(ns.scriptRunning(args['script'], 'home'))
|
if(!args['remoteExec'])
|
||||||
await ns.sleep(1000);
|
while(ns.scriptRunning(args['script'], localhost)) await ns.sleep(1000);
|
||||||
complete++;
|
complete.push(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output report
|
// Output report
|
||||||
if(!args['silent']) {
|
if(!args['silent']) {
|
||||||
ns.tprint('===================================================');
|
ns.tprint('===================================================');
|
||||||
ns.tprint(`Crawler Report: ${complete + failed + skipped} Devices`);
|
ns.tprint(`Crawler Report: ${complete.length + failed.length + skipped.length} Devices`);
|
||||||
ns.tprint('===================================================');
|
ns.tprint('===================================================');
|
||||||
ns.tprint(`Complete: ${complete}\tFailed: ${failed}\tSkipped: ${skipped}`);
|
if(args['verbose']) {
|
||||||
|
ns.tprint(`Complete (${complete.length}):`);
|
||||||
|
if(complete.length) ns.tprint(complete.join(', '));
|
||||||
ns.tprint('');
|
ns.tprint('');
|
||||||
|
ns.tprint(`Failed (${failed.length}):`);
|
||||||
|
if(failed.length) ns.tprint(failed.join(', '));
|
||||||
|
ns.tprint('');
|
||||||
|
ns.tprint(`Skipped (${skipped.length}):`);
|
||||||
|
if(skipped.length) ns.tprint(skipped.join(', '));
|
||||||
|
ns.tprint('');
|
||||||
|
} else {
|
||||||
|
ns.tprint(`Complete: ${complete.length}\tFailed: ${failed.length}\tSkipped: ${skipped.length}`);
|
||||||
|
ns.tprint('');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
if(err instanceof ArgError) return ns.tprint(argParser.help(err.message));
|
if(err instanceof ArgError) return ns.tprint(argParser.help(err.message));
|
||||||
|
@ -36,7 +36,7 @@ export async function main(ns) {
|
|||||||
ns.disableLog('ALL');
|
ns.disableLog('ALL');
|
||||||
const argParser = new ArgParser('network-graph.js', 'Scan the network for devices and display as an ASCII tree:\n home\n ├─ n00dles (ROOTED)\n | └─ max-hardware (80|1)\n | └─ neo-net (50|1)\n ├─ foodnstuff (ROOTED)\n └─ sigma-cosmetics (ROOTED)', null, [
|
const argParser = new ArgParser('network-graph.js', 'Scan the network for devices and display as an ASCII tree:\n home\n ├─ n00dles (ROOTED)\n | └─ max-hardware (80|1)\n | └─ neo-net (50|1)\n ├─ foodnstuff (ROOTED)\n └─ sigma-cosmetics (ROOTED)', null, [
|
||||||
{name: 'device', desc: 'Point to start scan from, defaults to current machine', optional: true, default: ns.getHostname(), type: 'string'},
|
{name: 'device', desc: 'Point to start scan from, defaults to current machine', optional: true, default: ns.getHostname(), type: 'string'},
|
||||||
{name: 'depth', desc: 'Depth to scan to, defaults is 3', flags: ['-d', '--depth'], default: Infinity, type: 'num'},
|
{name: 'depth', desc: 'Depth to scan to', flags: ['-d', '--depth'], default: Infinity, type: 'num'},
|
||||||
{name: 'filter', desc: 'Filter to device matching name', flags: ['-f', '--filter'], type: 'string'},
|
{name: 'filter', desc: 'Filter to device matching name', flags: ['-f', '--filter'], type: 'string'},
|
||||||
{name: 'regex', desc: 'Filter to devices matching pattern', flags: ['-e', '--regex'], type: 'string'},
|
{name: 'regex', desc: 'Filter to devices matching pattern', flags: ['-e', '--regex'], type: 'string'},
|
||||||
{name: 'rooted', desc: 'Filter to devices that have been rooted', flags: ['-r', '--rooted'], type: 'bool'},
|
{name: 'rooted', desc: 'Filter to devices that have been rooted', flags: ['-r', '--rooted'], type: 'bool'},
|
||||||
|
Loading…
Reference in New Issue
Block a user