Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/js/generated/ts/ssh.ts
2070 views
1
2
3
/**
4
* SSHClient is a client for SSH servers.
5
* Internally client uses github.com/zmap/zgrab2/lib/ssh driver.
6
* @example
7
* ```javascript
8
* const ssh = require('nuclei/ssh');
9
* const client = new ssh.SSHClient();
10
* ```
11
*/
12
export class SSHClient {
13
14
15
// Constructor of SSHClient
16
constructor() {}
17
/**
18
* SetTimeout sets the timeout for the SSH connection in seconds
19
* @example
20
* ```javascript
21
* const ssh = require('nuclei/ssh');
22
* const client = new ssh.SSHClient();
23
* client.SetTimeout(10);
24
* ```
25
*/
26
public SetTimeout(sec: number): void {
27
return;
28
}
29
30
31
/**
32
* Connect tries to connect to provided host and port
33
* with provided username and password with ssh.
34
* Returns state of connection and error. If error is not nil,
35
* state will be false
36
* @example
37
* ```javascript
38
* const ssh = require('nuclei/ssh');
39
* const client = new ssh.SSHClient();
40
* const connected = client.Connect('acme.com', 22, 'username', 'password');
41
* ```
42
*/
43
public Connect(host: string, port: number, username: string): boolean | null {
44
return null;
45
}
46
47
48
/**
49
* ConnectWithKey tries to connect to provided host and port
50
* with provided username and private_key.
51
* Returns state of connection and error. If error is not nil,
52
* state will be false
53
* @example
54
* ```javascript
55
* const ssh = require('nuclei/ssh');
56
* const client = new ssh.SSHClient();
57
* const privateKey = `-----BEGIN RSA PRIVATE KEY----- ...`;
58
* const connected = client.ConnectWithKey('acme.com', 22, 'username', privateKey);
59
* ```
60
*/
61
public ConnectWithKey(host: string, port: number, username: string): boolean | null {
62
return null;
63
}
64
65
66
/**
67
* ConnectSSHInfoMode tries to connect to provided host and port
68
* with provided host and port
69
* Returns HandshakeLog and error. If error is not nil,
70
* state will be false
71
* HandshakeLog is a struct that contains information about the
72
* ssh connection
73
* @example
74
* ```javascript
75
* const ssh = require('nuclei/ssh');
76
* const client = new ssh.SSHClient();
77
* const info = client.ConnectSSHInfoMode('acme.com', 22);
78
* log(to_json(info));
79
* ```
80
*/
81
public ConnectSSHInfoMode(host: string, port: number): HandshakeLog | null | null {
82
return null;
83
}
84
85
86
/**
87
* Run tries to open a new SSH session, then tries to execute
88
* the provided command in said session
89
* Returns string and error. If error is not nil,
90
* state will be false
91
* The string contains the command output
92
* @example
93
* ```javascript
94
* const ssh = require('nuclei/ssh');
95
* const client = new ssh.SSHClient();
96
* client.Connect('acme.com', 22, 'username', 'password');
97
* const output = client.Run('id');
98
* log(output);
99
* ```
100
*/
101
public Run(cmd: string): string | null {
102
return null;
103
}
104
105
106
/**
107
* Close closes the SSH connection and destroys the client
108
* Returns the success state and error. If error is not nil,
109
* state will be false
110
* @example
111
* ```javascript
112
* const ssh = require('nuclei/ssh');
113
* const client = new ssh.SSHClient();
114
* client.Connect('acme.com', 22, 'username', 'password');
115
* const closed = client.Close();
116
* ```
117
*/
118
public Close(): boolean | null {
119
return null;
120
}
121
122
123
}
124
125
126
127
/**
128
* Algorithms Interface
129
*/
130
export interface Algorithms {
131
132
Kex?: string,
133
134
HostKey?: string,
135
136
W?: DirectionAlgorithms,
137
138
R?: DirectionAlgorithms,
139
}
140
141
142
143
/**
144
* DirectionAlgorithms Interface
145
*/
146
export interface DirectionAlgorithms {
147
148
Cipher?: string,
149
150
MAC?: string,
151
152
Compression?: string,
153
}
154
155
156
157
/**
158
* EndpointId Interface
159
*/
160
export interface EndpointId {
161
162
SoftwareVersion?: string,
163
164
Comment?: string,
165
166
Raw?: string,
167
168
ProtoVersion?: string,
169
}
170
171
172
173
/**
174
* HandshakeLog Interface
175
*/
176
export interface HandshakeLog {
177
178
Banner?: string,
179
180
UserAuth?: string[],
181
182
ServerID?: EndpointId,
183
184
ClientID?: EndpointId,
185
186
ServerKex?: KexInitMsg,
187
188
ClientKex?: KexInitMsg,
189
190
AlgorithmSelection?: Algorithms,
191
}
192
193
194
195
/**
196
* KexInitMsg Interface
197
*/
198
export interface KexInitMsg {
199
200
KexAlgos?: string[],
201
202
CiphersClientServer?: string[],
203
204
MACsServerClient?: string[],
205
206
LanguagesClientServer?: string[],
207
208
CompressionClientServer?: string[],
209
210
CompressionServerClient?: string[],
211
212
Reserved?: number,
213
214
MACsClientServer?: string[],
215
216
/**
217
* fixed size array of length: [16]
218
*/
219
220
Cookie?: Uint8Array,
221
222
ServerHostKeyAlgos?: string[],
223
224
CiphersServerClient?: string[],
225
226
LanguagesServerClient?: string[],
227
228
FirstKexFollows?: boolean,
229
}
230
231
232