-
Notifications
You must be signed in to change notification settings - Fork 0
/
hack.js
38 lines (31 loc) · 822 Bytes
/
hack.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
/** @param {NS} ns **/
export async function main(ns) {
var target = ns.args[0];
var moneyThresh = ns.getServerMaxMoney(target) * 0.9;
var securityThresh = ns.getServerMinSecurityLevel(target);
if (ns.fileExists("BruteSSH.exe", "home")) {
ns.brutessh(target);
}
if (ns.fileExists("FTPCrack.exe", "home")) {
ns.ftpcrack(target)
}
if (ns.fileExists("SQLInject.exe", "home")) {
ns.sqlinject(target)
}
if (ns.fileExists("HTTPWorm.exe", "home")) {
ns.httpworm(target)
}
if (ns.fileExists("relaySMTP.exe", "home")) {
ns.relaysmtp(target)
}
ns.nuke(target);
while (true) {
if (ns.getServerSecurityLevel(target) > securityThresh) {
await ns.weaken(target);
} else if (ns.getServerMoneyAvailable(target) < moneyThresh) {
await ns.grow(target);
} else {
await ns.hack(target);
}
}
}