@grey-ts/types 1.3.0 → 1.4.0
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.
- package/dist/index.d.ts +1073 -97
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,51 +1,212 @@
|
|
|
1
1
|
declare namespace GreyHack {
|
|
2
2
|
interface Coin {
|
|
3
3
|
classID: "coin";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Registers a new account in the coin that can be used to manage services such as stores.
|
|
6
|
+
*
|
|
7
|
+
* It is necessary to provide the PIN of the owner's wallet that wants to register.
|
|
8
|
+
*
|
|
9
|
+
* In case of success, the method will return true. In case of an error, a string with the details is returned.
|
|
10
|
+
*/
|
|
11
|
+
createSubWallet(walletID: string, pin: string, subwalletUser: string, subwalletPassword: string): string | true;
|
|
12
|
+
/** Returns the configured address that will be shown to users who do not have the currency, indicating where they have to register.
|
|
13
|
+
*
|
|
14
|
+
* In case of an error, it returns a string with details.
|
|
15
|
+
*/
|
|
5
16
|
getAddress(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Returns a number representing the defined interval in which each user receives a coin reward when mining.
|
|
19
|
+
*
|
|
20
|
+
* In case of failure, the method will return a string with details.
|
|
21
|
+
*/
|
|
6
22
|
getCycleMining(): number | string;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a number representing the amount of coins that have been mined so far.
|
|
25
|
+
*
|
|
26
|
+
* In case of an error, it returns a string with details.
|
|
27
|
+
*/
|
|
7
28
|
getMinedCoins(): number | string;
|
|
29
|
+
/**
|
|
30
|
+
* Returns a number representing the amount of coins that will be received as a reward after each mining cycle.
|
|
31
|
+
*
|
|
32
|
+
* In case of failure, the method will return a string with details.
|
|
33
|
+
*/
|
|
8
34
|
getReward(): number | string;
|
|
9
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Returns a {@link SubWallet} on success.
|
|
37
|
+
*
|
|
38
|
+
* In case of error, it returns a string with the details.
|
|
39
|
+
*/
|
|
40
|
+
getSubwallet(subwalletUser: string): SubWallet | string;
|
|
41
|
+
/**
|
|
42
|
+
* Returns an array where each item is a {@link SubWallet}, including all the accounts registered in the cryptocurrency.
|
|
43
|
+
*
|
|
44
|
+
* In case of error, it returns a string with the details.
|
|
45
|
+
*/
|
|
10
46
|
getSubwallets(): SubWallet[] | string;
|
|
47
|
+
/** Resets the password of the coin. It returns true if resetting was successful; otherwise, it will return a string. */
|
|
11
48
|
resetPassword(newPassword: string): true | string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Configures a valid address that will be shown to users who do not have the currency, indicating where to register.
|
|
51
|
+
*
|
|
52
|
+
* In case of an error, it returns a string with the details. In case of success, true will be returned.
|
|
53
|
+
*/
|
|
54
|
+
setAddress(address: string): true | string;
|
|
55
|
+
/**
|
|
56
|
+
* Defines the interval (in-game hours) in which each user receives a coin reward when mining.
|
|
57
|
+
*
|
|
58
|
+
* The interval cannot be lower than 1 and not higher than 2160.
|
|
59
|
+
*
|
|
60
|
+
* On success, it will return true. In case of failure, the method will return a string with details.
|
|
61
|
+
*/
|
|
62
|
+
setCycleMining(rateHours: number): true | string;
|
|
63
|
+
/**
|
|
64
|
+
* Assigns the reward that miners will receive after each mining cycle. The reward value has to be above one.
|
|
65
|
+
*
|
|
66
|
+
* On success, it will return true. In case of failure, the method will return a string with details.
|
|
67
|
+
*/
|
|
68
|
+
setReward(coinAmount: number): true | string;
|
|
69
|
+
/**
|
|
70
|
+
* Facilitates a transaction of the currency between the indicated subwallets.
|
|
71
|
+
*
|
|
72
|
+
* In case of an error, a string with the details is returned. In case of success, true will be returned.
|
|
73
|
+
*/
|
|
74
|
+
transaction(subwalletFrom: string, subwalletTo: string, amount: number): true | string;
|
|
16
75
|
}
|
|
17
76
|
interface SubWallet {
|
|
18
77
|
classID: "subwallet";
|
|
19
|
-
|
|
78
|
+
/** Returns a boolean indicating if the credentials are correct. For some cases, this method will return a string with an error message. */
|
|
20
79
|
checkPassword(password: string): true | string;
|
|
80
|
+
/** Returns a string with the name of the wallet to which this subwallet belongs. */
|
|
81
|
+
walletUsername(): string;
|
|
82
|
+
/** Deletes the account registered in the cryptocurrency.
|
|
83
|
+
*
|
|
84
|
+
* Returns a boolean indicating if the deletion was successful. In case of certain failures, this method may return a string with details.
|
|
85
|
+
*/
|
|
21
86
|
delete(): boolean | string;
|
|
87
|
+
/** Returns a number of coins of a given currency. In case of error, a string with the details is returned. */
|
|
22
88
|
getBalance(): number | string;
|
|
89
|
+
/** Returns a string with the information stored by the coin creator. */
|
|
23
90
|
getInfo(): string;
|
|
91
|
+
/** Returns a string with the username associated with this subwallet. On failure, this method returns a string with an error message. */
|
|
24
92
|
getUser(): string;
|
|
93
|
+
/**
|
|
94
|
+
* Returns a list with the information of the last transaction.
|
|
95
|
+
*
|
|
96
|
+
* Index 0 is a string with the other subWallet. Index 1 is an integer with the amount. Index 2 is a number indicating the direction of the transaction (0 for Deposit, 1 for Withdrawal). Index 3 is a string indicating the date of the transaction.
|
|
97
|
+
*
|
|
98
|
+
* On failure, this method will either return false or a string with an error message.
|
|
99
|
+
*/
|
|
25
100
|
lastTransaction(): [string, number, 0 | 1, string] | false | string;
|
|
101
|
+
/**
|
|
102
|
+
* Starts the process of mining the cryptocurrency. The process leaves the terminal busy until a coin is mined.
|
|
103
|
+
*
|
|
104
|
+
* On success, this method will return true. On failure, this method will return a string with details.
|
|
105
|
+
*/
|
|
26
106
|
mining(): true | string;
|
|
107
|
+
/**
|
|
108
|
+
* Stores optional information in the Subwallet for any use.
|
|
109
|
+
*
|
|
110
|
+
* Upon success, true will be returned. In case of failure, a string with details will be returned.
|
|
111
|
+
*/
|
|
27
112
|
setInfo(info: string): true | string;
|
|
28
113
|
}
|
|
29
114
|
interface Wallet {
|
|
30
115
|
classID: "wallet";
|
|
116
|
+
/**
|
|
117
|
+
* Publishes a purchase offer indicating the number of coins you wish to buy and the price ($) per unit you are willing to pay.
|
|
118
|
+
*
|
|
119
|
+
* The purchase will be finalized if there is any sale offer with a price less than or equal to the one proposed in the purchase.
|
|
120
|
+
*
|
|
121
|
+
* If there is no eligible offer to sell at that time, the offer to buy will remain publicly visible until a new offer to sell satisfies the requirements.
|
|
122
|
+
*
|
|
123
|
+
* If the publication has been successful, true is returned. In case of error, a string with the details is returned.
|
|
124
|
+
*/
|
|
31
125
|
buyCoin(coinName: string, coinAmount: number, unitPrice: number, subwalletUser: string): true | string;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Cancel any pending offer of a certain coin.
|
|
128
|
+
*
|
|
129
|
+
* On success, an empty string will be returned. On failure, a string with an error message will be returned.
|
|
130
|
+
*/
|
|
131
|
+
cancelPendingTrade(coinName: string): string;
|
|
132
|
+
/** Returns a number of coins of a given currency. In case of error, a string with the details is returned. */
|
|
133
|
+
getBalance(coinName: string): number | string;
|
|
134
|
+
/**
|
|
135
|
+
* Returns a record with all the offers made by any player of a given currency.
|
|
136
|
+
*
|
|
137
|
+
* The key of the record represents the WalletID of the player who has made the offer, and the value of the record is an array where index 0 represents the type of offer with a string (Buy/Sell), index 1 represents the amount to sell or buy, and index 2 represents the price per unit.
|
|
138
|
+
*
|
|
139
|
+
* In case of failure, this method returns a string with details.
|
|
140
|
+
*/
|
|
141
|
+
getGlobalOffers(coinName: string): string | Record<"Buy" | "Sell", [string, number, number]>;
|
|
142
|
+
/**
|
|
143
|
+
* Returns an array with the pending sale or purchase offer of this wallet for a certain currency.
|
|
144
|
+
*
|
|
145
|
+
* Index 0 of the array represents the type of offer with a string (Buy/Sell), index 1 represents the quantity to be sold or bought, and index 2 represents the price per unit.
|
|
146
|
+
*
|
|
147
|
+
* On failure, this method will return a string with details.
|
|
148
|
+
*/
|
|
149
|
+
getPendingTrade(coinName: string): ["Buy" | "Sell", number, number] | string;
|
|
150
|
+
/** Returns a string with a PIN that refreshes every few minutes. This PIN is used to obtain an account in cryptocurrency services. */
|
|
36
151
|
getPin(): string;
|
|
152
|
+
/**
|
|
153
|
+
* Returns a list where each item is a string with the names of the coins available in the wallet.
|
|
154
|
+
*
|
|
155
|
+
* On failure this method returns a string with an error message.
|
|
156
|
+
*/
|
|
37
157
|
listCoins(): string[] | string;
|
|
158
|
+
/**
|
|
159
|
+
* Returns a list where each item is a string containing the names of all the currencies that exist.
|
|
160
|
+
*
|
|
161
|
+
* In case of failure, this method returns a string with details.
|
|
162
|
+
*/
|
|
38
163
|
listGlobalCoins(): string[] | string;
|
|
39
|
-
|
|
164
|
+
/**
|
|
165
|
+
* Change the password of the wallet. Only the account owner can perform this action.
|
|
166
|
+
*
|
|
167
|
+
* If the process is completed successfully, true will be returned. In case of an error, a string with details will be returned.
|
|
168
|
+
*/
|
|
169
|
+
resetPassword(newPassword: string): true | string;
|
|
170
|
+
/**
|
|
171
|
+
* Publishes a sale offer indicating the amount of coins you want to sell and the price ($) per unit you want to assign.
|
|
172
|
+
*
|
|
173
|
+
* The sale will be finalized if there is any purchase offer with a price greater than or equal to that proposed in the sale. If there is no existing offer to buy that matches the requirements at that time, the offer to sell will remain publicly visible until a new offer to buy satisfies the requirements.
|
|
174
|
+
*
|
|
175
|
+
* If the publication has been successful, true is returned. In case of error, a string with the details is returned.
|
|
176
|
+
*/
|
|
40
177
|
sellCoin(coinName: string, coinAmount: number, unitPrice: number, subwalletUser: string): true | string;
|
|
41
|
-
|
|
178
|
+
/**
|
|
179
|
+
* Returns a number representing the count of devices mining a specific coin for the same wallet.
|
|
180
|
+
*
|
|
181
|
+
* In case of an error, a string with details is returned.
|
|
182
|
+
*/
|
|
183
|
+
showNodes(coinName: string): string | number;
|
|
42
184
|
}
|
|
43
185
|
}
|
|
44
186
|
declare namespace GreyHack {
|
|
45
187
|
interface BaseComputer<FileType extends GreyHack.File | GreyHack.FtpFile> {
|
|
46
188
|
classID: "ftpComputer" | "computer";
|
|
189
|
+
/** Returns the hostname of the machine. */
|
|
47
190
|
getName: () => string;
|
|
48
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Creates a folder at the path provided in the arguments.
|
|
193
|
+
*
|
|
194
|
+
* There are certain limitations to creating a folder: the folder name has to be alphanumeric and below 128 characters. Creation will fail if there is already a folder in place or if there are lacking permissions. Additionally, there is a folder limit of about 250 in each folder and 3125 folders in the computer overall.
|
|
195
|
+
*
|
|
196
|
+
* In case the folder creation fails, the method will return a string with details. In case of success, it will return true.
|
|
197
|
+
*
|
|
198
|
+
* Using this method in an SSH encryption process will cause an error to be thrown, aborting further script execution.
|
|
199
|
+
*/
|
|
200
|
+
createFolder: (path: string, folderName?: string) => string | true;
|
|
201
|
+
/**
|
|
202
|
+
* Returns a file located at the path provided in the argument.
|
|
203
|
+
*
|
|
204
|
+
* The path can be either relative or absolute. It's important to note that any file object can represent a folder as well.
|
|
205
|
+
*
|
|
206
|
+
* If the provided path cannot be resolved, meaning that no file or folder exists, this method will return null.
|
|
207
|
+
*
|
|
208
|
+
* Providing an empty string for the path will result in an error, interrupting the script execution.
|
|
209
|
+
*/
|
|
49
210
|
file: (path: string) => FileType | null;
|
|
50
211
|
}
|
|
51
212
|
interface FtpComputer extends BaseComputer<FtpFile> {
|
|
@@ -53,95 +214,387 @@ declare namespace GreyHack {
|
|
|
53
214
|
}
|
|
54
215
|
interface Computer extends BaseComputer<File> {
|
|
55
216
|
classID: "computer";
|
|
217
|
+
/** The local IP address of the computer */
|
|
56
218
|
localIp: string;
|
|
219
|
+
/** The public IP address of the computer */
|
|
57
220
|
publicIp: string;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
221
|
+
/** Returns `WIFI` or `ETHERNET` depending on the connection type the computer is currently using */
|
|
222
|
+
activeNetCard: () => "WIFI" | "ETHERNET";
|
|
223
|
+
/**
|
|
224
|
+
* Changes the password of an existing user on the computer.
|
|
225
|
+
*
|
|
226
|
+
* Root access is necessary to successfully change the password. Passwords can only include alphanumeric characters and cannot exceed 15 characters. If the password change fails, this method will return a string containing information on why it failed. If the change succeeds, it will return true.
|
|
227
|
+
*
|
|
228
|
+
* If the provided username is empty, an error will be thrown, preventing any further script execution.
|
|
229
|
+
*/
|
|
230
|
+
changePassword: (username: string, password: string) => boolean | string;
|
|
231
|
+
/**
|
|
232
|
+
* Closes a program associated with the provided PID.
|
|
233
|
+
*
|
|
234
|
+
* You can see the list of active programs by either using {@link showProcs} or typing ps into your terminal. To close a program, you need to either be the owner of the running process or root. If closing the program fails, this method will return a string containing details. On success, it will return true. If there is no process with the provided PID, this method will return false.
|
|
235
|
+
*/
|
|
236
|
+
closeProgram: (pid: number) => boolean | string;
|
|
237
|
+
/**
|
|
238
|
+
* Sets up a new IP address on the computer through the Ethernet connection.
|
|
239
|
+
*
|
|
240
|
+
* It's not possible to set up a new IP address while being logged in as a guest. On failure, this method will either return a string with details or null. On success, it will return an empty string.
|
|
241
|
+
*
|
|
242
|
+
* If the computer is not connected to the internet, an error will be thrown, preventing any further script execution.
|
|
243
|
+
*/
|
|
61
244
|
connectEthernet: (netDevice: netDevice, address: string, gateway: string) => string | null;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Connects to the indicated Wi-Fi network.
|
|
247
|
+
*
|
|
248
|
+
* It's not possible to connect to a new Wi-Fi while being logged in as a guest. If connecting to a new Wi-Fi fails, this method will return a string containing details. On success, it will return true.
|
|
249
|
+
*
|
|
250
|
+
* Wi-Fi networks can be found via {@link wifiNetworks} or by typing iwlist as a command in the terminal.
|
|
251
|
+
*/
|
|
252
|
+
connectWifi: (netDevice: netDevice, bssid: string, essid: string, password: string) => true | string;
|
|
253
|
+
/**
|
|
254
|
+
* Creates a new group associated with an existing user on the computer.
|
|
255
|
+
*
|
|
256
|
+
* Root access is necessary to successfully create a group. There are limitations when creating a group, such as a character limit of 15 and that the group name may only contain alphanumeric characters. If the group creation fails, this method will return a string containing the cause of failure. On success, it will return true. If the provided arguments are empty or the username exceeds 15 characters, an error will be thrown, interrupting further script execution.
|
|
257
|
+
*/
|
|
258
|
+
createGroup: (username: string, group: string) => true | string;
|
|
259
|
+
/**
|
|
260
|
+
* Creates a user on the computer with the specified name and password.
|
|
261
|
+
*
|
|
262
|
+
* Root access is necessary to successfully create a user. Both the username and password cannot exceed more than 15 characters and must be alphanumeric. There cannot be more than 15 users created on the same computer. If the creation fails, this method will return a string containing the reason for the failure. On success, it will return true. If the provided username is empty or either of the values exceeds 15 characters, an error will be thrown, interrupting further script execution.
|
|
263
|
+
*/
|
|
264
|
+
createUser: (username: string, password: string) => true | string;
|
|
265
|
+
/**
|
|
266
|
+
* Deletes an existing group associated with an existing user on the computer.
|
|
267
|
+
*
|
|
268
|
+
* Root access is necessary to successfully delete a group. If the group deletion fails, this method will return a string containing the cause of failure. On success, it will return true. If either of the provided values is empty, an error will be thrown, preventing further script execution.
|
|
269
|
+
*/
|
|
270
|
+
deleteGroup: (username: string, group: string) => true | string;
|
|
271
|
+
/**
|
|
272
|
+
* Deletes the indicated user from the computer.
|
|
273
|
+
*
|
|
274
|
+
* Root access is necessary to successfully delete a user. Keep in mind that you cannot delete the root user.
|
|
275
|
+
*
|
|
276
|
+
* If the deletion fails, this method will return a string containing the cause of failure. On success, it will return true. If the provided username is empty, an error will be thrown, interrupting further script execution.
|
|
277
|
+
*
|
|
278
|
+
* @param username the user to remove
|
|
279
|
+
* @param removeHome remove the user's home folder as well
|
|
280
|
+
*/
|
|
281
|
+
deleteUser: (username: string, removeHome?: boolean) => true | string;
|
|
282
|
+
/** Returns an array of ports on the computer that are active. */
|
|
67
283
|
getPorts: () => Port[];
|
|
68
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Returns a string containing groups associated with an existing user on the computer.
|
|
286
|
+
*
|
|
287
|
+
* If the user does not exist, a string with an error message will be returned. If the provided username is empty, an error will be thrown, preventing further script execution.
|
|
288
|
+
*/
|
|
289
|
+
groups: (username: string) => string;
|
|
290
|
+
/** Returns a boolean indicating if the computer has internet access */
|
|
69
291
|
isNetworkActive: () => boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Returns a string containing information about all network devices available on the computer.
|
|
294
|
+
*
|
|
295
|
+
* Each item includes details about the interface name, chipset, and whether monitoring support is enabled.
|
|
296
|
+
*/
|
|
70
297
|
networkDevices: () => string;
|
|
298
|
+
/** Returns a string with the gateway IP address configured on the computer. */
|
|
71
299
|
networkGateway: () => string;
|
|
72
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Reboots the computer. By default, it reboots in standard mode.
|
|
302
|
+
*
|
|
303
|
+
* On success, the method returns true. If the reboot fails, a descriptive error message is returned as a string.
|
|
304
|
+
*
|
|
305
|
+
* Calling this method in an SSH encryption process will trigger an error, halting further script execution.
|
|
306
|
+
*
|
|
307
|
+
* @param safeMode reboot the system in safe mode instead
|
|
308
|
+
*/
|
|
309
|
+
reboot: (safeMode?: boolean) => true | string;
|
|
310
|
+
/**
|
|
311
|
+
* Returns a string with an overview of all active processes on the computer, including information about the user, PID, CPU, memory, and command.
|
|
312
|
+
*
|
|
313
|
+
* Using this method in an SSH encryption process will cause an error to be thrown, preventing any further script execution.
|
|
314
|
+
*/
|
|
73
315
|
showProcs: () => string;
|
|
74
|
-
|
|
316
|
+
/**
|
|
317
|
+
* Creates an empty text file at the provided path.
|
|
318
|
+
*
|
|
319
|
+
* Certain limitations apply to file creation: the file name must be alphanumeric and below 128 characters. Creation will fail if there is already a file in place or if permissions are lacking. Additionally, there is a file limit of about 250 in each folder and 3125 files in the computer overall.
|
|
320
|
+
*
|
|
321
|
+
*
|
|
322
|
+
*
|
|
323
|
+
* Using this method in an SSH encryption process will cause an error to be thrown, preventing any further script execution.
|
|
324
|
+
*/
|
|
325
|
+
touch: (destFolder: string, fileName: string) => true | string;
|
|
326
|
+
/**
|
|
327
|
+
* Returns a list of the Wi-Fi networks that are available for the provided interface.
|
|
328
|
+
*
|
|
329
|
+
* Each item in the list is a string containing information on the BSSID, PWR, and ESSID.
|
|
330
|
+
*
|
|
331
|
+
* If the active network card is not a Wi-Fi card, an error will be thrown, preventing any further script execution.
|
|
332
|
+
*
|
|
333
|
+
* @returns true on success
|
|
334
|
+
* @returns string with details on failure
|
|
335
|
+
* @returns null if no matching netDevice can be found
|
|
336
|
+
*/
|
|
75
337
|
wifiNetworks: (netDevice: netDevice) => string[] | null;
|
|
76
|
-
getName: () => string;
|
|
77
|
-
createFolder: (path: string, folderName?: string) => string | boolean;
|
|
78
338
|
}
|
|
79
339
|
}
|
|
80
340
|
declare namespace GreyHack {
|
|
81
341
|
interface FtpFile extends BaseFile {
|
|
82
342
|
classID: "ftpFile";
|
|
343
|
+
/** The parent folder of the current file or folder */
|
|
83
344
|
parent: FtpFile | null;
|
|
345
|
+
/**
|
|
346
|
+
* Returns an array of files inside this folder.
|
|
347
|
+
*
|
|
348
|
+
* 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.
|
|
349
|
+
*/
|
|
84
350
|
getFiles: () => FtpFile[] | null;
|
|
351
|
+
/**
|
|
352
|
+
* Returns an array of folders inside this folder.
|
|
353
|
+
*
|
|
354
|
+
* 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.
|
|
355
|
+
*/
|
|
85
356
|
getFolders: () => FtpFile[] | null;
|
|
86
357
|
}
|
|
87
358
|
interface File extends BaseFile {
|
|
88
359
|
classID: "file";
|
|
360
|
+
/** The parent folder of the current file or folder */
|
|
89
361
|
parent: File | null;
|
|
362
|
+
/** Indicates if the file is a binary and can be imported by other scripts */
|
|
90
363
|
allowImport: boolean;
|
|
364
|
+
/**
|
|
365
|
+
* Returns an array of files inside this folder.
|
|
366
|
+
*
|
|
367
|
+
* 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.
|
|
368
|
+
*/
|
|
91
369
|
getFiles: () => File[] | null;
|
|
370
|
+
/**
|
|
371
|
+
* Returns an array of folders inside this folder.
|
|
372
|
+
*
|
|
373
|
+
* 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.
|
|
374
|
+
*/
|
|
92
375
|
getFolders: () => File[] | null;
|
|
376
|
+
/**
|
|
377
|
+
* Modifies the file permissions.
|
|
378
|
+
*
|
|
379
|
+
* The format for applying permissions is as follows: `[references][operator][modes]`. The references type is defined through three possible types: user `u`, group `g`, and other `o`. The operator is used to define if permissions get added "+" or removed "-". There are three different modes that can be modified: read `r`, write `w`, and execute `x`. So, for example, `o-wrx` would remove all possible permissions for others. To add all permissions for others again, `o+wrx` would be used.
|
|
380
|
+
*
|
|
381
|
+
* In case the modification fails, this method will return a string containing information about the reason. Otherwise, an empty string is returned.
|
|
382
|
+
*
|
|
383
|
+
* @param recursive set the permissions recursively to every file inside this folder
|
|
384
|
+
*/
|
|
93
385
|
chmod: (perms: string, recursive?: boolean) => string;
|
|
386
|
+
/**
|
|
387
|
+
* Returns a string representing the content of the file. To read a file, the user requires read access or being root.
|
|
388
|
+
*
|
|
389
|
+
* Note that you cannot read a binary file. In case of failure, null will be returned.
|
|
390
|
+
*
|
|
391
|
+
* If this method is used within an SSH encryption process, an error will be thrown, preventing any further script execution.
|
|
392
|
+
*/
|
|
94
393
|
getContent: () => string | null;
|
|
394
|
+
/**
|
|
395
|
+
* Saves text into a file. The content will not get appended to the file; therefore, existing content will be overridden.
|
|
396
|
+
*
|
|
397
|
+
* To set new content, the user requires write permissions or being root. Keep in mind that text files cannot exceed the character limit of 160,000. In case setting the content was successful, true will be returned. Otherwise, a string with details will be returned.
|
|
398
|
+
*
|
|
399
|
+
* If this method is used within an SSH encryption process, an error will be thrown, preventing any further script execution. If the permissions are lacking, this method will return false. In case the file gets deleted this method will return null.
|
|
400
|
+
*/
|
|
95
401
|
setContent: (content: string) => string | boolean | null;
|
|
402
|
+
/**
|
|
403
|
+
* Change the group related to this file.
|
|
404
|
+
*
|
|
405
|
+
* The group name cannot exceed 15 characters. Additionally either write permissions or being root is required. In case of failure, a string with details. On success, an empty string gets returned. In case the current file gets deleted, this method will return null.
|
|
406
|
+
*
|
|
407
|
+
* If the passed group value is empty, the group value is longer than 15 characters, or the passed recursive value deviates from its original type, an error will be thrown, preventing further script execution.
|
|
408
|
+
*
|
|
409
|
+
* @param recursive set the group recursively to every file inside this folder
|
|
410
|
+
*/
|
|
96
411
|
setGroup: (group: string, recursive?: boolean) => string | null;
|
|
412
|
+
/**
|
|
413
|
+
* Change the owner of this file.
|
|
414
|
+
*
|
|
415
|
+
* The owner's name cannot exceed 15 characters. Additionally either write permissions or being root is required. In case of failure a string gets returned containing the cause. Otherwise an empty string gets returned. In case the current file gets deleted, this method will return null.
|
|
416
|
+
*
|
|
417
|
+
* If the passed owner value is empty, the owner value is longer than 15 characters, or the passed recursive value deviates from its original type, an error will be thrown, interrupting further script execution.
|
|
418
|
+
*
|
|
419
|
+
* @param recursive set the owner recursively to every file inside this folder
|
|
420
|
+
*/
|
|
97
421
|
setOwner: (owner: string, recursive?: boolean) => string | null;
|
|
98
|
-
|
|
422
|
+
/**
|
|
423
|
+
* Creates a symlink to the specified path.
|
|
424
|
+
*
|
|
425
|
+
* Symlinks can only be created if the user has write permissions or is root. The new filename must be alphanumeric and under 128 characters. Upon success, this method returns true. On failure, it returns a string with details.
|
|
426
|
+
*
|
|
427
|
+
* 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.
|
|
428
|
+
*/
|
|
429
|
+
symlink: (path: string, newName?: string) => true | string | null;
|
|
99
430
|
}
|
|
100
431
|
interface BaseFile {
|
|
101
432
|
classID: "ftpFile" | "file";
|
|
433
|
+
/** The name of the file. Is null if the file gets deleted before accessing this */
|
|
102
434
|
name: string | null;
|
|
103
|
-
group
|
|
435
|
+
/** The name of the group this file belongs to. Is null if the file gets deleted before accessing this */
|
|
436
|
+
group: string | null;
|
|
437
|
+
/** The name of the file owner. Is null if the file gets deleted before accessing this */
|
|
104
438
|
owner: string | null;
|
|
439
|
+
/**
|
|
440
|
+
* The permissions of the file. Is null if the file gets deleted before accessing this
|
|
441
|
+
*
|
|
442
|
+
* The format for this permissions string is as follows: `[fileType][wrx](u)[wrx](g)[wrx](o)`. The file type is either `d` in case it's a directory or `-`. The user type gets defined through three possible types: user `u`, group `g`, and other `o`. There are three different permission types: read `r`, write `w`, and execute `x`. An example of a string returned by this method would be `-rwxr-xr-x`.
|
|
443
|
+
*/
|
|
105
444
|
permissions: string | null;
|
|
445
|
+
/**
|
|
446
|
+
* The size of the file in bytes. Is null if the file gets deleted before accessing this
|
|
447
|
+
*
|
|
448
|
+
* There is no correlation between file size and actual file content. Instead, the file size is depending on the name of the file
|
|
449
|
+
*/
|
|
106
450
|
size: string | null;
|
|
451
|
+
/**
|
|
452
|
+
* Copies the file to the provided path.
|
|
453
|
+
*
|
|
454
|
+
* Files can only be copied if the user has read and write permissions or is root. The new filename has to be below 128 characters and alphanumeric. After success, this method will return true. Otherwise, it will return a string containing information about the reason for failure.
|
|
455
|
+
*
|
|
456
|
+
* 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.
|
|
457
|
+
*/
|
|
107
458
|
copy: (destFolder?: string, newName?: string) => string | boolean | null;
|
|
459
|
+
/**
|
|
460
|
+
* Delete the current file.
|
|
461
|
+
*
|
|
462
|
+
* To delete files, write permissions are required or being root. In case of failure, a string with details will be returned. Otherwise, an empty string gets returned.
|
|
463
|
+
*
|
|
464
|
+
* Note that deleting a file will leave a log entry.
|
|
465
|
+
*/
|
|
108
466
|
delete: () => string;
|
|
467
|
+
/** Returns a boolean indicating if the user who launched the script has the requested permissions.
|
|
468
|
+
*
|
|
469
|
+
* In case the file gets deleted, this method will return null instead.
|
|
470
|
+
*/
|
|
109
471
|
hasPermission: (perms: "r" | "w" | "x") => boolean | null;
|
|
472
|
+
/** Returns a boolean indicating if the file is a binary. Returns null if the file gets deleted */
|
|
110
473
|
isBinary: () => boolean | null;
|
|
474
|
+
/** Returns a boolean indicating if the file is a folder. Returns null if the file gets deleted */
|
|
111
475
|
isFolder: () => boolean | null;
|
|
476
|
+
/** Returns a boolean indicating if the file is a symlink. Returns null if the file gets deleted */
|
|
112
477
|
isSymlink: () => boolean | null;
|
|
478
|
+
/**
|
|
479
|
+
* Moves the file to the provided path.
|
|
480
|
+
*
|
|
481
|
+
* Files can only be moved if the user has read and write permissions or is root. The new filename has to be below 128 characters and alphanumeric. After success, this method will return true. Otherwise, this method will return a string with details.
|
|
482
|
+
*
|
|
483
|
+
* 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.
|
|
484
|
+
*/
|
|
113
485
|
move: (destFolder: string, newName?: string) => string | boolean | null;
|
|
486
|
+
/**
|
|
487
|
+
* 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.
|
|
488
|
+
* @param symLinkOriginalPath return the original path of the linked file instead
|
|
489
|
+
*/
|
|
114
490
|
path: (symLinkOriginalPath?: boolean) => string;
|
|
115
|
-
|
|
491
|
+
/**
|
|
492
|
+
* Rename the file with the name provided.
|
|
493
|
+
*
|
|
494
|
+
* Files can only be renamed if the user has write permissions or is root. The new filename has to be below 128 characters and alphanumeric. On failure, this method will return a string with details. Otherwise, this method will return an empty string.
|
|
495
|
+
*
|
|
496
|
+
* If this method is used within an SSH encryption process, an error will be thrown, causing the script execution to be interrupted.
|
|
497
|
+
*/
|
|
498
|
+
rename: (name: string) => string;
|
|
116
499
|
}
|
|
117
500
|
}
|
|
501
|
+
/** Provides access to global variables of this script */
|
|
118
502
|
declare var globals: any;
|
|
119
503
|
/** The parameters given to this script on launch */
|
|
120
504
|
declare var params: string[];
|
|
121
505
|
declare namespace GreyHack {
|
|
122
|
-
|
|
123
|
-
function acos(value: number): number;
|
|
506
|
+
/** Returns a string with the name of the user who is executing the current script. */
|
|
124
507
|
function activeUser(): string;
|
|
125
|
-
|
|
126
|
-
function atan(y: number, x?: number): number;
|
|
508
|
+
/** Performs a bitwise AND for the provided values. Warning: If either operand is >= `0x80000000`, it'll always return 0. */
|
|
127
509
|
function bitAnd(a: number, b: number): number;
|
|
510
|
+
/** Performs a bitwise OR for the provided values. Warning: If either operand is >= `0x80000000`, it'll always return 0. */
|
|
128
511
|
function bitOr(a: number, b: number): number;
|
|
512
|
+
/** Performs a bitwise XOR for the provided values. Warning: If either operand is >= `0x80000000`, it'll always return 0. */
|
|
129
513
|
function bitXor(a: number, b: number): number;
|
|
130
|
-
|
|
514
|
+
/**
|
|
515
|
+
* Returns a number by performing bitwise operations.
|
|
516
|
+
*
|
|
517
|
+
* Warning: If either operand is >= `0x80000000`, it'll always returns 0.
|
|
518
|
+
*/
|
|
519
|
+
function bitwise(operator: "~", a: number): number;
|
|
520
|
+
function bitwise(operator: "&" | "|" | "^" | "<<" | ">>" | ">>>", a: number, b: number): number;
|
|
521
|
+
/**
|
|
522
|
+
* Changes the current working directory of the active shell to the specified path.
|
|
523
|
+
*
|
|
524
|
+
* On success, an empty string is returned. If the operation fails, a descriptive error message is returned as a string.
|
|
525
|
+
*
|
|
526
|
+
* If this method is invoked during an SSH encryption process, a runtime error is thrown and further script execution is halted.
|
|
527
|
+
*/
|
|
131
528
|
function cd(path: string): string;
|
|
132
|
-
|
|
529
|
+
/**
|
|
530
|
+
* Returns the UTF-16 character string related to the provided unicode number.
|
|
531
|
+
*
|
|
532
|
+
* The provided number needs to be between 0 and 65535. Any number which is outside this range will cause the script to throw a runtime error.
|
|
533
|
+
*
|
|
534
|
+
* Beware when passing non-ASCII values to intrinsics as they will likely get re-encoded as UTF-8. For example, `md5(char(255))` will actually return the hash of the two-byte sequence `0xC3 0xBF`.
|
|
535
|
+
*/
|
|
133
536
|
function char(code: number): string;
|
|
537
|
+
/**
|
|
538
|
+
* Removes any text existing in a Terminal prior to this point.
|
|
539
|
+
*
|
|
540
|
+
* Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
|
|
541
|
+
*/
|
|
134
542
|
function clearScreen(): null;
|
|
543
|
+
/** Returns the Unicode number of the first character of the string. In case an empty string is provided the script execution will crash. */
|
|
135
544
|
function code(char: string): number;
|
|
545
|
+
/**
|
|
546
|
+
* Returns a string value of a translation. Translations include commands, documentation and other game-related things.
|
|
547
|
+
*
|
|
548
|
+
* Checkout {@link https://github.com/LoadingHome/Grey-Texts/blob/main/EnglishLang.json|Grey-Texts} for an overview of all available keys.
|
|
549
|
+
*
|
|
550
|
+
* If the provided command name is empty this method will throw an error causing the script to stop.
|
|
551
|
+
*/
|
|
136
552
|
function commandInfo(commandName: string): string;
|
|
137
|
-
|
|
553
|
+
/**
|
|
554
|
+
* Returns a string containing the current date and time. Ingame time passes 15 times as fast as real-time - 4 seconds per in-game minute.
|
|
555
|
+
*
|
|
556
|
+
* The initial time after every wipe will be the 1st of January 2000 at 6:00 AM. Additionally, the game time will not proceed while the server is offline.
|
|
557
|
+
*
|
|
558
|
+
* Output schema: `[day]/[month]/[year] - [hours]:[minutes]`
|
|
559
|
+
*
|
|
560
|
+
* Example output: `27/Jan/2000 - 08:19`
|
|
561
|
+
*/
|
|
138
562
|
function currentDate(): string;
|
|
563
|
+
/** Returns a string with the current active working directory. The working directory can be changed via the `cd` command. */
|
|
139
564
|
function currentPath(): string;
|
|
565
|
+
/**
|
|
566
|
+
* Stops execution of the currently running script.
|
|
567
|
+
*
|
|
568
|
+
* Optionally a message can be provided which will be shown in the Terminal. There is also the possibility of styling output by using {@link https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/index.html|TextMeshPro rich-text tags}.
|
|
569
|
+
*/
|
|
140
570
|
function exit(message?: string): never;
|
|
141
|
-
|
|
571
|
+
/**
|
|
572
|
+
* Returns a string which is the formatted version of the provided text.
|
|
573
|
+
*
|
|
574
|
+
* Keep in mind that {@link https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/index.html|TextMeshPro rich-text tags} might screw up the output. When using tags consider applying these after formatting.
|
|
575
|
+
*/
|
|
142
576
|
function formatColumns(columns: string): string;
|
|
577
|
+
/**
|
|
578
|
+
* Returns the absolute path of the given path string.
|
|
579
|
+
*
|
|
580
|
+
* If the path is already absolute, it is returned unchanged. Otherwise, it is resolved against the current working path by default, or against the provided base path if specified.
|
|
581
|
+
*
|
|
582
|
+
* If the path exceeds 1024 characters, the base path exceeds 64 characters, a runtime exception is thrown.
|
|
583
|
+
*/
|
|
143
584
|
function getAbsPath(path: string, basePath?: string): string;
|
|
585
|
+
/**
|
|
586
|
+
* Returns {@link CtfEvent} if there is one available.
|
|
587
|
+
*
|
|
588
|
+
* In case of failure this method will return a string with details.
|
|
589
|
+
*/
|
|
144
590
|
function getCtf(user: string, password: string, eventName: string): CtfEvent | string;
|
|
591
|
+
/**
|
|
592
|
+
* Returns an object which is shared throughout script execution.
|
|
593
|
+
*
|
|
594
|
+
* Can be helpful if it desired to pass or receive values when using {@link Shell.launch}.
|
|
595
|
+
*
|
|
596
|
+
* Using this method in a SSH encryption process will cause an error to be thrown preventing further script execution.
|
|
597
|
+
*/
|
|
145
598
|
function getCustomObject<T = object>(): T & Record<string, any>;
|
|
146
599
|
/** Returns by default the {@link Router router} to which the executing computer is connected to.
|
|
147
600
|
*
|
|
@@ -171,38 +624,132 @@ declare namespace GreyHack {
|
|
|
171
624
|
* if (switch) print("This device is a switch!");
|
|
172
625
|
*/
|
|
173
626
|
function getSwitch(ip: string): Router | null;
|
|
627
|
+
/**
|
|
628
|
+
* Returns numeric hash for the provided data.
|
|
629
|
+
*
|
|
630
|
+
* Using this method within a SSH encryption process will cause an error to be thrown causing the script execution to stop.
|
|
631
|
+
*/
|
|
174
632
|
function hash(value: any): number;
|
|
633
|
+
/** Returns a string with the home folder path of the user who is executing the current script. */
|
|
175
634
|
function homeDir(): string;
|
|
635
|
+
/** Enables to import code from different sources into one file. */
|
|
176
636
|
function importCode(path: string): null;
|
|
637
|
+
/**
|
|
638
|
+
* Enables the inclusion of library binaries, which can be used inside your script.
|
|
639
|
+
*
|
|
640
|
+
* If successful, an object related to the provided library will be returned; otherwise, null is returned.
|
|
641
|
+
*
|
|
642
|
+
* This function is exclusively for importing library binaries. If you want to import custom scripts or binaries into your project, use {@link importCode} instead. That is only for files ingame. For files in your editor, use {@link include}
|
|
643
|
+
*
|
|
644
|
+
* Leaving the path empty will cause an error to be thrown, interrupting further script execution.
|
|
645
|
+
*/
|
|
177
646
|
function includeLib(path: string): LibTypes[keyof LibTypes] | null;
|
|
647
|
+
/** Returns a boolean indicating if the given IP is a valid LAN address */
|
|
178
648
|
function isLanIp(ip: string): boolean;
|
|
649
|
+
/** Returns a boolean indicating if the given IP is valid */
|
|
179
650
|
function isValidIp(ip: string): boolean;
|
|
651
|
+
/** Returns a string containing the path of the script that was initially executed, meaning that even when using {@link Shell.launch}, it will still return the path of the initially executed script. */
|
|
180
652
|
function launchPath(): string;
|
|
181
|
-
|
|
182
|
-
|
|
653
|
+
/**
|
|
654
|
+
* Returns a {@link MetaMail} entity if the login was successful.
|
|
655
|
+
*
|
|
656
|
+
* On failure a string with details gets returned.
|
|
657
|
+
*
|
|
658
|
+
* Utilizing this method in an SSH encryption process will trigger an error, halting further script execution.
|
|
659
|
+
*/
|
|
660
|
+
function mailLogin(user: string, pass: string): MetaMail | string;
|
|
661
|
+
/**
|
|
662
|
+
* Returns the MD5 hash string of the provided string.
|
|
663
|
+
*
|
|
664
|
+
* Using this method within an SSH encryption process will cause an error to be thrown, stopping any further script execution.
|
|
665
|
+
*/
|
|
183
666
|
function md5(value: string): string;
|
|
667
|
+
/**
|
|
668
|
+
* Returns the IP address for the provided web address.
|
|
669
|
+
*
|
|
670
|
+
* In case the web address cannot be found a string gets returned containing the following message: `Not found`.
|
|
671
|
+
*
|
|
672
|
+
* If the provided web address is empty this method will throw an error preventing further script execution.
|
|
673
|
+
*/
|
|
184
674
|
function nslookup(webAddress: string): string;
|
|
675
|
+
/**
|
|
676
|
+
* Returns a string which is the parent path of the provided path.
|
|
677
|
+
*
|
|
678
|
+
* The path provided needs to be properly formatted. If the path is empty, this method will throw an error interrupting further script execution.
|
|
679
|
+
*/
|
|
185
680
|
function parentPath(path: string): string;
|
|
186
|
-
|
|
681
|
+
/**
|
|
682
|
+
* Print a message on the Terminal.
|
|
683
|
+
*
|
|
684
|
+
* There is also the possibility of styling output by using {@link https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/index.html|TextMeshPro rich-text tags}.
|
|
685
|
+
*
|
|
686
|
+
* @param replaceText Clear the terminal before printing. This can be useful for creating a loading bar for example.
|
|
687
|
+
*/
|
|
187
688
|
function print(value: any, replaceText?: boolean): null;
|
|
689
|
+
/** Returns a string containing the path of the script that is currently executing. It will update when using {@link Shell.launch|launch}, which makes it different from {@link launchPath}. */
|
|
188
690
|
function programPath(): string;
|
|
691
|
+
/**
|
|
692
|
+
* Generates an array where each item is a number. By default, if only one argument is provided, the list starts at the given value and decrements by one for each item.
|
|
693
|
+
*
|
|
694
|
+
* You can optionally define a start and end value, as well as customize the incremental value. However, if the incremental value is zero, or if the list exceeds `16777215L` items, the function will throw a runtime error.
|
|
695
|
+
*/
|
|
189
696
|
function range(start: number, end?: number, increment?: number): number[];
|
|
697
|
+
/**
|
|
698
|
+
* Resets the password of your CTF account.
|
|
699
|
+
*
|
|
700
|
+
* Returns true if resetting was successful; otherwise, it will return a string containing the reason for failure.
|
|
701
|
+
*/
|
|
190
702
|
function resetCtfPassword(newPassword: string): true | string;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
703
|
+
/**
|
|
704
|
+
* Returns a sliced version of the passed object.
|
|
705
|
+
*
|
|
706
|
+
* The returned object will contain all elements related to the provided start and end index. If no start or end index is provided this method will essentially return a shallow copy of the passed object.
|
|
707
|
+
*/
|
|
195
708
|
function slice<T extends Array<any> | string>(value: T, startIndex?: number, endIndex?: number): T extends string ? string : T;
|
|
196
|
-
|
|
709
|
+
/** Returns the string value of provided data. */
|
|
197
710
|
function str(value: any): string;
|
|
198
|
-
|
|
711
|
+
/** Returns a number of seconds representing the elapsed time since the script started. */
|
|
199
712
|
function time(): number;
|
|
713
|
+
/**
|
|
714
|
+
* Returns a string containing the bank account number of the player who is executing the script.
|
|
715
|
+
*
|
|
716
|
+
* If the user does not have a bank this method will return null.
|
|
717
|
+
*/
|
|
200
718
|
function userBankNumber(): string | null;
|
|
719
|
+
/**
|
|
720
|
+
* Pauses script execution to receive input from the user.
|
|
721
|
+
*
|
|
722
|
+
* The prompt message can include {@link https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/index.html|TextMeshPro rich-text tags} for styling. Input is submitted by pressing Enter.
|
|
723
|
+
*
|
|
724
|
+
* Using this function during an SSH encryption process will throw a runtime error and halt further script execution.
|
|
725
|
+
*
|
|
726
|
+
* @param message A message to display on the terminal
|
|
727
|
+
* @param isPassword hide what's being typed
|
|
728
|
+
* @param anyKey capture a single key press and return
|
|
729
|
+
* @param addToHistory saves the input to the input history, allowing it to be recalled with the arrow keys
|
|
730
|
+
*/
|
|
201
731
|
function userInput(message?: string, isPassword?: boolean, anyKey?: boolean, addToHistory?: boolean): string;
|
|
732
|
+
/**
|
|
733
|
+
* Returns a string containing the email address of the player who is executing the script.
|
|
734
|
+
*
|
|
735
|
+
* If the user does not have an email address this method will return null.
|
|
736
|
+
*/
|
|
202
737
|
function userMailAddress(): string | null;
|
|
203
|
-
|
|
738
|
+
/**
|
|
739
|
+
* Pauses the script execution. Optionally, the duration can be provided via the time argument. By default, the duration will be 1 second.
|
|
740
|
+
*
|
|
741
|
+
* The duration cannot be below 0.01 or above 300; otherwise, this method will throw a runtime exception.
|
|
742
|
+
*/
|
|
743
|
+
function wait(seconds?: number): null;
|
|
744
|
+
/**
|
|
745
|
+
* Returns a string containing the administrator information behind an IP address provided.
|
|
746
|
+
*
|
|
747
|
+
* In case of failure the returned string will contain an error message instead. If the provided ip is empty this method will throw an error causing the script to stop.
|
|
748
|
+
*/
|
|
204
749
|
function whois(ip: string): string;
|
|
750
|
+
/** Waits for the next tick. */
|
|
205
751
|
function yield(): null;
|
|
752
|
+
/** Returns the type of the object */
|
|
206
753
|
function getType(value: any): keyof GameTypeMap;
|
|
207
754
|
/** Checks if the given object is of a specific type
|
|
208
755
|
* @example
|
|
@@ -320,96 +867,359 @@ type GameTypeMap = ClassIDMap & OtherTypeMap;
|
|
|
320
867
|
declare namespace GreyHack {
|
|
321
868
|
interface Service {
|
|
322
869
|
classID: "service";
|
|
870
|
+
/**
|
|
871
|
+
* Installs the necessary files for the correct functioning of the service and starts it.
|
|
872
|
+
*
|
|
873
|
+
* If the installation is completed successfully, it returns true. In case of an error, it returns a string with details.
|
|
874
|
+
*/
|
|
323
875
|
installService(): true | string;
|
|
876
|
+
/**
|
|
877
|
+
* Starts the service and opens its associated port on the local machine.
|
|
878
|
+
*
|
|
879
|
+
* The service requires a port forwarded to the router to be accessible from the outside.
|
|
880
|
+
*
|
|
881
|
+
* If the service starts correctly, it returns true. In case of an error, it returns a string with details.
|
|
882
|
+
*/
|
|
324
883
|
startService(): true | string;
|
|
325
|
-
|
|
884
|
+
/**
|
|
885
|
+
* Stops the service and closes its associated port on the local machine.
|
|
886
|
+
*
|
|
887
|
+
* If the service is stopped successfully, it returns true.
|
|
888
|
+
*
|
|
889
|
+
* 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.
|
|
890
|
+
*/
|
|
891
|
+
stopService(): boolean | string;
|
|
326
892
|
}
|
|
327
893
|
interface Metaxploit {
|
|
328
894
|
classID: "MetaxploitLib";
|
|
895
|
+
/**
|
|
896
|
+
* 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.
|
|
897
|
+
*
|
|
898
|
+
* On failure, this method will return null. If the provided path is empty, this method will throw a runtime exception, preventing further script execution.
|
|
899
|
+
*/
|
|
329
900
|
load(path: string): MetaLib | null;
|
|
901
|
+
/**
|
|
902
|
+
* Returns a {@link NetSession} object for the provided IP address and port.
|
|
903
|
+
*
|
|
904
|
+
* Note that if the port is set to zero, it will return a {@link NetSession} related to the kernel router.
|
|
905
|
+
*
|
|
906
|
+
* 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.
|
|
907
|
+
*
|
|
908
|
+
* 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. */
|
|
330
909
|
netUse(ip: string, port: number): NetSession | null;
|
|
910
|
+
/**
|
|
911
|
+
* Launches a process on the victim's computer, silently attempting to continuously connect in the background to the specified address and port.
|
|
912
|
+
*
|
|
913
|
+
* 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.
|
|
914
|
+
*
|
|
915
|
+
* If the launch was successful, true will be returned. In case of failure, a string with details will be returned.
|
|
916
|
+
*/
|
|
331
917
|
rshellClient(ip: string, port: number, processName?: string): true | string;
|
|
918
|
+
/** This method returns an array of {@link Shell} objects that have been reverse shell connected to this computer.
|
|
919
|
+
*
|
|
920
|
+
* To manage the connections received, the rshell service must be installed on the machine that receives the victims' connections.
|
|
921
|
+
*
|
|
922
|
+
* In case of failure a string will be returned with details. */
|
|
332
923
|
rshellServer(): Shell[] | string;
|
|
924
|
+
/** Returns an array where each item is a string representing a memory area which has vulnerabilities related to the provided library.
|
|
925
|
+
*
|
|
926
|
+
* These memory areas can be used to make further scans via {@link Metaxploit.scanAddress}.
|
|
927
|
+
*
|
|
928
|
+
* In case of failure, this method returns null instead.
|
|
929
|
+
*
|
|
930
|
+
* An example of a memory area would be `0x7BFC1EAA`.
|
|
931
|
+
*
|
|
932
|
+
* Using this method within a SSH encryption process will throw a runtime exception. */
|
|
333
933
|
scan(metaLib: MetaLib): string[] | null;
|
|
934
|
+
/**
|
|
935
|
+
* Returns a string containing information about each vulnerability in the provided library and memory area.
|
|
936
|
+
*
|
|
937
|
+
* In case the scanning fails this method will return null.
|
|
938
|
+
*
|
|
939
|
+
* Using this method within a SSH encryption process will throw a runtime exception.
|
|
940
|
+
*/
|
|
334
941
|
scanAddress(metaLib: MetaLib, memoryAddress: string): string | null;
|
|
942
|
+
/**
|
|
943
|
+
* The terminal listens to the network packets of any connection that passes through the computer.
|
|
944
|
+
*
|
|
945
|
+
* When any connection information gets captured, it will print a string with the obtained data.
|
|
946
|
+
*
|
|
947
|
+
* In case saving of encryption source is enabled it will download the source code of the script responsible for encryption.
|
|
948
|
+
*
|
|
949
|
+
* In case the operation fails this method will return null.
|
|
950
|
+
*
|
|
951
|
+
* Using this method within a SSH encryption process will throw a runtime exception.
|
|
952
|
+
*/
|
|
335
953
|
sniffer(saveEncSource?: boolean): string | null;
|
|
336
954
|
}
|
|
337
955
|
interface MetaLib {
|
|
338
956
|
classID: "MetaLib";
|
|
957
|
+
/** The name of the library. An example of a name would be `init.so`. */
|
|
339
958
|
libName: string;
|
|
959
|
+
/** Version number of the library. An example of a version number would be `1.0.0`. */
|
|
340
960
|
version: string;
|
|
341
|
-
|
|
342
|
-
|
|
961
|
+
/**
|
|
962
|
+
* Returns a library in debug mode as a {@link DebugLibrary} object.
|
|
963
|
+
*
|
|
964
|
+
* A valid Neurobox engineer's username and password are required to access this mode.
|
|
965
|
+
*
|
|
966
|
+
* If successful, the {@link DebugLibrary} object is returned; in case of an error, a string with details is provided. */
|
|
967
|
+
debugTools(user: string, password: string): DebugLibrary | string;
|
|
968
|
+
/**
|
|
969
|
+
* Returns by default a boolean indicating whether the library has been patched.
|
|
970
|
+
*
|
|
971
|
+
* True indicates that the library has been patched, while false indicates that it has not.
|
|
972
|
+
*
|
|
973
|
+
* 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`.
|
|
974
|
+
*
|
|
975
|
+
* Additionally if there is any error the return value will be a string.
|
|
976
|
+
*/
|
|
977
|
+
isPatched(getDate?: boolean): boolean | string;
|
|
978
|
+
/**
|
|
979
|
+
* Exploits vulnerabilities in target systems by executing various attack vectors against libraries located in the `/lib` folder.
|
|
980
|
+
*
|
|
981
|
+
* 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).
|
|
982
|
+
*
|
|
983
|
+
* The system validates that the target library exists and is properly located in the `/lib` directory before proceeding otherwise it will return null.
|
|
984
|
+
*
|
|
985
|
+
* If the network where the library is located is disabled, the function returns a string indicating the network status.
|
|
986
|
+
*
|
|
987
|
+
* 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.
|
|
988
|
+
*
|
|
989
|
+
* If the target vulnerability is identified as a zero-day exploit, the system will load the appropriate zero-day vulnerability before execution.
|
|
990
|
+
*
|
|
991
|
+
* During execution, if a super admin intercepts the exploit attempt, user privileges are automatically lowered to guest level.
|
|
992
|
+
*
|
|
993
|
+
* Shell exploits, once all requirements are met, always return a shell object.
|
|
994
|
+
*
|
|
995
|
+
* Random folder exploits return a file object if the specified path exists or null if the folder cannot be found.
|
|
996
|
+
*
|
|
997
|
+
* 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.
|
|
998
|
+
*
|
|
999
|
+
* Settings override exploits work only on smart appliances like fridges or microwaves and return true for success or false for failure.
|
|
1000
|
+
*
|
|
1001
|
+
* Traffic light exploits require targets on the police station's network and return true for success or false for failure.
|
|
1002
|
+
*
|
|
1003
|
+
* Firewall exploits need router targets and return true for success or false for failure.
|
|
1004
|
+
*
|
|
1005
|
+
* 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.
|
|
1006
|
+
*
|
|
1007
|
+
* Using {@link isType} or {@link getType} to verify return value types is essential before processing results due to the variety of possible return types.
|
|
1008
|
+
*/
|
|
343
1009
|
overflow(memoryAddress: string, unsecZone: string, optArgs?: string): Shell | Computer | File | string | boolean | null;
|
|
344
1010
|
}
|
|
345
1011
|
interface DebugLibrary {
|
|
346
1012
|
classID: "debugLibrary";
|
|
347
|
-
|
|
348
|
-
|
|
1013
|
+
/** Applies a patch containing corrected code to the specified text file at the provided path.
|
|
1014
|
+
*
|
|
1015
|
+
* Returns a string with the result of the operation. */
|
|
1016
|
+
applyPatch(path: string): string;
|
|
1017
|
+
/** Returns a list containing a single partial computer object if zero-day vulnerabilities are detected within the specified memory zone.
|
|
1018
|
+
*
|
|
1019
|
+
* If a file path is provided, a partial file object associated with this path will also be included in the array.
|
|
1020
|
+
*
|
|
1021
|
+
* Additionally, if this file is a library, its corresponding metaLib object is added to the returned array.
|
|
1022
|
+
*
|
|
1023
|
+
* In case of an error, a string with details is returned. */
|
|
1024
|
+
payload(memZone: string): string | [Partial<Computer>];
|
|
1025
|
+
payload(memZone: string, filePath: string): string | [Partial<Computer>, Partial<File>] | [Partial<Computer>, Partial<File>, MetaLib];
|
|
1026
|
+
/** Scans the library in debug mode to identify potential code errors that may lead to vulnerabilities.
|
|
1027
|
+
*
|
|
1028
|
+
* If issues are detected, the relevant code snippets are printed. In case of an error, a string containing the error message is returned. */
|
|
349
1029
|
scan(): string;
|
|
350
|
-
|
|
1030
|
+
/** Conducts automated tests on the specified lines of code.
|
|
1031
|
+
*
|
|
1032
|
+
* 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.
|
|
1033
|
+
*
|
|
1034
|
+
* In case of failure, this function returns a string with an error message. */
|
|
1035
|
+
unitTesting(errorLines: number[]): string;
|
|
351
1036
|
}
|
|
352
1037
|
interface Crypto {
|
|
353
1038
|
classID: "cryptoLib";
|
|
1039
|
+
/** Returns a string containing the password based on the file which was generated via aireplay.
|
|
1040
|
+
*
|
|
1041
|
+
* In case of failure, it will return null instead. If the provided path is empty, an error will be thrown, interrupting the script execution. */
|
|
354
1042
|
aircrack(path: string): string | null;
|
|
1043
|
+
/** Used to inject frames on wireless interfaces.
|
|
1044
|
+
*
|
|
1045
|
+
* 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.
|
|
1046
|
+
*
|
|
1047
|
+
* Alternatively, a maximum of captured acks can be specified for the command to stop automatically, saving the `file.cap` file as described above.
|
|
1048
|
+
*
|
|
1049
|
+
* To figure out how many ACKs are required, you can use the following formula: `300000 / (Power + 15)`.
|
|
1050
|
+
*
|
|
1051
|
+
* 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.
|
|
1052
|
+
*
|
|
1053
|
+
* 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. */
|
|
355
1054
|
aireplay(bssid: string, essid: string, maxAcks?: number): string | null;
|
|
1055
|
+
/** Enables or disables the monitor mode of a network device.
|
|
1056
|
+
*
|
|
1057
|
+
* Monitor mode can only be enabled on Wifi cards.
|
|
1058
|
+
*
|
|
1059
|
+
* 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. */
|
|
356
1060
|
airmon(option: "start" | "stop", device: netDevice): boolean | string;
|
|
1061
|
+
/** Returns a decrypted password via the provided password MD5 hash.
|
|
1062
|
+
*
|
|
1063
|
+
* 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.
|
|
1064
|
+
*
|
|
1065
|
+
* So in case a password does not exist in the game world, the decryption will fail.
|
|
1066
|
+
*
|
|
1067
|
+
* 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. */
|
|
357
1068
|
decipher(hash: string): string | null;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
1069
|
+
/** Decrypts the specified file using the provided key.
|
|
1070
|
+
*
|
|
1071
|
+
* On success, the method returns true. If decryption fails, a descriptive error message is returned as a string. */
|
|
1072
|
+
decrypt(filePath: string, password: string): true | string;
|
|
1073
|
+
/** Encrypts the specified file using the provided key.
|
|
1074
|
+
*
|
|
1075
|
+
* On success, the method returns true. If encryption fails, a descriptive error message is returned as a string. */
|
|
1076
|
+
encrypt(filePath: string, password: string): true | string;
|
|
1077
|
+
/** Checks whether the specified file is encrypted.
|
|
1078
|
+
*
|
|
1079
|
+
* Returns true if the file is encrypted, or zero 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. */
|
|
1080
|
+
isEncrypted(filePath: string): boolean | string;
|
|
1081
|
+
/** Returns an array of the existing users on the computer where the SMTP service is running.
|
|
1082
|
+
*
|
|
1083
|
+
* If these users also have an email account registered on the SMTP server, it will be indicated in the array.
|
|
1084
|
+
*
|
|
1085
|
+
* SMTP services are usually running on port 25. In case of failure, this method will return a string containing the cause. */
|
|
1086
|
+
smtpUserList(ip: string, port: number): string[] | string;
|
|
362
1087
|
}
|
|
363
1088
|
interface BlockChain {
|
|
364
1089
|
classID: "blockchainLib";
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
1090
|
+
/** Returns a number representing the total amount of mined coins.
|
|
1091
|
+
*
|
|
1092
|
+
* In case of an error, it will return a string with the details.
|
|
1093
|
+
* @example
|
|
1094
|
+
* const blockChain = includeLib("/lib/blockchain.so");
|
|
1095
|
+
* if (!isType(blockChain, "blockchainLib"))
|
|
1096
|
+
* exit("Failed to get blockchain.so");
|
|
1097
|
+
*
|
|
1098
|
+
* const mined = blockChain.amountMined("bitcoin");
|
|
1099
|
+
* if (isType(mined, "string"))
|
|
1100
|
+
* exit(`Coudn't get the amount of mined coin: ${mined}`);
|
|
1101
|
+
*
|
|
1102
|
+
* print(`There are ${mined} coins mined for this coin`);
|
|
1103
|
+
*/
|
|
1104
|
+
amountMined(coinName: string): number | string;
|
|
1105
|
+
/** Returns a number representing the current unit value of the cryptocurrency.
|
|
1106
|
+
*
|
|
1107
|
+
* In case of an error, a string with the error details will be returned. */
|
|
1108
|
+
coinPrice(coinName: string): number | string;
|
|
1109
|
+
/** Creates a wallet and returns a wallet object on success, which can be used to manage cryptocurrencies.
|
|
1110
|
+
*
|
|
1111
|
+
* In case of an error, it will return a string with the details. */
|
|
1112
|
+
createWallet(user: string, password: string): Wallet | string;
|
|
1113
|
+
/** Removes a cryptocurrency from the world. The credentials used in the creation of the cryptocurrency are required.
|
|
1114
|
+
*
|
|
1115
|
+
* On success, it will return a true.
|
|
1116
|
+
*
|
|
1117
|
+
* On failure, it will return a string containing details. */
|
|
1118
|
+
deleteCoin(coinName: string, user: string, password: string): true | string;
|
|
1119
|
+
/** Returns a coin object used to manage the currency.
|
|
1120
|
+
*
|
|
1121
|
+
* In case of an error, it will return a string with the details. */
|
|
1122
|
+
getCoin(coinName: string, user: string, password: string): Coin | string;
|
|
1123
|
+
/** Returns a string with the name of the coin owned by the player.
|
|
1124
|
+
*
|
|
1125
|
+
* In case of an error, it returns a string with details. */
|
|
1126
|
+
getCoinName(user: string, password: string): string;
|
|
1127
|
+
/** Returns a wallet object on success. In case of an error, it will return a string indicating the reason. */
|
|
1128
|
+
loginWallet(user: string, password: string): Wallet | string;
|
|
1129
|
+
/** Returns an object with the latest changes in the value of a specific cryptocurrency.
|
|
1130
|
+
*
|
|
1131
|
+
* 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.
|
|
1132
|
+
*
|
|
1133
|
+
* If no coin exists with this name, the method will return null. */
|
|
372
1134
|
showHistory(coinName: string): Record<number, [number, string]> | string | null;
|
|
373
1135
|
}
|
|
374
1136
|
interface AptClient {
|
|
375
1137
|
classID: "aptClientLib";
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
1138
|
+
/** Inserts a repository address into the `/etc/apt/sources.txt` file.
|
|
1139
|
+
*
|
|
1140
|
+
* On success, it will return an empty string. In case of failure, it will return a string with an error message.
|
|
1141
|
+
*/
|
|
1142
|
+
addRepo(repositoryAddress: string, port?: number): string;
|
|
1143
|
+
/** Checks if there is a newer version of the program or library in the repository.
|
|
1144
|
+
*
|
|
1145
|
+
* 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.
|
|
1146
|
+
*
|
|
1147
|
+
* In case of failure, it will return a string containing an error message. */
|
|
1148
|
+
checkUpgrade(filePath: string): boolean | string;
|
|
1149
|
+
/** Deletes a repository address from the `/etc/apt/sources.txt` file.
|
|
1150
|
+
*
|
|
1151
|
+
* On success, it will return an empty string. In case of failure, it will return a string with an error message. */
|
|
1152
|
+
delRepo(repositoryAddress: string): string;
|
|
1153
|
+
/** Installs a program or library from a remote repository listed in `/etc/apt/sources.txt`.
|
|
1154
|
+
*
|
|
1155
|
+
* If no path is specified, the program installs in `/lib` if it is a library or in `/bin` otherwise.
|
|
1156
|
+
*
|
|
1157
|
+
* On success, this method will return true. In case of failure, it will return a string containing an error message. */
|
|
1158
|
+
install(package: string, installPath?: string): true | string;
|
|
1159
|
+
/** Search specifically looks for a package in any of the repositories listed in `/etc/apt/sources.txt`.
|
|
1160
|
+
*
|
|
1161
|
+
* On success, it will return a string containing all packages that partially match the provided search value.
|
|
1162
|
+
*
|
|
1163
|
+
* On failure, it will return a string with various error messages. */
|
|
1164
|
+
search(package: string): string;
|
|
1165
|
+
/** Show displays all the packages available in a repository. The repository must be listed in the `/etc/apt/sources.txt` file.
|
|
1166
|
+
*
|
|
1167
|
+
* If it cannot find a repository, it will return various error messages.
|
|
1168
|
+
*
|
|
1169
|
+
* On success, it will return a string containing all packages and their descriptions, with each entry separated by a newline. */
|
|
1170
|
+
show(repositoryAddress: string): string;
|
|
1171
|
+
/** 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`.
|
|
1172
|
+
*
|
|
1173
|
+
* If the update is successful, an empty string will be returned. In case of failure, a string with an error message will be returned.
|
|
1174
|
+
*
|
|
1175
|
+
* If for some reason the `/etc/apt/sources.txt` is malformed this method will return false. */
|
|
382
1176
|
update(): string | false;
|
|
383
1177
|
}
|
|
384
1178
|
interface SmartAppliance {
|
|
385
1179
|
classID: "SmartAppliance";
|
|
1180
|
+
/** Returns a string with the appliance model ID. */
|
|
386
1181
|
model(): string;
|
|
387
|
-
|
|
388
|
-
|
|
1182
|
+
/** Overrides the power and temperature settings of the appliance.
|
|
1183
|
+
*
|
|
1184
|
+
* If successful, true is returned; otherwise, it returns a string detailing the error. */
|
|
1185
|
+
overrideSettings(power: number, temperature: number): true | string;
|
|
1186
|
+
/** Activates or deactivates the sound alarm indicating any appliance malfunction.
|
|
1187
|
+
*
|
|
1188
|
+
* If successful, true is returned; otherwise, a string containing error details is returned. */
|
|
1189
|
+
setAlarm(enable: boolean): true | string;
|
|
389
1190
|
}
|
|
390
1191
|
interface TrafficNet {
|
|
391
1192
|
classID: "TrafficNet";
|
|
1193
|
+
/** Accesses the traffic camera system, opening a window with controls to switch between different cameras.
|
|
1194
|
+
*
|
|
1195
|
+
* If the window opens successfully, this method returns true. In case of an error, it returns a string with details. */
|
|
392
1196
|
cameraLinkSystem(): true | string;
|
|
1197
|
+
/** Returns string which contains job and name of a NPC. If an error occurs, a string with details is returned. */
|
|
393
1198
|
getCredentialsInfo(): string;
|
|
394
|
-
|
|
1199
|
+
/** Performs a search for the specified license plate to locate the vehicle.
|
|
1200
|
+
*
|
|
1201
|
+
* If the vehicle is visible on any camera, the viewer will switch to the camera currently displaying it and return true.
|
|
1202
|
+
*
|
|
1203
|
+
* If the vehicle cannot be located or the license plate is incorrect, a string indicating the error is returned. */
|
|
1204
|
+
locateVehicle(licensePlate: string, password: string): true | string;
|
|
395
1205
|
}
|
|
396
1206
|
}
|
|
397
1207
|
interface Math {
|
|
398
1208
|
readonly PI: number;
|
|
399
|
-
readonly abs:
|
|
400
|
-
readonly acos:
|
|
401
|
-
readonly asin:
|
|
402
|
-
readonly atan:
|
|
403
|
-
readonly ceil:
|
|
404
|
-
readonly floor:
|
|
405
|
-
readonly cos:
|
|
406
|
-
readonly sin:
|
|
407
|
-
readonly tan:
|
|
408
|
-
readonly sqrt:
|
|
409
|
-
readonly sign:
|
|
410
|
-
readonly round:
|
|
411
|
-
readonly random:
|
|
412
|
-
readonly log:
|
|
1209
|
+
readonly abs: (value: number) => number;
|
|
1210
|
+
readonly acos: (value: number) => number;
|
|
1211
|
+
readonly asin: (value: number) => number;
|
|
1212
|
+
readonly atan: (y: number, x?: number | undefined) => number;
|
|
1213
|
+
readonly ceil: (value: number) => number;
|
|
1214
|
+
readonly floor: (value: number) => number;
|
|
1215
|
+
readonly cos: (value: number) => number;
|
|
1216
|
+
readonly sin: (value: number) => number;
|
|
1217
|
+
readonly tan: (value: number) => number;
|
|
1218
|
+
readonly sqrt: (value: number) => number;
|
|
1219
|
+
readonly sign: (value: number) => number;
|
|
1220
|
+
readonly round: (value: number, fixed?: number | undefined) => number;
|
|
1221
|
+
readonly random: (seed?: number | undefined) => number;
|
|
1222
|
+
readonly log: (value: number, base?: number | undefined) => number;
|
|
413
1223
|
readonly min: (...values: number[]) => number;
|
|
414
1224
|
readonly max: (...values: number[]) => number;
|
|
415
1225
|
}
|
|
@@ -417,62 +1227,188 @@ declare var Math: Math;
|
|
|
417
1227
|
declare namespace GreyHack {
|
|
418
1228
|
interface CtfEvent {
|
|
419
1229
|
classID: "ctfEvent";
|
|
1230
|
+
/** Returns string with the name of the CTF event creator. */
|
|
420
1231
|
getCreatorName(): string;
|
|
1232
|
+
/** Returns string with the CTF event description. */
|
|
421
1233
|
getDescription(): string;
|
|
1234
|
+
/** Returns string with the mail content of the CTF event. */
|
|
422
1235
|
getMailContent(): string;
|
|
1236
|
+
/** Returns string with the CTF event template. */
|
|
423
1237
|
getTemplate(): string;
|
|
1238
|
+
/** Returns a boolean indicating if the CTF event got completed successfully */
|
|
424
1239
|
playerSuccess(): boolean;
|
|
425
1240
|
}
|
|
426
1241
|
interface MetaMail {
|
|
427
1242
|
classID: "MetaMail";
|
|
428
|
-
|
|
1243
|
+
/**
|
|
1244
|
+
* Delete the email corresponding to the provided email ID.
|
|
1245
|
+
*
|
|
1246
|
+
* Returns true if the email removal was successful. Otherwise, a string with an error message will be returned.
|
|
1247
|
+
*/
|
|
1248
|
+
delete(mailId: string): true | string;
|
|
1249
|
+
/**
|
|
1250
|
+
* 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.
|
|
1251
|
+
*
|
|
1252
|
+
* If there is any issue a string will be returned with details.
|
|
1253
|
+
*/
|
|
429
1254
|
fetch(): string[] | string;
|
|
430
|
-
|
|
431
|
-
|
|
1255
|
+
/**
|
|
1256
|
+
* Returns a string containing the content of a mail related to the provided mail id.
|
|
1257
|
+
*
|
|
1258
|
+
* The mail id argument can be obtained with fetch. In case the mail cannot be found this method will return `Mail not found`.
|
|
1259
|
+
*/
|
|
1260
|
+
read(mailId: string): string;
|
|
1261
|
+
/**
|
|
1262
|
+
* Send a new mail to the provided email address.
|
|
1263
|
+
*
|
|
1264
|
+
* Keep in mind that the subject can not exceed 128 characters and the message size should not exceed 2500 characters.
|
|
1265
|
+
*
|
|
1266
|
+
* @returns true indicating that the mail has been sent correctly, or a string with an error
|
|
1267
|
+
*/
|
|
1268
|
+
send(emailAddress: string, subject: string, message: string): string | true;
|
|
432
1269
|
}
|
|
433
1270
|
interface NetSession {
|
|
434
1271
|
classID: "NetSession";
|
|
1272
|
+
/**
|
|
1273
|
+
* Returns the {@link MetaLib} associated with the remote service.
|
|
1274
|
+
*
|
|
1275
|
+
* 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.
|
|
1276
|
+
*/
|
|
435
1277
|
dumpLib(): MetaLib;
|
|
1278
|
+
/**
|
|
1279
|
+
* Initiates a DDoS attack targeting the computer associated with the currently active NetSession object.
|
|
1280
|
+
*
|
|
1281
|
+
* 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`.
|
|
1282
|
+
*
|
|
1283
|
+
* This method always returns null and only prints a message upon a successful attack.
|
|
1284
|
+
*/
|
|
436
1285
|
floodConnection(): null;
|
|
1286
|
+
/** 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. */
|
|
437
1287
|
getNumConnGateway(): number;
|
|
1288
|
+
/** 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. */
|
|
438
1289
|
getNumPortforward(): number;
|
|
1290
|
+
/** Returns the number of user accounts on the system. */
|
|
439
1291
|
getNumUsers(): number;
|
|
1292
|
+
/** Return a boolean indicating if there is an active user on the system */
|
|
440
1293
|
isAnyActiveUser(): boolean;
|
|
1294
|
+
/** Return a boolean indicating if there is an active root user on the system */
|
|
441
1295
|
isRootActiveUser(): boolean;
|
|
442
1296
|
}
|
|
443
1297
|
interface Port {
|
|
444
1298
|
classID: "port";
|
|
1299
|
+
/** Port number used by this port */
|
|
445
1300
|
portNumber: number;
|
|
1301
|
+
/** Returns a boolean, where true indicates that the specified port is closed and false indicates that the port is open. */
|
|
446
1302
|
isClosed: () => boolean;
|
|
1303
|
+
/** Returns a string containing the local IP address of the computer to which the port is pointing. */
|
|
447
1304
|
getLanIp: () => string;
|
|
448
1305
|
}
|
|
449
1306
|
interface Router {
|
|
450
1307
|
classID: "router";
|
|
1308
|
+
/** BSSID value of the router */
|
|
451
1309
|
bssidName: string;
|
|
1310
|
+
/** ESSID value of the router */
|
|
452
1311
|
essidName: string;
|
|
1312
|
+
/** Version of the `kernel_router.so` library */
|
|
453
1313
|
kernelVersion: string;
|
|
1314
|
+
/** Local IP address of the router. */
|
|
454
1315
|
localIp: string;
|
|
1316
|
+
/** Public IP address of the router. */
|
|
455
1317
|
publicIp: string;
|
|
1318
|
+
/**
|
|
1319
|
+
* 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.
|
|
1320
|
+
*
|
|
1321
|
+
* 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. */
|
|
456
1322
|
devicePorts(ip: string): Port[] | string | null;
|
|
1323
|
+
/**
|
|
1324
|
+
* Returns an array where each item is a string representing a LAN IP address.
|
|
1325
|
+
*
|
|
1326
|
+
* 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.
|
|
1327
|
+
*/
|
|
457
1328
|
devicesLanIp(): string[];
|
|
1329
|
+
/** Returns an array where each item is a string containing a firewall rule. */
|
|
458
1330
|
firewallRules(): string[];
|
|
1331
|
+
/** Returns a {@link Port} that is behind the port number provided. In case the port does not exist null gets returned. */
|
|
459
1332
|
pingPort(portNumber: number): Port | null;
|
|
1333
|
+
/**
|
|
1334
|
+
* Returns a string with information about the provided port, including details about the running service and its version.
|
|
1335
|
+
*
|
|
1336
|
+
* For example, the output could be `http 1.0.0`. If the operation fails, null will be returned.
|
|
1337
|
+
*/
|
|
460
1338
|
portInfo(port: Port): string | null;
|
|
1339
|
+
/** Returns an array where each item is a {@link Port} used inside the router. */
|
|
461
1340
|
usedPorts(): Port[];
|
|
462
1341
|
}
|
|
463
1342
|
interface FtpShell {
|
|
464
1343
|
classID: "ftpShell";
|
|
1344
|
+
/** Returns a computer related to the shell. */
|
|
465
1345
|
hostComputer: FtpComputer;
|
|
1346
|
+
/**
|
|
1347
|
+
* Send a file to the computer related to the provided shell.
|
|
1348
|
+
*
|
|
1349
|
+
* 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.
|
|
1350
|
+
*
|
|
1351
|
+
* Via the optional isUpload parameter you can define the direction.
|
|
1352
|
+
*
|
|
1353
|
+
* 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.
|
|
1354
|
+
*/
|
|
466
1355
|
scp: Shell["scp"];
|
|
467
1356
|
}
|
|
468
1357
|
interface Shell {
|
|
469
1358
|
classID: "shell";
|
|
1359
|
+
/** Returns a computer related to the shell. */
|
|
470
1360
|
hostComputer: Computer;
|
|
1361
|
+
/**
|
|
1362
|
+
* Compiles a plain code file provided in the arguments to a binary.
|
|
1363
|
+
*
|
|
1364
|
+
* 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.
|
|
1365
|
+
*
|
|
1366
|
+
* In case any provided values deviate from the defined signature a runtime exception will be thrown.
|
|
1367
|
+
*/
|
|
471
1368
|
build: (sourcePath: string, binaryPath: string, allowImport?: boolean) => string;
|
|
1369
|
+
/**
|
|
1370
|
+
* Returns a shell if the connection attempt to the provided IP was successful.
|
|
1371
|
+
*
|
|
1372
|
+
* 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.
|
|
1373
|
+
*
|
|
1374
|
+
* 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.
|
|
1375
|
+
*/
|
|
472
1376
|
connectService: (ip: string, port: number, user: string, password: string, service?: "ssh" | "ftp") => Shell | FtpShell | string | null;
|
|
1377
|
+
/**
|
|
1378
|
+
* Launches the binary located at the provided path.
|
|
1379
|
+
*
|
|
1380
|
+
* 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.
|
|
1381
|
+
*
|
|
1382
|
+
* If you need to share variables between a launched script and the current process, consider using {@link getCustomObject}.
|
|
1383
|
+
*
|
|
1384
|
+
* 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.
|
|
1385
|
+
*
|
|
1386
|
+
* 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.
|
|
1387
|
+
*/
|
|
473
1388
|
launch: (program: string, params?: string) => string | boolean;
|
|
1389
|
+
/**
|
|
1390
|
+
* Pings an IP address.
|
|
1391
|
+
*
|
|
1392
|
+
* 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.
|
|
1393
|
+
*/
|
|
474
1394
|
ping: (ip: string) => string | boolean;
|
|
475
|
-
|
|
1395
|
+
/**
|
|
1396
|
+
* Send a file to the computer related to the provided shell.
|
|
1397
|
+
*
|
|
1398
|
+
* 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.
|
|
1399
|
+
*
|
|
1400
|
+
* Via the optional isUpload parameter you can define the direction.
|
|
1401
|
+
*
|
|
1402
|
+
* 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.
|
|
1403
|
+
*/
|
|
1404
|
+
scp: (file: string, folder: string, remoteShell: Shell, isUpload?: boolean) => boolean | string;
|
|
1405
|
+
/**
|
|
1406
|
+
* Launches an active terminal.
|
|
1407
|
+
*
|
|
1408
|
+
* 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.
|
|
1409
|
+
*
|
|
1410
|
+
* Using this method within an SSH encryption process will cause an error to be thrown, preventing further script execution.
|
|
1411
|
+
*/
|
|
476
1412
|
startTerminal: () => never;
|
|
477
1413
|
}
|
|
478
1414
|
}
|
|
@@ -506,6 +1442,22 @@ interface String {
|
|
|
506
1442
|
upper(): string;
|
|
507
1443
|
val(): number;
|
|
508
1444
|
values(): string[];
|
|
1445
|
+
/** Returns true if this string starts with the searchString. Otherwise returns false. */
|
|
1446
|
+
startsWith(searchString: string, position?: number): boolean;
|
|
1447
|
+
/** Returns true if this string ends with the searchString. Otherwise returns false. */
|
|
1448
|
+
endsWith(searchString: string, endPosition?: number): boolean;
|
|
1449
|
+
/**
|
|
1450
|
+
* Returns a string value that is made from count copies appended together.
|
|
1451
|
+
*
|
|
1452
|
+
* If count is 0, the empty string is returned.
|
|
1453
|
+
*/
|
|
1454
|
+
repeat(count: number): string;
|
|
1455
|
+
/**
|
|
1456
|
+
* Returns a section of a string.
|
|
1457
|
+
* @param start The index to the beginning of the specified portion of string.
|
|
1458
|
+
* @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.
|
|
1459
|
+
*/
|
|
1460
|
+
slice(start?: number, end?: number): string;
|
|
509
1461
|
readonly [index: number]: string;
|
|
510
1462
|
}
|
|
511
1463
|
interface Number {
|
|
@@ -546,9 +1498,14 @@ interface Array<T> {
|
|
|
546
1498
|
indexes(): number[];
|
|
547
1499
|
insert(index: number, value: T): T[];
|
|
548
1500
|
join(delimiter: string): string;
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
1501
|
+
/** Removes the first element from an array and returns it. If the array is empty, null is returned. */
|
|
1502
|
+
shift(): T | null;
|
|
1503
|
+
/** Inserts new elements at the start of an array, and returns the new length of the array. */
|
|
1504
|
+
unshift(...items: T[]): number;
|
|
1505
|
+
/** Removes the last element from an array and returns it. If the array is empty, null is returned. */
|
|
1506
|
+
pop(): T | null;
|
|
1507
|
+
/** Appends new elements to the end of an array, and returns the new length of the array. */
|
|
1508
|
+
push(...items: T[]): number;
|
|
552
1509
|
remove(index: number): null;
|
|
553
1510
|
replace(oldValue: T, newValue: T, maxCount?: number): T[];
|
|
554
1511
|
reverse(): null;
|
|
@@ -556,26 +1513,45 @@ interface Array<T> {
|
|
|
556
1513
|
sort(key: PropertyKey | null, ascending?: boolean): T[];
|
|
557
1514
|
sum(): number;
|
|
558
1515
|
values(): T[];
|
|
1516
|
+
/** Combines two or more arrays. This method returns a new array without modifying any existing arrays.
|
|
1517
|
+
* @param items Additional arrays and/or items to add to the end of the array.
|
|
1518
|
+
*/
|
|
559
1519
|
concat(...items: (T | T[])[]): T[];
|
|
1520
|
+
/** Calls a defined callback function on each element of an array, and returns an array that contains the results. */
|
|
560
1521
|
map<U>(callbackfn: (value: T, index: number, array: T[]) => U): U[];
|
|
1522
|
+
/** Returns the elements of an array that meet the condition specified in a callback function. */
|
|
561
1523
|
filter(predicate: (value: T, index: number, array: T[]) => unknown): T[];
|
|
1524
|
+
/** Returns the value of the first element in the array where predicate is true, and null otherwise. */
|
|
562
1525
|
find(predicate: (value: T, index: number, array: T[]) => unknown): T | null;
|
|
1526
|
+
/** Determines whether the specified callback function returns true for any element of an array. */
|
|
563
1527
|
some(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
|
|
1528
|
+
/** Determines whether all the members of an array satisfy the specified test. */
|
|
564
1529
|
every(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
|
|
1530
|
+
/** 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.
|
|
1531
|
+
*
|
|
1532
|
+
* For example, -2 refers to the second to last element of the array.
|
|
1533
|
+
* @param start The beginning index of the specified portion of the array. If start is undefined, then the slice begins at index 0.
|
|
1534
|
+
* @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.
|
|
1535
|
+
* */
|
|
1536
|
+
slice(start?: number, end?: number): T[];
|
|
565
1537
|
[n: number]: T;
|
|
566
1538
|
}
|
|
567
1539
|
interface Function {
|
|
568
1540
|
}
|
|
569
1541
|
declare var String: {
|
|
570
|
-
new (value?:
|
|
1542
|
+
new (value?: any): String;
|
|
571
1543
|
(value?: any): string;
|
|
572
1544
|
readonly prototype: String;
|
|
573
1545
|
};
|
|
574
1546
|
declare var Number: {
|
|
1547
|
+
new (value?: any): Number;
|
|
1548
|
+
(value?: any): number;
|
|
575
1549
|
readonly prototype: Number;
|
|
576
1550
|
};
|
|
577
1551
|
declare var Boolean: {
|
|
578
|
-
|
|
1552
|
+
new (value?: any): Boolean;
|
|
1553
|
+
<T>(value?: T): boolean;
|
|
1554
|
+
readonly prototype: Boolean;
|
|
579
1555
|
};
|
|
580
1556
|
declare var Array: {
|
|
581
1557
|
readonly prototype: Array<any>;
|