-
Notifications
You must be signed in to change notification settings - Fork 0
/
worldcracker.js
72 lines (67 loc) · 2.01 KB
/
worldcracker.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/** @param {NS} ns */
/**
* Intention
* - Try to nuke all servers; to be run after a new file was purchased or developed
*/
export async function main(ns) {
var target = [];
var waitTime = 1; //50;
//check, if argument was provided
//if so, crack that server
//if not, try to find a list of servers and use that.
if (ns.args.length == 0) {
if (ns.fileExists("ServersOfTheWorld.txt", "home")) {
ns.tprint("INFO: No argument provided, but file with servers found. Using this instead.");
target = ns.read("ServersOfTheWorld.txt").split(",");
//ns.tprint(target);
//ns.exit();
} else {
ns.tprint("ERROR: no argument provided and no list found. Exiting script.");
ns.exit();
}
} else {
target.push(ns.args[0]); //due to whatever reason, this scripts interprets the input string as individual characters
}
//ns.tprint(target);
ns.tprint(target.length);
//recurse over list
for (let i = 0; i < target.length; i++) {
var openPorts = 0;
//ns.tprint(target[i]);
//check if files exist, use them if so
if (ns.fileExists("BruteSSH.exe", "home")) {
ns.brutessh(target[i]);
openPorts++;
await ns.sleep(waitTime);
}
if (ns.fileExists("FTPCrack.exe", "home")) {
ns.ftpcrack(target[i]);
openPorts++;
await ns.sleep(waitTime);
}
if (ns.fileExists("relaySMTP.exe", "home")) {
ns.relaysmtp(target[i]);
openPorts++;
await ns.sleep(waitTime);
}
if (ns.fileExists("HTTPWorm.exe", "home")) {
ns.httpworm(target[i]);
openPorts++;
await ns.sleep(waitTime);
}
if (ns.fileExists("SQLInject.exe", "home")) {
ns.sqlinject(target[i]);
openPorts++;
await ns.sleep(waitTime);
}
//try to nuke the target
if (ns.getServerNumPortsRequired(target[i]) <= openPorts) {
ns.nuke(target[i]);
} else {
if (target.length == 1) {
ns.tprint('ERROR: Server could not be nuked yet. Requires ${ns.getServerNumPortsRequired(target[i])} open ports.')
}
}
}
ns.tprint("Script done running.");
}