forked from Zharay/BitburnerBotnet
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathweaken.js
More file actions
67 lines (57 loc) · 1.58 KB
/
Copy pathweaken.js
File metadata and controls
67 lines (57 loc) · 1.58 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
59
60
61
62
63
64
65
66
67
/**Weaken() script.
* This will report via ports to the coordinator which has 0 RAM cost!
* Requires the hack-daemon!
* Written By: Zharay
* URL: https://github.com/Zharay/BitburnerBotnet
**/
/** @param {NS} ns */
export async function main(ns) {
var target = "";
var host = "";
var threads = 0;
var ram = 0;
var security = 0;
if (ns.args.length) {
target = ns.args[0];
ns.print("Target: " + target);
} else {
ns.print("ERROR: No target set!");
return;
}
if (ns.args.length > 1) {
host = ns.args[1];
ns.print("Host: " + host);
}
if (ns.args.length > 2) {
threads = ns.args[2];
ns.print("Threads: " + threads);
}
if (ns.args.length > 3) {
ram = ns.args[3];
ns.print("RAM: " + ram);
}
if (ns.args.length > 4) {
security = ns.args[4];
ns.print("Security Risk: " + security);
}
var task = {"target" : target, "host" : host, "task" : "weaken", "done" : false, "threads" : threads, "ram" : ram, "security" : security};
if (host != "EXP") {
ns.print("Reporting of incoming weakening...")
await ns.tryWritePort(13, JSON.stringify(task));
} else {
ns.print("Reporting EXP weakening...");
await ns.tryWritePort(14, JSON.stringify(task));
}
ns.print("Weakening defenses...");
var amount = await ns.weaken(target);
ns.print("Defenses decreased by: " + amount)
task.done = true;
//task.security = -1 * amount;
if (host != "EXP") {
ns.print("Reporting of weakening completion...")
await ns.tryWritePort(13, JSON.stringify(task));
} else {
ns.print("Reporting EXP weakening completion...");
await ns.tryWritePort(14, JSON.stringify(task));
}
}