Compare commits

..

24 Commits

Author SHA1 Message Date
c316643787 Update README.md 2023-12-05 04:58:56 +00:00
4e6b125db7 Add .github/pull_request_template.md 2023-11-24 21:14:55 +00:00
9f867d9372 Update README.md 2023-08-07 17:05:33 +00:00
e16e56741a Update .github/issue_template/enhancement.md 2023-08-07 16:03:48 +00:00
fa384b41ab Update .github/issue_template/enhancment.md 2023-08-07 16:02:46 +00:00
0f450f23b8 Update .github/issue_template/bug.md 2023-08-07 16:02:33 +00:00
e25e4f989c Add .github/issue_templates/enhancment.md 2023-08-07 16:01:59 +00:00
207fe642d4 Add .github/issue_templates/bug.md 2023-08-07 16:01:42 +00:00
4c151dc301 Update README.md 2023-08-07 16:00:53 +00:00
ef915b69ba Update README.md 2023-08-07 15:57:46 +00:00
b961919274 Update README.md 2023-08-07 15:56:53 +00:00
865372fa9e Delete bitburner.png 2023-08-07 15:17:18 +00:00
54e53cbfbb Update LICENSE 2023-08-07 15:16:55 +00:00
67732b8dcd Add LICENSE 2023-08-07 15:14:00 +00:00
24699af95d Update README.md 2023-07-28 02:03:52 +00:00
7844d1467c Added logo 2023-07-27 23:36:08 +00:00
e9569b24f9 Delete bitburner.png 2023-07-27 23:35:35 +00:00
e664ae3ebc Added logo 2023-07-27 23:34:11 +00:00
f5615e985e Delete bitburner.png 2023-07-27 23:33:31 +00:00
d46e4dfa34 Update README.md 2023-07-27 23:33:21 +00:00
c77e320550 Added logo 2023-07-27 23:32:14 +00:00
40415c3a0d Use github URL 2022-08-13 00:43:46 +00:00
72d00c1d4b Update README.md 2022-08-13 00:38:51 +00:00
0e15103d31 Update README.md 2022-05-05 22:02:14 +00:00
15 changed files with 936 additions and 885 deletions

30
.github/issue_template/bug.md vendored Normal file
View File

@ -0,0 +1,30 @@
---
name: "Bug report"
about: "Encountered an issue"
ref: "develop"
labels:
- Type/Bug
---
# Bug Report
<!-- Description of problem -->
I tried to ...
But instead ...
## Steps to Reproduce
<!-- How can developers replicate & test the problem? -->
1.
2.
3.
## Logs
<!-- Any logs that accompenied the error -->
```
```
## Screenshots
<!-- Screenshots (annoted if possible) of the problem -->

22
.github/issue_template/enhancement.md vendored Normal file
View File

@ -0,0 +1,22 @@
---
name: "Enhancement"
about: "Request a feature"
ref: "develop"
labels:
- Type/Enhancement
---
# Feature Request
<!-- Detailed description -->
...
## Requirements
<!-- Bullet list of requirments -->
1. ...
2. ...
## Notes
<!-- Any additional considerations, solutions or design choices -->
...

14
.github/pull_request_template.md vendored Normal file
View File

@ -0,0 +1,14 @@
## Description
<!-- Adition information & context -->
...
## Issues
<!-- Issues this PR will address -->
- closes #___
- owner/repo#___
## Checklist
<!-- Compelte after creating PR -->
- [ ] Linked issues
- [ ] Reviewed changes
- [ ] Updated comments/documentation

7
LICENSE Normal file
View File

@ -0,0 +1,7 @@
Copyright (c) 2023 Zakary Timson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

238
README.md
View File

