@grey-ts/types 1.5.0 → 2.0.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.
- package/dist/index.d.ts +116 -88
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -187,7 +187,7 @@ declare namespace GreyHack {
|
|
|
187
187
|
interface BaseComputer<FileType extends GreyHack.File | GreyHack.FtpFile> {
|
|
188
188
|
classID: "ftpComputer" | "computer";
|
|
189
189
|
/** Returns the hostname of the machine. */
|
|
190
|
-
getName
|
|
190
|
+
getName(): string;
|
|
191
191
|
/**
|
|
192
192
|
* Creates a folder at the path provided in the arguments.
|
|
193
193
|
*
|
|
@@ -197,7 +197,7 @@ declare namespace GreyHack {
|
|
|
197
197
|
*
|
|
198
198
|
* Using this method in an SSH encryption process will cause an error to be thrown, aborting further script execution.
|
|
199
199
|
*/
|
|
200
|
-
createFolder
|
|
200
|
+
createFolder(path: string, folderName?: string): string | true;
|
|
201
201
|
/**
|
|
202
202
|
* Returns a file located at the path provided in the argument.
|
|
203
203
|
*
|
|
@@ -213,7 +213,7 @@ declare namespace GreyHack {
|
|
|
213
213
|
* print(`Content of passwd file\n${passwd.getContent()}`)
|
|
214
214
|
* }
|
|
215
215
|
*/
|
|
216
|
-
file
|
|
216
|
+
file(path: string): FileType | null;
|
|
217
217
|
}
|
|
218
218
|
interface FtpComputer extends BaseComputer<FtpFile> {
|
|
219
219
|
classID: "ftpComputer";
|
|
@@ -225,7 +225,7 @@ declare namespace GreyHack {
|
|
|
225
225
|
/** The public IP address of the computer */
|
|
226
226
|
publicIp: string;
|
|
227
227
|
/** Returns `WIFI` or `ETHERNET` depending on the connection type the computer is currently using */
|
|
228
|
-
activeNetCard
|
|
228
|
+
activeNetCard(): "WIFI" | "ETHERNET";
|
|
229
229
|
/**
|
|
230
230
|
* Changes the password of an existing user on the computer.
|
|
231
231
|
*
|
|
@@ -233,13 +233,13 @@ declare namespace GreyHack {
|
|
|
233
233
|
*
|
|
234
234
|
* If the provided username is empty, an error will be thrown, preventing any further script execution.
|
|
235
235
|
*/
|
|
236
|
-
changePassword
|
|
236
|
+
changePassword(username: string, password: string): boolean | string;
|
|
237
237
|
/**
|
|
238
238
|
* Closes a program associated with the provided PID.
|
|
239
239
|
*
|
|
240
240
|
* 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.
|
|
241
241
|
*/
|
|
242
|
-
closeProgram
|
|
242
|
+
closeProgram(pid: number): boolean | string;
|
|
243
243
|
/**
|
|
244
244
|
* Sets up a new IP address on the computer through the Ethernet connection.
|
|
245
245
|
*
|
|
@@ -247,7 +247,7 @@ declare namespace GreyHack {
|
|
|
247
247
|
*
|
|
248
248
|
* If the computer is not connected to the internet, an error will be thrown, preventing any further script execution.
|
|
249
249
|
*/
|
|
250
|
-
connectEthernet
|
|
250
|
+
connectEthernet(netDevice: netDevice, address: string, gateway: string): string | null;
|
|
251
251
|
/**
|
|
252
252
|
* Connects to the indicated Wi-Fi network.
|
|
253
253
|
*
|
|
@@ -255,25 +255,25 @@ declare namespace GreyHack {
|
|
|
255
255
|
*
|
|
256
256
|
* Wi-Fi networks can be found via {@link wifiNetworks} or by typing iwlist as a command in the terminal.
|
|
257
257
|
*/
|
|
258
|
-
connectWifi
|
|
258
|
+
connectWifi(netDevice: netDevice, bssid: string, essid: string, password: string): true | string;
|
|
259
259
|
/**
|
|
260
260
|
* Creates a new group associated with an existing user on the computer.
|
|
261
261
|
*
|
|
262
262
|
* 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.
|
|
263
263
|
*/
|
|
264
|
-
createGroup
|
|
264
|
+
createGroup(username: string, group: string): true | string;
|
|
265
265
|
/**
|
|
266
266
|
* Creates a user on the computer with the specified name and password.
|
|
267
267
|
*
|
|
268
268
|
* 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.
|
|
269
269
|
*/
|
|
270
|
-
createUser
|
|
270
|
+
createUser(username: string, password: string): true | string;
|
|
271
271
|
/**
|
|
272
272
|
* Deletes an existing group associated with an existing user on the computer.
|
|
273
273
|
*
|
|
274
274
|
* 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.
|
|
275
275
|
*/
|
|
276
|
-
deleteGroup
|
|
276
|
+
deleteGroup(username: string, group: string): true | string;
|
|
277
277
|
/**
|
|
278
278
|
* Deletes the indicated user from the computer.
|
|
279
279
|
*
|
|
@@ -284,25 +284,25 @@ declare namespace GreyHack {
|
|
|
284
284
|
* @param username the user to remove
|
|
285
285
|
* @param removeHome remove the user's home folder as well
|
|
286
286
|
*/
|
|
287
|
-
deleteUser
|
|
287
|
+
deleteUser(username: string, removeHome?: boolean): true | string;
|
|
288
288
|
/** Returns an array of ports on the computer that are active. */
|
|
289
|
-
getPorts
|
|
289
|
+
getPorts(): Port[];
|
|
290
290
|
/**
|
|
291
291
|
* Returns a string containing groups associated with an existing user on the computer.
|
|
292
292
|
*
|
|
293
293
|
* 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.
|
|
294
294
|
*/
|
|
295
|
-
groups
|
|
295
|
+
groups(username: string): string;
|
|
296
296
|
/** Returns a boolean indicating if the computer has internet access */
|
|
297
|
-
isNetworkActive
|
|
297
|
+
isNetworkActive(): boolean;
|
|
298
298
|
/**
|
|
299
299
|
* Returns a string containing information about all network devices available on the computer.
|
|
300
300
|
*
|
|
301
301
|
* Each item includes details about the interface name, chipset, and whether monitoring support is enabled.
|
|
302
302
|
*/
|
|
303
|
-
networkDevices
|
|
303
|
+
networkDevices(): string;
|
|
304
304
|
/** Returns a string with the gateway IP address configured on the computer. */
|
|
305
|
-
networkGateway
|
|
305
|
+
networkGateway(): string;
|
|
306
306
|
/**
|
|
307
307
|
* Reboots the computer. By default, it reboots in standard mode.
|
|
308
308
|
*
|
|
@@ -312,13 +312,13 @@ declare namespace GreyHack {
|
|
|
312
312
|
*
|
|
313
313
|
* @param safeMode reboot the system in safe mode instead
|
|
314
314
|
*/
|
|
315
|
-
reboot
|
|
315
|
+
reboot(safeMode?: boolean): true | string;
|
|
316
316
|
/**
|
|
317
317
|
* Returns a string with an overview of all active processes on the computer, including information about the user, PID, CPU, memory, and command.
|
|
318
318
|
*
|
|
319
319
|
* Using this method in an SSH encryption process will cause an error to be thrown, preventing any further script execution.
|
|
320
320
|
*/
|
|
321
|
-
showProcs
|
|
321
|
+
showProcs(): string;
|
|
322
322
|
/**
|
|
323
323
|
* Creates an empty text file at the provided path.
|
|
324
324
|
*
|
|
@@ -326,7 +326,7 @@ declare namespace GreyHack {
|
|
|
326
326
|
*
|
|
327
327
|
* Using this method in an SSH encryption process will cause an error to be thrown, preventing any further script execution.
|
|
328
328
|
*/
|
|
329
|
-
touch
|
|
329
|
+
touch(destFolder: string, fileName: string): true | string;
|
|
330
330
|
/**
|
|
331
331
|
* Returns an array of the Wi-Fi networks that are available for the provided interface.
|
|
332
332
|
*
|
|
@@ -336,7 +336,7 @@ declare namespace GreyHack {
|
|
|
336
336
|
*
|
|
337
337
|
* @returns null if no matching netDevice can be found, otherwise the available networks
|
|
338
338
|
*/
|
|
339
|
-
wifiNetworks
|
|
339
|
+
wifiNetworks(netDevice: netDevice): string[] | null;
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
declare namespace GreyHack {
|
|
@@ -349,13 +349,13 @@ declare namespace GreyHack {
|
|
|
349
349
|
*
|
|
350
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
351
|
*/
|
|
352
|
-
getFiles
|
|
352
|
+
getFiles(): FtpFile[] | null;
|
|
353
353
|
/**
|
|
354
354
|
* Returns an array of folders inside this folder.
|
|
355
355
|
*
|
|
356
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
357
|
*/
|
|
358
|
-
getFolders
|
|
358
|
+
getFolders(): FtpFile[] | null;
|
|
359
359
|
}
|
|
360
360
|
interface File extends BaseFile {
|
|
361
361
|
classID: "file";
|
|
@@ -368,13 +368,13 @@ declare namespace GreyHack {
|
|
|
368
368
|
*
|
|
369
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.
|
|
370
370
|
*/
|
|
371
|
-
getFiles
|
|
371
|
+
getFiles(): File[] | null;
|
|
372
372
|
/**
|
|
373
373
|
* Returns an array of folders inside this folder.
|
|
374
374
|
*
|
|
375
375
|
* 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
376
|
*/
|
|
377
|
-
getFolders
|
|
377
|
+
getFolders(): File[] | null;
|
|
378
378
|
/**
|
|
379
379
|
* Modifies the file permissions.
|
|
380
380
|
*
|
|
@@ -384,7 +384,7 @@ declare namespace GreyHack {
|
|
|
384
384
|
*
|
|
385
385
|
* @param recursive set the permissions recursively to every file inside this folder
|
|
386
386
|
*/
|
|
387
|
-
chmod
|
|
387
|
+
chmod(perms: string, recursive?: boolean): string;
|
|
388
388
|
/**
|
|
389
389
|
* Returns a string representing the content of the file. To read a file, the user requires read access or being root.
|
|
390
390
|
*
|
|
@@ -392,7 +392,7 @@ declare namespace GreyHack {
|
|
|
392
392
|
*
|
|
393
393
|
* If this method is used within an SSH encryption process, an error will be thrown, preventing any further script execution.
|
|
394
394
|
*/
|
|
395
|
-
getContent
|
|
395
|
+
getContent(): string | null;
|
|
396
396
|
/**
|
|
397
397
|
* Saves text into a file. The content will not get appended to the file; therefore, existing content will be overridden.
|
|
398
398
|
*
|
|
@@ -400,7 +400,7 @@ declare namespace GreyHack {
|
|
|
400
400
|
*
|
|
401
401
|
* 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.
|
|
402
402
|
*/
|
|
403
|
-
setContent
|
|
403
|
+
setContent(content: string): string | boolean | null;
|
|
404
404
|
/**
|
|
405
405
|
* Change the group related to this file.
|
|
406
406
|
*
|
|
@@ -410,7 +410,7 @@ declare namespace GreyHack {
|
|
|
410
410
|
*
|
|
411
411
|
* @param recursive set the group recursively to every file inside this folder
|
|
412
412
|
*/
|
|
413
|
-
setGroup
|
|
413
|
+
setGroup(group: string, recursive?: boolean): string | null;
|
|
414
414
|
/**
|
|
415
415
|
* Change the owner of this file.
|
|
416
416
|
*
|
|
@@ -420,7 +420,7 @@ declare namespace GreyHack {
|
|
|
420
420
|
*
|
|
421
421
|
* @param recursive set the owner recursively to every file inside this folder
|
|
422
422
|
*/
|
|
423
|
-
setOwner
|
|
423
|
+
setOwner(owner: string, recursive?: boolean): string | null;
|
|
424
424
|
/**
|
|
425
425
|
* Creates a symlink to the specified path.
|
|
426
426
|
*
|
|
@@ -428,7 +428,7 @@ declare namespace GreyHack {
|
|
|
428
428
|
*
|
|
429
429
|
* 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
430
|
*/
|
|
431
|
-
symlink
|
|
431
|
+
symlink(path: string, newName?: string): true | string | null;
|
|
432
432
|
}
|
|
433
433
|
interface BaseFile {
|
|
434
434
|
classID: "ftpFile" | "file";
|
|
@@ -457,7 +457,7 @@ declare namespace GreyHack {
|
|
|
457
457
|
*
|
|
458
458
|
* 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
459
|
*/
|
|
460
|
-
copy
|
|
460
|
+
copy(destFolder?: string, newName?: string): string | boolean | null;
|
|
461
461
|
/**
|
|
462
462
|
* Delete the current file.
|
|
463
463
|
*
|
|
@@ -465,18 +465,18 @@ declare namespace GreyHack {
|
|
|
465
465
|
*
|
|
466
466
|
* Note that deleting a file will leave a log entry.
|
|
467
467
|
*/
|
|
468
|
-
delete
|
|
468
|
+
delete(): string;
|
|
469
469
|
/** Returns a boolean indicating if the user who launched the script has the requested permissions.
|
|
470
470
|
*
|
|
471
471
|
* In case the file gets deleted, this method will return null instead.
|
|
472
472
|
*/
|
|
473
|
-
hasPermission
|
|
473
|
+
hasPermission(perms: "r" | "w" | "x"): boolean | null;
|
|
474
474
|
/** Returns a boolean indicating if the file is a binary. Returns null if the file gets deleted */
|
|
475
|
-
isBinary
|
|
475
|
+
isBinary(): boolean | null;
|
|
476
476
|
/** Returns a boolean indicating if the file is a folder. Returns null if the file gets deleted */
|
|
477
|
-
isFolder
|
|
477
|
+
isFolder(): boolean | null;
|
|
478
478
|
/** Returns a boolean indicating if the file is a symlink. Returns null if the file gets deleted */
|
|
479
|
-
isSymlink
|
|
479
|
+
isSymlink(): boolean | null;
|
|
480
480
|
/**
|
|
481
481
|
* Moves the file to the provided path.
|
|
482
482
|
*
|
|
@@ -484,12 +484,12 @@ declare namespace GreyHack {
|
|
|
484
484
|
*
|
|
485
485
|
* 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.
|
|
486
486
|
*/
|
|
487
|
-
move
|
|
487
|
+
move(destFolder: string, newName?: string): string | boolean | null;
|
|
488
488
|
/**
|
|
489
489
|
* 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.
|
|
490
490
|
* @param symLinkOriginalPath return the original path of the linked file instead
|
|
491
491
|
*/
|
|
492
|
-
path
|
|
492
|
+
path(symLinkOriginalPath?: boolean): string;
|
|
493
493
|
/**
|
|
494
494
|
* Rename the file with the name provided.
|
|
495
495
|
*
|
|
@@ -497,7 +497,7 @@ declare namespace GreyHack {
|
|
|
497
497
|
*
|
|
498
498
|
* If this method is used within an SSH encryption process, an error will be thrown, causing the script execution to be interrupted.
|
|
499
499
|
*/
|
|
500
|
-
rename
|
|
500
|
+
rename(name: string): string;
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
/** Provides access to global variables of this script */
|
|
@@ -752,7 +752,7 @@ declare namespace GreyHack {
|
|
|
752
752
|
/** Waits for the next tick. */
|
|
753
753
|
function yield(): null;
|
|
754
754
|
/** Returns the type of the object */
|
|
755
|
-
function getType(value: any):
|
|
755
|
+
function getType(value: any): string;
|
|
756
756
|
/** Checks if the given object is of a specific type
|
|
757
757
|
* @example
|
|
758
758
|
* const metax = includeLib("/lib/metaxploit.so");
|
|
@@ -776,7 +776,7 @@ declare namespace GreyHack {
|
|
|
776
776
|
* include("./commands");
|
|
777
777
|
*/
|
|
778
778
|
function include(file: string): void;
|
|
779
|
-
|
|
779
|
+
interface LibTypes {
|
|
780
780
|
"aptclient.so": GreyHack.AptClient;
|
|
781
781
|
"metaxploit.so": GreyHack.Metaxploit;
|
|
782
782
|
"crypto.so": GreyHack.Crypto;
|
|
@@ -786,7 +786,7 @@ declare namespace GreyHack {
|
|
|
786
786
|
"blockchain.so": GreyHack.BlockChain;
|
|
787
787
|
"libsmartappliance.so": GreyHack.SmartAppliance;
|
|
788
788
|
"libtrafficnet.so": GreyHack.TrafficNet;
|
|
789
|
-
}
|
|
789
|
+
}
|
|
790
790
|
}
|
|
791
791
|
declare var activeUser: typeof GreyHack.activeUser;
|
|
792
792
|
declare var bitAnd: typeof GreyHack.bitAnd;
|
|
@@ -835,18 +835,18 @@ declare var yield: typeof GreyHack.yield;
|
|
|
835
835
|
declare const getType: typeof GreyHack.getType;
|
|
836
836
|
declare const isType: typeof GreyHack.isType;
|
|
837
837
|
declare const include: typeof GreyHack.include;
|
|
838
|
-
|
|
838
|
+
interface PrimitiveTypeMap {
|
|
839
839
|
"null": null;
|
|
840
|
-
"pcomputer": unknown;
|
|
841
|
-
"pfile": unknown;
|
|
842
|
-
"prouter": unknown;
|
|
843
840
|
"number": number;
|
|
844
841
|
"list": Array<any>;
|
|
845
842
|
"map": Record<string, any>;
|
|
846
843
|
"function": Function;
|
|
847
844
|
"string": string;
|
|
848
|
-
}
|
|
849
|
-
|
|
845
|
+
}
|
|
846
|
+
interface ClassIDMap {
|
|
847
|
+
"pcomputer": unknown;
|
|
848
|
+
"pfile": unknown;
|
|
849
|
+
"prouter": unknown;
|
|
850
850
|
"aptClientLib": GreyHack.AptClient;
|
|
851
851
|
"blockChainLib": GreyHack.BlockChain;
|
|
852
852
|
"ctfEvent": GreyHack.CtfEvent;
|
|
@@ -870,8 +870,8 @@ type ClassIDMap = {
|
|
|
870
870
|
"subwallet": GreyHack.SubWallet;
|
|
871
871
|
"TrafficNet": GreyHack.TrafficNet;
|
|
872
872
|
"wallet": GreyHack.Wallet;
|
|
873
|
-
}
|
|
874
|
-
type GameTypeMap = ClassIDMap &
|
|
873
|
+
}
|
|
874
|
+
type GameTypeMap = ClassIDMap & PrimitiveTypeMap;
|
|
875
875
|
declare namespace GreyHack {
|
|
876
876
|
interface Service {
|
|
877
877
|
classID: "service";
|
|
@@ -1234,41 +1234,41 @@ interface Math {
|
|
|
1234
1234
|
/** Returns the value of pi to the precision of 6 */
|
|
1235
1235
|
readonly PI: number;
|
|
1236
1236
|
/** Returns the absolute value of number. */
|
|
1237
|
-
|
|
1237
|
+
abs(value: number): number;
|
|
1238
1238
|
/** Returns the inverse cosine (in radians) of a number. */
|
|
1239
|
-
|
|
1239
|
+
acos(value: number): number;
|
|
1240
1240
|
/** Returns the inverse sine (in radians) of a number. */
|
|
1241
|
-
|
|
1241
|
+
asin(value: number): number;
|
|
1242
1242
|
/** Returns the inverse tangent (in radians) of a number. */
|
|
1243
|
-
|
|
1243
|
+
atan(y: number, x?: number | undefined): number;
|
|
1244
1244
|
/** Returns number rounded up to the integer value of the provided number. */
|
|
1245
|
-
|
|
1245
|
+
ceil(value: number): number;
|
|
1246
1246
|
/** Returns number rounded down to the integer value of the provided number. */
|
|
1247
|
-
|
|
1247
|
+
floor(value: number): number;
|
|
1248
1248
|
/** Returns the cosine of a number in radians. */
|
|
1249
|
-
|
|
1249
|
+
cos(value: number): number;
|
|
1250
1250
|
/** Returns the sine of a number in radians. */
|
|
1251
|
-
|
|
1251
|
+
sin(value: number): number;
|
|
1252
1252
|
/** Returns the tangent of a number in radians. */
|
|
1253
|
-
|
|
1253
|
+
tan(value: number): number;
|
|
1254
1254
|
/** Returns the square root of a number. */
|
|
1255
|
-
|
|
1255
|
+
sqrt(value: number): number;
|
|
1256
1256
|
/** Returns 1 or -1 indicating the sign of the value passed or 0 if the value is 0 */
|
|
1257
|
-
|
|
1257
|
+
sign(value: number): -1 | 0 | 1;
|
|
1258
1258
|
/** Returns number rounded to the integer value of the provided number. */
|
|
1259
|
-
|
|
1259
|
+
round(value: number, fixed?: number | undefined): number;
|
|
1260
1260
|
/** Returns a random number between 0 and 1. Optionally a seed number can be provided. */
|
|
1261
|
-
|
|
1261
|
+
random(seed?: number | undefined): number;
|
|
1262
1262
|
/**
|
|
1263
1263
|
* Returns the natural logarithm of a number.
|
|
1264
1264
|
*
|
|
1265
1265
|
* By default, the base is 10. Optionally the base can be changed.
|
|
1266
1266
|
*/
|
|
1267
|
-
|
|
1267
|
+
log(value: number, base?: number | undefined): number;
|
|
1268
1268
|
/** Returns the smallest number of the given values */
|
|
1269
|
-
|
|
1269
|
+
min(...values: number[]): number;
|
|
1270
1270
|
/** Returns the largest number of the given values */
|
|
1271
|
-
|
|
1271
|
+
max(...values: number[]): number;
|
|
1272
1272
|
}
|
|
1273
1273
|
declare var Math: Math;
|
|
1274
1274
|
declare namespace GreyHack {
|
|
@@ -1346,9 +1346,9 @@ declare namespace GreyHack {
|
|
|
1346
1346
|
/** Port number used by this port */
|
|
1347
1347
|
portNumber: number;
|
|
1348
1348
|
/** Returns a boolean, where true indicates that the specified port is closed and false indicates that the port is open. */
|
|
1349
|
-
isClosed
|
|
1349
|
+
isClosed(): boolean;
|
|
1350
1350
|
/** Returns a string containing the local IP address of the computer to which the port is pointing. */
|
|
1351
|
-
getLanIp
|
|
1351
|
+
getLanIp(): string;
|
|
1352
1352
|
}
|
|
1353
1353
|
interface Router {
|
|
1354
1354
|
classID: "router";
|
|
@@ -1412,7 +1412,7 @@ declare namespace GreyHack {
|
|
|
1412
1412
|
*
|
|
1413
1413
|
* In case any provided values deviate from the defined signature a runtime exception will be thrown.
|
|
1414
1414
|
*/
|
|
1415
|
-
build
|
|
1415
|
+
build(sourcePath: string, binaryPath: string, allowImport?: boolean): string;
|
|
1416
1416
|
/**
|
|
1417
1417
|
* Returns a shell if the connection attempt to the provided IP was successful.
|
|
1418
1418
|
*
|
|
@@ -1420,7 +1420,7 @@ declare namespace GreyHack {
|
|
|
1420
1420
|
*
|
|
1421
1421
|
* 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.
|
|
1422
1422
|
*/
|
|
1423
|
-
connectService
|
|
1423
|
+
connectService(ip: string, port: number, user: string, password: string, service?: "ssh" | "ftp"): Shell | FtpShell | string | null;
|
|
1424
1424
|
/**
|
|
1425
1425
|
* Launches the binary located at the provided path.
|
|
1426
1426
|
*
|
|
@@ -1432,13 +1432,13 @@ declare namespace GreyHack {
|
|
|
1432
1432
|
*
|
|
1433
1433
|
* 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.
|
|
1434
1434
|
*/
|
|
1435
|
-
launch
|
|
1435
|
+
launch(program: string, params?: string): string | boolean;
|
|
1436
1436
|
/**
|
|
1437
1437
|
* Pings an IP address.
|
|
1438
1438
|
*
|
|
1439
1439
|
* 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.
|
|
1440
1440
|
*/
|
|
1441
|
-
ping
|
|
1441
|
+
ping(ip: string): string | boolean;
|
|
1442
1442
|
/**
|
|
1443
1443
|
* Send a file to the computer related to the provided shell.
|
|
1444
1444
|
*
|
|
@@ -1448,7 +1448,7 @@ declare namespace GreyHack {
|
|
|
1448
1448
|
*
|
|
1449
1449
|
* 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.
|
|
1450
1450
|
*/
|
|
1451
|
-
scp
|
|
1451
|
+
scp(file: string, folder: string, remoteShell: Shell, isUpload?: boolean): boolean | string;
|
|
1452
1452
|
/**
|
|
1453
1453
|
* Launches an active terminal.
|
|
1454
1454
|
*
|
|
@@ -1456,9 +1456,13 @@ declare namespace GreyHack {
|
|
|
1456
1456
|
*
|
|
1457
1457
|
* Using this method within an SSH encryption process will cause an error to be thrown, preventing further script execution.
|
|
1458
1458
|
*/
|
|
1459
|
-
startTerminal
|
|
1459
|
+
startTerminal(): never;
|
|
1460
1460
|
}
|
|
1461
1461
|
}
|
|
1462
|
+
declare const console: {
|
|
1463
|
+
readonly log: typeof GreyHack.print;
|
|
1464
|
+
readonly clear: typeof GreyHack.clearScreen;
|
|
1465
|
+
};
|
|
1462
1466
|
interface RegExp {
|
|
1463
1467
|
}
|
|
1464
1468
|
interface CallableFunction {
|
|
@@ -1470,6 +1474,7 @@ interface IArguments {
|
|
|
1470
1474
|
interface Boolean {
|
|
1471
1475
|
}
|
|
1472
1476
|
interface String {
|
|
1477
|
+
/** Returns the length of the string */
|
|
1473
1478
|
readonly length: number;
|
|
1474
1479
|
/** Returns the Unicode code of the first character of the string */
|
|
1475
1480
|
code(): number;
|
|
@@ -1567,19 +1572,6 @@ interface Number {
|
|
|
1567
1572
|
}
|
|
1568
1573
|
type PropertyKey = number | string | symbol;
|
|
1569
1574
|
interface Object {
|
|
1570
|
-
/** Returns the number of items inside the object */
|
|
1571
|
-
readonly size: number;
|
|
1572
|
-
hasIndex(key: PropertyKey): boolean;
|
|
1573
|
-
indexOf(value: any): any;
|
|
1574
|
-
indexes<T extends PropertyKey>(): T[];
|
|
1575
|
-
pop(): any;
|
|
1576
|
-
pull(): any;
|
|
1577
|
-
push(key: PropertyKey): any;
|
|
1578
|
-
remove(key: PropertyKey): boolean;
|
|
1579
|
-
replace(oldValue: any, newValue: any, maxCount?: number): any;
|
|
1580
|
-
shuffle(): null;
|
|
1581
|
-
sum(): number;
|
|
1582
|
-
values(): any[];
|
|
1583
1575
|
/** Returns a string representation of an object. */
|
|
1584
1576
|
toString(): string;
|
|
1585
1577
|
}
|
|
@@ -1590,15 +1582,51 @@ interface ObjectConstructor {
|
|
|
1590
1582
|
hasOwn<T extends PropertyKey, U = object>(o: U, key: T): o is (T extends keyof U ? U : U & {
|
|
1591
1583
|
[K in T]: unknown;
|
|
1592
1584
|
});
|
|
1585
|
+
/**
|
|
1586
|
+
* Returns a key of the object that has a value equal to the given value
|
|
1587
|
+
* @example
|
|
1588
|
+
* const myObject = { test: 123, other: 222 };
|
|
1589
|
+
* const key = Object.indexOf(myObject, 222);
|
|
1590
|
+
* print(key); // Prints "other"
|
|
1591
|
+
*/
|
|
1592
|
+
indexOf<T extends Record<any, any>>(o: T, value: T[keyof T]): keyof T | null;
|
|
1593
1593
|
/** Copy the properties of the source to the target */
|
|
1594
1594
|
assign<T extends {}, U>(target: T, source: U): T & U;
|
|
1595
1595
|
assign<T extends {}, U, V>(target: T, source: U, source2: V): T & U & V;
|
|
1596
1596
|
assign<T extends {}, U, V, W>(target: T, source: U, source2: V, source3: W): T & U & V & W;
|
|
1597
1597
|
assign(target: object, ...sources: any[]): any;
|
|
1598
|
+
/** Returns the number of items inside the object */
|
|
1599
|
+
size<T extends Record<any, any>>(o: T): number;
|
|
1598
1600
|
/** Returns an array of keys of the object */
|
|
1599
1601
|
keys<T extends Record<any, any>>(o: T): (Exclude<keyof T, symbol>)[];
|
|
1600
1602
|
/** Returns an array of values of the object */
|
|
1601
1603
|
values<T extends Record<any, any>>(o: T): (T[keyof T])[];
|
|
1604
|
+
/** Returns sum of all values inside the given object. Any non-numeric values will be considered a zero. */
|
|
1605
|
+
sum(o: Record<any, any>): number;
|
|
1606
|
+
/** Shuffles all **values** in the object. This operation will mutate the map. */
|
|
1607
|
+
shuffle(o: Record<any, any>): null;
|
|
1608
|
+
/**
|
|
1609
|
+
* Replaces each value of the object matching `oldValue` with `newValue`.
|
|
1610
|
+
*
|
|
1611
|
+
* This method will mutate the object
|
|
1612
|
+
* @example
|
|
1613
|
+
* const myObject = { status: "online" };
|
|
1614
|
+
* Object.replace(myObject, "online", "offline");
|
|
1615
|
+
* print(myObject); // Prints { "status": "offline" };
|
|
1616
|
+
*/
|
|
1617
|
+
replace<T extends Record<any, any>>(o: T, oldValue: T[keyof T], newValue: T[keyof T], maxCount?: number): T;
|
|
1618
|
+
/**
|
|
1619
|
+
* Removes a key-value pair from the object. This method mutates the object.
|
|
1620
|
+
*
|
|
1621
|
+
* @returns a boolean indicating success
|
|
1622
|
+
*/
|
|
1623
|
+
remove<T extends Record<any, any>>(o: T, key: keyof T): boolean;
|
|
1624
|
+
/**
|
|
1625
|
+
* Removes the first item of the object and returns it's key
|
|
1626
|
+
*
|
|
1627
|
+
* This method mutates the object.
|
|
1628
|
+
*/
|
|
1629
|
+
shift<T extends Record<any, any>>(o: T): keyof T | null;
|
|
1602
1630
|
}
|
|
1603
1631
|
interface Array<T> {
|
|
1604
1632
|
readonly length: number;
|