-
Notifications
You must be signed in to change notification settings - Fork 0
/
xrmailer.py
executable file
·507 lines (453 loc) · 14.3 KB
/
xrmailer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
#!/usr/bin/python3
######################################################################
# Copyright (c). All rights reserved #
# GNU GENERAL PUBLIC LICENSE #
# Version 3, 29 June 2007 #
# #
# Coded by Solomon Narh (::XploitsR Author::) #
# Github: https://github.com/XploitsR/XRMailer #
# Facebook: https://facebook.com/RXploits #
# Twitter: https://twitter.com/RXploits #
# Telegram: https://t.me/RXploits #
# Website: https://xploitsr.tk #
# #
# ::PERSONAL ME:: #
# Github: https://github.com/XploitsR/XRMailer #
# Facebook: https://facebook.com/solomon.narh.311 #
# Twitter: https://twitter.com/Solomon97062 #
# Instagram: @_xploitsr_author_1 #
# Email: [email protected] #
######################################################################
try:
import sys,csv,os
import smtplib, ssl
import getpass
import time
from email import encoders
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
except (ModuleNotFoundError,ImportError) as e:
print(e)
print("Wait....updating and upgrading your system")
time.sleep(2)
os.system("apt-get update && apt-get upgrade -y")
quit()
Temp = False
userMassBool = None
userDocBool = None
bBool = None
############################
# Pre-defined functions!! #
############################
#Temps && files
def Tempt():
return "templates/"
def Email():
return "emails/"
def File():
return "files/"
def Templates():
from templates.templates import friendly,business,customHtml,customText
return [friendly(),business(),customHtml(),customText()]
def print_customText():
print(
"""
[===========================]
[ ::CUSTOM TEXT:: ]
[ Put your Custom Text ]
[ Into The Templates Folder ]
[ And Specify The Name Here ]
[ Save It As .txt ]
[ Example: sample.txt ]
[===========================]
"""
)
def print_customTextHtml():
n = """
[==============================]
[ ::CUSTOM TEXT:: ]
[ Put your Custom Text ]
[ Into The Templates Folder ]
[ And Specify The Name Here ]
[ Save It As .txt ]
[ Example: sample.txt ]
[ It can include any <body> ]
[ Elements::example <b><a><i> ]
[ <img><p><span> and many more ]
[==============================]
"""
b = """
[===========================]
[ ::CUSTOM HTML TEMPLATE:: ]
[ Put your Custom Template ]
[ Into The Templates Folder ]
[ And Specify The Name Here ]
[ Example: sample.html ]
[===========================]
"""
return [n,b]
def print_docText():
print(
"""
[=============================]
[ ::Specify your attachment:: ]
[ put your file ]
[ into the files folder ]
[ and specify the name here ]
[ example: sample.png ]
[=============================]
"""
)
def accept_file(fileDir,filetype,readType,fileExt):
try:
cText = str(input(f"[#] File (eg: {filetype}): "))
if len(cText.strip()) > 0:
verifyTEXTFile = open(fileDir + cText.strip(),f"{readType}")
if verifyTEXTFile is not None:
with verifyTEXTFile as f:
r = f.read()
temp = Templates()[3] %(r.strip())
f.close()
else:
print(f"[!] Don't be silly!, please specify a {fileExt} file")
quit()
except FileNotFoundError:
print("[!] Don't be silly!, file not found")
quit()
return temp
def accept_docfile(filetype,readType):
#Accept Attachment
try:
global userDocBool,doc;
userDoc = str(input(f"[#] File(eg: {filetype}): "))
if len(userDoc.strip()) > 0:
verifyDOCFile = open(File() + userDoc.strip(),f"{readType}")
if verifyDOCFile is not None:
with verifyDOCFile as attachment:
#Add file as application/octet-stream
#The Email Client can download this attachment
userDocBool = True
doc = MIMEBase("application","octet-stream")
doc.set_payload(attachment.read())
encoders.encode_base64(doc)
doc.add_header(
"Content-Disposition",
f"attachment; filename={userDoc}",
)
else:
print("[!] Don't be silly!, please specify an attachment")
quit()
except FileNotFoundError:
print("[!] Don't be silly!, file not found")
quit()
def print_friendlyHdtext():
print(
"""
[===========================]
[ ::LETS EDIT THE FILE:: ]
[ HEADER ]
[ Title,Content..etc ]
[===========================]
"""
)
def accept_friendlyFunc(t,s,m,f,tw,num):
try:
cTitl = str(input(f"[#] Your Title (eg: {t}): "))
cSalu = str(input(f"[#] Your Salutation (eg: {s}): "))
time.sleep(1)
print(print_customTextHtml()[0])
cBody = str(input(f"[#] Your Message(File) (eg: {m}): "))
time.sleep(1)
print(
"""
[===========================]
[ ::LETS EDIT THE FILE:: ]
[ FOOTER ]
[ How one gets in touch ]
[ with you. ]
[===========================]
"""
)
cFb = str(input(f"{f}"))
cTw = str(input(f"{tw}"))
try:
if len(cTitl.strip()) > 0 and len(cSalu.strip()) > 0 and len(cBody.strip()) > 0 and len(cFb.strip()) > 0 and len(cTw.strip()) > 0:
verifyCBodyFile = open(Tempt() + cBody.strip())
if verifyCBodyFile is not None:
with verifyCBodyFile as f:
r = f.read()
if num == 0:
temp = Templates()[num] %(cTitl.strip(),cSalu.strip(),r.strip(),cFb.strip(),cTw.strip())
elif num == 1:
temp = Templates()[num] %(cTitl.strip(),cSalu.strip(),r.strip(),cFb.strip(),cTw.strip().replace(" ","+"),cTw.strip())
f.close()
else:
print("[!] Don't be silly!, please specify your custom message file(.txt)")
quit()
except FileNotFoundError:
print("[!] Don't be silly!, file not found")
quit()
except ValueError:
print("[!] Don't be silly!, Unknown value")
quit()
return temp
######################
####### End ##########
######################
#this extends smtp_*()
print(
"""
[=========================]
[ EMAIL SERVICE PROVIDERS ]
[=========================]
"""
)
try:
try:
from xrsmtp import XRSmtp
xr = XRSmtp()
except (ModuleNotFoundError,ImportError) as e:
print(e)
print("Type: pip install xrsmtp to install the missing module.")
quit()
print(" 1: Gmail\n 2: Yahoo")
userProv = int(input("[#] Choose: "))
#Verify Email Service Providers
if userProv == 1:
smtp_S = xr.smtp_portSSL("Gmail")[0]
smtp_P = xr.smtp_portSSL("Gmail")[1]
elif userProv == 2:
smtp_S = xr.smtp_portSSL("Yahoo")[0]
smtp_P = xr.smtp_portSSL("Yahoo")[1]
else:
print("[!] Don't be silly!, choose from above list");
quit()
except ValueError:
print("[!] Don't be silly!, Unknown value")
quit()
print(" ")
time.sleep(1)
#Email type
print(
"""
[==============================]
[ TYPE OF EMAIL ]
[==============================]
"""
)
try:
from templates.templates import customText
print(" 1: PlainText\n 2: HTML\n 3: PlainText With Attachment\n 4: HTML With Attachment")
userType = int(input("[#] Choose: "))
#Verify Email Type
if userType == 1:
Emtype = "plain"
userDocBool = None
print_customText()
temp = accept_file(Tempt(),"sample.txt","r",".txt")
elif userType == 2:
Emtype = "html"
Temp = True
userDocBool = None
elif userType == 3:
Emtype = "plain"
print_customText()
temp = accept_file(Tempt(),"sample.txt","r",".txt")
print(" ")
time.sleep(1)
print_docText()
accept_docfile("sample.pdf","rb")
elif userType == 4:
Emtype = "html"
Temp = True
print_docText()
accept_docfile("sample.pdf","rb")
else:
print("[!] Don't be silly!, choose from above list");
quit()
except ValueError:
print("[!] Don't be silly!, Unknown value")
quit()
print(" ")
time.sleep(1)
try:
if Temp:
print(
"""
[==============================]
[ CHOOSE TEMPLATE ]
[==============================]
"""
)
print(" 1: Friendly\n 2: Business\n 3: Custom ")
userTemp = int(input("[#] Choose: "))
if userTemp == 1:
print_friendlyHdtext()
fb = "[#] Facebook Link (eg: https://facebook.com/you): "
tw = "[#] Twitter Link (eg: https://twitter.com/you): "
temp = accept_friendlyFunc("Love letter","Hi Sarah","sample.txt",fb,tw,0)
elif userTemp == 2:
print_friendlyHdtext()
fb = "[#] Companies Name (eg: Facebook inc): "
tw = "[#] Companies Address (eg: 1601 Willow Road): "
bTemp = accept_friendlyFunc("Webinar","Dear members,","sample.txt",fb,tw,1)
bBool = True
elif userTemp == 3:
print(print_customTextHtml()[1])
temp = accept_file(Tempt(),"sample.html","r",".html")
else:
print("[!] Don't be silly!, choose from above list");
quit()
except ValueError:
print("[!] Don't be silly!, Unknown value")
quit()
time.sleep(1)
try:
print(
"""
[==============================]
[ TO MULTIPLE USERS ? ]
[==============================]
"""
)
print(" 1: Yes\n 2: No")
userMass = int(input("[#] Choose: "))
time.sleep(1)
print(" ")
if userMass == 1:
print(
"""
[===========================]
[ Put A File In Emails ]
[ Folder Containing Your ]
[ Emails... ]
[ First Line Of The File ]
[ Should Be *number,email* ]
[ Without the asterisks (*) ]
[ For Each Column, Specify ]
[ The Number... ]
[ File Should Be Saved With ]
[ An Extension as .csv in ]
[ Emails Folder... ]
[ ]
[ ::You can Check a sample::]
[ ::File in Emails Folder:: ]
[ ]
[ ::Example:: sample.csv ]
[ ]
[ number,email ]
[ 1,[email protected] ]
[ 2,[email protected] ]
[ 3,[email protected] ]
[===========================]
"""
)
try:
userMassFile = str(input("[#] File(eg: sample.csv): "))
if len(userMassFile.strip()) > 0:
verifyCSVFile = open(Email() + userMassFile.strip())
if verifyCSVFile is not None:
userMassBool = True
else:
print("[!] Don't be silly!, please specify your .csv file")
quit()
except FileNotFoundError:
print("[!] Don't be silly!, file not found")
quit()
elif userMass == 2:
userMassBool = None
except ValueError:
print("[!] Don't be silly!, Unknown value")
quit()
time.sleep(1)
print(
"""
[==============================]
[ SEND MAIL ]
[==============================]
"""
)
from_addr = str(input("[*] Senders email: "))
from_addr.strip()
password = getpass.getpass("[*] Senders password: ")
from_name = str(input("[*] Senders name: "))
if userMassBool is None:
to_addrs = str(input("[*] Recipients email: "))
subject = str(input("[*] Subject: "))
#Multipart Email Module :: Multipart("alternate")
msg = MIMEMultipart()
msg["Subject"] = subject
#Bug in Gmail is ;)
msg["From"] = from_name + " ;)"
if len(from_addr.strip()) > 0 and len(password.strip()) > 0 and len(subject.strip()) > 0:
print("[*] Sending Mail...Please Wait...")
#create a secure SSL context
context = ssl.create_default_context()
try:
with smtplib.SMTP_SSL(smtp_S, smtp_P, context=context) as server:
server.login(from_addr, password)
if userMassBool is not None and userDocBool is None:
with verifyCSVFile as file:
reader = csv.reader(file)
next(reader) # Skip header row
if bBool is not None:
temp = bTemp
# Turn these into plain/html MIMEText objects
Emtype = MIMEText(temp, Emtype)
msg.attach(Emtype)
for number,email in reader:
server.sendmail(
from_addr,
email.strip(),
msg.as_string(),
)
print(f"[*] Mail Sent To {email}")
elif userMassBool is not None and userDocBool is not None:
with verifyCSVFile as file:
reader = csv.reader(file)
next(reader) # Skip header row
if bBool is not None:
temp = bTemp
# Turn these into plain/html MIMEText objects
Emtype = MIMEText(temp, Emtype)
msg.attach(Emtype)
msg.attach(doc)
for number,email in reader:
server.sendmail(
from_addr,
email.strip(),
msg.as_string(),
)
print(f"[*] Mail Sent To {email}")
elif userMassBool is None and userDocBool is None:
msg["To"] = to_addrs.strip()
if bBool is not None:
temp = bTemp
Emtype = MIMEText(temp, Emtype)
msg.attach(Emtype)
server.sendmail(
from_addr,
to_addrs.strip(),
msg.as_string(),
)
print("[*] Mail Sent To " + to_addrs)
elif userMassBool is None and userDocBool is not None:
if bBool is not None:
temp = bTemp
Emtype = MIMEText(temp, Emtype)
msg.attach(Emtype)
msg.attach(doc)
server.sendmail(
from_addr,
to_addrs.strip(),
msg.as_string(),
)
print("[*] Mail Sent To " + to_addrs)
server.quit()
except Exception as e:
print(e)
quit()
else:
print("[!] Don't be silly!, spaces cant be empty")
quit()