-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhack.js
More file actions
66 lines (56 loc) · 1.47 KB
/
hack.js
File metadata and controls
66 lines (56 loc) · 1.47 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
/**Hack() 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" : "hack", "done" : false, "threads" : threads, "ram" : ram, "security" : security};
if (host != "EXP") {
ns.print("Reporting of incoming hack...");
await ns.tryWritePort(13, JSON.stringify(task));
} else {
ns.print("Reporting EXP hack...");
await ns.tryWritePort(14, JSON.stringify(task));
}
ns.print("Hacking...");
await ns.hack(target);
task.done = true;
task.security *= -1;
if (host != "EXP") {
ns.print("Reporting of hack completion...")
await ns.tryWritePort(13, JSON.stringify(task));
} else {
ns.print("Reporting EXP hack completion...");
await ns.tryWritePort(14, JSON.stringify(task));
}
}