-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHackAllServers.js
40 lines (38 loc) · 1.32 KB
/
HackAllServers.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
/**
* @author DerDeathraven
* @param {NS} ns
* {@link https://github.com/DerDeathraven}
*
* Hack all available servers and update the Hack.js on all servers
*
* **/
import * as LB from "./LuckysLib.js"
export async function main(ns) {
var arr = LB.getAllServers(ns)
arr.splice(arr.indexOf("home"),1)
arr.splice(arr.indexOf("darkweb"),1)
var hackinglvlArr = []
await LB.asyncForEach(arr,async (f,i)=>{
await ns.scp("Hack.js",f)
if(ns.getServerRequiredHackingLevel(f)<=ns.getHackingLevel()){
if(ns.hasRootAccess(f)){
if(ns.isRunning("Hack.js",f))ns.scriptKill("Hack.js",f)
await ns.scp("Hack.js",f)
}else{
ns.tprint("Trying to BruteForce: "+f)
try{
if(ns.fileExists("brutessh.exe","home"))await ns.brutessh(f)
if(ns.fileExists("ftpcrack.exe","home"))await ns.ftpcrack(f)
if(ns.fileExists("httpworm.exe","home"))await ns.httpworm(f)
if(ns.fileExists("relaysmtp.exe","home"))await ns.relaysmtp(f)
ns.nuke(f)
}catch{
ns.tprint("Failed to Hack: "+f)
}
}
}else{
hackinglvlArr.push(ns.getServerRequiredHackingLevel(f))
}
})
ns.tprint("Next Hacking lvl has to be: "+ hackinglvlArr[0])
}