Just getting started on this game and I wrote a script that I thought I would let others critique

the script helps me identify paths to servers for contract hunting (I have another script that finds cct files, but getting to them is a PITA. at the same time I I'm checcking for root, backdoor, and throwing a highlight on things I can backdoor based on current capabilities. I also have a script that is based on this that allows me to identify a specific server and its path so I can manually navigate the hit the contract or the backdoor or whatever.

Thoughts?

https://preview.redd.it/0pnyqv29t91g1.png?width=650&format=png&auto=webp&s=9a2a79e02d91d99dc1c53f38e25edbe083e6da24

/**  {NS} ns **/
export async function main(ns) {
    const visited = new Set();
    const myHack = ns.getHackingLevel();


    function serverInfo(server) {
        const s = ns.getServer(server);


        const reqLevel = s.requiredHackingSkill;
        const backdoor = s.backdoorInstalled;
        const rooted = s.hasAdminRights;


        let flag = "";


        // Eligibility for backdoor:
        if (server !== "home" &&
            rooted &&
            !backdoor &&
            myHack >= reqLevel) {
            flag = "👈💥⛩️💥";
        }


        return `(R:${rooted ? "✅" : "❌"}  B:${backdoor ? "✅" : "❌"})${flag}`;
    }


    function drawTree(server, prefix = "") {
        visited.add(server);
        const neighbors = ns.scan(server).filter(s => !visited.has(s));


        for (let i = 0; i < neighbors.length; i++) {
            const child = neighbors[i];
            const isLast = i === neighbors.length - 1;


            const branch = isLast ? "└─ " : "├─ ";
            ns.tprint(prefix + branch + `${child}  ${serverInfo(child)}`);


            const newPrefix = prefix + (isLast ? "   " : "│  ");
            drawTree(child, newPrefix);
        }
    }


    ns.tprint(`home  ${serverInfo("home")}`);
    drawTree("home");
}

Posted Nov 14, 2025, 7:05 PM UTC

83
Loading comments…