Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Lucksi
GitHub Repository: Lucksi/Mr.Holmes
Path: blob/master/Core/Support/Creds.py
1071 views
1
# ORIGINAL CREATOR: Luca Garofalo (Lucksi)
2
# AUTHOR: Luca Garofalo (Lucksi)
3
# Copyright (C) 2021-2023 Lucksi <[email protected]>
4
# License: GNU General Public License v3.0
5
6
from email import encoders
7
from email.mime.base import MIMEBase
8
from email.mime.text import MIMEText
9
from Core.Support import Font
10
from email.mime.multipart import MIMEMultipart
11
from configparser import ConfigParser
12
from Core.Support import Language
13
import smtplib
14
import re as Regex
15
16
LangFile = Language.Translation.Get_Language()
17
LangFile
18
19
20
class Sender:
21
22
@staticmethod
23
def mail(report, username):
24
nomefile = "Configuration/Configuration.ini"
25
Parser = ConfigParser()
26
Parser.read(nomefile)
27
status = Parser["Smtp"]["status"]
28
if status == "Enabled":
29
simbols = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
30
email = Parser["Smtp"]["email"]
31
destination = Parser["Smtp"]["destination"]
32
if Regex.fullmatch(simbols, email) and Regex.fullmatch(simbols, destination):
33
mail = int(input(
34
Font.Color.BLUE + "\n[?]" + Font.Color.WHITE + Language.Translation.Translate_Language(LangFile, "RecapEmail", "Sender", "None") + Font.Color.GREEN + "\n\n[#MR.HOLMES#]" + Font.Color.WHITE + "-->"))
35
if mail == 1:
36
print(
37
Font.Color.GREEN + "\n[+]" + Font.Color.WHITE + Language.Translation.Translate_Language(LangFile, "RecapEmail", "InProgress", "None"))
38
email = Parser["Smtp"]["email"]
39
password = Parser["Smtp"]["password"]
40
destination = Parser["Smtp"]["destination"]
41
host = Parser["Smtp"]["server"]
42
host2 = (str(host))
43
port = Parser["Smtp"]["port"]
44
port2 = (int(port))
45
message = MIMEMultipart()
46
message['From'] = "MR.HOLMES:"
47
message["To"] = destination
48
message["Subject"] = "RESULTS FOR: " + username
49
msg = "Query results:"
50
message.attach(MIMEText(msg, "plain"))
51
filename = report
52
attachment = open(filename, "rb")
53
file = MIMEBase("application", "octet-stream")
54
file.set_payload(attachment.read())
55
encoders.encode_base64(file)
56
file.add_header("Content-Disposition",
57
"attachment;filename=" + filename)
58
message.attach(file)
59
try:
60
server = smtplib.SMTP(host2, port2)
61
server.ehlo()
62
server.starttls()
63
server.login(email, password)
64
text = message.as_string()
65
server.sendmail(email, destination, text)
66
inp = input(
67
Font.Color.YELLOW + "\n[v]" + Font.Color.WHITE + Language.Translation.Translate_Language(LangFile, "RecapEmail", "Sent", "None"))
68
server.close()
69
except smtplib.SMTPException:
70
inp = input(Font.Color.RED + "\n[!]" + Font.Color.WHITE +
71
Language.Translation.Translate_Language(LangFile, "RecapEmail", "NotSent", "None"))
72
elif mail == 2:
73
pass
74
#inp = input(Language.Translation.Translate_Language(
75
# LangFile, "Default", "Continue", "None"))
76
else:
77
print(Font.Color.RED + "\n[!]" + Font.Color.WHITE + Language.Translation.Translate_Language(
78
LangFile, "RecapEmail", "NotValid", "None"))
79
else:
80
print(Font.Color.RED + "\n[!]" + Font.Color.WHITE + Language.Translation.Translate_Language(
81
LangFile, "RecapEmail", "Disabled", "None"))
82
83