-
Notifications
You must be signed in to change notification settings - Fork 11
/
fakemail.py
126 lines (108 loc) · 4.93 KB
/
fakemail.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
import pyperclip
import requests
import random
import string
import time
import sys
import re
import os
API = 'https://www.1secmail.com/api/v1/'
domainList = ['1secmail.com', '1secmail.net', '1secmail.org']
domain = random.choice(domainList)
def banner():
print(r'''
▄████ ██ █ █▀ ▄███▄ █▀▄▀█ ██ ▄█ █
█▀ ▀ █ █ █▄█ █▀ ▀ █ █ █ █ █ ██ █
█▀▀ █▄▄█ █▀▄ ██▄▄ █ ▄ █ █▄▄█ ██ █
█ █ █ █ █ █▄ ▄▀ █ █ █ █ ▐█ ███▄
█ █ █ ▀███▀ █ █ ▐ ▀
▀ █ ▀ ▀ █
▀ ▀
domainList = ['1secmail.com','1secmail.net','1secmail.org']
''')
def generateUserName():
name = string.ascii_lowercase + string.digits
username = ''.join(random.choice(name) for i in range(10))
return username
def extract():
getUserName = re.search(r'login=(.*)&',newMail).group(1)
getDomain = re.search(r'domain=(.*)', newMail).group(1)
return [getUserName, getDomain]
# Got this from https://stackoverflow.com/a/43952192/13276219
def print_statusline(msg: str):
last_msg_length = len(print_statusline.last_msg) if hasattr(print_statusline, 'last_msg') else 0
print(' ' * last_msg_length, end='\r')
print(msg, end='\r')
sys.stdout.flush()
print_statusline.last_msg = msg
def deleteMail():
url = 'https://www.1secmail.com/mailbox'
data = {
'action': 'deleteMailbox',
'login': f'{extract()[0]}',
'domain': f'{extract()[1]}'
}
print_statusline("Disposing your email address - " + mail + '\n')
req = requests.post(url, data=data)
def checkMails():
reqLink = f'{API}?action=getMessages&login={extract()[0]}&domain={extract()[1]}'
req = requests.get(reqLink).json()
length = len(req)
if length == 0:
print_statusline("Your mailbox is empty. Hold tight. Mailbox is refreshed automatically every 5 seconds.")
else:
idList = []
for i in req:
for k,v in i.items():
if k == 'id':
mailId = v
idList.append(mailId)
x = 'mails' if length > 1 else 'mail'
print_statusline(f"You received {length} {x}. (Mailbox is refreshed automatically every 5 seconds.)")
current_directory = os.getcwd()
final_directory = os.path.join(current_directory, r'All Mails')
if not os.path.exists(final_directory):
os.makedirs(final_directory)
for i in idList:
msgRead = f'{API}?action=readMessage&login={extract()[0]}&domain={extract()[1]}&id={i}'
req = requests.get(msgRead).json()
for k,v in req.items():
if k == 'from':
sender = v
if k == 'subject':
subject = v
if k == 'date':
date = v
if k == 'textBody':
content = v
mail_file_path = os.path.join(final_directory, f'{i}.txt')
with open(mail_file_path,'w') as file:
file.write("Sender: " + sender + '\n' + "To: " + mail + '\n' + "Subject: " + subject + '\n' + "Date: " + date + '\n' + "Content: " + content + '\n')
banner()
userInput1 = input("Do you wish to use to a custom domain name (Y/N): ").capitalize()
try:
if userInput1 == 'Y' or userInput1 == 'y' :
userInput2 = input("\nEnter the name that you wish to use as your domain name: ")
newMail = f"{API}?login={userInput2}&domain={domain}"
reqMail = requests.get(newMail)
mail = f"{extract()[0]}@{extract()[1]}"
pyperclip.copy(mail)
print("\nYour temporary email is " + mail + " (Email address copied to clipboard.)" +"\n")
print(f"---------------------------- | Inbox of {mail}| ----------------------------\n")
while True:
checkMails()
time.sleep(5)
if userInput1 == 'N' or userInput1 == 'n':
newMail = f"{API}?login={generateUserName()}&domain={domain}"
reqMail = requests.get(newMail)
mail = f"{extract()[0]}@{extract()[1]}"
pyperclip.copy(mail)
print("\nYour temporary email is " + mail + " (Email address copied to clipboard.)" + "\n")
print(f"---------------------------- | Inbox of {mail} | ----------------------------\n")
while True:
checkMails()
time.sleep(5)
except(KeyboardInterrupt):
deleteMail()
print("\nProgramme Interrupted")
os.system('cls' if os.name == 'nt' else 'clear')