-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanNhack.js
More file actions
58 lines (55 loc) · 1.72 KB
/
Copy pathscanNhack.js
File metadata and controls
58 lines (55 loc) · 1.72 KB
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
49
50
51
52
53
54
55
56
57
58
/** @param {NS} ns **/
;
function getRootAccess(host, ns) {
try {
ns.brutessh(host)
} catch {
ns.print('execution of BruteSSH on ' + host + ' failed');
}
try {
ns.ftpcrack(host)
} catch {
ns.print('execution of FTPCrack on ' + host + ' failed');
}
try {
ns.nuke(host);
} catch {
ns.print('execution of NUKE on ' + host + ' failed');
}
}
async function ScanForServers(ns) {
const serverList = ns.scan();
for (let x = 0; x < serverList.length; x++) {
if (serverList.length <= 1) {
ns.exit();
ns.killall(serverList[x]);
}
if (serverList[x] === "home" || serverList[x] === "Volhaven-node" || serverList[x] === "darkweb" || serverList[x] === "n00dles" || serverList[x] === "CSEC" || serverList[x] === ns.args[0]) {
continue;
}
if (!ns.hasRootAccess(serverList[x])) {
getRootAccess(serverList[x], ns);
} else {
ns.killall(serverList[x]);
await ns.run('CopyScriptsToServers.js', 1, serverList[x]);
await ns.sleep(1000);
ns.exec('scanNhack.js', serverList[x], 1, ns.getHostname());
await ns.sleep(1000);
ns.exec('weaken.js', serverList[x], 1, serverList[x]);
ns.exec('hack.js', serverList[x], 1, serverList[x]);
ns.exec('grow.js', serverList[x], 3, serverList[x]);
}
await ns.sleep(100);
// Pew Pew
}
}
export async function main(ns) {
ns.disableLog("exec");
ns.disableLog("sleep");
ns.disableLog("run");
ns.disableLog("brutessh");
ns.disableLog("nuke");
ns.disableLog("killall");
ns.clearLog();
await ScanForServers(ns);
}