@grey-ts/types 1.3.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/LICENSE +7 -0
- package/README.md +9 -0
- package/dist/index.d.ts +644 -0
- package/package.json +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2026 Oskari Hirsikangas
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
`npm install --save @grey-ts/types`
|
|
3
|
+
|
|
4
|
+
or
|
|
5
|
+
|
|
6
|
+
`npm install --save https://github.com/OkkaOk/grey-ts-types`
|
|
7
|
+
|
|
8
|
+
# Summary
|
|
9
|
+
This package contains type definitions for GreyHack's functions and objects to be used by the `@grey-ts/transpiler` package
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
declare namespace GreyHack {
|
|
2
|
+
interface Coin {
|
|
3
|
+
classID: "coin";
|
|
4
|
+
createSubWallet(walletID: string, pin: string, subwalletUser: string, subwalletPassword: string): string | true | null;
|
|
5
|
+
getAddress(): string;
|
|
6
|
+
getCycleMining(): number | string;
|
|
7
|
+
getMinedCoins(): number | string;
|
|
8
|
+
getReward(): number | string;
|
|
9
|
+
getSubwallet(subwalletUser: string): SubWallet | string | null;
|
|
10
|
+
getSubwallets(): SubWallet[] | string;
|
|
11
|
+
resetPassword(newPassword: string): true | string;
|
|
12
|
+
setAddress(address: string): true | string | null;
|
|
13
|
+
setCycleMining(rateHours: number): true | string | null;
|
|
14
|
+
setReward(coinAmount: number): true | string | null;
|
|
15
|
+
transaction(subwalletFrom: string, subwalletTo: string, amount: number): true | string | null;
|
|
16
|
+
}
|
|
17
|
+
interface SubWallet {
|
|
18
|
+
classID: "subwallet";
|
|
19
|
+
walletUsername(): string;
|
|
20
|
+
checkPassword(password: string): true | string;
|
|
21
|
+
delete(): boolean | string;
|
|
22
|
+
getBalance(): number | string;
|
|
23
|
+
getInfo(): string;
|
|
24
|
+
getUser(): string;
|
|
25
|
+
lastTransaction(): [string, number, 0 | 1, string] | false | string;
|
|
26
|
+
mining(): true | string;
|
|
27
|
+
setInfo(info: string): true | string;
|
|
28
|
+
}
|
|
29
|
+
interface Wallet {
|
|
30
|
+
classID: "wallet";
|
|
31
|
+
buyCoin(coinName: string, coinAmount: number, unitPrice: number, subwalletUser: string): true | string;
|
|
32
|
+
cancelPendingTrade(coinName: string): string | null;
|
|
33
|
+
getBalance(coinName: string): number | string | null;
|
|
34
|
+
getGlobalOffers(coinName: string): string | Record<string, [string, number, number]> | null;
|
|
35
|
+
getPendingTrade(coinName: string): string | Record<string, [string, number, number]> | null;
|
|
36
|
+
getPin(): string;
|
|
37
|
+
listCoins(): string[] | string;
|
|
38
|
+
listGlobalCoins(): string[] | string;
|
|
39
|
+
resetPassword(newPassword: string): true | string | null;
|
|
40
|
+
sellCoin(coinName: string, coinAmount: number, unitPrice: number, subwalletUser: string): true | string;
|
|
41
|
+
showNodes(coinName: string): string | number | null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
declare namespace GreyHack {
|
|
45
|
+
interface BaseComputer<FileType extends GreyHack.File | GreyHack.FtpFile> {
|
|
46
|
+
classID: "ftpComputer" | "computer";
|
|
47
|
+
getName: () => string;
|
|
48
|
+
createFolder: (path: string, folderName?: string) => string | boolean;
|
|
49
|
+
file: (path: string) => FileType | null;
|
|
50
|
+
}
|
|
51
|
+
interface FtpComputer extends BaseComputer<FtpFile> {
|
|
52
|
+
classID: "ftpComputer";
|
|
53
|
+
}
|
|
54
|
+
interface Computer extends BaseComputer<File> {
|
|
55
|
+
classID: "computer";
|
|
56
|
+
localIp: string;
|
|
57
|
+
publicIp: string;
|
|
58
|
+
activeNetCard: () => string;
|
|
59
|
+
changePassword: (username: string, password: string) => boolean | string | null;
|
|
60
|
+
closeProgram: (pid: number) => boolean | string | null;
|
|
61
|
+
connectEthernet: (netDevice: netDevice, address: string, gateway: string) => string | null;
|
|
62
|
+
connectWifi: (netDevice: netDevice, bssid: string, essid: string, password: string) => boolean | string | null;
|
|
63
|
+
createGroup: (username: string, group: string) => boolean | string | null;
|
|
64
|
+
createUser: (username: string, password: string) => boolean | string | null;
|
|
65
|
+
deleteGroup: (username: string, group: string) => boolean | string | null;
|
|
66
|
+
deleteUser: (username: string, removeHome?: boolean) => boolean | string | null;
|
|
67
|
+
getPorts: () => Port[];
|
|
68
|
+
groups: (username: string) => string | null;
|
|
69
|
+
isNetworkActive: () => boolean;
|
|
70
|
+
networkDevices: () => string;
|
|
71
|
+
networkGateway: () => string;
|
|
72
|
+
reboot: (safeMode?: boolean) => boolean | string | null;
|
|
73
|
+
showProcs: () => string;
|
|
74
|
+
touch: (destFolder: string, fileName: string) => boolean | string;
|
|
75
|
+
wifiNetworks: (netDevice: netDevice) => string[] | null;
|
|
76
|
+
getName: () => string;
|
|
77
|
+
createFolder: (path: string, folderName?: string) => string | boolean;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
declare namespace GreyHack {
|
|
81
|
+
interface FtpFile extends BaseFile {
|
|
82
|
+
classID: "ftpFile";
|
|
83
|
+
parent: FtpFile | null;
|
|
84
|
+
getFiles: () => FtpFile[] | null;
|
|
85
|
+
getFolders: () => FtpFile[] | null;
|
|
86
|
+
}
|
|
87
|
+
interface File extends BaseFile {
|
|
88
|
+
classID: "file";
|
|
89
|
+
parent: File | null;
|
|
90
|
+
allowImport: boolean;
|
|
91
|
+
getFiles: () => File[] | null;
|
|
92
|
+
getFolders: () => File[] | null;
|
|
93
|
+
chmod: (perms: string, recursive?: boolean) => string;
|
|
94
|
+
getContent: () => string | null;
|
|
95
|
+
setContent: (content: string) => string | boolean | null;
|
|
96
|
+
setGroup: (group: string, recursive?: boolean) => string | null;
|
|
97
|
+
setOwner: (owner: string, recursive?: boolean) => string | null;
|
|
98
|
+
symlink: (path: string, newName?: string) => string | boolean | null;
|
|
99
|
+
}
|
|
100
|
+
interface BaseFile {
|
|
101
|
+
classID: "ftpFile" | "file";
|
|
102
|
+
name: string | null;
|
|
103
|
+
group: string;
|
|
104
|
+
owner: string | null;
|
|
105
|
+
permissions: string | null;
|
|
106
|
+
size: string | null;
|
|
107
|
+
copy: (destFolder?: string, newName?: string) => string | boolean | null;
|
|
108
|
+
delete: () => string;
|
|
109
|
+
hasPermission: (perms: "r" | "w" | "x") => boolean | null;
|
|
110
|
+
isBinary: () => boolean | null;
|
|
111
|
+
isFolder: () => boolean | null;
|
|
112
|
+
isSymlink: () => boolean | null;
|
|
113
|
+
move: (destFolder: string, newName?: string) => string | boolean | null;
|
|
114
|
+
path: (symLinkOriginalPath?: boolean) => string;
|
|
115
|
+
rename: (name: string) => string | boolean;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
declare var globals: any;
|
|
119
|
+
/** The parameters given to this script on launch */
|
|
120
|
+
declare var params: string[];
|
|
121
|
+
declare namespace GreyHack {
|
|
122
|
+
function abs(value: number): number;
|
|
123
|
+
function acos(value: number): number;
|
|
124
|
+
function activeUser(): string;
|
|
125
|
+
function asin(value: number): number;
|
|
126
|
+
function atan(y: number, x?: number): number;
|
|
127
|
+
function bitAnd(a: number, b: number): number;
|
|
128
|
+
function bitOr(a: number, b: number): number;
|
|
129
|
+
function bitXor(a: number, b: number): number;
|
|
130
|
+
function bitwise(operator: "~" | "&" | "|" | "^" | "<<" | ">>" | ">>>", a: number, b?: number): number;
|
|
131
|
+
function cd(path: string): string;
|
|
132
|
+
function ceil(value: number): number;
|
|
133
|
+
function char(code: number): string;
|
|
134
|
+
function clearScreen(): null;
|
|
135
|
+
function code(char: string): number;
|
|
136
|
+
function commandInfo(commandName: string): string;
|
|
137
|
+
function cos(value: number): number;
|
|
138
|
+
function currentDate(): string;
|
|
139
|
+
function currentPath(): string;
|
|
140
|
+
function exit(message?: string): never;
|
|
141
|
+
function floor(value: number): number;
|
|
142
|
+
function formatColumns(columns: string): string;
|
|
143
|
+
function getAbsPath(path: string, basePath?: string): string;
|
|
144
|
+
function getCtf(user: string, password: string, eventName: string): CtfEvent | string;
|
|
145
|
+
function getCustomObject<T = object>(): T & Record<string, any>;
|
|
146
|
+
/** Returns by default the {@link Router router} to which the executing computer is connected to.
|
|
147
|
+
*
|
|
148
|
+
* Optionally an IP address can be provided. In case of failure `null` is returned.
|
|
149
|
+
*
|
|
150
|
+
* If there is no active internet connection, this method will throw an error, interrupting further script execution.
|
|
151
|
+
* @example
|
|
152
|
+
* const router = getRouter();
|
|
153
|
+
* print("Router's essid name is: " + router.essidName);
|
|
154
|
+
*/
|
|
155
|
+
function getRouter(ip?: string): Router | null;
|
|
156
|
+
/**
|
|
157
|
+
* Returns the {@link Shell shell} that is executing the current script.
|
|
158
|
+
*
|
|
159
|
+
* Optionally, a username and password can be provided, allowing the use of a shell with other user privileges.
|
|
160
|
+
*
|
|
161
|
+
* If the username or password does not match an existing user or if the provided values deviate from the defined signature, this method will return `null`.
|
|
162
|
+
* @example
|
|
163
|
+
* const shell = getShell("root", "test");
|
|
164
|
+
* print("My public IP is: " + shell.hostComputer.publicIp);
|
|
165
|
+
*/
|
|
166
|
+
function getShell(): Shell;
|
|
167
|
+
function getShell(username?: string, password?: string): Shell | null;
|
|
168
|
+
/** Returns the switch on the local network whose IP address matches
|
|
169
|
+
* @example
|
|
170
|
+
* const switch = getSwitch("192.168.1.4");
|
|
171
|
+
* if (switch) print("This device is a switch!");
|
|
172
|
+
*/
|
|
173
|
+
function getSwitch(ip: string): Router | null;
|
|
174
|
+
function hash(value: any): number;
|
|
175
|
+
function homeDir(): string;
|
|
176
|
+
function importCode(path: string): null;
|
|
177
|
+
function includeLib(path: string): LibTypes[keyof LibTypes] | null;
|
|
178
|
+
function isLanIp(ip: string): boolean;
|
|
179
|
+
function isValidIp(ip: string): boolean;
|
|
180
|
+
function launchPath(): string;
|
|
181
|
+
function log(value: number, base?: number): number;
|
|
182
|
+
function mailLogin(user: string, pass: string): MetaMail | string | null;
|
|
183
|
+
function md5(value: string): string;
|
|
184
|
+
function nslookup(webAddress: string): string;
|
|
185
|
+
function parentPath(path: string): string;
|
|
186
|
+
function pi(): number;
|
|
187
|
+
function print(value: any, replaceText?: boolean): null;
|
|
188
|
+
function programPath(): string;
|
|
189
|
+
function range(start: number, end?: number, increment?: number): number[];
|
|
190
|
+
function resetCtfPassword(newPassword: string): true | string;
|
|
191
|
+
function rnd(seed?: number): number;
|
|
192
|
+
function round(value: number, fixed?: number): number;
|
|
193
|
+
function sign(value: number): number;
|
|
194
|
+
function sin(value: number): number;
|
|
195
|
+
function slice<T extends Array<any> | string>(value: T, startIndex?: number, endIndex?: number): T extends string ? string : T;
|
|
196
|
+
function sqrt(value: number): number;
|
|
197
|
+
function str(value: any): string;
|
|
198
|
+
function tan(value: number): number;
|
|
199
|
+
function time(): number;
|
|
200
|
+
function userBankNumber(): string | null;
|
|
201
|
+
function userInput(message?: string, isPassword?: boolean, anyKey?: boolean, addToHistory?: boolean): string;
|
|
202
|
+
function userMailAddress(): string | null;
|
|
203
|
+
function wait(seconds: number): null;
|
|
204
|
+
function whois(ip: string): string;
|
|
205
|
+
function yield(): null;
|
|
206
|
+
function getType(value: any): keyof GameTypeMap;
|
|
207
|
+
/** Checks if the given object is of a specific type
|
|
208
|
+
* @example
|
|
209
|
+
* const metax = includeLib("/lib/metaxploit.so");
|
|
210
|
+
* if (isType(metax, "MetaxploitLib")) {
|
|
211
|
+
* // Here TypeScript understands that metax is of type Metaxploit
|
|
212
|
+
* // So you can use something like this without errors
|
|
213
|
+
* metax.sniffer();
|
|
214
|
+
* }
|
|
215
|
+
*/
|
|
216
|
+
function isType<T extends keyof GameTypeMap>(value: any, type: T): value is GameTypeMap[T];
|
|
217
|
+
/** FOR TRANSPILER ONLY
|
|
218
|
+
*
|
|
219
|
+
* Includes the given source to this position. If the file was already transpiled then this does nothing
|
|
220
|
+
*
|
|
221
|
+
* Can be a folder if you want to include all the files inside
|
|
222
|
+
* @param file The absolute or relative path of the file */
|
|
223
|
+
function include(file: string): void;
|
|
224
|
+
type LibTypes = {
|
|
225
|
+
"aptclient.so": GreyHack.AptClient;
|
|
226
|
+
"metaxploit.so": GreyHack.Metaxploit;
|
|
227
|
+
"crypto.so": GreyHack.Crypto;
|
|
228
|
+
"libftp.so": GreyHack.Service;
|
|
229
|
+
"libssh.so": GreyHack.Service;
|
|
230
|
+
"libhttp.so": GreyHack.Service;
|
|
231
|
+
"blockchain.so": GreyHack.BlockChain;
|
|
232
|
+
"libsmartappliance.so": GreyHack.SmartAppliance;
|
|
233
|
+
"libtrafficnet.so": GreyHack.TrafficNet;
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
declare var activeUser: typeof GreyHack.activeUser;
|
|
237
|
+
declare var bitAnd: typeof GreyHack.bitAnd;
|
|
238
|
+
declare var bitOr: typeof GreyHack.bitOr;
|
|
239
|
+
declare var bitXor: typeof GreyHack.bitXor;
|
|
240
|
+
declare var bitwise: typeof GreyHack.bitwise;
|
|
241
|
+
declare var cd: typeof GreyHack.cd;
|
|
242
|
+
declare var char: typeof GreyHack.char;
|
|
243
|
+
declare var clearScreen: typeof GreyHack.clearScreen;
|
|
244
|
+
declare var code: typeof GreyHack.code;
|
|
245
|
+
declare var commandInfo: typeof GreyHack.commandInfo;
|
|
246
|
+
declare var currentDate: typeof GreyHack.currentDate;
|
|
247
|
+
declare var currentPath: typeof GreyHack.currentPath;
|
|
248
|
+
declare var exit: typeof GreyHack.exit;
|
|
249
|
+
declare var formatColumns: typeof GreyHack.formatColumns;
|
|
250
|
+
declare var getAbsPath: typeof GreyHack.getAbsPath;
|
|
251
|
+
declare var getCtf: typeof GreyHack.getCtf;
|
|
252
|
+
declare var getCustomObject: typeof GreyHack.getCustomObject;
|
|
253
|
+
declare var getRouter: typeof GreyHack.getRouter;
|
|
254
|
+
declare var getShell: typeof GreyHack.getShell;
|
|
255
|
+
declare var getSwitch: typeof GreyHack.getSwitch;
|
|
256
|
+
declare var hash: typeof GreyHack.hash;
|
|
257
|
+
declare var homeDir: typeof GreyHack.homeDir;
|
|
258
|
+
declare var importCode: typeof GreyHack.importCode;
|
|
259
|
+
declare var includeLib: typeof GreyHack.includeLib;
|
|
260
|
+
declare var isLanIp: typeof GreyHack.isLanIp;
|
|
261
|
+
declare var isValidIp: typeof GreyHack.isValidIp;
|
|
262
|
+
declare var launchPath: typeof GreyHack.launchPath;
|
|
263
|
+
declare var mailLogin: typeof GreyHack.mailLogin;
|
|
264
|
+
declare var md5: typeof GreyHack.md5;
|
|
265
|
+
declare var nslookup: typeof GreyHack.nslookup;
|
|
266
|
+
declare var parentPath: typeof GreyHack.parentPath;
|
|
267
|
+
declare var print: typeof GreyHack.print;
|
|
268
|
+
declare var programPath: typeof GreyHack.programPath;
|
|
269
|
+
declare var range: typeof GreyHack.range;
|
|
270
|
+
declare var resetCtfPassword: typeof GreyHack.resetCtfPassword;
|
|
271
|
+
declare var slice: typeof GreyHack.slice;
|
|
272
|
+
declare var str: typeof GreyHack.str;
|
|
273
|
+
declare var time: typeof GreyHack.time;
|
|
274
|
+
declare var userBankNumber: typeof GreyHack.userBankNumber;
|
|
275
|
+
declare var userInput: typeof GreyHack.userInput;
|
|
276
|
+
declare var userMailAddress: typeof GreyHack.userMailAddress;
|
|
277
|
+
declare var wait: typeof GreyHack.wait;
|
|
278
|
+
declare var whois: typeof GreyHack.whois;
|
|
279
|
+
declare var yield: typeof GreyHack.yield;
|
|
280
|
+
declare const getType: typeof GreyHack.getType;
|
|
281
|
+
declare const isType: typeof GreyHack.isType;
|
|
282
|
+
declare const include: typeof GreyHack.include;
|
|
283
|
+
type OtherTypeMap = {
|
|
284
|
+
"null": null;
|
|
285
|
+
"pcomputer": unknown;
|
|
286
|
+
"pfile": unknown;
|
|
287
|
+
"prouter": unknown;
|
|
288
|
+
"number": number;
|
|
289
|
+
"list": Array<any>;
|
|
290
|
+
"map": Record<string, any>;
|
|
291
|
+
"function": Function;
|
|
292
|
+
"string": string;
|
|
293
|
+
};
|
|
294
|
+
type ClassIDMap = {
|
|
295
|
+
"aptClientLib": GreyHack.AptClient;
|
|
296
|
+
"blockChainLib": GreyHack.BlockChain;
|
|
297
|
+
"ctfEvent": GreyHack.CtfEvent;
|
|
298
|
+
"coin": GreyHack.Coin;
|
|
299
|
+
"computer": GreyHack.Computer;
|
|
300
|
+
"ftpComputer": GreyHack.FtpComputer;
|
|
301
|
+
"cryptoLib": GreyHack.Crypto;
|
|
302
|
+
"debugLibrary": GreyHack.DebugLibrary;
|
|
303
|
+
"file": GreyHack.File;
|
|
304
|
+
"ftpFile": GreyHack.FtpFile;
|
|
305
|
+
"MetaLib": GreyHack.MetaLib;
|
|
306
|
+
"MetaMail": GreyHack.MetaMail;
|
|
307
|
+
"MetaxploitLib": GreyHack.Metaxploit;
|
|
308
|
+
"NetSession": GreyHack.NetSession;
|
|
309
|
+
"port": GreyHack.Port;
|
|
310
|
+
"router": GreyHack.Router;
|
|
311
|
+
"service": GreyHack.Service;
|
|
312
|
+
"shell": GreyHack.Shell;
|
|
313
|
+
"ftpShell": GreyHack.FtpShell;
|
|
314
|
+
"SmartAppliance": GreyHack.SmartAppliance;
|
|
315
|
+
"subwallet": GreyHack.SubWallet;
|
|
316
|
+
"TrafficNet": GreyHack.TrafficNet;
|
|
317
|
+
"wallet": GreyHack.Wallet;
|
|
318
|
+
};
|
|
319
|
+
type GameTypeMap = ClassIDMap & OtherTypeMap;
|
|
320
|
+
declare namespace GreyHack {
|
|
321
|
+
interface Service {
|
|
322
|
+
classID: "service";
|
|
323
|
+
installService(): true | string;
|
|
324
|
+
startService(): true | string;
|
|
325
|
+
stopService(): true | string;
|
|
326
|
+
}
|
|
327
|
+
interface Metaxploit {
|
|
328
|
+
classID: "MetaxploitLib";
|
|
329
|
+
load(path: string): MetaLib | null;
|
|
330
|
+
netUse(ip: string, port: number): NetSession | null;
|
|
331
|
+
rshellClient(ip: string, port: number, processName?: string): true | string;
|
|
332
|
+
rshellServer(): Shell[] | string;
|
|
333
|
+
scan(metaLib: MetaLib): string[] | null;
|
|
334
|
+
scanAddress(metaLib: MetaLib, memoryAddress: string): string | null;
|
|
335
|
+
sniffer(saveEncSource?: boolean): string | null;
|
|
336
|
+
}
|
|
337
|
+
interface MetaLib {
|
|
338
|
+
classID: "MetaLib";
|
|
339
|
+
libName: string;
|
|
340
|
+
version: string;
|
|
341
|
+
debugTools(user: string, password: string): string | DebugLibrary | null;
|
|
342
|
+
isPatched(getDate?: boolean): boolean | string | null;
|
|
343
|
+
overflow(memoryAddress: string, unsecZone: string, optArgs?: string): Shell | Computer | File | string | boolean | null;
|
|
344
|
+
}
|
|
345
|
+
interface DebugLibrary {
|
|
346
|
+
classID: "debugLibrary";
|
|
347
|
+
applyPatch(path: string): string | null;
|
|
348
|
+
payload<T extends string | undefined>(memZone: string, filePath?: T): string | null | (T extends string ? [Partial<Computer>, Partial<File>, MetaLib] : [Partial<Computer>]);
|
|
349
|
+
scan(): string;
|
|
350
|
+
unitTesting(errorLines: number[]): string | null;
|
|
351
|
+
}
|
|
352
|
+
interface Crypto {
|
|
353
|
+
classID: "cryptoLib";
|
|
354
|
+
aircrack(path: string): string | null;
|
|
355
|
+
aireplay(bssid: string, essid: string, maxAcks?: number): string | null;
|
|
356
|
+
airmon(option: "start" | "stop", device: netDevice): boolean | string;
|
|
357
|
+
decipher(hash: string): string | null;
|
|
358
|
+
decrypt(filePath: string, password: string): true | string | null;
|
|
359
|
+
encrypt(filePath: string, password: string): true | string | null;
|
|
360
|
+
isEncrypted(filePath: string): boolean | string | null;
|
|
361
|
+
smtpUserList(ip: string, port: number): string[] | string | null;
|
|
362
|
+
}
|
|
363
|
+
interface BlockChain {
|
|
364
|
+
classID: "blockchainLib";
|
|
365
|
+
amountMined(coinName: string): number | string | null;
|
|
366
|
+
coinPrice(coinName: string): number | string | null;
|
|
367
|
+
createWallet(user: string, password: string): Wallet | string | null;
|
|
368
|
+
deleteCoin(coinName: string, user: string, password: string): true | string | null;
|
|
369
|
+
getCoin(coinName: string, user: string, password: string): Coin | string | null;
|
|
370
|
+
getCoinName(user: string, password: string): string | null;
|
|
371
|
+
loginWallet(user: string, password: string): Wallet | string | null;
|
|
372
|
+
showHistory(coinName: string): Record<number, [number, string]> | string | null;
|
|
373
|
+
}
|
|
374
|
+
interface AptClient {
|
|
375
|
+
classID: "aptClientLib";
|
|
376
|
+
addRepo(repositoryAddress: string, port?: number): string | null;
|
|
377
|
+
checkUpgrade(filePath: string): boolean | string | null;
|
|
378
|
+
delRepo(repositoryAddress: string): string | null;
|
|
379
|
+
install(package: string, installPath?: string): true | string | null;
|
|
380
|
+
search(package: string): string | null;
|
|
381
|
+
show(repositoryAddress: string): string | null;
|
|
382
|
+
update(): string | false;
|
|
383
|
+
}
|
|
384
|
+
interface SmartAppliance {
|
|
385
|
+
classID: "SmartAppliance";
|
|
386
|
+
model(): string;
|
|
387
|
+
overrideSettings(power: number, temperature: number): true | string | null;
|
|
388
|
+
setAlarm(enable: boolean): true | string | null;
|
|
389
|
+
}
|
|
390
|
+
interface TrafficNet {
|
|
391
|
+
classID: "TrafficNet";
|
|
392
|
+
cameraLinkSystem(): true | string;
|
|
393
|
+
getCredentialsInfo(): string;
|
|
394
|
+
locateVehicle(licensePlate: string, password: string): true | string | null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
interface Math {
|
|
398
|
+
readonly PI: number;
|
|
399
|
+
readonly abs: typeof GreyHack.abs;
|
|
400
|
+
readonly acos: typeof GreyHack.acos;
|
|
401
|
+
readonly asin: typeof GreyHack.asin;
|
|
402
|
+
readonly atan: typeof GreyHack.atan;
|
|
403
|
+
readonly ceil: typeof GreyHack.ceil;
|
|
404
|
+
readonly floor: typeof GreyHack.floor;
|
|
405
|
+
readonly cos: typeof GreyHack.cos;
|
|
406
|
+
readonly sin: typeof GreyHack.sin;
|
|
407
|
+
readonly tan: typeof GreyHack.tan;
|
|
408
|
+
readonly sqrt: typeof GreyHack.sqrt;
|
|
409
|
+
readonly sign: typeof GreyHack.sign;
|
|
410
|
+
readonly round: typeof GreyHack.round;
|
|
411
|
+
readonly random: typeof GreyHack.rnd;
|
|
412
|
+
readonly log: typeof GreyHack.log;
|
|
413
|
+
readonly min: (...values: number[]) => number;
|
|
414
|
+
readonly max: (...values: number[]) => number;
|
|
415
|
+
}
|
|
416
|
+
declare var Math: Math;
|
|
417
|
+
declare namespace GreyHack {
|
|
418
|
+
interface CtfEvent {
|
|
419
|
+
classID: "ctfEvent";
|
|
420
|
+
getCreatorName(): string;
|
|
421
|
+
getDescription(): string;
|
|
422
|
+
getMailContent(): string;
|
|
423
|
+
getTemplate(): string;
|
|
424
|
+
playerSuccess(): boolean;
|
|
425
|
+
}
|
|
426
|
+
interface MetaMail {
|
|
427
|
+
classID: "MetaMail";
|
|
428
|
+
delete(mailId: string): true | string | null;
|
|
429
|
+
fetch(): string[] | string;
|
|
430
|
+
read(mailId: string): string | null;
|
|
431
|
+
send(emailAddress: string, subject: string, message: string): string | true | null;
|
|
432
|
+
}
|
|
433
|
+
interface NetSession {
|
|
434
|
+
classID: "NetSession";
|
|
435
|
+
dumpLib(): MetaLib;
|
|
436
|
+
floodConnection(): null;
|
|
437
|
+
getNumConnGateway(): number;
|
|
438
|
+
getNumPortforward(): number;
|
|
439
|
+
getNumUsers(): number;
|
|
440
|
+
isAnyActiveUser(): boolean;
|
|
441
|
+
isRootActiveUser(): boolean;
|
|
442
|
+
}
|
|
443
|
+
interface Port {
|
|
444
|
+
classID: "port";
|
|
445
|
+
portNumber: number;
|
|
446
|
+
isClosed: () => boolean;
|
|
447
|
+
getLanIp: () => string;
|
|
448
|
+
}
|
|
449
|
+
interface Router {
|
|
450
|
+
classID: "router";
|
|
451
|
+
bssidName: string;
|
|
452
|
+
essidName: string;
|
|
453
|
+
kernelVersion: string;
|
|
454
|
+
localIp: string;
|
|
455
|
+
publicIp: string;
|
|
456
|
+
devicePorts(ip: string): Port[] | string | null;
|
|
457
|
+
devicesLanIp(): string[];
|
|
458
|
+
firewallRules(): string[];
|
|
459
|
+
pingPort(portNumber: number): Port | null;
|
|
460
|
+
portInfo(port: Port): string | null;
|
|
461
|
+
usedPorts(): Port[];
|
|
462
|
+
}
|
|
463
|
+
interface FtpShell {
|
|
464
|
+
classID: "ftpShell";
|
|
465
|
+
hostComputer: FtpComputer;
|
|
466
|
+
scp: Shell["scp"];
|
|
467
|
+
}
|
|
468
|
+
interface Shell {
|
|
469
|
+
classID: "shell";
|
|
470
|
+
hostComputer: Computer;
|
|
471
|
+
build: (sourcePath: string, binaryPath: string, allowImport?: boolean) => string;
|
|
472
|
+
connectService: (ip: string, port: number, user: string, password: string, service?: "ssh" | "ftp") => Shell | FtpShell | string | null;
|
|
473
|
+
launch: (program: string, params?: string) => string | boolean;
|
|
474
|
+
ping: (ip: string) => string | boolean;
|
|
475
|
+
scp: (file: string, folder: string, remoteShell: Shell, isUpload?: boolean) => boolean | string | null;
|
|
476
|
+
startTerminal: () => never;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
interface RegExp {
|
|
480
|
+
}
|
|
481
|
+
interface CallableFunction {
|
|
482
|
+
}
|
|
483
|
+
interface NewableFunction {
|
|
484
|
+
}
|
|
485
|
+
interface IArguments {
|
|
486
|
+
}
|
|
487
|
+
interface Boolean {
|
|
488
|
+
}
|
|
489
|
+
interface String {
|
|
490
|
+
readonly length: number;
|
|
491
|
+
/** Returns the Unicode code of the first character of the string */
|
|
492
|
+
code(): number;
|
|
493
|
+
hasIndex(index: number): boolean;
|
|
494
|
+
indexOf(value: string, offset?: number): number | null;
|
|
495
|
+
indexes(): number[];
|
|
496
|
+
insert(index: number, value: string): string;
|
|
497
|
+
isMatch(pattern: string | RegExp, regexOptions?: string): number;
|
|
498
|
+
lastIndexOf(value: string): number;
|
|
499
|
+
lower(): string;
|
|
500
|
+
matches(pattern: string | RegExp, regexOptions?: string): Record<number, string>;
|
|
501
|
+
remove(value: string): string;
|
|
502
|
+
replace(pattern: string | RegExp, newValue: string, regexOptions?: string): string;
|
|
503
|
+
split(pattern: string | RegExp, regexOptions?: string): string[];
|
|
504
|
+
toInt(): string | number;
|
|
505
|
+
trim(): string;
|
|
506
|
+
upper(): string;
|
|
507
|
+
val(): number;
|
|
508
|
+
values(): string[];
|
|
509
|
+
readonly [index: number]: string;
|
|
510
|
+
}
|
|
511
|
+
interface Number {
|
|
512
|
+
}
|
|
513
|
+
type PropertyKey = number | string | symbol;
|
|
514
|
+
interface Object {
|
|
515
|
+
/** Returns the number of items inside the object */
|
|
516
|
+
readonly size: number;
|
|
517
|
+
hasIndex(key: PropertyKey): boolean;
|
|
518
|
+
indexOf(value: any): any;
|
|
519
|
+
indexes<T extends PropertyKey>(): T[];
|
|
520
|
+
pop(): any;
|
|
521
|
+
pull(): any;
|
|
522
|
+
push(key: PropertyKey): any;
|
|
523
|
+
remove(key: PropertyKey): boolean;
|
|
524
|
+
replace(oldValue: any, newValue: any, maxCount?: number): any;
|
|
525
|
+
shuffle(): null;
|
|
526
|
+
sum(): number;
|
|
527
|
+
values(): any[];
|
|
528
|
+
}
|
|
529
|
+
interface ObjectConstructor {
|
|
530
|
+
new (value?: any): Object;
|
|
531
|
+
readonly prototype: Object;
|
|
532
|
+
hasOwn<T extends PropertyKey, U = object>(o: U, key: T): o is (T extends keyof U ? U : U & {
|
|
533
|
+
[K in T]: unknown;
|
|
534
|
+
});
|
|
535
|
+
/** Copy the properties of the source to the target */
|
|
536
|
+
assign<T extends {}, U>(target: T, source: U): T & U;
|
|
537
|
+
assign<T extends {}, U, V>(target: T, source: U, source2: V): T & U & V;
|
|
538
|
+
assign<T extends {}, U, V, W>(target: T, source: U, source2: V, source3: W): T & U & V & W;
|
|
539
|
+
assign(target: object, ...sources: any[]): any;
|
|
540
|
+
keys<T extends Record<any, any>>(o: T): (Exclude<keyof T, symbol>)[];
|
|
541
|
+
}
|
|
542
|
+
interface Array<T> {
|
|
543
|
+
readonly length: number;
|
|
544
|
+
hasIndex(index: number): boolean;
|
|
545
|
+
indexOf(value: T, offset?: number): number | null;
|
|
546
|
+
indexes(): number[];
|
|
547
|
+
insert(index: number, value: T): T[];
|
|
548
|
+
join(delimiter: string): string;
|
|
549
|
+
pop(): T;
|
|
550
|
+
pull(): T;
|
|
551
|
+
push(value: T): T[];
|
|
552
|
+
remove(index: number): null;
|
|
553
|
+
replace(oldValue: T, newValue: T, maxCount?: number): T[];
|
|
554
|
+
reverse(): null;
|
|
555
|
+
shuffle(): null;
|
|
556
|
+
sort(key: PropertyKey | null, ascending?: boolean): T[];
|
|
557
|
+
sum(): number;
|
|
558
|
+
values(): T[];
|
|
559
|
+
concat(...items: (T | T[])[]): T[];
|
|
560
|
+
map<U>(callbackfn: (value: T, index: number, array: T[]) => U): U[];
|
|
561
|
+
filter(predicate: (value: T, index: number, array: T[]) => unknown): T[];
|
|
562
|
+
find(predicate: (value: T, index: number, array: T[]) => unknown): T | null;
|
|
563
|
+
some(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
|
|
564
|
+
every(predicate: (value: T, index: number, array: T[]) => unknown): boolean;
|
|
565
|
+
[n: number]: T;
|
|
566
|
+
}
|
|
567
|
+
interface Function {
|
|
568
|
+
}
|
|
569
|
+
declare var String: {
|
|
570
|
+
new (value?: string): String;
|
|
571
|
+
(value?: any): string;
|
|
572
|
+
readonly prototype: String;
|
|
573
|
+
};
|
|
574
|
+
declare var Number: {
|
|
575
|
+
readonly prototype: Number;
|
|
576
|
+
};
|
|
577
|
+
declare var Boolean: {
|
|
578
|
+
readonly prototype: Number;
|
|
579
|
+
};
|
|
580
|
+
declare var Array: {
|
|
581
|
+
readonly prototype: Array<any>;
|
|
582
|
+
};
|
|
583
|
+
declare var Function: {
|
|
584
|
+
readonly prototype: Function;
|
|
585
|
+
};
|
|
586
|
+
declare var Object: ObjectConstructor;
|
|
587
|
+
type netDeviceNumbers = 0 | 1 | 2 | 3 | 4;
|
|
588
|
+
type wlanDevice = `wlan${netDeviceNumbers}`;
|
|
589
|
+
type ethDevice = `eth${netDeviceNumbers}`;
|
|
590
|
+
type netDevice = wlanDevice | ethDevice;
|
|
591
|
+
/**
|
|
592
|
+
* Make all properties in T optional
|
|
593
|
+
*/
|
|
594
|
+
type Partial<T> = {
|
|
595
|
+
[P in keyof T]?: T[P];
|
|
596
|
+
};
|
|
597
|
+
/**
|
|
598
|
+
* Make all properties in T required
|
|
599
|
+
*/
|
|
600
|
+
type Required<T> = {
|
|
601
|
+
[P in keyof T]-?: T[P];
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* Make all properties in T readonly
|
|
605
|
+
*/
|
|
606
|
+
type Readonly<T> = {
|
|
607
|
+
readonly [P in keyof T]: T[P];
|
|
608
|
+
};
|
|
609
|
+
/**
|
|
610
|
+
* From T, pick a set of properties whose keys are in the union K
|
|
611
|
+
*/
|
|
612
|
+
type Pick<T, K extends keyof T> = {
|
|
613
|
+
[P in K]: T[P];
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* Construct a type with a set of properties K of type T
|
|
617
|
+
*/
|
|
618
|
+
type Record<K extends keyof any, T> = {
|
|
619
|
+
[P in K]: T;
|
|
620
|
+
};
|
|
621
|
+
/**
|
|
622
|
+
* Exclude from T those types that are assignable to U
|
|
623
|
+
*/
|
|
624
|
+
type Exclude<T, U> = (T extends U ? never : T);
|
|
625
|
+
/**
|
|
626
|
+
* Extract from T those types that are assignable to U
|
|
627
|
+
*/
|
|
628
|
+
type Extract<T, U> = (T extends U ? T : never);
|
|
629
|
+
/**
|
|
630
|
+
* Construct a type with the properties of T except for those in type K.
|
|
631
|
+
*/
|
|
632
|
+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
633
|
+
/**
|
|
634
|
+
* Obtain the parameters of a function type in a tuple
|
|
635
|
+
*/
|
|
636
|
+
type Parameters<T extends (...args: any) => any> = T extends (...args: infer P) => any ? P : never;
|
|
637
|
+
/**
|
|
638
|
+
* Obtain the parameters of a constructor function type in a tuple
|
|
639
|
+
*/
|
|
640
|
+
type ConstructorParameters<T extends abstract new (...args: any) => any> = T extends abstract new (...args: infer P) => any ? P : never;
|
|
641
|
+
/**
|
|
642
|
+
* Obtain the return type of a function type
|
|
643
|
+
*/
|
|
644
|
+
type ReturnType<T extends (...args: any) => any> = T extends (...args: any) => infer R ? R : any;
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@grey-ts/types",
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "TypeScript definitions for GreyHack's functions and objects",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/index.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"typescript": "^5.9.3"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"prepare": "npm run build",
|
|
15
|
+
"build": "tsc"
|
|
16
|
+
}
|
|
17
|
+
}
|