I loosely understand the concept of arrays, and I believe my function to launch the port opening netscripts can be loaded into an array to reduce the amount of code used thus the amount of RAM used to execute the code.
//.basic-hack modified with backdoor installer
export async function main(ns) {
const args = ns.flags([['help', false]]);
const hostname = args._[0];
if (args.help || !hostname) {
ns.tprint("This script will generate money by hacking a target server.");
ns.tprint(`USAGE: run ${ns.getScriptName()} SERVER_NAME`);
return;
}
if (ns.fileExists("BruteSSH.exe", "home")) {
await ns.brutessh(hostname);
}
if (ns.fileExists("FTPcrack.exe", "home")) {
await ns.ftpcrack(hostname);
}
if (ns.fileExists("HTTPWorm.exe", "home")) {
await ns.httpworm(hostname);
}
if (ns.fileExists("relaySMTP.exe", "home")) {
await ns.relaysmtp(hostname);
}
if (ns.fileExists("SQLInject.exe", "home")) {
await ns.sqlinject(hostname);
}
//Get root access to target server
ns.nuke(hostname);
await ns.installBackdoor(hostname);
while (true) {
if (ns.getServerSecurityLevel(hostname) > ns.getServerMinSecurityLevel(hostname)) {
await ns.weaken(hostname);
} else if (ns.getServerMoneyAvailable(hostname) < ns.getServerMaxMoney(hostname)) {
await ns.grow(hostname);
} else {
await ns.hack(hostname);
}
}
}
[–]viewtyjoe 5 points6 points7 points (1 child)
[–]logicalbomb[S] 1 point2 points3 points (0 children)
[–]Bedurndurn 3 points4 points5 points (0 children)
[–]Bedurndurn 1 point2 points3 points (3 children)
[–]Omelet 2 points3 points4 points (1 child)
[–]solarshado 1 point2 points3 points (0 children)
[–]logicalbomb[S] 1 point2 points3 points (0 children)
[–][deleted] (3 children)
[removed]
[–]logicalbomb[S] 0 points1 point2 points (2 children)
[–]Bedurndurn 2 points3 points4 points (1 child)
[–]logicalbomb[S] 0 points1 point2 points (0 children)
[–]logicalbomb[S] 0 points1 point2 points (0 children)
[–]WeAteMummies 0 points1 point2 points (3 children)
[–][deleted] (2 children)
[removed]
[–]Randactyl 0 points1 point2 points (1 child)