Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/js/generated/ts/mysql.ts
2070 views
1
2
3
/**
4
* BuildDSN builds a MySQL data source name (DSN) from the given options.
5
* @example
6
* ```javascript
7
* const mysql = require('nuclei/mysql');
8
* const options = new mysql.MySQLOptions();
9
* options.Host = 'acme.com';
10
* options.Port = 3306;
11
* const dsn = mysql.BuildDSN(options);
12
* ```
13
*/
14
export function BuildDSN(opts: MySQLOptions): string | null {
15
return null;
16
}
17
18
19
20
/**
21
* MySQLClient is a client for MySQL database.
22
* Internally client uses go-sql-driver/mysql driver.
23
* @example
24
* ```javascript
25
* const mysql = require('nuclei/mysql');
26
* const client = new mysql.MySQLClient;
27
* ```
28
*/
29
export class MySQLClient {
30
31
32
// Constructor of MySQLClient
33
constructor() {}
34
/**
35
* IsMySQL checks if the given host is running MySQL database.
36
* If the host is running MySQL database, it returns true.
37
* If the host is not running MySQL database, it returns false.
38
* @example
39
* ```javascript
40
* const mysql = require('nuclei/mysql');
41
* const isMySQL = mysql.IsMySQL('acme.com', 3306);
42
* ```
43
*/
44
public IsMySQL(host: string, port: number): boolean | null {
45
return null;
46
}
47
48
49
/**
50
* Connect connects to MySQL database using given credentials.
51
* If connection is successful, it returns true.
52
* If connection is unsuccessful, it returns false and error.
53
* The connection is closed after the function returns.
54
* @example
55
* ```javascript
56
* const mysql = require('nuclei/mysql');
57
* const client = new mysql.MySQLClient;
58
* const connected = client.Connect('acme.com', 3306, 'username', 'password');
59
* ```
60
*/
61
public Connect(host: string, port: number, username: string): boolean | null {
62
return null;
63
}
64
65
66
/**
67
* returns MySQLInfo when fingerpint is successful
68
* @example
69
* ```javascript
70
* const mysql = require('nuclei/mysql');
71
* const info = mysql.FingerprintMySQL('acme.com', 3306);
72
* log(to_json(info));
73
* ```
74
*/
75
public FingerprintMySQL(host: string, port: number): MySQLInfo | null {
76
return null;
77
}
78
79
80
/**
81
* ConnectWithDSN connects to MySQL database using given DSN.
82
* we override mysql dialer with fastdialer so it respects network policy
83
* If connection is successful, it returns true.
84
* @example
85
* ```javascript
86
* const mysql = require('nuclei/mysql');
87
* const client = new mysql.MySQLClient;
88
* const connected = client.ConnectWithDSN('username:password@tcp(acme.com:3306)/');
89
* ```
90
*/
91
public ConnectWithDSN(dsn: string): boolean | null {
92
return null;
93
}
94
95
96
/**
97
* ExecuteQueryWithOpts connects to Mysql database using given credentials
98
* and executes a query on the db.
99
* @example
100
* ```javascript
101
* const mysql = require('nuclei/mysql');
102
* const options = new mysql.MySQLOptions();
103
* options.Host = 'acme.com';
104
* options.Port = 3306;
105
* const result = mysql.ExecuteQueryWithOpts(options, 'SELECT * FROM users');
106
* log(to_json(result));
107
* ```
108
*/
109
public ExecuteQueryWithOpts(opts: MySQLOptions, query: string): SQLResult | null | null {
110
return null;
111
}
112
113
114
/**
115
* ExecuteQuery connects to Mysql database using given credentials
116
* and executes a query on the db.
117
* @example
118
* ```javascript
119
* const mysql = require('nuclei/mysql');
120
* const result = mysql.ExecuteQuery('acme.com', 3306, 'username', 'password', 'SELECT * FROM users');
121
* log(to_json(result));
122
* ```
123
*/
124
public ExecuteQuery(host: string, port: number, username: string): SQLResult | null | null {
125
return null;
126
}
127
128
129
/**
130
* ExecuteQuery connects to Mysql database using given credentials
131
* and executes a query on the db.
132
* @example
133
* ```javascript
134
* const mysql = require('nuclei/mysql');
135
* const result = mysql.ExecuteQueryOnDB('acme.com', 3306, 'username', 'password', 'dbname', 'SELECT * FROM users');
136
* log(to_json(result));
137
* ```
138
*/
139
public ExecuteQueryOnDB(host: string, port: number, username: string): SQLResult | null | null {
140
return null;
141
}
142
143
144
}
145
146
147
148
/**
149
* MySQLInfo contains information about MySQL server.
150
* this is returned when fingerprint is successful
151
*/
152
export interface MySQLInfo {
153
154
Host?: string,
155
156
IP?: string,
157
158
Port?: number,
159
160
Protocol?: string,
161
162
TLS?: boolean,
163
164
Transport?: string,
165
166
Version?: string,
167
168
Debug?: ServiceMySQL,
169
170
Raw?: string,
171
}
172
173
174
175
/**
176
* MySQLOptions defines the data source name (DSN) options required to connect to a MySQL database.
177
* along with other options like Timeout etc
178
* @example
179
* ```javascript
180
* const mysql = require('nuclei/mysql');
181
* const options = new mysql.MySQLOptions();
182
* options.Host = 'acme.com';
183
* options.Port = 3306;
184
* ```
185
*/
186
export interface MySQLOptions {
187
188
Host?: string,
189
190
Port?: number,
191
192
Protocol?: string,
193
194
Username?: string,
195
196
Password?: string,
197
198
DbName?: string,
199
200
RawQuery?: string,
201
202
Timeout?: number,
203
}
204
205
206
207
/**
208
* SQLResult Interface
209
*/
210
export interface SQLResult {
211
212
Count?: number,
213
214
Columns?: string[],
215
}
216
217
218
219
/**
220
* ServiceMySQL Interface
221
*/
222
export interface ServiceMySQL {
223
224
PacketType?: string,
225
226
ErrorMessage?: string,
227
228
ErrorCode?: number,
229
}
230
231
232