grow helpers improvement
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
/** @param {import(".").NS } ns */
|
||||||
|
|
||||||
|
export async function main(ns) {
|
||||||
|
// ns.disableLog('ALL');
|
||||||
|
|
||||||
|
ns.alterReality();
|
||||||
|
ns.rainbow('noodles');
|
||||||
|
}
|
||||||
@@ -3,12 +3,24 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all servers
|
* remove write log ✓
|
||||||
* for servers ram > 0 get ram, get money
|
* loop
|
||||||
* home ram substract ram needed for bots
|
* get all servers
|
||||||
* get available threads for each server for hack/grow/weaken
|
* nuke if possible
|
||||||
* sum all money
|
* send scripts hack, grow weaken
|
||||||
* run with proportion to the money available
|
* backdoor factions
|
||||||
|
* buy grow servers
|
||||||
|
* start helpers if not running include home //remove from hacknet
|
||||||
|
* grow if needed
|
||||||
|
* weaken if needed
|
||||||
|
* hack if no grow or weaken
|
||||||
|
* do simple hack
|
||||||
|
* check if money available
|
||||||
|
* check threads
|
||||||
|
* run hack
|
||||||
|
* run grow to recover
|
||||||
|
* run weaken if security too high
|
||||||
|
* buy hack tools
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -23,22 +35,20 @@ export async function main(ns) {
|
|||||||
let hour = (timeNow.getHours() < 10 ? '0' : '') + timeNow.getHours();
|
let hour = (timeNow.getHours() < 10 ? '0' : '') + timeNow.getHours();
|
||||||
let minute = (timeNow.getMinutes() < 10 ? '0' : '') + timeNow.getMinutes();
|
let minute = (timeNow.getMinutes() < 10 ? '0' : '') + timeNow.getMinutes();
|
||||||
let second = (timeNow.getSeconds() < 10 ? '0' : '') + timeNow.getSeconds();
|
let second = (timeNow.getSeconds() < 10 ? '0' : '') + timeNow.getSeconds();
|
||||||
let timestamp = `${year}${month}${day}_${hour}${minute}${second}`;
|
let timestamp = `${year}.${month}.${day}_${hour}:${minute}:${second}`;
|
||||||
await ns.tryWritePort(2, `t${timestamp}_${type} = ${obj};\n`);
|
ns.print(`${type}_${timestamp} = ${obj};`);
|
||||||
|
|
||||||
if (['ERROR', 'TERMINAL'].indexOf(type) != -1) ns.tprint(`${timestamp} ${type} = ${obj}`);
|
if (['ERROR', 'TERMINAL'].indexOf(type) != -1) ns.tprint(`${type}_${timestamp} = ${obj};`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runHack(server) {
|
async function runNuke(server) {
|
||||||
let script = 'simple-hack.js';
|
|
||||||
|
|
||||||
let serverStatus = analyzeServer(server);
|
let serverStatus = analyzeServer(server);
|
||||||
await writeLog('ANALYZE', `{server: "${server}", status: ${JSON.stringify(serverStatus)}}`);
|
await writeLog('ANALYZE', `{server: "${server}", status: ${JSON.stringify(serverStatus)}}`);
|
||||||
|
|
||||||
if (!serverStatus.rootAccess) {
|
if (!serverStatus.rootAccess) {
|
||||||
if (serverStatus.nukeAvailable) {
|
if (serverStatus.nukeAvailable) {
|
||||||
await writeLog('NUKE', `"Nuking ${server}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"`);
|
await writeLog('NUKE', `"Nuking ${server}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"`);
|
||||||
for (let i = 0; i < maxPortsToHack(); ++i) {
|
for (let i = 0; i < maxPortsToHack(); ++i) { // TODO: change to try/catch
|
||||||
switch (EXPLOITS[i]) {
|
switch (EXPLOITS[i]) {
|
||||||
case 'BruteSSH.exe':
|
case 'BruteSSH.exe':
|
||||||
ns.brutessh(server);
|
ns.brutessh(server);
|
||||||
@@ -64,9 +74,13 @@ export async function main(ns) {
|
|||||||
}
|
}
|
||||||
ns.nuke(server);
|
ns.nuke(server);
|
||||||
}
|
}
|
||||||
|
// TODO: if faction > backdoor
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
async function runHack(server) {
|
||||||
|
let script = 'simple-hack.js';
|
||||||
|
|
||||||
serverStatus = analyzeServer(server);
|
let serverStatus = analyzeServer(server);
|
||||||
|
|
||||||
if (serverStatus.rootAccess) {
|
if (serverStatus.rootAccess) {
|
||||||
if (!ns.fileExists(script, 'home')) {
|
if (!ns.fileExists(script, 'home')) {
|
||||||
+52
-86
@@ -66,48 +66,49 @@ export async function main(ns) {
|
|||||||
* @param {string} server server to nuke and hack
|
* @param {string} server server to nuke and hack
|
||||||
* @returns {Promise<number>} exit code; if negative error, if positive hack script PID, if 0 already running
|
* @returns {Promise<number>} exit code; if negative error, if positive hack script PID, if 0 already running
|
||||||
*/
|
*/
|
||||||
|
async function runNuke(server) {
|
||||||
|
let serverStatus = analyzeServer(server);
|
||||||
|
ns.print('INFO ', `{server: "${server}", status: ${JSON.stringify(serverStatus)}}`);
|
||||||
|
|
||||||
|
if (!serverStatus.rootAccess && serverStatus.nukeAvailable) {
|
||||||
|
ns.print(`"Nuking ${server}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"`);
|
||||||
|
for (let i = 0; i < maxPortsToHack(); ++i) {
|
||||||
|
switch (EXPLOITS[i]) {
|
||||||
|
case 'BruteSSH.exe':
|
||||||
|
ns.brutessh(server);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'FTPCrack.exe':
|
||||||
|
ns.ftpcrack(server);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'relaySMTP.exe':
|
||||||
|
ns.relaysmtp(server);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'HTTPWorm.exe':
|
||||||
|
ns.httpworm(server);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'SQLInject.exe':
|
||||||
|
ns.sqlinject(server);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ns.nuke(server);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function runHack(server) {
|
async function runHack(server) {
|
||||||
let script = 'simple-hack.js';
|
let script = 'simple-hack.js';
|
||||||
|
|
||||||
let serverStatus = analyzeServer(server);
|
let serverStatus = analyzeServer(server);
|
||||||
await writeLog('ANALYZE', `{server: "${server}", status: ${JSON.stringify(serverStatus)}}`);
|
ns.print('INFO ', `{server: "${server}", status: ${JSON.stringify(serverStatus)}}`);
|
||||||
|
|
||||||
if (!serverStatus.rootAccess) {
|
if (serverStatus.rootAccess && serverStatus.nukeAvailable) {
|
||||||
if (serverStatus.nukeAvailable) {
|
|
||||||
await writeLog('NUKE', `"Nuking ${server}!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"`);
|
|
||||||
for (let i = 0; i < maxPortsToHack(); ++i) {
|
|
||||||
switch (EXPLOITS[i]) {
|
|
||||||
case 'BruteSSH.exe':
|
|
||||||
ns.brutessh(server);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'FTPCrack.exe':
|
|
||||||
ns.ftpcrack(server);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'relaySMTP.exe':
|
|
||||||
ns.relaysmtp(server);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'HTTPWorm.exe':
|
|
||||||
ns.httpworm(server);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'SQLInject.exe':
|
|
||||||
ns.sqlinject(server);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ns.nuke(server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
serverStatus = analyzeServer(server);
|
|
||||||
|
|
||||||
if (serverStatus.rootAccess) {
|
|
||||||
if (!ns.fileExists(script, 'home')) {
|
if (!ns.fileExists(script, 'home')) {
|
||||||
await writeLog('ERROR', `"Script '${script}' doesn't exist!"`);
|
ns.print(`ERROR Script '${script}' doesn't exist!`);
|
||||||
// return -3;
|
// return -3;
|
||||||
}
|
}
|
||||||
ns.scp(script, server, 'home');
|
ns.scp(script, server, 'home');
|
||||||
@@ -143,42 +144,6 @@ export async function main(ns) {
|
|||||||
return -6;
|
return -6;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let nukedServers = ['home', 'CSEC', 'avmnite-02h'];
|
|
||||||
// /**
|
|
||||||
// * Recursively scan, try to nuke and hack servers in the network
|
|
||||||
// * @async
|
|
||||||
// * @param {string} server server to scan
|
|
||||||
// */
|
|
||||||
// async function scanServer(server, maxDepth = Number.MAX_SAFE_INTEGER, depth = 1) {
|
|
||||||
// if (depth <= maxDepth) {
|
|
||||||
// let availableServers = ns.scan(server);
|
|
||||||
|
|
||||||
// // hack servers in current scan
|
|
||||||
// for (let i = 0; i < availableServers.length; ++i) {
|
|
||||||
// await writeLog('SCAN', `{server: "${availableServers[i]}", index: ${nukedServers.indexOf(availableServers[i])}, available: ["${availableServers.toString().replaceAll(',','","')}"]}`);
|
|
||||||
// if (nukedServers.indexOf(availableServers[i]) == -1) {
|
|
||||||
// nukedServers.push(availableServers[i]);
|
|
||||||
// await scanServer(availableServers[i], maxDepth, depth + 1);
|
|
||||||
// let hackExitCode = await runHack(availableServers[i]);
|
|
||||||
|
|
||||||
// if (hackExitCode == 0) {
|
|
||||||
// await writeLog('HACK', `"Hack already running on ${availableServers[i]}"`);
|
|
||||||
// } if (hackExitCode == -6) {
|
|
||||||
// await writeLog('HACK', `"No root access to ${availableServers[i]}!"`);
|
|
||||||
// } else {
|
|
||||||
// if (hackExitCode < 0) {
|
|
||||||
// await writeLog('ERROR', `"Hack exec ERROR on '${availableServers[i]}': ${hackExitCode}!"`);
|
|
||||||
// } else {
|
|
||||||
// await writeLog('HACK', `"Hack started on '${availableServers[i]}'"`);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// await ns.sleep(10);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively kill simple-hack.js running on servers in the network
|
* Recursively kill simple-hack.js running on servers in the network
|
||||||
* @async
|
* @async
|
||||||
@@ -191,22 +156,23 @@ export async function main(ns) {
|
|||||||
let nextServer = availableServers[i];
|
let nextServer = availableServers[i];
|
||||||
|
|
||||||
if (nextServer != currentServer && nextServer != previousServer) {
|
if (nextServer != currentServer && nextServer != previousServer) {
|
||||||
|
await runNuke(nextServer);
|
||||||
if (EXCLUDE_SERVERS.indexOf(nextServer) == -1) {
|
if (EXCLUDE_SERVERS.indexOf(nextServer) == -1) {
|
||||||
let hackExitCode = await runHack(nextServer);
|
let hackExitCode = await runHack(nextServer);
|
||||||
|
|
||||||
if (hackExitCode == 0) {
|
// if (hackExitCode == 0) {
|
||||||
await writeLog('HACK', `"Hack already running on ${nextServer}"`);
|
// ns.print('INFO ' + `"Hack already running on ${nextServer}"`);
|
||||||
} else if (hackExitCode == -6) {
|
// } else if (hackExitCode == -6) {
|
||||||
await writeLog('HACK', `"No root access to ${nextServer}!"`);
|
// ns.print('ERROR ' + `"No root access to ${nextServer}!"`);
|
||||||
} else if (hackExitCode == -4) {
|
// } else if (hackExitCode == -4) {
|
||||||
await writeLog('HACK', `"Not enough RAM to run script on ${nextServer}!"`);
|
// ns.print('WARN ' + `"Not enough RAM to run script on ${nextServer}!"`);
|
||||||
} else {
|
// } else {
|
||||||
if (hackExitCode < 0) {
|
// if (hackExitCode < 0) {
|
||||||
await writeLog('ERROR', `"Hack exec ERROR on '${nextServer}': ${hackExitCode}!"`);
|
// ns.print('ERROR ' + `"Hack exec ERROR on '${nextServer}': ${hackExitCode}!"`);
|
||||||
} else {
|
// } else {
|
||||||
await writeLog('HACK', `"Hack started on '${nextServer}'"`);
|
// ns.print('INFO ' + `"Hack started on '${nextServer}'"`);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
await scanServer(nextServer, currentServer);
|
await scanServer(nextServer, currentServer);
|
||||||
}
|
}
|
||||||
@@ -219,7 +185,7 @@ export async function main(ns) {
|
|||||||
ns.tprint(`TERMINAL = "Running scan"`);
|
ns.tprint(`TERMINAL = "Running scan"`);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
await writeLog('INFO', `"Running scan"`);
|
ns.print(`INFO Running scan`);
|
||||||
await scanServer('home');
|
await scanServer('home');
|
||||||
await ns.sleep(60000);
|
await ns.sleep(60000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/** @param {import(".").NS } ns */
|
||||||
|
const doc = eval('document');
|
||||||
|
|
||||||
|
export async function main(ns) {
|
||||||
|
// ns.disableLog('ALL');
|
||||||
|
|
||||||
|
const terminalInput = doc.getElementById("terminal-input");
|
||||||
|
const handler = Object.keys(terminalInput)[1];
|
||||||
|
|
||||||
|
async function scanServer(currentServer, previousServer = currentServer, connectString = '', scanLevel = 0) {
|
||||||
|
let availableServers = ns.scan(currentServer);
|
||||||
|
let nextConnectString = connectString + `connect ${currentServer}; `;
|
||||||
|
|
||||||
|
let backdoorCommand = nextConnectString;
|
||||||
|
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';
|
||||||
|
|
||||||
|
terminalInput.value = backdoorCommand;
|
||||||
|
terminalInput[handler].onChange({ target: terminalInput });
|
||||||
|
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
||||||
|
await ns.sleep(60000)
|
||||||
|
|
||||||
|
for (let i = 0; i < availableServers.length; ++i) {
|
||||||
|
let nextServer = availableServers[i];
|
||||||
|
|
||||||
|
if (nextServer != currentServer && nextServer != previousServer) {
|
||||||
|
await scanServer(nextServer, currentServer, nextConnectString, scanLevel + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await scanServer('home');
|
||||||
|
terminalInput.value = 'home';
|
||||||
|
terminalInput[handler].onChange({ target: terminalInput });
|
||||||
|
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
||||||
|
}
|
||||||
+5
-4
@@ -1,4 +1,5 @@
|
|||||||
/** @param {import(".").NS } ns */
|
/** @param {import(".").NS } ns */
|
||||||
|
const doc = eval('document');
|
||||||
|
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
// ns.disableLog('ALL');
|
// ns.disableLog('ALL');
|
||||||
@@ -9,7 +10,7 @@ export async function main(ns) {
|
|||||||
* @param {string} currentServer server to scan
|
* @param {string} currentServer server to scan
|
||||||
*/
|
*/
|
||||||
function scanServer(currentServer, targetServer, previousServer = currentServer) {
|
function scanServer(currentServer, targetServer, previousServer = currentServer) {
|
||||||
ns.tprint(currentServer);
|
// ns.tprint(currentServer);
|
||||||
if (currentServer == targetServer) {
|
if (currentServer == targetServer) {
|
||||||
return [currentServer];
|
return [currentServer];
|
||||||
} else {
|
} else {
|
||||||
@@ -34,7 +35,7 @@ export async function main(ns) {
|
|||||||
let targetPath = scanServer('home', ns.args[0]);
|
let targetPath = scanServer('home', ns.args[0]);
|
||||||
ns.tprint(targetPath);
|
ns.tprint(targetPath);
|
||||||
|
|
||||||
const terminalInput = document.getElementById("terminal-input");
|
const terminalInput = doc.getElementById("terminal-input");
|
||||||
const handler = Object.keys(terminalInput)[1];
|
const handler = Object.keys(terminalInput)[1];
|
||||||
let backdoorCommand = '';
|
let backdoorCommand = '';
|
||||||
|
|
||||||
@@ -44,7 +45,7 @@ export async function main(ns) {
|
|||||||
backdoorCommand += `connect ${server}; `;
|
backdoorCommand += `connect ${server}; `;
|
||||||
}
|
}
|
||||||
|
|
||||||
ns.tprint(backdoorCommand);
|
// ns.tprint(backdoorCommand);
|
||||||
terminalInput.value = backdoorCommand;
|
terminalInput.value = backdoorCommand;
|
||||||
terminalInput[handler].onChange({ target: terminalInput });
|
terminalInput[handler].onChange({ target: terminalInput });
|
||||||
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
||||||
@@ -57,7 +58,7 @@ export async function main(ns) {
|
|||||||
backdoorCommand += 'run NUKE.exe; ';
|
backdoorCommand += 'run NUKE.exe; ';
|
||||||
backdoorCommand += 'backdoor';
|
backdoorCommand += 'backdoor';
|
||||||
|
|
||||||
ns.tprint(backdoorCommand);
|
// ns.tprint(backdoorCommand);
|
||||||
terminalInput.value = backdoorCommand;
|
terminalInput.value = backdoorCommand;
|
||||||
terminalInput[handler].onChange({ target: terminalInput });
|
terminalInput[handler].onChange({ target: terminalInput });
|
||||||
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
||||||
|
|||||||
@@ -1,7 +1,65 @@
|
|||||||
/** @param {import(".").NS } ns */
|
/** @param {import(".").NS } ns */
|
||||||
|
const doc = eval('document');
|
||||||
|
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
// ns.disableLog('ALL');
|
// 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);
|
||||||
|
|
||||||
|
const terminalInput = doc.getElementById("terminal-input");
|
||||||
|
const handler = Object.keys(terminalInput)[1];
|
||||||
|
let backdoorCommand = '';
|
||||||
|
|
||||||
|
for (let index = 1; index < targetPath.length; index++) {
|
||||||
|
const server = targetPath[index];
|
||||||
|
|
||||||
|
backdoorCommand += `connect ${server}; `;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ns.tprint(backdoorCommand);
|
||||||
|
terminalInput.value = backdoorCommand;
|
||||||
|
terminalInput[handler].onChange({ target: terminalInput });
|
||||||
|
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
||||||
|
|
||||||
|
// 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';
|
||||||
|
|
||||||
|
// ns.tprint(backdoorCommand);
|
||||||
|
// terminalInput.value = backdoorCommand;
|
||||||
|
// terminalInput[handler].onChange({ target: terminalInput });
|
||||||
|
// terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
||||||
}
|
}
|
||||||
+37
-4
@@ -3,6 +3,14 @@
|
|||||||
|
|
||||||
export const EXCLUDE_SERVERS = [
|
export const EXCLUDE_SERVERS = [
|
||||||
'home',
|
'home',
|
||||||
|
'darkweb',
|
||||||
|
'CSEC',
|
||||||
|
'avmnite-02h',
|
||||||
|
'I.I.I.I',
|
||||||
|
'run4theh111z'
|
||||||
|
];
|
||||||
|
|
||||||
|
export const FACTION_SERVERS = [
|
||||||
'CSEC',
|
'CSEC',
|
||||||
'avmnite-02h',
|
'avmnite-02h',
|
||||||
'I.I.I.I',
|
'I.I.I.I',
|
||||||
@@ -30,11 +38,36 @@ const DARKWEB_PROGRAMS = [
|
|||||||
|
|
||||||
const COMPLETED_FACTIONS = [
|
const COMPLETED_FACTIONS = [
|
||||||
'CyberSec',
|
'CyberSec',
|
||||||
|
'Tian Di Hui',
|
||||||
'Netburners',
|
'Netburners',
|
||||||
|
//'Shadows of Anarchy',
|
||||||
|
//'Sector-12',
|
||||||
|
'Chongquing',
|
||||||
|
'New Tokyo',
|
||||||
|
'Ishima',
|
||||||
|
'Aevum',
|
||||||
|
'Volhaven',
|
||||||
'NiteSec',
|
'NiteSec',
|
||||||
'The Black Hand',
|
'The Black Hand',
|
||||||
'Aevum',
|
//'BitRunners',
|
||||||
'Sector-12',
|
//'ECorp',
|
||||||
'Volhaven',
|
//'MegaCorp',
|
||||||
'Tian Di Hui'
|
//'KuaiGong International',
|
||||||
|
//'Four Sigma',
|
||||||
|
//'NWO',
|
||||||
|
//'Blade Industries',
|
||||||
|
//'OmniTek Incorporated',
|
||||||
|
//'Bachman & Associates',
|
||||||
|
//'Clarke Incorporated',
|
||||||
|
//'Fulcrum Secret Technologies',
|
||||||
|
//'Slum Snakes',
|
||||||
|
//'Tetrads',
|
||||||
|
//'Silhouette',
|
||||||
|
//'Speakers for the Dead',
|
||||||
|
//'The Dark Army',
|
||||||
|
//'The Syndicate',
|
||||||
|
//'The Covenant',
|
||||||
|
//'Daedalus',
|
||||||
|
//'Illuminati',
|
||||||
|
//'',
|
||||||
];
|
];
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/** @param {import(".").NS } ns */
|
||||||
|
const doc = eval('document');
|
||||||
|
|
||||||
|
export async function main(ns) {
|
||||||
|
// ns.disableLog('ALL');
|
||||||
|
|
||||||
|
const terminalInput = doc.getElementById("terminal-input");
|
||||||
|
const handler = Object.keys(terminalInput)[1];
|
||||||
|
|
||||||
|
terminalInput.value = "COMMAND";
|
||||||
|
terminalInput[handler].onChange({ target: terminalInput });
|
||||||
|
terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
||||||
|
}
|
||||||
+4
-8
@@ -11,13 +11,9 @@ export async function main(ns) {
|
|||||||
let nextServer = availableServers[i];
|
let nextServer = availableServers[i];
|
||||||
|
|
||||||
if (nextServer != currentServer && nextServer != previousServer) {
|
if (nextServer != currentServer && nextServer != previousServer) {
|
||||||
if (ns.scriptRunning('simple-hack.js', nextServer)) {
|
let currentMoney = ns.getServerMoneyAvailable(nextServer);
|
||||||
let maxMoney = ns.getServerMaxMoney(nextServer);
|
if (ns.hasRootAccess(nextServer) && currentMoney > 0) {
|
||||||
let currentMoney = ns.getServerMoneyAvailable(nextServer);
|
await ns.grow(nextServer);
|
||||||
|
|
||||||
if (currentMoney < 0.2 * maxMoney) {
|
|
||||||
await ns.grow(nextServer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await scanServer(nextServer, currentServer);
|
await scanServer(nextServer, currentServer);
|
||||||
}
|
}
|
||||||
@@ -27,6 +23,6 @@ export async function main(ns) {
|
|||||||
while (true) {
|
while (true) {
|
||||||
ns.print(`Running scan`);
|
ns.print(`Running scan`);
|
||||||
await scanServer('home');
|
await scanServer('home');
|
||||||
ns.sleep(50);
|
await ns.sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,5 +3,5 @@
|
|||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
// ns.disableLog('ALL');
|
// ns.disableLog('ALL');
|
||||||
|
|
||||||
|
await ns.grow(ns.args.length > 0 ? ns.args[0] : '');
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
// ns.disableLog('ALL');
|
// ns.disableLog('ALL');
|
||||||
|
|
||||||
|
await ns.hack(ns.args.length > 0 ? ns.args[0] : '');
|
||||||
}
|
}
|
||||||
+7
-7
@@ -7,7 +7,7 @@ export async function main(ns) {
|
|||||||
const upgradeCostThreshold = ns.args.length > 1 ? ns.args[1] : 0.1;
|
const upgradeCostThreshold = ns.args.length > 1 ? ns.args[1] : 0.1;
|
||||||
const upgradeCount = ns.args.length > 2 ? ns.args[2] : 1;
|
const upgradeCount = ns.args.length > 2 ? ns.args[2] : 1;
|
||||||
const helperBuyThreshold = ns.args.length > 3 ? ns.args[3] : 0.2;
|
const helperBuyThreshold = ns.args.length > 3 ? ns.args[3] : 0.2;
|
||||||
const nodeCap = 200;
|
const nodeCap = 24;
|
||||||
const levelCap = 200;
|
const levelCap = 200;
|
||||||
const ramCap = 64;
|
const ramCap = 64;
|
||||||
const coreCap = 16;
|
const coreCap = 16;
|
||||||
@@ -63,13 +63,13 @@ export async function main(ns) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
let logFiles = ['hack-log.js', 'nuke-log.js'];
|
// let logFiles = ['hack-log.js', 'nuke-log.js'];
|
||||||
|
|
||||||
for (let index = 0; index < logFiles.length; index++) {
|
// for (let index = 0; index < logFiles.length; index++) {
|
||||||
const logFile = logFiles[index];
|
// const logFile = logFiles[index];
|
||||||
let portData = ns.readPort(index + 1);
|
// let portData = ns.readPort(index + 1);
|
||||||
if (portData != 'NULL PORT DATA') ns.write(logFile, portData, 'a');
|
// if (portData != 'NULL PORT DATA') ns.write(logFile, portData, 'a');
|
||||||
}
|
// }
|
||||||
|
|
||||||
await ns.sleep(1000);
|
await ns.sleep(1000);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
ns.disableLog('ALL');
|
ns.disableLog('ALL');
|
||||||
|
|
||||||
|
ns.scriptKill('grow-helper.js', `home`);
|
||||||
|
|
||||||
for (let server = 0; ns.serverExists(`home-${server}`); server++) {
|
for (let server = 0; ns.serverExists(`home-${server}`); server++) {
|
||||||
ns.scriptKill('grow-helper.js', `home-${server}`);
|
ns.scriptKill('grow-helper.js', `home-${server}`);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-3
@@ -26,8 +26,6 @@ export async function main(ns) {
|
|||||||
while (maxMoney != 0) {
|
while (maxMoney != 0) {
|
||||||
let currentMoney = ns.getServerMoneyAvailable(server);
|
let currentMoney = ns.getServerMoneyAvailable(server);
|
||||||
let currentSecurity = ns.getServerSecurityLevel(server);
|
let currentSecurity = ns.getServerSecurityLevel(server);
|
||||||
ns.print(`Money: ${currentMoney} / ${maxMoney}`);
|
|
||||||
ns.print(`Security: ${currentSecurity} / ${minSecurity}`);
|
|
||||||
|
|
||||||
let hackedMoney = 0;
|
let hackedMoney = 0;
|
||||||
if (currentMoney > 0.1 * maxMoney) {
|
if (currentMoney > 0.1 * maxMoney) {
|
||||||
@@ -48,7 +46,7 @@ export async function main(ns) {
|
|||||||
currentSecurity = ns.getServerSecurityLevel(server);
|
currentSecurity = ns.getServerSecurityLevel(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
await writeLog('LOG', `{server: '${server}', loop: ${++loop}, hack: ${Math.floor(hackedMoney)}, money: ${Math.floor(currentMoney)} / ${Math.floor(maxMoney)} == ${((currentMoney / maxMoney) * 100).toFixed(2)}, security: ${currentSecurity.toFixed(2)} / ${Math.floor(minSecurity)} == ${((currentSecurity / minSecurity) * 100).toFixed(4)}}`);
|
ns.print(`{loop: ${++loop}, hack: ${Math.floor(hackedMoney)}, money: ${Math.floor(currentMoney)} / ${Math.floor(maxMoney)} == ${((currentMoney / maxMoney) * 100).toFixed(2)}, security: ${currentSecurity.toFixed(2)} / ${Math.floor(minSecurity)} == ${((currentSecurity / minSecurity) * 100).toFixed(4)}}`);
|
||||||
await ns.sleep(50);
|
await ns.sleep(50);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+16
-2
@@ -2,9 +2,23 @@
|
|||||||
|
|
||||||
export async function main(ns) {
|
export async function main(ns) {
|
||||||
ns.disableLog('ALL');
|
ns.disableLog('ALL');
|
||||||
|
let script = 'grow-helper.js';
|
||||||
|
|
||||||
|
|
||||||
|
let serverMaxRam = ns.getServerMaxRam(`home`);
|
||||||
|
let serverUsedRam = ns.getServerUsedRam(`home`);
|
||||||
|
let serverFreeRam = serverMaxRam - serverUsedRam;
|
||||||
|
let scriptRam = ns.getScriptRam(script, `home`);
|
||||||
|
let maxThreads = Math.floor(serverFreeRam / scriptRam);
|
||||||
|
if (maxThreads > 0) ns.exec(script, `home`, maxThreads);
|
||||||
|
|
||||||
for (let server = 0; ns.serverExists(`home-${server}`); server++) {
|
for (let server = 0; ns.serverExists(`home-${server}`); server++) {
|
||||||
ns.scp('grow-helper.js', `home-${server}`, 'home');
|
let serverMaxRam = ns.getServerMaxRam(`home-${server}`);
|
||||||
ns.exec('grow-helper.js', `home-${server}`, 10);
|
let serverUsedRam = ns.getServerUsedRam(`home-${server}`);
|
||||||
|
let serverFreeRam = serverMaxRam - serverUsedRam;
|
||||||
|
let scriptRam = ns.getScriptRam(script, `home-${server}`);
|
||||||
|
let maxThreads = Math.floor(serverFreeRam / scriptRam);
|
||||||
|
ns.scp(script, `home-${server}`, 'home');
|
||||||
|
ns.exec(script, `home-${server}`, maxThreads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/** @param {import(".").NS } ns */
|
||||||
|
const doc = eval('document');
|
||||||
|
|
||||||
|
export async function main(ns) {
|
||||||
|
// ns.disableLog('ALL');
|
||||||
|
|
||||||
|
// const terminalInput = doc.getElementById("terminal-input");
|
||||||
|
// const handler = Object.keys(terminalInput)[1];
|
||||||
|
|
||||||
|
// terminalInput.value = "COMMAND";
|
||||||
|
// terminalInput[handler].onChange({ target: terminalInput });
|
||||||
|
// terminalInput[handler].onKeyDown({ key: 'Enter', preventDefault: () => null });
|
||||||
|
|
||||||
|
// const terminalButton = doc.querySelector();
|
||||||
|
let terminal;
|
||||||
|
let city;
|
||||||
|
let travel;
|
||||||
|
for (const elem of doc.querySelectorAll('div.MuiDrawer-root.MuiDrawer-docked p')) {
|
||||||
|
if (elem.textContent == 'Terminal') {
|
||||||
|
terminal = elem;
|
||||||
|
}
|
||||||
|
if (elem.textContent == 'City') {
|
||||||
|
city = elem;
|
||||||
|
}
|
||||||
|
if (elem.textContent == 'Travel') {
|
||||||
|
travel = elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
travel.click(); await ns.sleep(100);
|
||||||
|
|
||||||
|
for (const aevum of doc.querySelectorAll('div#root span')) {
|
||||||
|
if (aevum.textContent == 'A') {
|
||||||
|
aevum.click(); await ns.sleep(100);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const travelConfirm of doc.querySelectorAll('div[role="presentation"] p')) {
|
||||||
|
if (travelConfirm.textContent == 'Travel') {
|
||||||
|
travelConfirm.click(); await ns.sleep(100);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeButton = doc.querySelector('div[role="presentation"] button');
|
||||||
|
if(!closeButton == undefined) closeButton.click();
|
||||||
|
|
||||||
|
city.click(); await ns.sleep(100);
|
||||||
|
|
||||||
|
for (const uni of doc.querySelectorAll('div#root span')) {
|
||||||
|
if (uni.textContent == 'U') {
|
||||||
|
uni.click(); await ns.sleep(100);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const course of doc.querySelectorAll('div#root button')) {
|
||||||
|
if (course.textContent == 'Take Algorithms course ($-1.280k / sec)') {
|
||||||
|
course.click(); await ns.sleep(100);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const closeCourse of doc.querySelectorAll('div#root button')) {
|
||||||
|
if (closeCourse.textContent == 'Do something else simultaneously') {
|
||||||
|
closeCourse.click(); await ns.sleep(100);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await ns.sleep(1000);
|
||||||
|
console.log(terminal)
|
||||||
|
terminal.click(); await ns.sleep(100);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user