save backup

This commit is contained in:
2022-09-11 05:03:16 +02:00
parent 7b393a7ffc
commit 3529597fb0
10 changed files with 71 additions and 9 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
/** @param {import(".").NS } ns */ /** @param {import(".").NS } ns */
export async function main(ns) { export async function main(ns) {
// ns.disableLog('ALL'); ns.disableLog('ALL');
async function writeLog(type, obj) { async function writeLog(type, obj) {
let timestamp = ''; let timestamp = '';
+58
View File
@@ -0,0 +1,58 @@
/** @param {import(".").NS } ns */
export async function main(ns) {
// ns.disableLog('ALL');
/**
* Recursively kill simple-hack.js running on servers in the network
* @async
* @param {string} currentServer server to scan
*/
function scanServer(currentServer, targetServer, previousServer = currentServer) {
ns.tprint(currentServer);
if (currentServer == targetServer) {
return [currentServer];
} else {
let availableServers = ns.scan(currentServer);
for (let i = 0; i < availableServers.length; ++i) {
let nextServer = availableServers[i];
if (nextServer != currentServer && nextServer != previousServer) {
let result = scanServer(nextServer, targetServer, currentServer);
if (result != null) {
return [currentServer].concat(result);
}
}
}
return null;
}
}
let targetPath = scanServer('home', ns.args[0]);
ns.tprint(targetPath);
let backdoorCommand = '';
for (let index = 1; index < targetPath.length; index++) {
const server = targetPath[index];
backdoorCommand += `connect ${server}; `;
}
backdoorCommand += 'run BruteSSH.exe; ';
backdoorCommand += 'run FTPCrack.exe; ';
backdoorCommand += 'run relaySMTP.exe; ';
backdoorCommand += 'run HTTPWorm.exe; ';
backdoorCommand += 'run SQLInject.exe; ';
backdoorCommand += 'run NUKE.exe; ';
backdoorCommand += 'backdoor; home';
ns.tprint(backdoorCommand);
const terminalInput = document.getElementById("terminal-input");
terminalInput.value = backdoorCommand;
const handler = Object.keys(terminalInput)[1];
terminalInput[handler].onChange({ target: terminalInput });
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
}
+4 -4
View File
@@ -1,7 +1,7 @@
/** @param {import(".").NS } ns */ /** @param {import(".").NS } ns */
export async function main(ns) { export async function main(ns) {
// ns.disableLog('ALL'); ns.disableLog('ALL');
let excludeServers = ['home']; let excludeServers = ['home'];
for (let index = 0; index < 25; index++) { for (let index = 0; index < 25; index++) {
@@ -9,7 +9,7 @@ export async function main(ns) {
} }
excludeServers.push('CSEC'); excludeServers.push('CSEC');
excludeServers.push('avmnite-02h'); excludeServers.push('avmnite-02h');
async function scanServer(currentServer, maxDepth = Number.MAX_SAFE_INTEGER, depth = 1, previousServer = currentServer) { async function scanServer(currentServer, maxDepth = Number.MAX_SAFE_INTEGER, depth = 1, previousServer = currentServer) {
if (depth <= maxDepth) { if (depth <= maxDepth) {
let availableServers = ns.scan(currentServer); let availableServers = ns.scan(currentServer);
@@ -32,11 +32,11 @@ export async function main(ns) {
} }
await ns.sleep(10); await ns.sleep(10);
} }
let runDepth = ns.args.length ? ns.args[0] : 1;
while (true) { while (true) {
let runDepth = ns.args.length ? ns.args[0] : 1; ns.print(`Running scan depth: ${runDepth}`);
ns.tprint(`Running scan depth: ${runDepth}`);
await scanServer('home', runDepth); await scanServer('home', runDepth);
} }
} }
+2 -1
View File
@@ -9,6 +9,7 @@ export async function main(ns) {
let levelCap = 150; let levelCap = 150;
let ramCap = 64; let ramCap = 64;
let coreCap = 4; let coreCap = 4;
let nodeCap = 15;
ns.tprint(`Bot started {nodeCostThreshold: ${nodeCostThreshold}, upgradeCostThreshold: ${upgradeCostThreshold}, upgradeCount: ${upgradeCount}}`); ns.tprint(`Bot started {nodeCostThreshold: ${nodeCostThreshold}, upgradeCostThreshold: ${upgradeCostThreshold}, upgradeCount: ${upgradeCount}}`);
while (true) { while (true) {
@@ -16,7 +17,7 @@ export async function main(ns) {
let nodePurchaseCost = ns.hacknet.getPurchaseNodeCost(); let nodePurchaseCost = ns.hacknet.getPurchaseNodeCost();
let nodeCount = ns.hacknet.numNodes(); let nodeCount = ns.hacknet.numNodes();
if (nodePurchaseCost / Math.abs(currentMoney) < nodeCostThreshold) { if (nodeCount < nodeCap && nodePurchaseCost / Math.abs(currentMoney) < nodeCostThreshold) {
ns.hacknet.purchaseNode(); ns.hacknet.purchaseNode();
currentMoney = ns.getServerMoneyAvailable("home"); currentMoney = ns.getServerMoneyAvailable("home");
++nodeCount; ++nodeCount;
Vendored
+1 -1
View File
@@ -461,7 +461,7 @@
export interface Server { export interface Server {
/** /**
* How many CPU cores this server has. Maximum of 8. * How many CPU cores this server has. Maximum of 8.
* Affects magnitude of grow and weaken. * Affects magnitude of grow and weaken.p
*/ */
cpuCores: number; cpuCores: number;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,7 +1,7 @@
/** @param {import(".").NS } ns */ /** @param {import(".").NS } ns */
export async function main(ns) { export async function main(ns) {
// ns.disableLog('ALL'); ns.disableLog('ALL');
async function writeLog(obj) { async function writeLog(obj) {
await ns.tryWritePort(1, obj + '\n'); await ns.tryWritePort(1, obj + '\n');
+2 -1
View File
@@ -1,9 +1,10 @@
/** @param {import(".").NS } ns */ /** @param {import(".").NS } ns */
export async function main(ns) { export async function main(ns) {
// ns.disableLog('ALL'); ns.disableLog('ALL');
for (let server = 0; server <= ns.args[0]; server++) { for (let server = 0; server <= ns.args[0]; server++) {
ns.scp('grow-helper.js', `home-${server}`, 'home');
ns.exec('grow-helper.js', `home-${server}`, 5, 20); ns.exec('grow-helper.js', `home-${server}`, 5, 20);
} }
} }