miner updates
This commit is contained in:
parent
3e2a2b92da
commit
ef717eb825
37
README.md
37
README.md
@ -4,14 +4,13 @@ These scripts are for playing the [open source](https://github.com/danielyxie/bi
|
|||||||
## Table of Contents
|
## Table of Contents
|
||||||
[[_TOC_]]
|
[[_TOC_]]
|
||||||
|
|
||||||
## Setup
|
|
||||||
The repository can be loaded into the game by doing the following:
|
|
||||||
1. Download the update script ingame: `wget https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/update.js scripts/update.js`
|
|
||||||
2. Run update script: `run scripts/update.js`
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
```bash
|
```bash
|
||||||
# Start the node manager
|
# Download & run the update script ingame
|
||||||
|
wget https://gitlab.zakscode.com/ztimson/BitBurner/-/raw/develop/scripts/update.js scripts/update.js
|
||||||
|
run scripts/update.js
|
||||||
|
|
||||||
|
# Start the node manager with 8 nodes
|
||||||
run scripts/node-manager.js 8
|
run scripts/node-manager.js 8
|
||||||
|
|
||||||
# Chain the crawler, auto-pwner & miner to hack everything within 3 hops
|
# Chain the crawler, auto-pwner & miner to hack everything within 3 hops
|
||||||
@ -35,7 +34,7 @@ Usage: run auto-pwn.js [TARGET] [SCRIPT] [ARGS]...
|
|||||||
|
|
||||||
TARGET Target machine to root. Defaults to localhost
|
TARGET Target machine to root. Defaults to localhost
|
||||||
SCRIPT Script to copy & execute
|
SCRIPT Script to copy & execute
|
||||||
ARGS Any aditional arguments to pass to SCRIPT. Passing '{{TARGET}}' will forward the current target
|
ARGS Aditional arguments for SCRIPT. Forward the target with "{{TARGET}}"
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h --help Display help message
|
-h --help Display help message
|
||||||
@ -51,10 +50,28 @@ Scans the network to a desired depth & runs the specified script against targets
|
|||||||
|
|
||||||
It's recommended you use this in combination with `auto-pwn.js`.
|
It's recommended you use this in combination with `auto-pwn.js`.
|
||||||
|
|
||||||
### [miner.js](./scripts/miner.js) (WIP)
|
### [miner.js](./scripts/miner.js)
|
||||||
Will weaken, spoof & hack the target in a loop.
|
**RAM:** 2.35 GB
|
||||||
|
|
||||||
It's recommended you run this in combination with `auto-pwn.js` to gain root & run the miner on the remote machine.
|
Weaken, spoof & hack the target in a loop for money.
|
||||||
|
```
|
||||||
|
[home ~/]> run scripts/miner.js --help
|
||||||
|
|
||||||
|
Running script with 1 thread(s), pid 41 and args: ["--help"].
|
||||||
|
|
||||||
|
/scripts/miner.js:
|
||||||
|
|
||||||
|
Weaken, spoof & hack the target in a loop for money.
|
||||||
|
|
||||||
|
Usage: run miner.js [OPTIONS] [TARGET]
|
||||||
|
run miner.js --help
|
||||||
|
|
||||||
|
TARGET Target to mine. Defaults to localhost
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-t --threads Speed up script with more CPU power
|
||||||
|
-h --help Display help message
|
||||||
|
```
|
||||||
|
|
||||||
### [node-manager.js](./scripts/node-manager.js)
|
### [node-manager.js](./scripts/node-manager.js)
|
||||||
**RAM:** 5.70 GB
|
**RAM:** 5.70 GB
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import {ArgParser} from './scripts/lib/arg-parser';
|
import {ArgParser} from './scripts/lib/arg-parser';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pwn a target server will availible tools. Can also copy & execute a script after pwning.
|
||||||
|
*/
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
ns.disableLog('ALL');
|
ns.disableLog('ALL');
|
||||||
|
|
||||||
@ -24,7 +27,7 @@ export async function main(ns) {
|
|||||||
args: [
|
args: [
|
||||||
{key: 'TARGET', desc: 'Target machine to root. Defaults to localhost'},
|
{key: 'TARGET', desc: 'Target machine to root. Defaults to localhost'},
|
||||||
{key: 'SCRIPT', desc: 'Script to copy & execute'},
|
{key: 'SCRIPT', desc: 'Script to copy & execute'},
|
||||||
{key: 'ARGS', desc: 'Any aditional arguments to pass to SCRIPT. Passing \'{{TARGET}}\' will forward the current target'},
|
{key: 'ARGS', desc: 'Aditional arguments for SCRIPT. Forward the target with "{{TARGET}}"'},
|
||||||
{key: 'help', alias: 'h', optional: true, desc: 'Display help message'},
|
{key: 'help', alias: 'h', optional: true, desc: 'Display help message'},
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
@ -1,36 +1,72 @@
|
|||||||
|
import {ArgParser} from './scripts/lib/arg-parser';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hack a server for it's money.
|
||||||
|
*/
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
ns.disableLog('ALL');
|
ns.disableLog('ALL');
|
||||||
const TARGET = ns.args[0];
|
|
||||||
const SECURITY = ns.getServerMinSecurityLevel(TARGET) + 2;
|
|
||||||
let BALANCE, once = true;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print header with logs
|
||||||
|
* @param message - message to append to logs
|
||||||
|
*/
|
||||||
|
function log(message) {
|
||||||
|
const sec = `${Math.round(security)}/${minSecurity}`;
|
||||||
|
ns.clearLog();
|
||||||
|
ns.print('===================================================');
|
||||||
|
ns.print(`💎⛏️ Mining: ${target}`);
|
||||||
|
ns.print('===================================================');
|
||||||
|
ns.print(`Security: ${sec}${sec.length < 6 ? '\t' : ''}\tBalance: $${Math.round(balance * 100) / 100}`);
|
||||||
|
ns.print('===================================================');
|
||||||
|
if(message != null) messageHistory.push(message);
|
||||||
|
messageHistory.splice(0, messageHistory.length - historyLength);
|
||||||
|
messageHistory.forEach(m => ns.print(m));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initilize script arguments
|
||||||
|
const argParser = new ArgParser({
|
||||||
|
desc: 'Weaken, spoof & hack the target in a loop for money.',
|
||||||
|
examples: [
|
||||||
|
'run miner.js [OPTIONS] [TARGET]',
|
||||||
|
'run miner.js --help',
|
||||||
|
],
|
||||||
|
args: [
|
||||||
|
{key: 'TARGET', desc: 'Target to mine. Defaults to localhost'},
|
||||||
|
{key: 'threads', alias: 't', optional: true, desc: 'Speed up script with more CPU power'},
|
||||||
|
{key: 'help', alias: 'h', optional: true, desc: 'Display help message'},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
const args = argParser.parse(ns.args);
|
||||||
|
if(args['help']) return ns.tprint(argParser.help());
|
||||||
|
|
||||||
|
// Setup
|
||||||
|
const historyLength = 15;
|
||||||
|
const messageHistory = Array(historyLength).fill('');
|
||||||
|
const threads = args['threads'] || 1;
|
||||||
|
const target = args['TARGET'] && args['TARGET'] != 'localhost' ? args['TARGET'] : ns.getHostname();
|
||||||
|
const minSecurity = ns.getServerMinSecurityLevel(target) + 2;
|
||||||
|
let orgBalance, balance, security;
|
||||||
|
|
||||||
|
log();
|
||||||
while(true) {
|
while(true) {
|
||||||
let s = await ns.getServerSecurityLevel(TARGET);
|
// Update information
|
||||||
let b = await ns.getServerMoneyAvailable(TARGET);
|
security = await ns.getServerSecurityLevel(target);
|
||||||
if(BALANCE == null) BALANCE = b;
|
balance = await ns.getServerMoneyAvailable(target);
|
||||||
|
if(orgBalance == null) orgBalance = balance;
|
||||||
|
|
||||||
if(once) {
|
// Pick step
|
||||||
ns.print('===================================================');
|
if(security > minSecurity) {
|
||||||
ns.print(`Bankrupting: ${TARGET}`);
|
log('Attacking Security...');
|
||||||
ns.print('===================================================');
|
const w = await ns.weaken(target, {threads});
|
||||||
ns.print(`Security: ${Math.round(s * 100) / 100}/${SECURITY}`);
|
log(`Security: -${w}`);
|
||||||
ns.print(`Balance: $${Math.round(BALANCE * 100) / 100}`);
|
} else if(balance <= orgBalance) {
|
||||||
ns.print('===================================================');
|
log('Spoofing Balance...');
|
||||||
once = false;
|
const g = await ns.grow(target, {threads});
|
||||||
}
|
log(`Balance: +$${Math.round((g * balance - balance) * 100) / 100}`);
|
||||||
|
|
||||||
if(s > SECURITY) {
|
|
||||||
ns.print('Attacking Security...');
|
|
||||||
const w = await ns.weaken(TARGET);
|
|
||||||
ns.print(`Security: -${w} (${Math.round((s - w) * 100) / 100}/${SECURITY})`);
|
|
||||||
} else if(b < BALANCE) {
|
|
||||||
ns.print('Spoofing Balance...');
|
|
||||||
const g = await ns.grow(TARGET);
|
|
||||||
ns.print(`Balance: +${Math.round(g * 10) / 10}% ($${Math.round(b * g * 100) / 100})`);
|
|
||||||
} else {
|
} else {
|
||||||
ns.print('Hacking Account...');
|
log('Hacking Account...');
|
||||||
const h = await ns.hack(TARGET);
|
const h = await ns.hack(target, {threads});
|
||||||
ns.print(`Balance: -$${h} ($${Math.round((b - h) * 100) / 100})`);
|
log(`Balance: -$${h}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
ns.disableLog('ALL');
|
ns.disableLog('ALL');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download a file from the repo with some fancy styling & deplays.
|
||||||
|
* @param file {String} - file name
|
||||||
|
*/
|
||||||
async function download(file) {
|
async function download(file) {
|
||||||
await ns.wget(`${src}${file}`, `${dest}${file}`);
|
await ns.wget(`${src}${file}`, `${dest}${file}`);
|
||||||
const speed = ~~((Math.random() * 200) + 100) / 10;
|
const speed = ~~((Math.random() * 200) + 100) / 10;
|
||||||
|
Loading…
Reference in New Issue
Block a user