@ -1,33 +1,65 @@
# BitBurner - Scripts <!-- Header -->
A collection of scripts & information pertaining to the [open source](https://github.com/danielyxie/bitburner) game <div id="top" align="center">
[BitBurner](https://danielyxie.github.io/bitburner/). <br />
<!-- Logo -->
<img src="https://git.zakscode.com/repo-avatars/9b25b57330ba3a1d9da80dad4051be68373e52c4bfffc6f6ba9e89f7392f5f7d" alt="Logo" width="200" height="200">
<!-- Title -->
### Bitburner
<!-- Description -->
Collection of Bitburner scipts
<!-- Repo badges -->
[![Version](https://img.shields.io/badge/dynamic/json.svg?label=Version&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/bitburner/tags&query=$[0].name)](https://git.zakscode.com/ztimson/bitburner/tags)
[![Pull Requests](https://img.shields.io/badge/dynamic/json.svg?label=Pull%20Requests&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/bitburner&query=open_pr_counter)](https://git.zakscode.com/ztimson/bitburner/pulls)
[![Issues](https://img.shields.io/badge/dynamic/json.svg?label=Issues&style=for-the-badge&url=https://git.zakscode.com/api/v1/repos/ztimson/bitburner&query=open_issues_count)](https://git.zakscode.com/ztimson/bitburner/issues)
<!-- Links -->
---
<div>
<a href="https://git.zakscode.com/ztimson/bitburner/releases" target="_blank">Release Notes</a>
<a href="https://git.zakscode.com/ztimson/bitburner/issues/new?template=.github%2fissue_template%2fbug.md" target="_blank">Report a Bug</a>
<a href="https://git.zakscode.com/ztimson/bitburner/issues/new?template=.github%2fissue_template%2fenhancement.md" target="_blank">Request a Feature</a>
</div>
---
</div>
## Table of Contents ## Table of Contents
- [BitBurner - Scripts](#bitburner-scripts) - [Bitburner](#top)
- [Table of Contents](#table-of-contents) - [About](#about)
- [Quick Start](#quick-start) - [Built With](#built-with)
- [Guide](#guide) - [Quick Start](#qiuck-start)
- [BitNode 1](#bitnode-1) - [Scripts](#scripts)
- [Scripts](#scripts) - [banner.js](#banner)
- [banner.js](#bannerjs) - [botnet-manager.js (WIP)](#botnet)
- [botnet-manager.js (WIP)](#botnet-managerjs-wip) - [connect.js](#connect)
- [connect.js](#connectjs) - [copy.js](#copy)
- [copy.js](#copyjs) - [crawler.js](#crawler)
- [crawler.js](#crawlerjs) - [find-target.js](#find-target)
- [find-target.js](#find-targetjs) - [hacknet-manager.js](#hacknet)
- [hacknet-manager.js](#hacknet-managerjs) - [miner.js](#miner)
- [miner.js](#minerjs) - [network-graph.js](#network-graph)
- [network-graph.js](#network-graphjs) - [rm.js](#rm)
- [rm.js](#rmjs) - [rootkit.js](#rootkit)
- [rootkit.js](#rootkitjs) - [server-manager.js](#server-manager)
- [server-manager.js](#server-managerjs) - [update.js](#update)
- [update.js](#updatejs) - [License](#license)
## About
A collection of scripts & information pertaining to the [open source](https://github.com/danielyxie/bitburner) game [Bitburner](https://danielyxie.github.io/bitburner/)
### Built with
[![JavaScript](https://img.shields.io/badge/JavaScript-000000?style=for-the-badge&logo=javascript)](https://javascript.com/)
## Quick Start ## Quick Start
```bash ```bash
# Download the update script in-game & run it # 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 scripts/update.js # Repeat to pull the latest
# View the network # View the network
@ -50,31 +82,15 @@ run scripts/connect.js CSEC
backdoor backdoor
``` ```
Learn more about the [available scripts](#scripts) bellow or pass the `--help` flag to any of the included scripts in-game.
## Guide
This guide documents how you can use this repository to progress through the game. You should complete the tutorial
first if you haven't already.
### BitNode 1
1. First you need to download this repo into the game. Manually download `update.js` & run it:
`wget https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/update.js scripts/update.js; run scripts/update.js`
2. Scan the network to figure out your bearings, take note of discovered server's required hack level:
`run scripts/network-graph.js -vd 3`
3. Root the lowest level server (probably n00dles) & make it hack itself for money. You should repeat this step when
ever your hack level is high enough to hack another a new server. `run scripts/rootkit.js n00dles /scripts/miner.js`
4. Start `hacknet-manger.js`. You won't have enough *RAM* in the beginning to run the manager & hack servers. It's
recommended you `tail` the manager, so you can easily start/stop it as needed. `run script/hacknet-manager.js -a`
5. Once you have enough money ($??,???.??), upgrade your home severs *RAM*:
`City > alpha ent. > Upgrade 'home' RAM (8.00GB -> 16.00GB)`
6. At this point you have enough *RAM* to use `crawler.js` to automatically discover servers & hack them. Continue to
run this periodically as your hack level increases & you unlock more exploits:
`run scripts/crawler.js -n /scripts/rootkit.js {{TARGET}} /scripts/miner.js`
## Scripts ## Scripts
### [banner.js](./scripts/banner.js) <details>
**RAM:** 1.60 GB <summary>
<h3 id="banner" style="display: inline">banner.js</h3>
</summary>
<br />
**RAM:** 1.60 GB | [Code](./src/banner.js)
Aesthetic & serves no real purpose. Prints a banner to the terminal & can repeat after game restarts. Aesthetic & serves no real purpose. Prints a banner to the terminal & can repeat after game restarts.
``` ```
@ -91,9 +107,15 @@ Options:
-r, --reboot Automatically display after game reboots -r, --reboot Automatically display after game reboots
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [botnet-manager.js (WIP)](./scripts/botnet-manager.js) <details>
**RAM:** 7.15 GB <summary>
<h3 id="botnet" style="display: inline">botnet-manager.js (WIP)</h3>
</summary>
<br />
**RAM:** 7.15 GB | [Code](./scripts/botnet-manager.js)
Late-game solution to hack servers. It orchestrates an unlimited number of servers to carry out distributed batched Late-game solution to hack servers. It orchestrates an unlimited number of servers to carry out distributed batched
attacks against targets. It includes a bunch of utilities to quickly dispatch single commands to all workers. Manger attacks against targets. It includes a bunch of utilities to quickly dispatch single commands to all workers. Manger
@ -121,9 +143,15 @@ Commands:
run Copy & run script on all worker nodes run Copy & run script on all worker nodes
start Start this device as the swarm manager start Start this device as the swarm manager
``` ```
</details>
### [connect.js](./scripts/connect.js) <details>
**RAM:** 1.85 GB <summary>
<h3 id="connect" style="display: inline">connect.js</h3>
</summary>
<br />
**RAM:** 1.85 GB | [Code](./scripts/connect.js)
The built in `connect` command only allows you to connect to devices in the immediate vicinity or servers that have The built in `connect` command only allows you to connect to devices in the immediate vicinity or servers that have
backdoors installed requiring you to make several jumps. This script will automatically find a path & connect you saving backdoors installed requiring you to make several jumps. This script will automatically find a path & connect you saving
@ -143,9 +171,15 @@ Usage: run connect.js [OPTIONS] SERVER
Options: Options:
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [copy.js](./scripts/copy.js) <details>
**RAM:** 4.20 GB <summary>
<h3 id="copy" style="display: inline">copy.js</h3>
</summary>
<br />
**RAM:** 4.20 GB | [Code](./scripts/copy.js)
Scripts often import other scripts requiring multiple `scp` calls before it can be run on a remote machine. This script Scripts often import other scripts requiring multiple `scp` calls before it can be run on a remote machine. This script
will automatically scan the file being copied for imports & recursively scan & copy the dependencies. Plus it has a will automatically scan the file being copied for imports & recursively scan & copy the dependencies. Plus it has a
@ -171,9 +205,15 @@ Options:
-q, --quite Suppress program output -q, --quite Suppress program output
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [crawler.js](./scripts/crawler.js) <details>
**RAM:** 5.80 GB <summary>
<h3 id="crawler" style="display: inline">crawler.js</h3>
</summary>
<br />
**RAM:** 5.80 GB | [Code](./scripts/crawler.js)
Mid-game solution to distribute & run scripts across the network. Mid-game solution to distribute & run scripts across the network.
``` ```
@ -202,9 +242,15 @@ Options:
-v, --verbose Display the server names in the final report -v, --verbose Display the server names in the final report
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [find-target.js](./scripts/find-target.js) <details>
**RAM:** 4.05 GB <summary>
<h3 id="find-target" style="display: inline">find-target.js</h3>
</summary>
<br />
**RAM:** 4.05 GB | [Code](./scripts/find-target.js)
A utility to help figure out which server is worth hacking the most. It does this by estimating the financial yield per A utility to help figure out which server is worth hacking the most. It does this by estimating the financial yield per
minute for each server & returns the servers in a sorted list. minute for each server & returns the servers in a sorted list.
@ -225,9 +271,15 @@ Options:
-v, --verbose Display the estimated income per minute per core -v, --verbose Display the estimated income per minute per core
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [hacknet-manager.js](./scripts/hacknet-manager.js) <details>
**RAM:** 5.70 GB <summary>
<h3 id="hacknet" style="display: inline">hacknet-manager.js</h3>
</summary>
<br />
**RAM:** 5.70 GB | [Code](./scripts/hacknet-manager.js)
An early game solution to automate the hacknet & get easy money. An early game solution to automate the hacknet & get easy money.
``` ```
@ -248,12 +300,18 @@ Options:
-s, --sleep Amount of time to wait between purchases, defaults to 1 (second) -s, --sleep Amount of time to wait between purchases, defaults to 1 (second)
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [miner.js](./scripts/miner.js) <details>
**RAM:** 2.45 GB <summary>
<h3 id="miner" style="display: inline">miner.js</h3>
</summary>
<br />
**RAM:** 2.45 GB | [Code](./scripts/miner.js)
An early-game HGW script to steal money from servers. You can deploy this on each server and have them hack themselves, An early-game HGW script to steal money from servers. You can deploy this on each server and have them hack themselves,
or they can all target the server with the most money which is more efficient (see [find-target.js](#find-targetjs)). or they can all target the server with the most money which is more efficient (see [find-target.js](#find-target)).
``` ```
[home ~/]> run scripts/miner.js --help [home ~/]> run scripts/miner.js --help
Running script with 1 thread(s), pid 1 and args: ["--help"]. Running script with 1 thread(s), pid 1 and args: ["--help"].
@ -272,9 +330,15 @@ Options:
-s, --sleep Amount of time to wait between purchases, defaults to 1 (second) -s, --sleep Amount of time to wait between purchases, defaults to 1 (second)
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [network-graph.js](./scripts/network-graph.js) <details>
**RAM:** 3.85 GB <summary>
<h3 id="network-graph" style="display: inline">network-graph.js</h3>
</summary>
<br />
**RAM:** 3.85 GB | [Code](./scripts/network-graph.js)
A utility to scan the network & build a visual tree of all the devices. It comes with lots of flags to narrow down the A utility to scan the network & build a visual tree of all the devices. It comes with lots of flags to narrow down the
results. It's useful for figuring out where you are, manually finding targets & discovering the path to a server & results. It's useful for figuring out where you are, manually finding targets & discovering the path to a server &
@ -304,11 +368,17 @@ Options:
-v, --verbose Display level, specs & usage in that order: [HL|P] {CPU|RAM} (USG%) -v, --verbose Display level, specs & usage in that order: [HL|P] {CPU|RAM} (USG%)
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [rm.js](./scripts/rm.js) <details>
**RAM:** 2.85 GB <summary>
<h3 id="rm" style="display: inline">rm.js</h3>
</summary>
<br />
[BitBurner-Connector](https://plugins.jetbrains.com/plugin/18338-bitburner-connector) would occasionally push my IDE **RAM:** 2.85 GB | [Code](./scripts/rm.js)
[bitburner-connector](https://plugins.jetbrains.com/plugin/18338-bitburner-connector) would occasionally push my IDE
files to the game, so I created this simple script to recursively search & delete files from a directory to save me files to the game, so I created this simple script to recursively search & delete files from a directory to save me
from having to delete files one-by-one. from having to delete files one-by-one.
``` ```
@ -329,9 +399,15 @@ Options:
-r, --recursive Delete everything inside directory -r, --recursive Delete everything inside directory
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [rootkit.js](./scripts/rootkit.js) <details>
**RAM:** 4.65 GB <summary>
<h3 id="rootkit" style="display: inline">rootkit.js</h3>
</summary>
<br />
**RAM:** 4.65 GB | [Code](./scripts/rootkit.js)
Automatically gains root on the local or remote server. A script can be passed as an additional argument; it will be Automatically gains root on the local or remote server. A script can be passed as an additional argument; it will be
copied and automatically executed with the maximum number of threads after being rooted. copied and automatically executed with the maximum number of threads after being rooted.
@ -359,9 +435,15 @@ Options:
-v, --verbose Display level, specs & usage in that order: [HL|P] {CPU|RAM} (USG%) -v, --verbose Display level, specs & usage in that order: [HL|P] {CPU|RAM} (USG%)
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [server-manager.js](./scripts/server-manager.js) <details>
**RAM:** 11.35 GB <summary>
<h3 id="server-miner" style="display: inline">server-miner.js</h3>
</summary>
<br />
**RAM:** 11.35 GB | [Code](./scripts/server-manager.js)
Mid-game script to handle purchasing and upgrading servers for more computer power. You can also set a script to run Mid-game script to handle purchasing and upgrading servers for more computer power. You can also set a script to run
automatically after purchase. Useful to chain with `miner.js` or `botnet.js`. automatically after purchase. Useful to chain with `miner.js` or `botnet.js`.
@ -386,9 +468,15 @@ Options:
-s, --sleep Amount of time to wait between purchases, defaults to 1 (second) -s, --sleep Amount of time to wait between purchases, defaults to 1 (second)
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
### [update.js](./scripts/update.js) <details>
**RAM:** 2.65 GB <summary>
<h3 id="update" style="display: inline">update.js</h3>
</summary>
<br />
**RAM:** 2.65 GB | [Code](./scripts/update.js)
Uses the in-game `wget` to download all the scripts in this repository. Can target remote servers to quickly copy the Uses the in-game `wget` to download all the scripts in this repository. Can target remote servers to quickly copy the
entire toolkit to the target. entire toolkit to the target.
@ -409,3 +497,9 @@ Options:
--no-banner Hide the banner (Used internally) --no-banner Hide the banner (Used internally)
-h, --help Display this help message -h, --help Display this help message
``` ```
</details>
## License
Copyright © 2023 Zakary Timson | Available under MIT Licensing
See the [license](./LICENSE) for more information.

View File

@ -1,34 +0,0 @@
/**
* Automatically complete the current BitNode.
*
* @param {NS} ns - BitBurner API
*/
export function main(ns) {
let modules = [
'auto-root',
'auto-hack',
'botnet-manager',
'hacknet-manager',
'server-manager'
];
// Banner
ns.run('/scripts/banner.js', 1, '-r');
ns.tprint(`Starting BitBurner with ${modules.length} enabled: `);
ns.tprint(modules.join(', '));
// botnet-manager
// hacknet-manager
ns.run('/scripts/hacknet-manager', 1, '-a');
// server-manager
ns.run('/scripts/server-manager', 1, '');
while(true) {
// auto-hack
ns.sleep(1000);
}
}

View File

@ -1,20 +1,16 @@
import {ArgParser} from '/scripts/lib/arg-parser'; import {ArgParser} from '/scripts/lib/arg-parser';
import {Config} from '/scripts/lib/data-file';
import {Logger} from '/scripts/lib/logger'; import {Logger} from '/scripts/lib/logger';
import {copyWithDependencies} from '/scripts/copy'; import {copyWithDependencies} from '/scripts/copy';
const configPath = '/etc/botnet.txt';
const port = 1;
class Manager { class Manager {
running; running;
workers = []; workers = [];
async constructor(ns, hostname) { constructor(ns, device, port, config = '/conf/botnet.txt') {
ns.disableLog('ALL'); ns.disableLog('ALL');
this.ns = ns; this.ns = ns;
this.config = new Config(configPath); this.config = config;
this.hostname = hostname; this.device = device;
this.logger = new Logger(this.ns, [ this.logger = new Logger(this.ns, [
() => `Botnet: ${device}`, () => `Botnet: ${device}`,
() => `Workers: ${this.workers.length}\tCores: ${this.workers.reduce((acc, w) => acc + w.cpuCores, 0)}\tRAM: ${this.workers.reduce((acc, w) => acc + w.maxRam, 0)} GB` () => `Workers: ${this.workers.length}\tCores: ${this.workers.reduce((acc, w) => acc + w.cpuCores, 0)}\tRAM: ${this.workers.reduce((acc, w) => acc + w.maxRam, 0)} GB`
@ -128,8 +124,7 @@ class Manager {
export async function main(ns) { export async function main(ns) {
// Setup // Setup
ns.disableLog('ALL'); ns.disableLog('ALL');
const config = await new Config(ns, configPath).load(); const hostname = ns.getHostname(), portNum = 1;
const hostname = ns.getHostname();
const argParser = new ArgParser('botnet-manager.js', 'Connect & manage a network of servers to launch distributed attacks.', [ const argParser = new ArgParser('botnet-manager.js', 'Connect & manage a network of servers to launch distributed attacks.', [
new ArgParser('copy', 'Copy file & dependencies to botnet', [ new ArgParser('copy', 'Copy file & dependencies to botnet', [
{name: 'file', desc: 'File to copy', default: false}, {name: 'file', desc: 'File to copy', default: false},
@ -144,7 +139,6 @@ export async function main(ns) {
new ArgParser('leave', 'Disconnect worker node from swarm', [ new ArgParser('leave', 'Disconnect worker node from swarm', [
{name: 'device', desc: 'Device to disconnect, defaults to the current machine', optional: true, default: hostname} {name: 'device', desc: 'Device to disconnect, defaults to the current machine', optional: true, default: hostname}
]), ]),
new ArgParser('list', 'List connected worker nodes'),
new ArgParser('run', 'Copy & run script on the botnet', [ new ArgParser('run', 'Copy & run script on the botnet', [
{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}, {name: 'args', desc: 'Arguments for script. Forward the current target with: {{TARGET}}', optional: true, extras: true},
@ -160,9 +154,9 @@ export async function main(ns) {
// Run command // Run command
if(args['_command'] == 'start') { // Start botnet manager if(args['_command'] == 'start') { // Start botnet manager
ns.tprint(`Starting botnet controller on: ${hostname}`); ns.tprint(`Starting ${hostname} as botnet manager`);
ns.tprint(`Connect workers to botnet with: run botnet-manager.js join [SERVER]`); ns.tprint(`Connect more nodes with: run botnet-manager.js join [SERVER]`);
await new Manager(ns, hostname).start(); await new Manager(ns, hostname, portNum).start();
} else if(args['_command'] == 'copy') { // Issue copy command } else if(args['_command'] == 'copy') { // Issue copy command
await ns.writePort(portNum, JSON.stringify({ await ns.writePort(portNum, JSON.stringify({
command: 'copy', command: 'copy',
@ -182,9 +176,6 @@ export async function main(ns) {
command: 'leave', command: 'leave',
value: args['device'] value: args['device']
})); }));
} else if(args['_command'] == 'list') {
ns.tprint('Botnet workers:');
ns.tprint(config['workers'].map(worker => worker.hostname).join(', '));
} else if(args['_command'] == 'run') { // Issue run command } else if(args['_command'] == 'run') { // Issue run command
await ns.writePort(portNum, JSON.stringify({ await ns.writePort(portNum, JSON.stringify({
command: 'run', command: 'run',

View File

@ -1,31 +0,0 @@
export class DataFile {
/**
* Read & write data to a JSON file.
*
* @param {NS} ns - Bitburner API
* @param path - Path to config file
*/
constructor(ns, path) {
this.ns = ns;
this.path = path;
}
/**
* Load data file
*
* @returns {Promise<any>} - Saved data
*/
async load() {
return JSON.parse(await this.ns.read(this.path) || 'null');
}
/**
* Save data to file
*
* @param values - Data to save
* @returns {Promise<void>} - Save complete
*/
async save(values) {
await this.ns.write(this.path, JSON.stringify(values), 'w');
}
}

View File

@ -1,42 +0,0 @@
export class PortHelper {
/**
*
* @param ns
* @param port
* @param host
*/
constructor(ns, port, host) {
this.ns = ns;
this.host = host;
this.portNum = port;
this.port = ns.getPortHandle(port);
this.callbacks = {};
}
check() {
const pending = [];
while(!this.port.empty()) pending.push(this.port.read());
pending.filter(p => {
try {
const payload = JSON.parse(p);
if(this.callbacks[payload.subject]) return !this.callbacks[payload.subject](payload.value);
if(this.callbacks['*']) return !this.callbacks['*'](payload.value);
return true;
} catch {
return true;
}
}).forEach(p => this.port.write(p));
}
subscribe(subject, callback) { if(typeof callback == 'function') this.callbacks[subject] = callback; }
send(subject, value) {
this.ns.writePort(this.portNum, JSON.stringify({
from: this.host,
subject,
value
}));
}
unsubscribe(subject) { delete this.callbacks[subject]; }
}

View File

@ -183,7 +183,7 @@ export async function main(ns) {
{name: 'no-banner', desc: 'Hide the banner (Used internally)', flags: ['--no-banner'], default: false} {name: 'no-banner', desc: 'Hide the banner (Used internally)', flags: ['--no-banner'], default: false}
]); ]);
const args = argParser.parse(ns.args || []); const args = argParser.parse(ns.args || []);
const src = 'https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/'; const src = 'https://raw.githubusercontent.com/PointyTrident/Bitburner/develop/scripts/';
const dest = '/scripts/'; const dest = '/scripts/';
const fileList = [ const fileList = [
'lib/arg-parser.js', 'lib/arg-parser.js',