-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathinc_etc.py
138 lines (119 loc) · 3.38 KB
/
inc_etc.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
#!/usr/local/opt/[email protected]/bin/python3
# -*- coding: utf-8 -*-
__author__ = 'DrPython3'
__date__ = '2021-12-04'
__version__ = '2.51'
__contact__ = 'https://github.com/DrPython3'
'''
-------------------------------------
Various Functions used by Mail.Rip V3
-------------------------------------
Part of << Mail.Rip V3: https://github.com/DrPython3/MailRipV3 >>
'''
# [IMPORTS]
# ---------
import sys
import os
import re
import json
import tkinter as tk
from tkinter import filedialog
# [FUNCTIONS]
# -----------
def result(target_file, result_output):
'''
Saves any output to a certain file in directory "results".
:param str target_file: file to use
:param str result_output: output to save
:return: True (output saved), False (output not saved)
'''
# create results directory if not exists:
try:
os.makedirs('results')
except:
pass
# write output to given file:
try:
output_file = os.path.join('results', str(f'{target_file}.txt'))
with open(str(output_file), 'a+') as output:
output.write(str(f'{result_output}\n'))
return True
except:
return False
def email_verification(email):
'''
Checks whether a certain string represents an email.
:param str email: string to check
:return: True (is email), False (no email)
'''
email_format = '^([\w\.\-]+)@([\w\-]+)((\.(\w){2,63}){1,3})$'
# check given email using format-string:
if re.search(email_format, email):
return True
else:
return False
def blacklist_check(email):
'''
Checks whether the domain of a given email is on the blacklist.
:param str email: email to check
:return: True (blacklisted), False (not blacklisted)
'''
# try to load blacklist from JSON-file:
try:
with open('inc_domainblacklist.json') as included_imports:
load_blacklist = json.load(included_imports)
blacklist = (load_blacklist['domainblacklist'])
# on errors, set empty blacklist:
except:
blacklist = []
# check email domain against blacklist:
if str(email.split('@')[1]) in blacklist:
return True
else:
return False
def domain_verification(domain):
'''
Checks whether a certain string represents a domain.
:param str domain: string to check
:return: True (is domain), False (no domain)
'''
domain_format = '^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$'
# check whether string is a valid domain:
if re.search(domain_format, domain):
return True
else:
return False
def clean():
'''
NO-GUI-Version only: Provides a blank screen on purpose.
:return: None
'''
try:
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
except:
pass
return None
def get_combofile_nogui():
'''
NO-GUI-Version only: Provides a open-file-dialog using tkinter.
:return: combofile chosen by user
'''
open_file = tk.Tk()
# hide Tk window:
open_file.withdraw()
# start dialog:
import_file = filedialog.askopenfilename(
title='Select Combofile',
filetypes=(('txt files', '*.txt'),('all files','*.*'))
)
# kill Tk window and return chosen file:
try:
open_file.destroy()
open_file.quit()
except:
pass
return import_file
# DrPython3 (C) 2021 @ GitHub.com