@grey-ts/types 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.ts +1065 -779
  2. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -1,3 +1,234 @@
1
+ declare namespace GreyHack {
2
+ interface AptClient {
3
+ classID: "aptClientLib";
4
+ /**
5
+ * Inserts a repository address into the `/etc/apt/sources.txt` file.
6
+ *
7
+ * On success, it will return an empty string. In case of failure, it will return a string with an error message.
8
+ * @example
9
+ * const aptClient = includeLib("/lib/aptclient.so");
10
+ * if (!isType(aptClient, "aptClientLib")) exit("Failed to find aptclient.");
11
+ *
12
+ * const failString = aptClient.addRepo("42.141.12.6");
13
+ * if (failString)
14
+ * console.log("Failed to add repo: " + failString);
15
+ * else
16
+ * console.log("Added repo successfully!");
17
+ */
18
+ addRepo(repositoryAddress: string, port?: number): string;
19
+ /**
20
+ * Checks if there is a newer version of the program or library in the repository.
21
+ *
22
+ * On success, it will return a boolean, with false indicating that there is no new version, while true indicates that there is a new version available.
23
+ *
24
+ * In case of failure, it will return a string containing an error message.
25
+ */
26
+ checkUpgrade(filePath: string): boolean | string;
27
+ /**
28
+ * Deletes a repository address from the `/etc/apt/sources.txt` file.
29
+ *
30
+ * On success, it will return an empty string. In case of failure, it will return a string with an error message.
31
+ */
32
+ delRepo(repositoryAddress: string): string;
33
+ /**
34
+ * Installs a program or library from a remote repository listed in `/etc/apt/sources.txt`.
35
+ *
36
+ * If no path is specified, the program installs in `/lib` if it is a library or in `/bin` otherwise.
37
+ *
38
+ * On success, this method will return true. In case of failure, it will return a string containing an error message.
39
+ */
40
+ install(package: string, installPath?: string): true | string;
41
+ /**
42
+ * Search specifically looks for a package in any of the repositories listed in `/etc/apt/sources.txt`.
43
+ *
44
+ * On success, it will return a string containing all packages that partially match the provided search value.
45
+ *
46
+ * On failure, it will return a string with various error messages.
47
+ */
48
+ search(package: string): string;
49
+ /**
50
+ * Show displays all the packages available in a repository. The repository must be listed in the `/etc/apt/sources.txt` file.
51
+ *
52
+ * If it cannot find a repository, it will return various error messages.
53
+ *
54
+ * On success, it will return a string containing all packages and their descriptions, with each entry separated by a newline.
55
+ */
56
+ show(repositoryAddress: string): string;
57
+ /**
58
+ * Update refreshes the list of available packages after adding a new repository in `/etc/apt/sources.txt`, or if the remote repository has updated its information in `/server/conf/repod.conf`.
59
+ *
60
+ * If the update is successful, an empty string will be returned. In case of failure, a string with an error message will be returned.
61
+ *
62
+ * If for some reason the `/etc/apt/sources.txt` is malformed this method will return false.
63
+ */
64
+ update(): string | false;
65
+ }
66
+ }
67
+ interface Array<T> {
68
+ readonly length: number;
69
+ /** Returns a boolean indicating if the provided index exists in the array */
70
+ hasIndex(index: number): boolean;
71
+ /** Returns the index of the first occurrence of a value in an array, or null if it is not present. */
72
+ indexOf(value: T, offset?: number): number | null;
73
+ /** Returns an array containing the indexes of the array */
74
+ indexes(): number[];
75
+ /** Inserts a value into the array at the provided index. This method mutates the array and returns a reference to the same array. */
76
+ insert(index: number, value: T): T[];
77
+ /**
78
+ * Returns a concatenated string containing all stringified values inside the list. These values will be separated via the provided separator.
79
+ *
80
+ * In case the list exceeds `16777215L` items or the delimiter exceeds 128 characters, this method will throw an error, interrupting further script execution.
81
+ */
82
+ join(delimiter: string): string;
83
+ /** Removes the first element from an array and returns it. If the array is empty, null is returned. */
84
+ shift(): T | null;
85
+ /** Inserts new elements at the start of an array, and returns the new length of the array. */
86
+ unshift(...items: T[]): number;
87
+ /** Removes the last element from an array and returns it. If the array is empty, null is returned. */
88
+ pop(): T | null;
89
+ /** Appends new elements to the end of an array, and returns the new length of the array. */
90
+ push(...items: T[]): number;
91
+ /**
92
+ * Removes an item from the list with the provided index. Due to the removal the list will get mutated.
93
+ */
94
+ remove(index: number): null;
95
+ /**
96
+ * Changes every value of the array that matches `oldValue` into `newValue`
97
+ *
98
+ * This method mutates the array and returns a reference to the same array.
99
+ */
100
+ replace(oldValue: T, newValue: T, maxCount?: number): T[];
101
+ /** Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array. */
102
+ reverse(): T;
103
+ /** Shuffles all values in the array. This method mutates the array. */
104
+ shuffle(): null;
105
+ /**
106
+ * Sorts the values of an array alphanumerically.
107
+ *
108
+ * This operation mutates the original array. Optionally, a key can be provided, which is used if the items are objects or arrays. Finally, this method returns the updated array.
109
+ * @example
110
+ * const myArray = [{ key: 123 }, { key: 5 }, { key: 17 }];
111
+ * myArray.sort("key");
112
+ *
113
+ * const numbers = [1,2,3,4,5];
114
+ * numbers.sort()
115
+ */
116
+ sort(key?: PropertyKey | null, ascending?: boolean): T[];
117
+ /** Returns a sum of all values inside the array. Any non-numeric values will be considered a zero. */
118
+ sum(): number;
119
+ values(): T[];
120
+ /**
121
+ * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
122
+ * @param value value to fill array section with
123
+ * @param start index to start filling the array at. If start is negative, it is treated as
124
+ * length+start where length is the length of the array.
125
+ * @param end index to stop filling the array at. If end is negative, it is treated as
126
+ * length+end.
127
+ */
128
+ fill(value: T, start?: number, end?: number): this;
129
+ /** Determines whether an array includes a certain element, returning true or false as appropriate. */
130
+ includes(searchElement: T, fromIndex?: number): boolean;
131
+ /**
132
+ * Combines two or more arrays. This method returns a new array without modifying any existing arrays.
133
+ * @param items Additional arrays and/or items to add to the end of the array.
134
+ */
135
+ concat(...items: (T | T[])[]): T[];
136
+ /** Calls a defined callback function on each element of an array, and returns an array that contains the results. */
137
+ map<U>(callbackfn: (value: T, index: number, array: T[]) => U): U[];
138
+ /** Returns the elements of an array that meet the condition specified in a callback function. */
139
+ filter(predicate: (value: T, index: number, array: T[]) => unknown): T[];
140
+ /** Returns the value of the first element in the array where predicate is true, and null otherwise. */
141
+ find(predicate: (value: T, index: number, array: T[]) => unknown): T | null;
142
+ /** Determines whether the specified callback function returns true for any element of an array. */
143
+ some(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
144
+ /** Determines whether all the members of an array satisfy the specified test. */
145
+ every(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
146
+ /**
147
+ * Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array.
148
+ *
149
+ * For example, -2 refers to the second to last element of the array.
150
+ * @param start The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.
151
+ * @param end The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array.
152
+ * */
153
+ slice(start?: number, end?: number): T[];
154
+ /**
155
+ * Removes elements from an array and returns the deleted elements.
156
+ *
157
+ * For example, -2 refers to the second to last element of the array.
158
+ * @param start The zero-based location in the array from which to start removing elements
159
+ * @param end The number of elements to remove. Omitting this argument will remove all elements from the start paramater location to end of the array.
160
+ * */
161
+ splice(start: number, deleteCount?: number): T[];
162
+ /** Returns a string representation of an array. */
163
+ toString(): string;
164
+ [n: number]: T;
165
+ }
166
+ declare var Array: {
167
+ readonly prototype: Array<any>;
168
+ };
169
+ declare namespace GreyHack {
170
+ interface BlockChain {
171
+ classID: "blockchainLib";
172
+ /**
173
+ * Returns a number representing the total amount of mined coins.
174
+ *
175
+ * In case of an error, it will return a string with the details.
176
+ * @example
177
+ * const blockChain = includeLib("/lib/blockchain.so");
178
+ * if (!isType(blockChain, "blockchainLib"))
179
+ * exit("Failed to get blockchain.so");
180
+ *
181
+ * const mined = blockChain.amountMined("bitcoin");
182
+ * if (isType(mined, "string"))
183
+ * exit(`Coudn't get the amount of mined coin: ${mined}`);
184
+ *
185
+ * print(`There are ${mined} coins mined for this coin`);
186
+ */
187
+ amountMined(coinName: string): number | string;
188
+ /**
189
+ * Returns a number representing the current unit value of the cryptocurrency.
190
+ *
191
+ * In case of an error, a string with the error details will be returned.
192
+ */
193
+ coinPrice(coinName: string): number | string;
194
+ /**
195
+ * Creates a wallet and returns a wallet object on success, which can be used to manage cryptocurrencies.
196
+ *
197
+ * In case of an error, it will return a string with the details.
198
+ */
199
+ createWallet(user: string, password: string): Wallet | string;
200
+ /**
201
+ * Removes a cryptocurrency from the world. The credentials used in the creation of the cryptocurrency are required.
202
+ *
203
+ * On success, it will return a true.
204
+ *
205
+ * On failure, it will return a string containing details.
206
+ */
207
+ deleteCoin(coinName: string, user: string, password: string): true | string;
208
+ /**
209
+ * Returns a coin object used to manage the currency.
210
+ *
211
+ * In case of an error, it will return a string with the details.
212
+ */
213
+ getCoin(coinName: string, user: string, password: string): Coin | string;
214
+ /**
215
+ * Returns a string with the name of the coin owned by the player.
216
+ *
217
+ * In case of an error, it returns a string with details.
218
+ */
219
+ getCoinName(user: string, password: string): string;
220
+ /** Returns a wallet object on success. In case of an error, it will return a string indicating the reason. */
221
+ loginWallet(user: string, password: string): Wallet | string;
222
+ /**
223
+ * Returns an object with the latest changes in the value of a specific cryptocurrency.
224
+ *
225
+ * The key of the object is an index represented by a number. The value is an array, where index 0 is the historical price of the coin and index 1 is the date when the price change occurred.
226
+ *
227
+ * If no coin exists with this name, the method will return null.
228
+ */
229
+ showHistory(coinName: string): Record<number, [number, string]> | string | null;
230
+ }
231
+ }
1
232
  declare namespace GreyHack {
2
233
  interface Coin {
3
234
  classID: "coin";
@@ -340,37 +571,250 @@ declare namespace GreyHack {
340
571
  }
341
572
  }
342
573
  declare namespace GreyHack {
343
- interface FtpFile extends BaseFile {
344
- classID: "ftpFile";
345
- /** The parent folder of the current file or folder */
346
- parent: FtpFile | null;
574
+ interface Crypto {
575
+ classID: "cryptoLib";
347
576
  /**
348
- * Returns an array of files inside this folder.
577
+ * Returns a string containing the password based on the file which was generated via aireplay.
349
578
  *
350
- * In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
351
- */
352
- getFiles(): FtpFile[] | null;
353
- /**
354
- * Returns an array of folders inside this folder.
579
+ * In case of failure, it will return null instead. If the provided path is empty, an error will be thrown, interrupting the script execution.
580
+ * @example
581
+ * const crypto = includeLib("/lib/crypto.so");
582
+ * if (!isType(crypto, "cryptoLib"))
583
+ * exit("Failed to load crypto");
355
584
  *
356
- * In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
357
- */
358
- getFolders(): FtpFile[] | null;
359
- }
360
- interface File extends BaseFile {
361
- classID: "file";
362
- /** The parent folder of the current file or folder */
363
- parent: File | null;
364
- /** Indicates if the file is a binary and can be imported by other scripts */
365
- allowImport: boolean;
366
- /**
367
- * Returns an array of files inside this folder.
585
+ * const capFile = computer.file(currentPath() + "/file.cap");
586
+ * if (!capFile)
587
+ * exit(".cap file doesn't exist in the current folder");
368
588
  *
369
- * In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
589
+ * const wifiPassword = crypto.aircrack(currentPath() + "/file.cap");
590
+ * if (wifiPassword === null)
591
+ * exit("Failed to crack wifi password");
592
+ *
593
+ * console.log(`The wifi password for ${best.essid} is: ${wifiPassword}`);
370
594
  */
371
- getFiles(): File[] | null;
595
+ aircrack(path: string): string | null;
372
596
  /**
373
- * Returns an array of folders inside this folder.
597
+ * Used to inject frames on wireless interfaces.
598
+ *
599
+ * Once the command with `Control+C` is stopped, it will save the captured information in a text file called `file.cap` in the path where the terminal is currently located.
600
+ *
601
+ * Alternatively, a maximum of captured acks can be specified for the command to stop automatically, saving the `file.cap` file as described above.
602
+ *
603
+ * To figure out how many ACKs are required, you can use the following formula: `300000 / (Power + 15)`.
604
+ *
605
+ * If there is an error, a string will be returned with the message indicating the problem. On success, it will return null, it is advised though to verify that the capture file actually exists.
606
+ *
607
+ * In case any of the provided values deviate from the signature types or bssid/essid is empty, an error will be thrown preventing any further script execution.
608
+ *
609
+ * @example
610
+ * const crypto = includeLib("/lib/crypto.so");
611
+ * if (!isType(crypto, "cryptoLib")) exit("Failed to load crypto");
612
+ *
613
+ * const airmonRes = crypto.airmon("start", "wlan0");
614
+ * if (airmonRes !== true) exit("Failed to start airmon: " + airmonRes);
615
+ *
616
+ * const computer = getShell().hostComputer;
617
+ * const networks = computer.wifiNetworks("wlan0") ?? [];
618
+ * const result: { bssid: string, pwr: number, essid: string; }[] = [];
619
+ * for (const network of networks) {
620
+ * const parsedItem = network.split(" ");
621
+ * result.push({
622
+ * bssid: parsedItem[0],
623
+ * pwr: parsedItem[1].slice(0, -1).toInt() as number,
624
+ * essid: parsedItem[2],
625
+ * });
626
+ * }
627
+ *
628
+ * result.sort("pwr", false);
629
+ *
630
+ * const best = result[0];
631
+ * const aireplayRes = crypto.aireplay(best.bssid, best.essid, 300000 / (best.pwr + 15));
632
+ * crypto.airmon("stop", "wlan0");
633
+ * if (isType(aireplayRes, "string")) exit(aireplayRes);
634
+ *
635
+ * const capFile = computer.file(currentPath() + "/file.cap");
636
+ * if (capFile)
637
+ * console.log(".cap file created!")
638
+ * else
639
+ * exit("Failed to create .cap file in the current folder");
640
+ */
641
+ aireplay(bssid: string, essid: string, maxAcks?: number): string | null;
642
+ /**
643
+ * Enables or disables the monitor mode of a network device.
644
+ *
645
+ * Monitor mode can only be enabled on Wifi cards.
646
+ *
647
+ * If it wasn't possible to enable or disable the monitor mode, this method will return either false or a string with details. In case of success, it will return true.
648
+ *
649
+ * @example
650
+ * const crypto = includeLib("/lib/crypto.so");
651
+ * if (!isType(crypto, "cryptoLib")) exit("Failed to load crypto");
652
+ *
653
+ * const airmonRes = crypto.airmon("start", "wlan0");
654
+ * if (airmonRes === true)
655
+ * console.log("Monitoring mode switched successfully.")
656
+ * else
657
+ * exit("Failed to switch monitoring mode: " + airmonRes);
658
+ */
659
+ airmon(option: "start" | "stop", device: netDevice): boolean | string;
660
+ /**
661
+ * Returns a decrypted password via the provided password MD5 hash.
662
+ *
663
+ * Keep in mind that this method is not decrypting a password but rather checking for existing passwords within the game world with a matching MD5 hash.
664
+ *
665
+ * So in case a password does not exist in the game world, the decryption will fail.
666
+ *
667
+ * On failure, this method will return null. Using this method in an SSH encryption process will cause an error to be thrown, aborting further script execution.
668
+ * @example
669
+ * const crypto = includeLib("/lib/crypto.so");
670
+ * if (!isType(crypto, "cryptoLib")) exit("Failed to load crypto.so");
671
+ *
672
+ * const computer = getShell().hostComputer;
673
+ * const passwdFile = computer.file("/etc/passwd");
674
+ * if (!passwdFile) exit("Failed to get passwd file");
675
+ *
676
+ * const lines = passwdFile.getContent()!.split(char(10));
677
+ * for (const line of lines) {
678
+ * const parsed = line.split(":");
679
+ * const username = parsed[0];
680
+ * const passwordhash = parsed[1];
681
+ *
682
+ * const password = crypto.decipher(passwordhash);
683
+ * print(`Password for user '${username}' is: ${password}`);
684
+ * }
685
+ */
686
+ decipher(hash: string): string | null;
687
+ /**
688
+ * Decrypts the specified file using the provided key.
689
+ *
690
+ * On success, the method returns true. If decryption fails, a descriptive error message is returned as a string.
691
+ *
692
+ * @example
693
+ * const crypto = includeLib("/lib/crypto.so");
694
+ * if (!isType(crypto, "cryptoLib")) exit("Failed to load crypto");
695
+ *
696
+ * const decryptionResult = crypto.decrypt("/etc/passwd", "mySecretKey");
697
+ * if (isType(decryptionResult, "string"))
698
+ * console.log("Failed to decrypt file due to: " + decryptionResult);
699
+ * else
700
+ * console.log("File got decrypted!");
701
+ */
702
+ decrypt(filePath: string, password: string): true | string;
703
+ /**
704
+ * Encrypts the specified file using the provided key.
705
+ *
706
+ * On success, the method returns true. If encryption fails, a descriptive error message is returned as a string.
707
+ *
708
+ * @example
709
+ * const crypto = includeLib("/lib/crypto.so");
710
+ * if (!isType(crypto, "cryptoLib")) exit("Failed to load crypto");
711
+ *
712
+ * const encryptionResult = crypto.encrypt("/etc/passwd", "mySecretKey");
713
+ * if (isType(encryptionResult, "string"))
714
+ * console.log("Failed to encrypt file due to: " + encryptionResult);
715
+ * else
716
+ * console.log("File got encrypted!");
717
+ */
718
+ encrypt(filePath: string, password: string): true | string;
719
+ /**
720
+ * Checks whether the specified file is encrypted.
721
+ *
722
+ * Returns true if the file is encrypted, or false if it is not. If the check fails (e.g., due to a missing or unreadable file), a descriptive error message is returned as a string.
723
+ */
724
+ isEncrypted(filePath: string): boolean | string;
725
+ /**
726
+ * Returns an array of the existing users on the computer where the SMTP service is running.
727
+ *
728
+ * If these users also have an email account registered on the SMTP server, it will be indicated in the array.
729
+ *
730
+ * SMTP services are usually running on port 25. In case of failure, this method will return a string containing the cause.
731
+ */
732
+ smtpUserList(ip: string, port: number): string[] | string;
733
+ }
734
+ }
735
+ declare namespace GreyHack {
736
+ interface CtfEvent {
737
+ classID: "ctfEvent";
738
+ /** Returns string with the name of the CTF event creator. */
739
+ getCreatorName(): string;
740
+ /** Returns string with the CTF event description. */
741
+ getDescription(): string;
742
+ /** Returns string with the mail content of the CTF event. */
743
+ getMailContent(): string;
744
+ /** Returns string with the CTF event template. */
745
+ getTemplate(): string;
746
+ /** Returns a boolean indicating if the CTF event got completed successfully */
747
+ playerSuccess(): boolean;
748
+ }
749
+ }
750
+ declare namespace GreyHack {
751
+ interface DebugLibrary {
752
+ classID: "debugLibrary";
753
+ /**
754
+ * Applies a patch containing corrected code to the specified text file at the provided path.
755
+ *
756
+ * Returns a string with the result of the operation.
757
+ */
758
+ applyPatch(path: string): string;
759
+ /**
760
+ * Returns a list containing a single partial computer object if zero-day vulnerabilities are detected within the specified memory zone.
761
+ *
762
+ * If a file path is provided, a partial file object associated with this path will also be included in the array.
763
+ *
764
+ * Additionally, if this file is a library, its corresponding metaLib object is added to the returned array.
765
+ *
766
+ * In case of an error, a string with details is returned.
767
+ */
768
+ payload(memZone: string): string | [Partial<Computer>];
769
+ payload(memZone: string, filePath: string): string | [Partial<Computer>, Partial<File>] | [Partial<Computer>, Partial<File>, MetaLib];
770
+ /**
771
+ * Scans the library in debug mode to identify potential code errors that may lead to vulnerabilities.
772
+ *
773
+ * If issues are detected, the relevant code snippets are printed. In case of an error, a string containing the error message is returned.
774
+ */
775
+ scan(): string;
776
+ /**
777
+ * Conducts automated tests on the specified lines of code.
778
+ *
779
+ * If potential vulnerabilities are detected due to errors in these lines, this method will print partial objects that could be obtained by exploiting the vulnerability, along with the affected memory zone and detailed vulnerability information.
780
+ *
781
+ * In case of failure, this function returns a string with an error message.
782
+ */
783
+ unitTesting(errorLines: number[]): string;
784
+ }
785
+ }
786
+ declare namespace GreyHack {
787
+ interface FtpFile extends BaseFile {
788
+ classID: "ftpFile";
789
+ /** The parent folder of the current file or folder */
790
+ parent: FtpFile | null;
791
+ /**
792
+ * Returns an array of files inside this folder.
793
+ *
794
+ * In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
795
+ */
796
+ getFiles(): FtpFile[] | null;
797
+ /**
798
+ * Returns an array of folders inside this folder.
799
+ *
800
+ * In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
801
+ */
802
+ getFolders(): FtpFile[] | null;
803
+ }
804
+ interface File extends BaseFile {
805
+ classID: "file";
806
+ /** The parent folder of the current file or folder */
807
+ parent: File | null;
808
+ /** Indicates if the file is a binary and can be imported by other scripts */
809
+ allowImport: boolean;
810
+ /**
811
+ * Returns an array of files inside this folder.
812
+ *
813
+ * In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
814
+ */
815
+ getFiles(): File[] | null;
816
+ /**
817
+ * Returns an array of folders inside this folder.
374
818
  *
375
819
  * In case the current entity is a file instead of a folder this method will return null, so it is advisable to first use the isFolder function before calling this method. In case the current folder gets deleted this method will return null as well.
376
820
  */
@@ -428,7 +872,7 @@ declare namespace GreyHack {
428
872
  *
429
873
  * If used within an SSH encryption process, if the new name exceeds 128 characters, or if the path is too long, an error will be thrown, interrupting script execution. If the current file is deleted, this method will return null.
430
874
  */
431
- symlink(path: string, newName?: string): true | string | null;
875
+ symlink(path: string, newName: string): true | string | null;
432
876
  }
433
877
  interface BaseFile {
434
878
  classID: "ftpFile" | "file";
@@ -457,7 +901,7 @@ declare namespace GreyHack {
457
901
  *
458
902
  * If this method is used within an SSH encryption process, the new name exceeds 128 characters, or the path is too long, an error will be thrown, causing an interruption of script execution. In case the current file gets deleted, this method will return null.
459
903
  */
460
- copy(destFolder?: string, newName?: string): string | true | null;
904
+ copy(destFolder: string, newName: string): string | true | null;
461
905
  /**
462
906
  * Delete the current file.
463
907
  *
@@ -485,7 +929,7 @@ declare namespace GreyHack {
485
929
  *
486
930
  * If this method is used within an SSH encryption process, the new name exceeds 128 characters, or the path is too long, an error will be thrown, causing an interruption of script execution. In case the current file gets deleted, this method will return null.
487
931
  */
488
- move(destFolder: string, newName?: string): string | true | null;
932
+ move(destFolder: string, newName: string): string | true | null;
489
933
  /**
490
934
  * Returns a string containing the file path. If the file has been deleted, this method will still return the path it had prior to deletion.
491
935
  * @param symLinkOriginalPath return the original path of the linked file instead
@@ -505,6 +949,10 @@ declare namespace GreyHack {
505
949
  declare var globals: any;
506
950
  /** The parameters given to this script on launch */
507
951
  declare var params: string[];
952
+ declare const console: {
953
+ readonly log: typeof GreyHack.print;
954
+ readonly clear: typeof GreyHack.clearScreen;
955
+ };
508
956
  declare namespace GreyHack {
509
957
  /** Returns a string with the name of the user who is executing the current script. */
510
958
  function activeUser(): string;
@@ -876,38 +1324,173 @@ interface ClassIDMap {
876
1324
  "wallet": GreyHack.Wallet;
877
1325
  }
878
1326
  type GameTypeMap = ClassIDMap & PrimitiveTypeMap;
1327
+ interface Math {
1328
+ /** Returns the value of pi to the precision of 6 */
1329
+ readonly PI: number;
1330
+ /** Returns the absolute value of number. */
1331
+ abs(value: number): number;
1332
+ /** Returns the inverse cosine (in radians) of a number. */
1333
+ acos(value: number): number;
1334
+ /** Returns the inverse sine (in radians) of a number. */
1335
+ asin(value: number): number;
1336
+ /** Returns the inverse tangent (in radians) of a number. */
1337
+ atan(y: number, x?: number | undefined): number;
1338
+ /** Returns number rounded up to the integer value of the provided number. */
1339
+ ceil(value: number): number;
1340
+ /** Returns number rounded down to the integer value of the provided number. */
1341
+ floor(value: number): number;
1342
+ /** Returns the cosine of a number in radians. */
1343
+ cos(value: number): number;
1344
+ /** Returns the sine of a number in radians. */
1345
+ sin(value: number): number;
1346
+ /** Returns the tangent of a number in radians. */
1347
+ tan(value: number): number;
1348
+ /** Returns the square root of a number. */
1349
+ sqrt(value: number): number;
1350
+ /** Returns 1 or -1 indicating the sign of the value passed or 0 if the value is 0 */
1351
+ sign(value: number): -1 | 0 | 1;
1352
+ /** Returns number rounded to the integer value of the provided number. */
1353
+ round(value: number, fixed?: number | undefined): number;
1354
+ /** Returns a random number between 0 and 1. Optionally a seed number can be provided. */
1355
+ random(seed?: number | undefined): number;
1356
+ /**
1357
+ * Returns the natural logarithm of a number.
1358
+ *
1359
+ * By default, the base is 10. Optionally the base can be changed.
1360
+ */
1361
+ log(value: number, base?: number | undefined): number;
1362
+ /** Returns the smallest number of the given values */
1363
+ min(...values: number[]): number;
1364
+ /** Returns the largest number of the given values */
1365
+ max(...values: number[]): number;
1366
+ }
1367
+ declare var Math: Math;
879
1368
  declare namespace GreyHack {
880
- interface Service {
881
- classID: "service";
1369
+ interface MetaLib {
1370
+ classID: "MetaLib";
1371
+ /** The name of the library. An example of a name would be `init.so`. */
1372
+ libName: string;
1373
+ /** Version number of the library. An example of a version number would be `1.0.0`. */
1374
+ version: string;
882
1375
  /**
883
- * Installs the necessary files for the correct functioning of the service and starts it.
1376
+ * Returns a library in debug mode as a {@link DebugLibrary} object.
884
1377
  *
885
- * If the installation is completed successfully, it returns true. In case of an error, it returns a string with details.
886
- */
887
- installService(): true | string;
1378
+ * A valid Neurobox engineer's username and password are required to access this mode.
1379
+ *
1380
+ * If successful, the {@link DebugLibrary} object is returned; in case of an error, a string with details is provided. */
1381
+ debugTools(user: string, password: string): DebugLibrary | string;
888
1382
  /**
889
- * Starts the service and opens its associated port on the local machine.
1383
+ * Returns by default a boolean indicating whether the library has been patched.
890
1384
  *
891
- * The service requires a port forwarded to the router to be accessible from the outside.
1385
+ * True indicates that the library has been patched, while false indicates that it has not.
892
1386
  *
893
- * If the service starts correctly, it returns true. In case of an error, it returns a string with details.
1387
+ * If the getdate parameter is set to true, the function will return a string containing the date of the last patch. The data format is as follows: `dd/MM/yyyy`.
1388
+ *
1389
+ * Additionally if there is any error the return value will be a string.
894
1390
  */
895
- startService(): true | string;
1391
+ isPatched(getDate?: boolean): boolean | string;
896
1392
  /**
897
- * Stops the service and closes its associated port on the local machine.
1393
+ * Exploits vulnerabilities in target systems by executing various attack vectors against libraries located in the `/lib` folder.
898
1394
  *
899
- * If the service is stopped successfully, it returns true.
1395
+ * The function requires a memory address, vulnerability identifier, and optional arguments that are mandatory for password changes (new password) and computer exploits (LAN IP address).
900
1396
  *
901
- * If an error occurs during the process, it returns a string with details. In some cases, the returned value might be false, indicating that the service removal failed.
1397
+ * The system validates that the target library exists and is properly located in the `/lib` directory before proceeding otherwise it will return null.
1398
+ *
1399
+ * If the network where the library is located is disabled, the function returns a string indicating the network status.
1400
+ *
1401
+ * The exploit will fail and return null if the target is behind a firewall or if any of the specific vulnerability requirements aren't met, such as insufficient registered users, missing required libraries with correct versions, inadequate port forwards, absence of required user types like active guests or root users, or invalid file paths.
1402
+ *
1403
+ * If the target vulnerability is identified as a zero-day exploit, the system will load the appropriate zero-day vulnerability before execution.
1404
+ *
1405
+ * During execution, if a super admin intercepts the exploit attempt, user privileges are automatically lowered to guest level.
1406
+ *
1407
+ * Shell exploits, once all requirements are met, always return a shell object.
1408
+ *
1409
+ * Random folder exploits return a file object if the specified path exists or null if the folder cannot be found.
1410
+ *
1411
+ * Password change exploits return true for successful password modification or false for failure due to guest user restrictions, invalid alphanumeric format, or exceeding the 15-character limit.
1412
+ *
1413
+ * Settings override exploits work only on smart appliances like fridges or microwaves and return true for success or false for failure.
1414
+ *
1415
+ * Traffic light exploits require targets on the police station's network and return true for success or false for failure.
1416
+ *
1417
+ * Firewall exploits need router targets and return true for success or false for failure.
1418
+ *
1419
+ * Computer exploits return a computer object when successful or false if the LAN IP is invalid, the computer doesn't exist, or no non-root user is available.
1420
+ *
1421
+ * Using {@link isType} or {@link getType} to verify return value types is essential before processing results due to the variety of possible return types.
1422
+ *
1423
+ * @example
1424
+ * const metax = includeLib("/lib/metaxploit.so");
1425
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1426
+ *
1427
+ * const metaLib = metax.load("/lib/init.so");
1428
+ * if (!metaLib) exit("Failed to load the library");
1429
+ *
1430
+ * const result = metaLib.overflow("0x14F45286", "Eyworde");
1431
+ * if (isType(result, "shell")) {
1432
+ * // Do stuff with shell
1433
+ * }
1434
+ * else if (isType(result, "computer")) {
1435
+ * // Do stuff with computer
1436
+ * }
1437
+ * else if (isType(result, "file")) {
1438
+ * // Do stuff with file
1439
+ * console.log("Obtained file: " + result.name);
1440
+ * }
902
1441
  */
903
- stopService(): boolean | string;
1442
+ overflow(memoryAddress: string, unsecZone: string, optArgs?: string): Shell | Computer | File | string | boolean | null;
1443
+ }
1444
+ }
1445
+ declare namespace GreyHack {
1446
+ interface MetaMail {
1447
+ classID: "MetaMail";
1448
+ /**
1449
+ * Delete the email corresponding to the provided email ID.
1450
+ *
1451
+ * Returns true if the email removal was successful. Otherwise, a string with an error message will be returned.
1452
+ */
1453
+ delete(mailId: string): true | string;
1454
+ /**
1455
+ * Returns an array where each item is a string containing mail id, from, subject and a small preview of the content consisting of the first 125 characters.
1456
+ *
1457
+ * If there is any issue a string will be returned with details.
1458
+ */
1459
+ fetch(): string[] | string;
1460
+ /**
1461
+ * Returns a string containing the content of a mail related to the provided mail id.
1462
+ *
1463
+ * The mail id argument can be obtained with fetch. In case the mail cannot be found this method will return `Mail not found`.
1464
+ */
1465
+ read(mailId: string): string;
1466
+ /**
1467
+ * Send a new mail to the provided email address.
1468
+ *
1469
+ * Keep in mind that the subject can not exceed 128 characters and the message size should not exceed 2500 characters.
1470
+ *
1471
+ * @returns true indicating that the mail has been sent correctly, or a string with an error
1472
+ */
1473
+ send(emailAddress: string, subject: string, message: string): string | true;
904
1474
  }
1475
+ }
1476
+ declare namespace GreyHack {
905
1477
  interface Metaxploit {
906
1478
  classID: "MetaxploitLib";
907
1479
  /**
908
1480
  * Returns a {@link MetaLib} object for the provided path to the library binary. Keep in mind that this can only be used on library files.
909
1481
  *
910
1482
  * On failure, this method will return null. If the provided path is empty, this method will throw a runtime exception, preventing further script execution.
1483
+ * @example
1484
+ * const metax = includeLib("/lib/metaxploit.so");
1485
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1486
+ *
1487
+ * const libFolder = getShell().hostComputer.file("/lib")!;
1488
+ * for (const file of libFolder.getFiles()!) {
1489
+ * const metaLib = metax.load(file.path());
1490
+ * if (!metaLib) continue; // Failed to load
1491
+ *
1492
+ * console.log(`Library: ${metaLib.libName}-${metaLib.version}`);
1493
+ * }
911
1494
  */
912
1495
  load(path: string): MetaLib | null;
913
1496
  /**
@@ -917,7 +1500,26 @@ declare namespace GreyHack {
917
1500
  *
918
1501
  * The main purpose of this method is to gain a {@link NetSession} and then use {@link NetSession.dumpLib} to receive a {@link MetaLib} object to exploit vulnerabilities.
919
1502
  *
920
- * In case of failure, this method will return null. If this method is used within an SSH encryption process or with disabled internet, or if an invalid target IP is provided, this method will throw a runtime exception. */
1503
+ * In case of failure, this method will return null. If this method is used within an SSH encryption process or with disabled internet, or if an invalid target IP is provided, this method will throw a runtime exception.
1504
+ *
1505
+ * @example
1506
+ * const metax = includeLib("/lib/metaxploit.so");
1507
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1508
+ *
1509
+ * const targetRouter = getRouter("1.1.1.1");
1510
+ * if (!targetRouter) exit("Failed to get target router");
1511
+ *
1512
+ * const ports = targetRouter.usedPorts();
1513
+ * for (const port of ports) {
1514
+ * if (port.isClosed()) continue;
1515
+ *
1516
+ * const netSession = metax.netUse(targetRouter.publicIp, port.portNumber);
1517
+ * if (!netSession) continue;
1518
+ *
1519
+ * const metaLib = netSession.dumpLib();
1520
+ * console.log(`Library: ${metaLib.libName}-${metaLib.version}`);
1521
+ * }
1522
+ */
921
1523
  netUse(ip: string, port: number): NetSession | null;
922
1524
  /**
923
1525
  * Launches a process on the victim's computer, silently attempting to continuously connect in the background to the specified address and port.
@@ -925,6 +1527,14 @@ declare namespace GreyHack {
925
1527
  * For the reverse shell to run successfully, the rshell service must be installed, and the port forward must be configured correctly on the machine where the server is waiting for the victim's connection.
926
1528
  *
927
1529
  * If the launch was successful, true will be returned. In case of failure, a string with details will be returned.
1530
+ *
1531
+ * @example
1532
+ * const metax = includeLib("/lib/metaxploit.so");
1533
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1534
+ *
1535
+ * const result = metax.rshellClient("1.1.1.1", 1222, "bgprocess");
1536
+ * if (isType(result, "string"))
1537
+ * console.log("Failed to launch rshell client: " + result);
928
1538
  */
929
1539
  rshellClient(ip: string, port: number, processName?: string): true | string;
930
1540
  /**
@@ -932,7 +1542,18 @@ declare namespace GreyHack {
932
1542
  *
933
1543
  * To manage the connections received, the rshell service must be installed on the machine that receives the victims' connections.
934
1544
  *
935
- * In case of failure a string will be returned with details. */
1545
+ * In case of failure a string will be returned with details.
1546
+ *
1547
+ * @example
1548
+ * const metax = includeLib("/lib/metaxploit.so");
1549
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1550
+ *
1551
+ * const shells = metax.rshellServer();
1552
+ * if (isType(shells, "string"))
1553
+ * exit("Failed to get reverse shells: " + shells)
1554
+ *
1555
+ * console.log(`You have access to ${shells.length} shells`);
1556
+ */
936
1557
  rshellServer(): Shell[] | string;
937
1558
  /**
938
1559
  * Returns an array where each item is a string representing a memory area which has vulnerabilities related to the provided library.
@@ -943,7 +1564,19 @@ declare namespace GreyHack {
943
1564
  *
944
1565
  * An example of a memory area would be `0x7BFC1EAA`.
945
1566
  *
946
- * Using this method within a SSH encryption process will throw a runtime exception. */
1567
+ * Using this method within a SSH encryption process will throw a runtime exception.
1568
+ * @example
1569
+ * const metax = includeLib("/lib/metaxploit.so");
1570
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1571
+ *
1572
+ * const metaLib = metax.load("/lib/init.so");
1573
+ * if (!metaLib) exit("Failed to load the library");
1574
+ *
1575
+ * const addresses = metax.scan(metaLib) ?? [];
1576
+ * for (const address of addresses) {
1577
+ * console.log("Memory address containing a vulnerability: " + address);
1578
+ * }
1579
+ */
947
1580
  scan(metaLib: MetaLib): string[] | null;
948
1581
  /**
949
1582
  * Returns a string containing information about each vulnerability in the provided library and memory area.
@@ -951,705 +1584,146 @@ declare namespace GreyHack {
951
1584
  * In case the scanning fails this method will return null.
952
1585
  *
953
1586
  * Using this method within a SSH encryption process will throw a runtime exception.
954
- */
955
- scanAddress(metaLib: MetaLib, memoryAddress: string): string | null;
956
- /**
957
- * The terminal listens to the network packets of any connection that passes through the computer.
958
- *
959
- * When any connection information gets captured, it will print a string with the obtained data.
960
- *
961
- * In case saving of encryption source is enabled it will download the source code of the script responsible for encryption.
962
- *
963
- * In case the operation fails this method will return null.
964
1587
  *
965
- * Using this method within a SSH encryption process will throw a runtime exception.
966
- */
967
- sniffer(saveEncSource?: boolean): string | null;
968
- }
969
- interface MetaLib {
970
- classID: "MetaLib";
971
- /** The name of the library. An example of a name would be `init.so`. */
972
- libName: string;
973
- /** Version number of the library. An example of a version number would be `1.0.0`. */
974
- version: string;
975
- /**
976
- * Returns a library in debug mode as a {@link DebugLibrary} object.
1588
+ * @example
1589
+ * const metax = includeLib("/lib/metaxploit.so");
1590
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
977
1591
  *
978
- * A valid Neurobox engineer's username and password are required to access this mode.
1592
+ * const metaLib = metax.load("/lib/init.so");
1593
+ * if (!metaLib) exit("Failed to load the library");
979
1594
  *
980
- * If successful, the {@link DebugLibrary} object is returned; in case of an error, a string with details is provided. */
981
- debugTools(user: string, password: string): DebugLibrary | string;
982
- /**
983
- * Returns by default a boolean indicating whether the library has been patched.
1595
+ * const addresses = metax.scan(metaLib) ?? [];
1596
+ * for (const address of addresses) {
1597
+ * const info = metax.scanAddress(metaLib, address);
1598
+ * if (!info) continue;
984
1599
  *
985
- * True indicates that the library has been patched, while false indicates that it has not.
1600
+ * const segments = info.split("Unsafe check: ").slice(1);
1601
+ * for (const segment of segments) {
1602
+ * const labelStart = segment.indexOf("<b>")!;
1603
+ * const labelEnd = segment.indexOf("</b>")!;
986
1604
  *
987
- * If the getdate parameter is set to true, the function will return a string containing the date of the last patch. The data format is as follows: `dd/MM/yyyy`.
1605
+ * const unsecZone = segment.slice(labelStart + 3, labelEnd);
988
1606
  *
989
- * Additionally if there is any error the return value will be a string.
1607
+ * const result = metaLib.overflow(address, unsecZone);
1608
+ * // Do stuff with result...
1609
+ * }
1610
+ * }
990
1611
  */
991
- isPatched(getDate?: boolean): boolean | string;
1612
+ scanAddress(metaLib: MetaLib, memoryAddress: string): string | null;
992
1613
  /**
993
- * Exploits vulnerabilities in target systems by executing various attack vectors against libraries located in the `/lib` folder.
994
- *
995
- * The function requires a memory address, vulnerability identifier, and optional arguments that are mandatory for password changes (new password) and computer exploits (LAN IP address).
996
- *
997
- * The system validates that the target library exists and is properly located in the `/lib` directory before proceeding otherwise it will return null.
998
- *
999
- * If the network where the library is located is disabled, the function returns a string indicating the network status.
1000
- *
1001
- * The exploit will fail and return null if the target is behind a firewall or if any of the specific vulnerability requirements aren't met, such as insufficient registered users, missing required libraries with correct versions, inadequate port forwards, absence of required user types like active guests or root users, or invalid file paths.
1002
- *
1003
- * If the target vulnerability is identified as a zero-day exploit, the system will load the appropriate zero-day vulnerability before execution.
1004
- *
1005
- * During execution, if a super admin intercepts the exploit attempt, user privileges are automatically lowered to guest level.
1006
- *
1007
- * Shell exploits, once all requirements are met, always return a shell object.
1008
- *
1009
- * Random folder exploits return a file object if the specified path exists or null if the folder cannot be found.
1614
+ * The terminal listens to the network packets of any connection that passes through the computer.
1010
1615
  *
1011
- * Password change exploits return true for successful password modification or false for failure due to guest user restrictions, invalid alphanumeric format, or exceeding the 15-character limit.
1616
+ * When any connection information gets captured, it will print a string with the obtained data.
1012
1617
  *
1013
- * Settings override exploits work only on smart appliances like fridges or microwaves and return true for success or false for failure.
1618
+ * In case saving of encryption source is enabled it will download the source code of the script responsible for encryption.
1014
1619
  *
1015
- * Traffic light exploits require targets on the police station's network and return true for success or false for failure.
1620
+ * In case the operation fails this method will return null.
1016
1621
  *
1017
- * Firewall exploits need router targets and return true for success or false for failure.
1622
+ * Using this method within a SSH encryption process will throw a runtime exception.
1018
1623
  *
1019
- * Computer exploits return a computer object when successful or false if the LAN IP is invalid, the computer doesn't exist, or no non-root user is available.
1624
+ * @example
1625
+ * const metax = includeLib("/lib/metaxploit.so");
1626
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1020
1627
  *
1021
- * Using {@link isType} or {@link getType} to verify return value types is essential before processing results due to the variety of possible return types.
1628
+ * metax.sniffer()
1022
1629
  */
1023
- overflow(memoryAddress: string, unsecZone: string, optArgs?: string): Shell | Computer | File | string | boolean | null;
1630
+ sniffer(saveEncSource?: boolean): string | null;
1024
1631
  }
1025
- interface DebugLibrary {
1026
- classID: "debugLibrary";
1027
- /**
1028
- * Applies a patch containing corrected code to the specified text file at the provided path.
1029
- *
1030
- * Returns a string with the result of the operation.
1031
- */
1032
- applyPatch(path: string): string;
1632
+ }
1633
+ declare namespace GreyHack {
1634
+ interface NetSession {
1635
+ classID: "NetSession";
1033
1636
  /**
1034
- * Returns a list containing a single partial computer object if zero-day vulnerabilities are detected within the specified memory zone.
1035
- *
1036
- * If a file path is provided, a partial file object associated with this path will also be included in the array.
1637
+ * Returns the {@link MetaLib} associated with the remote service.
1037
1638
  *
1038
- * Additionally, if this file is a library, its corresponding metaLib object is added to the returned array.
1639
+ * For example if the {@link Metaxploit} method netUse was used on a ssh port it will return the MetaLib related to the ssh service. In case the port was zero is will return a MetaLib related to the kernel router.
1039
1640
  *
1040
- * In case of an error, a string with details is returned.
1041
- */
1042
- payload(memZone: string): string | [Partial<Computer>];
1043
- payload(memZone: string, filePath: string): string | [Partial<Computer>, Partial<File>] | [Partial<Computer>, Partial<File>, MetaLib];
1044
- /**
1045
- * Scans the library in debug mode to identify potential code errors that may lead to vulnerabilities.
1641
+ * @example
1642
+ * const metax = includeLib("/lib/metaxploit.so");
1643
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1046
1644
  *
1047
- * If issues are detected, the relevant code snippets are printed. In case of an error, a string containing the error message is returned.
1048
- */
1049
- scan(): string;
1050
- /**
1051
- * Conducts automated tests on the specified lines of code.
1645
+ * const targetRouter = getRouter("1.1.1.1");
1646
+ * if (!targetRouter) exit("Failed to get target router");
1052
1647
  *
1053
- * If potential vulnerabilities are detected due to errors in these lines, this method will print partial objects that could be obtained by exploiting the vulnerability, along with the affected memory zone and detailed vulnerability information.
1648
+ * const ports = targetRouter.usedPorts();
1649
+ * for (const port of ports) {
1650
+ * if (port.isClosed()) continue;
1054
1651
  *
1055
- * In case of failure, this function returns a string with an error message.
1056
- */
1057
- unitTesting(errorLines: number[]): string;
1058
- }
1059
- interface Crypto {
1060
- classID: "cryptoLib";
1061
- /**
1062
- * Returns a string containing the password based on the file which was generated via aireplay.
1652
+ * const netSession = metax.netUse(targetRouter.publicIp, port.portNumber);
1653
+ * if (!netSession) continue;
1063
1654
  *
1064
- * In case of failure, it will return null instead. If the provided path is empty, an error will be thrown, interrupting the script execution.
1655
+ * const metaLib = netSession.dumpLib();
1656
+ * console.log(`Library: ${metaLib.libName}-${metaLib.version}`);
1657
+ * }
1065
1658
  */
1066
- aircrack(path: string): string | null;
1659
+ dumpLib(): MetaLib;
1067
1660
  /**
1068
- * Used to inject frames on wireless interfaces.
1661
+ * Initiates a DDoS attack targeting the computer associated with the currently active NetSession object.
1069
1662
  *
1070
- * Once the command with `Control+C` is stopped, it will save the captured information in a text file called `file.cap` in the path where the terminal is currently located.
1663
+ * To successfully force a reboot, there must be at least 4 concurrent floodConnection calls for every 1 unit of net speed on the target computer. Keep in mind that these calls need to come from different IPs. So for example PackS would require 12 active floodConnection calls. If the threshold is met, the target computer will be forced to reboot, and the terminal will output: `remote connection interrupted`.
1071
1664
  *
1072
- * Alternatively, a maximum of captured acks can be specified for the command to stop automatically, saving the `file.cap` file as described above.
1665
+ * This method always returns null and only prints a message upon a successful attack.
1073
1666
  *
1074
- * To figure out how many ACKs are required, you can use the following formula: `300000 / (Power + 15)`.
1667
+ * @example
1668
+ * const metax = includeLib("/lib/metaxploit.so");
1669
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1075
1670
  *
1076
- * If there is an error, a string will be returned with the message indicating the problem. On success, it will return null, it is advised though to verify that the capture file actually exists.
1671
+ * const targetRouter = getRouter("1.1.1.1");
1672
+ * if (!targetRouter) exit("Failed to get target router");
1077
1673
  *
1078
- * In case any of the provided values deviate from the signature types or bssid/essid is empty, an error will be thrown preventing any further script execution.
1079
- */
1080
- aireplay(bssid: string, essid: string, maxAcks?: number): string | null;
1081
- /**
1082
- * Enables or disables the monitor mode of a network device.
1674
+ * const ports = targetRouter.usedPorts();
1675
+ * for (const port of ports) {
1676
+ * if (port.isClosed()) continue;
1083
1677
  *
1084
- * Monitor mode can only be enabled on Wifi cards.
1678
+ * const netSession = metax.netUse(targetRouter.publicIp, port.portNumber);
1679
+ * if (!netSession) continue;
1085
1680
  *
1086
- * If it wasn't possible to enable or disable the monitor mode, this method will return either false or a string with details. In case of success, it will return true.
1087
- */
1088
- airmon(option: "start" | "stop", device: netDevice): boolean | string;
1681
+ * netSession.floodConnection();
1682
+ * }
1683
+ */
1684
+ floodConnection(): null;
1089
1685
  /**
1090
- * Returns a decrypted password via the provided password MD5 hash.
1091
- *
1092
- * Keep in mind that this method is not decrypting a password but rather checking for existing passwords within the game world with a matching MD5 hash.
1093
- *
1094
- * So in case a password does not exist in the game world, the decryption will fail.
1686
+ * Returns the number of devices using this router as a gateway. If you obtained your NetSession from a computer, it will fetch and return the value from its gateway router.
1095
1687
  *
1096
- * On failure, this method will return null. Using this method in an SSH encryption process will cause an error to be thrown, aborting further script execution.
1097
1688
  * @example
1098
- * const crypto = includeLib("/lib/crypto.so");
1099
- * if (!isType(crypto, "cryptoLib")) exit("Failed to load crypto.so");
1689
+ * const metax = includeLib("/lib/metaxploit.so");
1690
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1100
1691
  *
1101
- * const computer = getShell().hostComputer;
1102
- * const passwdFile = computer.file("/etc/passwd");
1103
- * if (!passwdFile) exit("Failed to get passwd file");
1104
- *
1105
- * const lines = passwdFile.getContent()!.split(char(10));
1106
- * for (const line of lines) {
1107
- * const parsed = line.split(":");
1108
- * const username = parsed[0];
1109
- * const passwordhash = parsed[1];
1692
+ * const targetRouter = getRouter("1.1.1.4");
1693
+ * if (!targetRouter) exit("Failed to get target router");
1110
1694
  *
1111
- * const password = crypto.decipher(passwordhash);
1112
- * print(`Password for user '${username}' is: ${password}`);
1695
+ * const ports = targetRouter.usedPorts();
1696
+ * const netSession = metax.netUse(targetRouter.publicIp, ports[0].portNumber);
1697
+ * if (netSession) {
1698
+ * console.log("Gateway clients: " + netSession.getNumConnGateway())
1113
1699
  * }
1114
1700
  */
1115
- decipher(hash: string): string | null;
1701
+ getNumConnGateway(): number;
1116
1702
  /**
1117
- * Decrypts the specified file using the provided key.
1703
+ * Returns the number of ports forwarded by this router. If you obtained your NetSession from a computer, it will fetch and return the value from its gateway router.
1118
1704
  *
1119
- * On success, the method returns true. If decryption fails, a descriptive error message is returned as a string.
1120
- */
1121
- decrypt(filePath: string, password: string): true | string;
1122
- /**
1123
- * Encrypts the specified file using the provided key.
1705
+ * @example
1706
+ * const metax = includeLib("/lib/metaxploit.so");
1707
+ * if (!isType(metax, "MetaxploitLib")) exit("Failed to get metaxploit");
1124
1708
  *
1125
- * On success, the method returns true. If encryption fails, a descriptive error message is returned as a string.
1709
+ * const targetRouter = getRouter("1.1.1.4");
1710
+ * if (!targetRouter) exit("Failed to get target router");
1711
+ *
1712
+ * const ports = targetRouter.usedPorts();
1713
+ * const netSession = metax.netUse(targetRouter.publicIp, ports[0].portNumber);
1714
+ * if (netSession) {
1715
+ * console.log("Port forwards: " + netSession.getNumPortforward())
1716
+ * }
1126
1717
  */
1127
- encrypt(filePath: string, password: string): true | string;
1128
- /**
1129
- * Checks whether the specified file is encrypted.
1130
- *
1131
- * Returns true if the file is encrypted, or false if it is not. If the check fails (e.g., due to a missing or unreadable file), a descriptive error message is returned as a string.
1132
- */
1133
- isEncrypted(filePath: string): boolean | string;
1134
- /**
1135
- * Returns an array of the existing users on the computer where the SMTP service is running.
1136
- *
1137
- * If these users also have an email account registered on the SMTP server, it will be indicated in the array.
1138
- *
1139
- * SMTP services are usually running on port 25. In case of failure, this method will return a string containing the cause.
1140
- */
1141
- smtpUserList(ip: string, port: number): string[] | string;
1142
- }
1143
- interface BlockChain {
1144
- classID: "blockchainLib";
1145
- /**
1146
- * Returns a number representing the total amount of mined coins.
1147
- *
1148
- * In case of an error, it will return a string with the details.
1149
- * @example
1150
- * const blockChain = includeLib("/lib/blockchain.so");
1151
- * if (!isType(blockChain, "blockchainLib"))
1152
- * exit("Failed to get blockchain.so");
1153
- *
1154
- * const mined = blockChain.amountMined("bitcoin");
1155
- * if (isType(mined, "string"))
1156
- * exit(`Coudn't get the amount of mined coin: ${mined}`);
1157
- *
1158
- * print(`There are ${mined} coins mined for this coin`);
1159
- */
1160
- amountMined(coinName: string): number | string;
1161
- /**
1162
- * Returns a number representing the current unit value of the cryptocurrency.
1163
- *
1164
- * In case of an error, a string with the error details will be returned.
1165
- */
1166
- coinPrice(coinName: string): number | string;
1167
- /**
1168
- * Creates a wallet and returns a wallet object on success, which can be used to manage cryptocurrencies.
1169
- *
1170
- * In case of an error, it will return a string with the details.
1171
- */
1172
- createWallet(user: string, password: string): Wallet | string;
1173
- /**
1174
- * Removes a cryptocurrency from the world. The credentials used in the creation of the cryptocurrency are required.
1175
- *
1176
- * On success, it will return a true.
1177
- *
1178
- * On failure, it will return a string containing details.
1179
- */
1180
- deleteCoin(coinName: string, user: string, password: string): true | string;
1181
- /**
1182
- * Returns a coin object used to manage the currency.
1183
- *
1184
- * In case of an error, it will return a string with the details.
1185
- */
1186
- getCoin(coinName: string, user: string, password: string): Coin | string;
1187
- /**
1188
- * Returns a string with the name of the coin owned by the player.
1189
- *
1190
- * In case of an error, it returns a string with details.
1191
- */
1192
- getCoinName(user: string, password: string): string;
1193
- /** Returns a wallet object on success. In case of an error, it will return a string indicating the reason. */
1194
- loginWallet(user: string, password: string): Wallet | string;
1195
- /**
1196
- * Returns an object with the latest changes in the value of a specific cryptocurrency.
1197
- *
1198
- * The key of the object is an index represented by a number. The value is an array, where index 0 is the historical price of the coin and index 1 is the date when the price change occurred.
1199
- *
1200
- * If no coin exists with this name, the method will return null.
1201
- */
1202
- showHistory(coinName: string): Record<number, [number, string]> | string | null;
1203
- }
1204
- interface AptClient {
1205
- classID: "aptClientLib";
1206
- /**
1207
- * Inserts a repository address into the `/etc/apt/sources.txt` file.
1208
- *
1209
- * On success, it will return an empty string. In case of failure, it will return a string with an error message.
1210
- */
1211
- addRepo(repositoryAddress: string, port?: number): string;
1212
- /**
1213
- * Checks if there is a newer version of the program or library in the repository.
1214
- *
1215
- * On success, it will return a boolean, with false indicating that there is no new version, while true indicates that there is a new version available.
1216
- *
1217
- * In case of failure, it will return a string containing an error message.
1218
- */
1219
- checkUpgrade(filePath: string): boolean | string;
1220
- /**
1221
- * Deletes a repository address from the `/etc/apt/sources.txt` file.
1222
- *
1223
- * On success, it will return an empty string. In case of failure, it will return a string with an error message.
1224
- */
1225
- delRepo(repositoryAddress: string): string;
1226
- /**
1227
- * Installs a program or library from a remote repository listed in `/etc/apt/sources.txt`.
1228
- *
1229
- * If no path is specified, the program installs in `/lib` if it is a library or in `/bin` otherwise.
1230
- *
1231
- * On success, this method will return true. In case of failure, it will return a string containing an error message.
1232
- */
1233
- install(package: string, installPath?: string): true | string;
1234
- /**
1235
- * Search specifically looks for a package in any of the repositories listed in `/etc/apt/sources.txt`.
1236
- *
1237
- * On success, it will return a string containing all packages that partially match the provided search value.
1238
- *
1239
- * On failure, it will return a string with various error messages.
1240
- */
1241
- search(package: string): string;
1242
- /**
1243
- * Show displays all the packages available in a repository. The repository must be listed in the `/etc/apt/sources.txt` file.
1244
- *
1245
- * If it cannot find a repository, it will return various error messages.
1246
- *
1247
- * On success, it will return a string containing all packages and their descriptions, with each entry separated by a newline.
1248
- */
1249
- show(repositoryAddress: string): string;
1250
- /**
1251
- * Update refreshes the list of available packages after adding a new repository in `/etc/apt/sources.txt`, or if the remote repository has updated its information in `/server/conf/repod.conf`.
1252
- *
1253
- * If the update is successful, an empty string will be returned. In case of failure, a string with an error message will be returned.
1254
- *
1255
- * If for some reason the `/etc/apt/sources.txt` is malformed this method will return false.
1256
- */
1257
- update(): string | false;
1258
- }
1259
- interface SmartAppliance {
1260
- classID: "SmartAppliance";
1261
- /** Returns a string with the appliance model ID. */
1262
- model(): string;
1263
- /**
1264
- * Overrides the power and temperature settings of the appliance.
1265
- *
1266
- * If successful, true is returned; otherwise, it returns a string detailing the error.
1267
- */
1268
- overrideSettings(power: number, temperature: number): true | string;
1269
- /**
1270
- * Activates or deactivates the sound alarm indicating any appliance malfunction.
1271
- *
1272
- * If successful, true is returned; otherwise, a string containing error details is returned.
1273
- */
1274
- setAlarm(enable: boolean): true | string;
1275
- }
1276
- interface TrafficNet {
1277
- classID: "TrafficNet";
1278
- /**
1279
- * Accesses the traffic camera system, opening a window with controls to switch between different cameras.
1280
- *
1281
- * If the window opens successfully, this method returns true. In case of an error, it returns a string with details.
1282
- */
1283
- cameraLinkSystem(): true | string;
1284
- /** Returns string which contains job and name of a NPC. If an error occurs, a string with details is returned. */
1285
- getCredentialsInfo(): string;
1286
- /**
1287
- * Performs a search for the specified license plate to locate the vehicle.
1288
- *
1289
- * If the vehicle is visible on any camera, the viewer will switch to the camera currently displaying it and return true.
1290
- *
1291
- * If the vehicle cannot be located or the license plate is incorrect, a string indicating the error is returned.
1292
- */
1293
- locateVehicle(licensePlate: string, password: string): true | string;
1294
- }
1295
- }
1296
- interface Math {
1297
- /** Returns the value of pi to the precision of 6 */
1298
- readonly PI: number;
1299
- /** Returns the absolute value of number. */
1300
- abs(value: number): number;
1301
- /** Returns the inverse cosine (in radians) of a number. */
1302
- acos(value: number): number;
1303
- /** Returns the inverse sine (in radians) of a number. */
1304
- asin(value: number): number;
1305
- /** Returns the inverse tangent (in radians) of a number. */
1306
- atan(y: number, x?: number | undefined): number;
1307
- /** Returns number rounded up to the integer value of the provided number. */
1308
- ceil(value: number): number;
1309
- /** Returns number rounded down to the integer value of the provided number. */
1310
- floor(value: number): number;
1311
- /** Returns the cosine of a number in radians. */
1312
- cos(value: number): number;
1313
- /** Returns the sine of a number in radians. */
1314
- sin(value: number): number;
1315
- /** Returns the tangent of a number in radians. */
1316
- tan(value: number): number;
1317
- /** Returns the square root of a number. */
1318
- sqrt(value: number): number;
1319
- /** Returns 1 or -1 indicating the sign of the value passed or 0 if the value is 0 */
1320
- sign(value: number): -1 | 0 | 1;
1321
- /** Returns number rounded to the integer value of the provided number. */
1322
- round(value: number, fixed?: number | undefined): number;
1323
- /** Returns a random number between 0 and 1. Optionally a seed number can be provided. */
1324
- random(seed?: number | undefined): number;
1325
- /**
1326
- * Returns the natural logarithm of a number.
1327
- *
1328
- * By default, the base is 10. Optionally the base can be changed.
1329
- */
1330
- log(value: number, base?: number | undefined): number;
1331
- /** Returns the smallest number of the given values */
1332
- min(...values: number[]): number;
1333
- /** Returns the largest number of the given values */
1334
- max(...values: number[]): number;
1335
- }
1336
- declare var Math: Math;
1337
- declare namespace GreyHack {
1338
- interface CtfEvent {
1339
- classID: "ctfEvent";
1340
- /** Returns string with the name of the CTF event creator. */
1341
- getCreatorName(): string;
1342
- /** Returns string with the CTF event description. */
1343
- getDescription(): string;
1344
- /** Returns string with the mail content of the CTF event. */
1345
- getMailContent(): string;
1346
- /** Returns string with the CTF event template. */
1347
- getTemplate(): string;
1348
- /** Returns a boolean indicating if the CTF event got completed successfully */
1349
- playerSuccess(): boolean;
1350
- }
1351
- interface MetaMail {
1352
- classID: "MetaMail";
1353
- /**
1354
- * Delete the email corresponding to the provided email ID.
1355
- *
1356
- * Returns true if the email removal was successful. Otherwise, a string with an error message will be returned.
1357
- */
1358
- delete(mailId: string): true | string;
1359
- /**
1360
- * Returns an array where each item is a string containing mail id, from, subject and a small preview of the content consisting of the first 125 characters.
1361
- *
1362
- * If there is any issue a string will be returned with details.
1363
- */
1364
- fetch(): string[] | string;
1365
- /**
1366
- * Returns a string containing the content of a mail related to the provided mail id.
1367
- *
1368
- * The mail id argument can be obtained with fetch. In case the mail cannot be found this method will return `Mail not found`.
1369
- */
1370
- read(mailId: string): string;
1371
- /**
1372
- * Send a new mail to the provided email address.
1373
- *
1374
- * Keep in mind that the subject can not exceed 128 characters and the message size should not exceed 2500 characters.
1375
- *
1376
- * @returns true indicating that the mail has been sent correctly, or a string with an error
1377
- */
1378
- send(emailAddress: string, subject: string, message: string): string | true;
1379
- }
1380
- interface NetSession {
1381
- classID: "NetSession";
1382
- /**
1383
- * Returns the {@link MetaLib} associated with the remote service.
1384
- *
1385
- * For example if the {@link Metaxploit} method netUse was used on a ssh port it will return the MetaLib related to the ssh service. In case the port was zero is will return a MetaLib related to the kernel router.
1386
- */
1387
- dumpLib(): MetaLib;
1388
- /**
1389
- * Initiates a DDoS attack targeting the computer associated with the currently active NetSession object.
1390
- *
1391
- * To successfully force a reboot, there must be at least 4 concurrent floodConnection calls for every 1 unit of net speed on the target computer. Keep in mind that these calls need to come from different IPs. So for example PackS would require 12 active floodConnection calls. If the threshold is met, the target computer will be forced to reboot, and the terminal will output: `remote connection interrupted`.
1392
- *
1393
- * This method always returns null and only prints a message upon a successful attack.
1394
- */
1395
- floodConnection(): null;
1396
- /** Returns the number of devices using this router as a gateway. If you obtained your NetSession from a computer, it will fetch and return the value from its gateway router. */
1397
- getNumConnGateway(): number;
1398
- /** Returns the number of ports forwarded by this router. If you obtained your NetSession from a computer, it will fetch and return the value from its gateway router. */
1399
- getNumPortforward(): number;
1400
- /** Returns the number of user accounts on the system. */
1401
- getNumUsers(): number;
1402
- /** Return a boolean indicating if there is an active user on the system */
1403
- isAnyActiveUser(): boolean;
1404
- /** Return a boolean indicating if there is an active root user on the system */
1405
- isRootActiveUser(): boolean;
1406
- }
1407
- interface Port {
1408
- classID: "port";
1409
- /** Port number used by this port */
1410
- portNumber: number;
1411
- /** Returns a boolean, where true indicates that the specified port is closed and false indicates that the port is open. */
1412
- isClosed(): boolean;
1413
- /** Returns a string containing the local IP address of the computer to which the port is pointing. */
1414
- getLanIp(): string;
1415
- }
1416
- interface Router {
1417
- classID: "router";
1418
- /** BSSID value of the router */
1419
- bssidName: string;
1420
- /** ESSID value of the router */
1421
- essidName: string;
1422
- /** Version of the `kernel_router.so` library */
1423
- kernelVersion: string;
1424
- /** Local IP address of the router. */
1425
- localIp: string;
1426
- /** Public IP address of the router. */
1427
- publicIp: string;
1428
- /**
1429
- * Returns an array where each item is an open port related to the device of the provided LAN IP address. The device needs to be within the network of the router.
1430
- *
1431
- * In case of failure, this method will return null or a string with details. In case an empty ip is provided this method will throw a runtime exception.
1432
- */
1433
- devicePorts(ip: string): Port[] | string | null;
1434
- /**
1435
- * Returns an array where each item is a string representing a LAN IP address.
1436
- *
1437
- * All devices are within the network of the router and can be reached by using the ping method. Some of the devices might be behind a firewall.
1438
- */
1439
- devicesLanIp(): string[];
1440
- /** Returns an array where each item is a string containing a firewall rule. */
1441
- firewallRules(): string[];
1442
- /** Returns a {@link Port} that is behind the port number provided. In case the port does not exist null gets returned. */
1443
- pingPort(portNumber: number): Port | null;
1444
- /**
1445
- * Returns a string with information about the provided port, including details about the running service and its version.
1446
- *
1447
- * For example, the output could be `http 1.0.0`. If the operation fails, null will be returned.
1448
- */
1449
- portInfo(port: Port): string | null;
1450
- /** Returns an array where each item is a {@link Port} used inside the router. */
1451
- usedPorts(): Port[];
1452
- }
1453
- interface FtpShell {
1454
- classID: "ftpShell";
1455
- /** Returns a computer related to the shell. */
1456
- hostComputer: FtpComputer;
1457
- /**
1458
- * Send a file to the computer related to the provided shell.
1459
- *
1460
- * You require permission to read the file on the computer from which you are uploading and write permissions in the folder of the computer you are trying to upload to.
1461
- *
1462
- * Via the optional isUpload parameter you can define the direction.
1463
- *
1464
- * In case of failure, this method will return a string with the cause. Otherwise, true will be returned. In case the string for sourceFile or destinationFolder is empty, an error will be thrown, preventing further script execution. Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
1465
- */
1466
- scp: Shell["scp"];
1467
- }
1468
- interface Shell {
1469
- classID: "shell";
1470
- /** Returns a computer related to the shell. */
1471
- hostComputer: Computer;
1472
- /**
1473
- * Compiles a plain code file provided in the arguments to a binary.
1474
- *
1475
- * On success, the new binary will be available under the provided build folder. The binary name will be the same as the source file just without the file extension. Optionally, an allowImport flag can be set which enables the use of import_code on the binary. All provided paths must be absolute. Returns an empty string on success. On failure, it will return a string containing details about the reason for failure.
1476
- *
1477
- * In case any provided values deviate from the defined signature a runtime exception will be thrown.
1478
- */
1479
- build(sourcePath: string, binaryPath: string, allowImport?: boolean): string;
1480
- /**
1481
- * Returns a shell if the connection attempt to the provided IP was successful.
1482
- *
1483
- * This method can only connect to ports running an SSH or FTP service. SSH services usually run on port 22 and FTP services usually on port 21. Keep in mind to pass the right service value depending on which service is going to be used. By default, it will use SSH as the service. Please note that connecting will leave a log entry.
1484
- *
1485
- * In case of failure, a string is returned containing details. If this method is run in an SSH encryption process, or if the computer is not connected to the internet, a runtime exception will be thrown.
1486
- */
1487
- connectService(ip: string, port: number, user: string, password: string, service?: "ssh" | "ftp"): Shell | FtpShell | string | null;
1488
- /**
1489
- * Launches the binary located at the provided path.
1490
- *
1491
- * Optionally, parameters can be passed. Returns a boolean indicating the success of the launch. In some cases, a string will be returned containing an error message.
1492
- *
1493
- * If you need to share variables between a launched script and the current process, consider using {@link getCustomObject}.
1494
- *
1495
- * Note that launching a script is not asynchronous, meaning that the current script will pause its execution until the launched script finishes. If any provided values deviate from the method signature or it is used within an SSH encryption process, a runtime exception will be thrown.
1496
- *
1497
- * There is a cooldown of 2 seconds between launches to prevent abuse. If you attempt to launch a script during this cooldown period, the method will return false.
1498
- */
1499
- launch(program: string, params?: string): string | boolean;
1500
- /**
1501
- * Pings an IP address.
1502
- *
1503
- * Return a boolean indicating if the remote address could be reached. Firewalls do not block ping requests. Passing an invalid ip will cause the method to return a string with an error message.
1504
- */
1505
- ping(ip: string): string | boolean;
1506
- /**
1507
- * Send a file to the computer related to the provided shell.
1508
- *
1509
- * You require permission to read the file on the computer from which you are uploading and write permissions in the folder of the computer you are trying to upload to.
1510
- *
1511
- * Via the optional isUpload parameter you can define the direction.
1512
- *
1513
- * In case of failure, this method will return a string with the cause. Otherwise, true will be returned. In case the string for sourceFile or destinationFolder is empty, an error will be thrown, preventing further script execution. Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
1514
- */
1515
- scp(file: string, folder: string, remoteShell: Shell, isUpload?: boolean): true | string;
1516
- /**
1517
- * Launches an active terminal.
1518
- *
1519
- * The terminal's color will change, displaying the IP of the connected shell. Script execution will be stopped upon starting a new terminal, unless this is called from another script that was executed via {@link Shell.launch}. In that case, you will enter the shell after closing your root-level script within that terminal window.
1520
- *
1521
- * Using this method within an SSH encryption process will cause an error to be thrown, preventing further script execution.
1522
- */
1523
- startTerminal(): never;
1718
+ getNumPortforward(): number;
1719
+ /** Returns the number of user accounts on the system. */
1720
+ getNumUsers(): number;
1721
+ /** Return a boolean indicating if there is an active user on the system */
1722
+ isAnyActiveUser(): boolean;
1723
+ /** Return a boolean indicating if there is an active root user on the system */
1724
+ isRootActiveUser(): boolean;
1524
1725
  }
1525
1726
  }
1526
- declare const console: {
1527
- readonly log: typeof GreyHack.print;
1528
- readonly clear: typeof GreyHack.clearScreen;
1529
- };
1530
- interface RegExp {
1531
- }
1532
- interface CallableFunction {
1533
- }
1534
- interface NewableFunction {
1535
- }
1536
- interface IArguments {
1537
- }
1538
- interface Boolean {
1539
- }
1540
- interface String {
1541
- /** Returns the length of the string */
1542
- readonly length: number;
1543
- /** Returns the Unicode code of the first character of the string */
1544
- code(): number;
1545
- hasIndex(index: number): boolean;
1546
- indexOf(value: string, offset?: number): number | null;
1547
- indexes(): number[];
1548
- insert(index: number, value: string): string;
1549
- /**
1550
- * Uses regular expression to check if a string matches a certain pattern.
1551
- *
1552
- * If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or if the regular expression times out, an error will be thrown, preventing further script execution.
1553
- */
1554
- isMatch(pattern: string | RegExp, regexOptions?: string): boolean;
1555
- /** Returns the last occurrence of a substring in the string. */
1556
- lastIndexOf(searchString: string): number;
1557
- /** Converts all the alphabetic characters in a string to lowercase. */
1558
- toLowerCase(): string;
1559
- /** Converts all the alphabetic characters in a string to uppercase. */
1560
- toUpperCase(): string;
1561
- /**
1562
- * Returns an object with all search results for the provided regular expression.
1563
- *
1564
- * Each key contains the index and the value contains the matching string.
1565
- *
1566
- * If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or if the regular expression times out, an error will be thrown, preventing further script execution.
1567
- */
1568
- matches(pattern: string | RegExp, regexOptions?: string): Record<number, string>;
1569
- /**
1570
- * Returns a new string with the provided value removed
1571
- * @example
1572
- * const myString = "I will not eat an ice cream!";
1573
- * const newString = myString.remove("not ");
1574
- * print(newString); // Prints "I will eat an ice cream!"
1575
- */
1576
- remove(value: string): string;
1577
- /**
1578
- * Returns a string with the replaced content by using regular expressions.
1579
- *
1580
- * If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid or if the regular expression times out, an error will be thrown, preventing further script execution.
1581
- *
1582
- * @example
1583
- * const myString = "I am now online";
1584
- * const newString = myString.replace("online", "offline");
1585
- * print(newString); // Prints "I am now offline"
1586
- */
1587
- replace(pattern: string | RegExp, newValue: string, regexOptions?: string): string;
1588
- /**
1589
- * Returns an array where each item is a segment of the string, separated by the provided separator string.
1590
- *
1591
- * This method uses regular expressions for matching, so remember to escape special characters such as dots.
1592
- *
1593
- * In case the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or the regular expression times out, an error will be thrown, preventing further script execution.
1594
- *
1595
- * @example
1596
- * const csvString = "cat,turtle,dog,mouse";
1597
- * const animals = csvString.split(",");
1598
- * print(animals); // Prints ["cat", "turtle", "dog", "mouse"]
1599
- */
1600
- split(pattern: string | RegExp, regexOptions?: string): string[];
1601
- /**
1602
- * Returns a number which is parsed from the string as an integer.
1603
- *
1604
- * In case the string is not numeric it will return the original string.
1605
- */
1606
- toInt(): string | number;
1607
- /** Removes the leading and trailing white space characters from a string. */
1608
- trim(): string;
1609
- /** Returns a number which is parsed from the string. In case the string is not numeric it will return a zero. */
1610
- val(): number;
1611
- /** Returns an array where each item is a string representing all available characters in the string. Could be compared to using {@link String.split|split} but with empty separator. */
1612
- values(): string[];
1613
- /** Removes the leading white space characters from a string. */
1614
- trimStart(): string;
1615
- /** Removes the trailing white space characters from a string. */
1616
- trimEnd(): string;
1617
- /**
1618
- * Returns true if searchString appears as a substring of this string, at one or more positions that are greater than or equal to position; otherwise, returns false.
1619
- *
1620
- * @param searchString search string
1621
- * @param position If position is undefined, 0 is assumed, so as to search all of the string.
1622
- */
1623
- includes(searchString: string, position?: number): boolean;
1624
- /** Returns true if this string starts with the searchString. Otherwise returns false. */
1625
- startsWith(searchString: string, position?: number): boolean;
1626
- /** Returns true if this string ends with the searchString. Otherwise returns false. */
1627
- endsWith(searchString: string, endPosition?: number): boolean;
1628
- /**
1629
- * Returns a string value that is made from count copies appended together.
1630
- *
1631
- * If count is 0, the empty string is returned.
1632
- */
1633
- repeat(count: number): string;
1634
- /**
1635
- * Returns a section of a string.
1636
- * @param start The index to the beginning of the specified portion of string.
1637
- * @param end The index to the end of the specified portion of string. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of string.
1638
- */
1639
- slice(start?: number, end?: number): string;
1640
- /** Returns a string representation of a string. */
1641
- toString(): string;
1642
- readonly [index: number]: string;
1643
- }
1644
- interface Number {
1645
- /** Returns a string representation of a number. */
1646
- toString(): string;
1647
- /**
1648
- * Returns a string representing a number in fixed-point notation.
1649
- * @param fractionDigits Number of digits after the decimal point.
1650
- */
1651
- toFixed(fractionDigits?: number): string;
1652
- }
1653
1727
  type PropertyKey = number | string | symbol;
1654
1728
  interface Object {
1655
1729
  /** Returns a string representation of an object. */
@@ -1708,104 +1782,140 @@ interface ObjectConstructor {
1708
1782
  */
1709
1783
  shift<T extends Record<any, any>>(o: T): keyof T | null;
1710
1784
  }
1711
- interface Array<T> {
1785
+ declare var Object: ObjectConstructor;
1786
+ declare namespace GreyHack {
1787
+ interface Port {
1788
+ classID: "port";
1789
+ /** Port number used by this port */
1790
+ portNumber: number;
1791
+ /** Returns a boolean, where true indicates that the specified port is closed and false indicates that the port is open. */
1792
+ isClosed(): boolean;
1793
+ /** Returns a string containing the local IP address of the computer to which the port is pointing. */
1794
+ getLanIp(): string;
1795
+ }
1796
+ }
1797
+ interface RegExp {
1798
+ }
1799
+ interface CallableFunction {
1800
+ }
1801
+ interface NewableFunction {
1802
+ }
1803
+ interface IArguments {
1804
+ }
1805
+ interface Boolean {
1806
+ }
1807
+ interface String {
1808
+ /** Returns the length of the string */
1712
1809
  readonly length: number;
1713
- /** Returns a boolean indicating if the provided index exists in the array */
1810
+ /** Returns the Unicode code of the first character of the string */
1811
+ code(): number;
1714
1812
  hasIndex(index: number): boolean;
1715
- /** Returns the index of the first occurrence of a value in an array, or null if it is not present. */
1716
- indexOf(value: T, offset?: number): number | null;
1717
- /** Returns an array containing the indexes of the array */
1813
+ indexOf(value: string, offset?: number): number | null;
1718
1814
  indexes(): number[];
1719
- /** Inserts a value into the array at the provided index. This method mutates the array and returns a reference to the same array. */
1720
- insert(index: number, value: T): T[];
1815
+ insert(index: number, value: string): string;
1721
1816
  /**
1722
- * Returns a concatenated string containing all stringified values inside the list. These values will be separated via the provided separator.
1817
+ * Uses regular expression to check if a string matches a certain pattern.
1723
1818
  *
1724
- * In case the list exceeds `16777215L` items or the delimiter exceeds 128 characters, this method will throw an error, interrupting further script execution.
1819
+ * If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or if the regular expression times out, an error will be thrown, preventing further script execution.
1725
1820
  */
1726
- join(delimiter: string): string;
1727
- /** Removes the first element from an array and returns it. If the array is empty, null is returned. */
1728
- shift(): T | null;
1729
- /** Inserts new elements at the start of an array, and returns the new length of the array. */
1730
- unshift(...items: T[]): number;
1731
- /** Removes the last element from an array and returns it. If the array is empty, null is returned. */
1732
- pop(): T | null;
1733
- /** Appends new elements to the end of an array, and returns the new length of the array. */
1734
- push(...items: T[]): number;
1821
+ isMatch(pattern: string | RegExp, regexOptions?: string): boolean;
1822
+ /** Returns the last occurrence of a substring in the string. */
1823
+ lastIndexOf(searchString: string): number;
1824
+ /** Converts all the alphabetic characters in a string to lowercase. */
1825
+ toLowerCase(): string;
1826
+ /** Converts all the alphabetic characters in a string to uppercase. */
1827
+ toUpperCase(): string;
1735
1828
  /**
1736
- * Removes an item from the list with the provided index. Due to the removal the list will get mutated.
1829
+ * Returns an object with all search results for the provided regular expression.
1830
+ *
1831
+ * Each key contains the index and the value contains the matching string.
1832
+ *
1833
+ * If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or if the regular expression times out, an error will be thrown, preventing further script execution.
1737
1834
  */
1738
- remove(index: number): null;
1835
+ matches(pattern: string | RegExp, regexOptions?: string): Record<number, string>;
1739
1836
  /**
1740
- * Changes every value of the array that matches `oldValue` into `newValue`
1741
- *
1742
- * This method mutates the array and returns a reference to the same array.
1837
+ * Returns a new string with the provided value removed
1838
+ * @example
1839
+ * const myString = "I will not eat an ice cream!";
1840
+ * const newString = myString.remove("not ");
1841
+ * print(newString); // Prints "I will eat an ice cream!"
1743
1842
  */
1744
- replace(oldValue: T, newValue: T, maxCount?: number): T[];
1745
- /** Reverses the elements in an array in place. This method mutates the array and returns a reference to the same array. */
1746
- reverse(): T;
1747
- /** Shuffles all values in the array. This method mutates the array. */
1748
- shuffle(): null;
1843
+ remove(value: string): string;
1749
1844
  /**
1750
- * Sorts the values of an array alphanumerically.
1845
+ * Returns a string with the replaced content by using regular expressions.
1751
1846
  *
1752
- * This operation mutates the original array. Optionally, a key can be provided, which is used if the items are objects or arrays. Finally, this method returns the updated array.
1753
- * @example
1754
- * const myArray = [{ key: 123 }, { key: 5 }, { key: 17 }];
1755
- * myArray.sort("key");
1847
+ * If the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid or if the regular expression times out, an error will be thrown, preventing further script execution.
1756
1848
  *
1757
- * const numbers = [1,2,3,4,5];
1758
- * numbers.sort()
1849
+ * @example
1850
+ * const myString = "I am now online";
1851
+ * const newString = myString.replace("online", "offline");
1852
+ * print(newString); // Prints "I am now offline"
1759
1853
  */
1760
- sort(key?: PropertyKey | null, ascending?: boolean): T[];
1761
- /** Returns a sum of all values inside the array. Any non-numeric values will be considered a zero. */
1762
- sum(): number;
1763
- values(): T[];
1854
+ replace(pattern: string | RegExp, newValue: string, regexOptions?: string): string;
1764
1855
  /**
1765
- * Changes all array elements from `start` to `end` index to a static `value` and returns the modified array
1766
- * @param value value to fill array section with
1767
- * @param start index to start filling the array at. If start is negative, it is treated as
1768
- * length+start where length is the length of the array.
1769
- * @param end index to stop filling the array at. If end is negative, it is treated as
1770
- * length+end.
1771
- */
1772
- fill(value: T, start?: number, end?: number): this;
1773
- /** Determines whether an array includes a certain element, returning true or false as appropriate. */
1774
- includes(searchElement: T, fromIndex?: number): boolean;
1856
+ * Returns an array where each item is a segment of the string, separated by the provided separator string.
1857
+ *
1858
+ * This method uses regular expressions for matching, so remember to escape special characters such as dots.
1859
+ *
1860
+ * In case the pattern is empty, the provided {@link https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-options|regexOptions} are invalid, or the regular expression times out, an error will be thrown, preventing further script execution.
1861
+ *
1862
+ * @example
1863
+ * const csvString = "cat,turtle,dog,mouse";
1864
+ * const animals = csvString.split(",");
1865
+ * print(animals); // Prints ["cat", "turtle", "dog", "mouse"]
1866
+ */
1867
+ split(pattern: string | RegExp, regexOptions?: string): string[];
1775
1868
  /**
1776
- * Combines two or more arrays. This method returns a new array without modifying any existing arrays.
1777
- * @param items Additional arrays and/or items to add to the end of the array.
1869
+ * Returns a number which is parsed from the string as an integer.
1870
+ *
1871
+ * In case the string is not numeric it will return the original string.
1778
1872
  */
1779
- concat(...items: (T | T[])[]): T[];
1780
- /** Calls a defined callback function on each element of an array, and returns an array that contains the results. */
1781
- map<U>(callbackfn: (value: T, index: number, array: T[]) => U): U[];
1782
- /** Returns the elements of an array that meet the condition specified in a callback function. */
1783
- filter(predicate: (value: T, index: number, array: T[]) => unknown): T[];
1784
- /** Returns the value of the first element in the array where predicate is true, and null otherwise. */
1785
- find(predicate: (value: T, index: number, array: T[]) => unknown): T | null;
1786
- /** Determines whether the specified callback function returns true for any element of an array. */
1787
- some(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
1788
- /** Determines whether all the members of an array satisfy the specified test. */
1789
- every(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
1873
+ toInt(): string | number;
1874
+ /** Removes the leading and trailing white space characters from a string. */
1875
+ trim(): string;
1876
+ /** Returns a number which is parsed from the string. In case the string is not numeric it will return a zero. */
1877
+ val(): number;
1878
+ /** Returns an array where each item is a string representing all available characters in the string. Could be compared to using {@link String.split|split} but with empty separator. */
1879
+ values(): string[];
1880
+ /** Removes the leading white space characters from a string. */
1881
+ trimStart(): string;
1882
+ /** Removes the trailing white space characters from a string. */
1883
+ trimEnd(): string;
1790
1884
  /**
1791
- * Returns a copy of a section of an array. For both start and end, a negative index can be used to indicate an offset from the end of the array.
1885
+ * Returns true if searchString appears as a substring of this string, at one or more positions that are greater than or equal to position; otherwise, returns false.
1792
1886
  *
1793
- * For example, -2 refers to the second to last element of the array.
1794
- * @param start The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.
1795
- * @param end The end index of the specified portion of the array. This is exclusive of the element at the index 'end'. If end is undefined, then the slice extends to the end of the array.
1796
- * */
1797
- slice(start?: number, end?: number): T[];
1887
+ * @param searchString search string
1888
+ * @param position If position is undefined, 0 is assumed, so as to search all of the string.
1889
+ */
1890
+ includes(searchString: string, position?: number): boolean;
1891
+ /** Returns true if this string starts with the searchString. Otherwise returns false. */
1892
+ startsWith(searchString: string, position?: number): boolean;
1893
+ /** Returns true if this string ends with the searchString. Otherwise returns false. */
1894
+ endsWith(searchString: string, endPosition?: number): boolean;
1798
1895
  /**
1799
- * Removes elements from an array and returns the deleted elements.
1896
+ * Returns a string value that is made from count copies appended together.
1800
1897
  *
1801
- * For example, -2 refers to the second to last element of the array.
1802
- * @param start The zero-based location in the array from which to start removing elements
1803
- * @param end The number of elements to remove. Omitting this argument will remove all elements from the start paramater location to end of the array.
1804
- * */
1805
- splice(start: number, deleteCount?: number): T[];
1806
- /** Returns a string representation of an array. */
1898
+ * If count is 0, the empty string is returned.
1899
+ */
1900
+ repeat(count: number): string;
1901
+ /**
1902
+ * Returns a section of a string.
1903
+ * @param start The index to the beginning of the specified portion of string.
1904
+ * @param end The index to the end of the specified portion of string. The substring includes the characters up to, but not including, the character indicated by end. If this value is not specified, the substring continues to the end of string.
1905
+ */
1906
+ slice(start?: number, end?: number): string;
1907
+ /** Returns a string representation of a string. */
1807
1908
  toString(): string;
1808
- [n: number]: T;
1909
+ readonly [index: number]: string;
1910
+ }
1911
+ interface Number {
1912
+ /** Returns a string representation of a number. */
1913
+ toString(): string;
1914
+ /**
1915
+ * Returns a string representing a number in fixed-point notation.
1916
+ * @param fractionDigits Number of digits after the decimal point.
1917
+ */
1918
+ toFixed(fractionDigits?: number): string;
1809
1919
  }
1810
1920
  interface Function {
1811
1921
  /** Returns a string representation of a function. */
@@ -1826,13 +1936,189 @@ declare var Boolean: {
1826
1936
  <T>(value?: T): boolean;
1827
1937
  readonly prototype: Boolean;
1828
1938
  };
1829
- declare var Array: {
1830
- readonly prototype: Array<any>;
1831
- };
1832
1939
  declare var Function: {
1833
1940
  readonly prototype: Function;
1834
1941
  };
1835
- declare var Object: ObjectConstructor;
1942
+ declare namespace GreyHack {
1943
+ interface Router {
1944
+ classID: "router";
1945
+ /** BSSID value of the router */
1946
+ bssidName: string;
1947
+ /** ESSID value of the router */
1948
+ essidName: string;
1949
+ /** Version of the `kernel_router.so` library */
1950
+ kernelVersion: string;
1951
+ /** Local IP address of the router. */
1952
+ localIp: string;
1953
+ /** Public IP address of the router. */
1954
+ publicIp: string;
1955
+ /**
1956
+ * Returns an array where each item is an open port related to the device of the provided LAN IP address. The device needs to be within the network of the router.
1957
+ *
1958
+ * In case of failure, this method will return null or a string with details. In case an empty ip is provided this method will throw a runtime exception.
1959
+ */
1960
+ devicePorts(ip: string): Port[] | string | null;
1961
+ /**
1962
+ * Returns an array where each item is a string representing a LAN IP address.
1963
+ *
1964
+ * All devices are within the network of the router and can be reached by using the ping method. Some of the devices might be behind a firewall.
1965
+ */
1966
+ devicesLanIp(): string[];
1967
+ /** Returns an array where each item is a string containing a firewall rule. */
1968
+ firewallRules(): string[];
1969
+ /** Returns a {@link Port} that is behind the port number provided. In case the port does not exist null gets returned. */
1970
+ pingPort(portNumber: number): Port | null;
1971
+ /**
1972
+ * Returns a string with information about the provided port, including details about the running service and its version.
1973
+ *
1974
+ * For example, the output could be `http 1.0.0`. If the operation fails, null will be returned.
1975
+ */
1976
+ portInfo(port: Port): string | null;
1977
+ /** Returns an array where each item is a {@link Port} used inside the router. */
1978
+ usedPorts(): Port[];
1979
+ }
1980
+ }
1981
+ declare namespace GreyHack {
1982
+ interface Service {
1983
+ classID: "service";
1984
+ /**
1985
+ * Installs the necessary files for the correct functioning of the service and starts it.
1986
+ *
1987
+ * If the installation is completed successfully, it returns true. In case of an error, it returns a string with details.
1988
+ */
1989
+ installService(): true | string;
1990
+ /**
1991
+ * Starts the service and opens its associated port on the local machine.
1992
+ *
1993
+ * The service requires a port forwarded to the router to be accessible from the outside.
1994
+ *
1995
+ * If the service starts correctly, it returns true. In case of an error, it returns a string with details.
1996
+ */
1997
+ startService(): true | string;
1998
+ /**
1999
+ * Stops the service and closes its associated port on the local machine.
2000
+ *
2001
+ * If the service is stopped successfully, it returns true.
2002
+ *
2003
+ * If an error occurs during the process, it returns a string with details. In some cases, the returned value might be false, indicating that the service removal failed.
2004
+ */
2005
+ stopService(): boolean | string;
2006
+ }
2007
+ }
2008
+ declare namespace GreyHack {
2009
+ interface FtpShell {
2010
+ classID: "ftpShell";
2011
+ /** Returns a computer related to the shell. */
2012
+ hostComputer: FtpComputer;
2013
+ /**
2014
+ * Send a file to the computer related to the provided shell.
2015
+ *
2016
+ * You require permission to read the file on the computer from which you are uploading and write permissions in the folder of the computer you are trying to upload to.
2017
+ *
2018
+ * Via the optional isUpload parameter you can define the direction.
2019
+ *
2020
+ * In case of failure, this method will return a string with the cause. Otherwise, true will be returned. In case the string for sourceFile or destinationFolder is empty, an error will be thrown, preventing further script execution. Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
2021
+ */
2022
+ scp: Shell["scp"];
2023
+ }
2024
+ interface Shell {
2025
+ classID: "shell";
2026
+ /** Returns a computer related to the shell. */
2027
+ hostComputer: Computer;
2028
+ /**
2029
+ * Compiles a plain code file provided in the arguments to a binary.
2030
+ *
2031
+ * On success, the new binary will be available under the provided build folder. The binary name will be the same as the source file just without the file extension. Optionally, an allowImport flag can be set which enables the use of import_code on the binary. All provided paths must be absolute. Returns an empty string on success. On failure, it will return a string containing details about the reason for failure.
2032
+ *
2033
+ * In case any provided values deviate from the defined signature a runtime exception will be thrown.
2034
+ */
2035
+ build(sourcePath: string, binaryPath: string, allowImport?: boolean): string;
2036
+ /**
2037
+ * Returns a shell if the connection attempt to the provided IP was successful.
2038
+ *
2039
+ * This method can only connect to ports running an SSH or FTP service. SSH services usually run on port 22 and FTP services usually on port 21. Keep in mind to pass the right service value depending on which service is going to be used. By default, it will use SSH as the service. Please note that connecting will leave a log entry.
2040
+ *
2041
+ * In case of failure, a string is returned containing details. If this method is run in an SSH encryption process, or if the computer is not connected to the internet, a runtime exception will be thrown.
2042
+ */
2043
+ connectService(ip: string, port: number, user: string, password: string, service?: "ssh" | "ftp"): Shell | FtpShell | string | null;
2044
+ /**
2045
+ * Launches the binary located at the provided path.
2046
+ *
2047
+ * Optionally, parameters can be passed. Returns a boolean indicating the success of the launch. In some cases, a string will be returned containing an error message.
2048
+ *
2049
+ * If you need to share variables between a launched script and the current process, consider using {@link getCustomObject}.
2050
+ *
2051
+ * Note that launching a script is not asynchronous, meaning that the current script will pause its execution until the launched script finishes. If any provided values deviate from the method signature or it is used within an SSH encryption process, a runtime exception will be thrown.
2052
+ *
2053
+ * There is a cooldown of 2 seconds between launches to prevent abuse. If you attempt to launch a script during this cooldown period, the method will return false.
2054
+ */
2055
+ launch(program: string, params?: string): string | boolean;
2056
+ /**
2057
+ * Pings an IP address.
2058
+ *
2059
+ * Return a boolean indicating if the remote address could be reached. Firewalls do not block ping requests. Passing an invalid ip will cause the method to return a string with an error message.
2060
+ */
2061
+ ping(ip: string): string | boolean;
2062
+ /**
2063
+ * Send a file to the computer related to the provided shell.
2064
+ *
2065
+ * You require permission to read the file on the computer from which you are uploading and write permissions in the folder of the computer you are trying to upload to.
2066
+ *
2067
+ * Via the optional isUpload parameter you can define the direction.
2068
+ *
2069
+ * In case of failure, this method will return a string with the cause. Otherwise, true will be returned. In case the string for sourceFile or destinationFolder is empty, an error will be thrown, preventing further script execution. Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
2070
+ */
2071
+ scp(file: string, folder: string, remoteShell: Shell, isUpload?: boolean): true | string;
2072
+ /**
2073
+ * Launches an active terminal.
2074
+ *
2075
+ * The terminal's color will change, displaying the IP of the connected shell. Script execution will be stopped upon starting a new terminal, unless this is called from another script that was executed via {@link Shell.launch}. In that case, you will enter the shell after closing your root-level script within that terminal window.
2076
+ *
2077
+ * Using this method within an SSH encryption process will cause an error to be thrown, preventing further script execution.
2078
+ */
2079
+ startTerminal(): never;
2080
+ }
2081
+ }
2082
+ declare namespace GreyHack {
2083
+ interface SmartAppliance {
2084
+ classID: "SmartAppliance";
2085
+ /** Returns a string with the appliance model ID. */
2086
+ model(): string;
2087
+ /**
2088
+ * Overrides the power and temperature settings of the appliance.
2089
+ *
2090
+ * If successful, true is returned; otherwise, it returns a string detailing the error.
2091
+ */
2092
+ overrideSettings(power: number, temperature: number): true | string;
2093
+ /**
2094
+ * Activates or deactivates the sound alarm indicating any appliance malfunction.
2095
+ *
2096
+ * If successful, true is returned; otherwise, a string containing error details is returned.
2097
+ */
2098
+ setAlarm(enable: boolean): true | string;
2099
+ }
2100
+ }
2101
+ declare namespace GreyHack {
2102
+ interface TrafficNet {
2103
+ classID: "TrafficNet";
2104
+ /**
2105
+ * Accesses the traffic camera system, opening a window with controls to switch between different cameras.
2106
+ *
2107
+ * If the window opens successfully, this method returns true. In case of an error, it returns a string with details.
2108
+ */
2109
+ cameraLinkSystem(): true | string;
2110
+ /** Returns string which contains job and name of a NPC. If an error occurs, a string with details is returned. */
2111
+ getCredentialsInfo(): string;
2112
+ /**
2113
+ * Performs a search for the specified license plate to locate the vehicle.
2114
+ *
2115
+ * If the vehicle is visible on any camera, the viewer will switch to the camera currently displaying it and return true.
2116
+ *
2117
+ * If the vehicle cannot be located or the license plate is incorrect, a string indicating the error is returned.
2118
+ */
2119
+ locateVehicle(licensePlate: string, password: string): true | string;
2120
+ }
2121
+ }
1836
2122
  type netDeviceNumbers = 0 | 1 | 2 | 3 | 4;
1837
2123
  type wlanDevice = `wlan${netDeviceNumbers}`;
1838
2124
  type ethDevice = `eth${netDeviceNumbers}`;