Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
projectdiscovery
GitHub Repository: projectdiscovery/nuclei
Path: blob/dev/pkg/js/generated/ts/smtp.ts
2070 views
1
2
3
/**
4
* Client is a minimal SMTP client for nuclei scripts.
5
* @example
6
* ```javascript
7
* const smtp = require('nuclei/smtp');
8
* const client = new smtp.Client('acme.com', 25);
9
* ```
10
*/
11
export class Client {
12
13
14
// Constructor of Client
15
constructor(public host: string, public port: string ) {}
16
17
18
/**
19
* IsSMTP checks if a host is running a SMTP server.
20
* @example
21
* ```javascript
22
* const smtp = require('nuclei/smtp');
23
* const client = new smtp.Client('acme.com', 25);
24
* const isSMTP = client.IsSMTP();
25
* log(isSMTP)
26
* ```
27
*/
28
public IsSMTP(): SMTPResponse | null {
29
return null;
30
}
31
32
33
/**
34
* IsOpenRelay checks if a host is an open relay.
35
* @example
36
* ```javascript
37
* const smtp = require('nuclei/smtp');
38
* const message = new smtp.SMTPMessage();
39
* message.From('[email protected]');
40
* message.To('[email protected]');
41
* message.Subject('hello');
42
* message.Body('hello');
43
* const client = new smtp.Client('acme.com', 25);
44
* const isRelay = client.IsOpenRelay(message);
45
* ```
46
*/
47
public IsOpenRelay(msg: SMTPMessage): boolean | null {
48
return null;
49
}
50
51
52
/**
53
* SendMail sends an email using the SMTP protocol.
54
* @example
55
* ```javascript
56
* const smtp = require('nuclei/smtp');
57
* const message = new smtp.SMTPMessage();
58
* message.From('[email protected]');
59
* message.To('[email protected]');
60
* message.Subject('hello');
61
* message.Body('hello');
62
* const client = new smtp.Client('acme.com', 25);
63
* const isSent = client.SendMail(message);
64
* log(isSent)
65
* ```
66
*/
67
public SendMail(msg: SMTPMessage): boolean | null {
68
return null;
69
}
70
71
72
}
73
74
75
76
/**
77
* SMTPMessage is a message to be sent over SMTP
78
* @example
79
* ```javascript
80
* const smtp = require('nuclei/smtp');
81
* const message = new smtp.SMTPMessage();
82
* message.From('[email protected]');
83
* ```
84
*/
85
export class SMTPMessage {
86
87
88
// Constructor of SMTPMessage
89
constructor() {}
90
/**
91
* From adds the from field to the message
92
* @example
93
* ```javascript
94
* const smtp = require('nuclei/smtp');
95
* const message = new smtp.SMTPMessage();
96
* message.From('[email protected]');
97
* ```
98
*/
99
public From(email: string): SMTPMessage {
100
return this;
101
}
102
103
104
/**
105
* To adds the to field to the message
106
* @example
107
* ```javascript
108
* const smtp = require('nuclei/smtp');
109
* const message = new smtp.SMTPMessage();
110
* message.To('[email protected]');
111
* ```
112
*/
113
public To(email: string): SMTPMessage {
114
return this;
115
}
116
117
118
/**
119
* Subject adds the subject field to the message
120
* @example
121
* ```javascript
122
* const smtp = require('nuclei/smtp');
123
* const message = new smtp.SMTPMessage();
124
* message.Subject('hello');
125
* ```
126
*/
127
public Subject(sub: string): SMTPMessage {
128
return this;
129
}
130
131
132
/**
133
* Body adds the message body to the message
134
* @example
135
* ```javascript
136
* const smtp = require('nuclei/smtp');
137
* const message = new smtp.SMTPMessage();
138
* message.Body('hello');
139
* ```
140
*/
141
public Body(msg: Uint8Array): SMTPMessage {
142
return this;
143
}
144
145
146
/**
147
* Auth when called authenticates using username and password before sending the message
148
* @example
149
* ```javascript
150
* const smtp = require('nuclei/smtp');
151
* const message = new smtp.SMTPMessage();
152
* message.Auth('username', 'password');
153
* ```
154
*/
155
public Auth(username: string): SMTPMessage {
156
return this;
157
}
158
159
160
/**
161
* String returns the string representation of the message
162
* @example
163
* ```javascript
164
* const smtp = require('nuclei/smtp');
165
* const message = new smtp.SMTPMessage();
166
* message.From('[email protected]');
167
* message.To('[email protected]');
168
* message.Subject('hello');
169
* message.Body('hello');
170
* log(message.String());
171
* ```
172
*/
173
public String(): string {
174
return "";
175
}
176
177
178
}
179
180
181
182
/**
183
* SMTPResponse is the response from the IsSMTP function.
184
* @example
185
* ```javascript
186
* const smtp = require('nuclei/smtp');
187
* const client = new smtp.Client('acme.com', 25);
188
* const isSMTP = client.IsSMTP();
189
* log(isSMTP)
190
* ```
191
*/
192
export interface SMTPResponse {
193
194
IsSMTP?: boolean,
195
196
Banner?: string,
197
}
198
199
200