r/Bitburner • • Oct 25 '26

NetscriptJS Script First post (script share)

This is my home:/callback.js script. I have just maxed out sourcefile 1 and am working on BN4.2 so am finally getting a chance to go crazy with the ns.singularity API!

/**  {NS} ns */
export async function main(ns) {
ns.exec("abyssal_scan.js", "home");

/* returns master_hosts.txt, a list of all vanilla servers as: 
[hostname, maxRAM, requiredPorts, requiredHackingLevel, \n] 
and launches abyssal_sort.js, which iterates through master_hosts.txt, 
divvys up the entries by whether or not they have maxRAM > 0, 
sorts each list by requiredHackingLevel, and outputs each list respectively as
nonzeroRAM_hosts.txt and zeroRAM_hosts.txt. */

await ns.sleep(10000);

ns.exec("purchasePortbreakers.js", "home");

/* If not already present, purchases a TOR router. 
iterates through 
["bruteSSH.exe", "FTPCrack.exe", "RelaySMTP.exe", "HTTPWorm.exe", "SQLInject.exe"],
checks if they need to be purchased and whether I can afford them, and purchases them if
necessary/possible. Exits once SQLInject.exe is purchased. */

await ns.sleep(10000);

ns.exec("RAMShare_launcher.js", "home");

/* calculates half of my available RAM and dedicates it to ns.exec("RAMShare.js", "home",
n_threads). Every 10min, it checks to see if I have more/less RAM available than before,
assigns the new n_threads value in the event of a change, kills the currently running
process, and starts a fresh instance with the newly adjusted thread count. */

await ns.sleep(10000);

ns.exec("backdoor_targets.js", "home");

/* iterates through the list of servers I know of to be backdoored: 
["CSEC", "avmnite02h", "I.I.I.I", "run4theh111z", "fulcrumassets"], 
checks if they currently have a "pathFile" (`${target}_connect.txt`) and if not, 
runs a script called path.js which traces the physical path from /home to target,
outputting the path to `${target}_connect.txt`. exits when pathfiles for all listed
entries have been generated successfully. */

await ns.sleep(10000);

ns.exec("install_backdoors.js", "home");

/* iterates through the list of servers I know of to be backdoored: 
["CSEC", "avmnite-02h", "I.I.I.I", "run4theh111z", "fulcrumassets"], 
checks if they currently have a backdoor and if not, whether I can successfully pull off
installing one. uses the pathfiles generated earlier to traverse the network path, verify
connection to target host, install backdoors on the eligible entries that need it, 
return /home, sleep for 5min, and repeat until exit condition of: "fulcrumassets" has
been successfully backdoored. */

await ns.sleep(10000);

ns.exec("breakdown.js", "home");

/* iterates through "master_hosts.txt", checks for closed ports, runs the necessary
portbreakers if present, checks if openPorts >= requiredPorts, runs nuke.exe if so, and
++'s a var called nukedHosts. exits when nukedHosts === 69, since I haven't figured out a
way to arrive at the target figure programmatically. */

await ns.sleep(10000);

ns.exec("swarm.js", "home");

/* iterates through "nonzeroRAM_hosts.txt", checks for getserver().hasAdminAccess and
sufficient hacking skill, then checks to see if "local_attack.js" (my w/g/h script) is
present and/or running. If yes to both, ++'s a var called hackedHosts and moves on. If
not present, scp's it from home and executes it with the maximum number of threads
available on the target host. If present and not running, deletes the existing copy,
scp's the current copy from /home, and executes it with max threads available on target
host. exits when hackedHosts === 43,  since I haven't figured out a way to arrive at the
target figure programmatically. */
}

Currently in the works:

prestige_hacks.js <- to automate hacking the high value targets in "zeroRAM_hosts.txt" from /home,

life_of_crime.js <- to automate criminal activity,

symbol_nerd.js <- to automate stock trading,

auto_augment.js <- to automate faction work/augmentations,

working_stiff.js <- to automate vanilla job activity

0 Upvotes

9 comments sorted by

View all comments

Show parent comment

0

u/cofm-gaming Oct 25 '26

Thanks for the warm (dogshit) welcome. If it were not my code, why do you think I would bother to extensively describe the structure and function of the scripts detailed in the comments? Anyway, not engaging further with you, your tone, or your reply.

3

u/Spartelfant Noodle Enjoyer Oct 26 '26

Why so salty? Their criticism is valid.

The code you've posted is literally nothing more than 7 ns.exec() calls and 6 ns.sleep() statements.

Sure there's a bunch of comments (good habit!), but they are only a description of what those scripts are doing.

Without posting any of the code of the scripts being executed there's nothing to engage with other than those few lines of code.

-1

u/cofm-gaming Oct 26 '26

It's not valid; either they have no manners or they were deliberately being an ass. If you think it is valid, your standards are too low.

3

u/KlePu Oct 26 '26

¯_(ツ)_/¯