-
Notifications
You must be signed in to change notification settings - Fork 0
/
backdoor.js
48 lines (38 loc) · 1.27 KB
/
backdoor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Intention:
* - connect to a server
* - backdoor it
* - connect back to home
*
* Requires singularity functions
*/
/** @param {NS} ns */
export async function main(ns) {
var serverToConnectTo = ns.args[0]; // server we are looking for
var childList; // list of servers, the current server is connected to
var parentServer; // first item of childList is the parent server
var pathList = []; // list of servers, that lead the path to the target
pathList[0] = serverToConnectTo;
//scan from target server
childList = ns.scan(serverToConnectTo);
parentServer = childList[0];
pathList.unshift(parentServer);
//if parent is not already "home", iterate until home is found
while (parentServer != "home") {
childList = ns.scan(parentServer);
parentServer = childList[0];
pathList.unshift(parentServer);
}
//use singularity functions to connect to the server
for (let i = 0; i < pathList.length; i++) {
ns.singularity.connect(pathList[i]);
}
//backdoor the server
await ns.singularity.installBackdoor();
//connect back to home
ns.singularity.connect("home");
}
// enable autocomplete of server names, also found in steamcommunity-link
export function autocomplete(data, args) {
return [...data.servers]; // This script autocompletes the list of servers.
}