Skip to content

Commit

Permalink
Merge pull request #19 from paveldat/dev/pdat
Browse files Browse the repository at this point in the history
Add one_sec_mail tool
  • Loading branch information
paveldat committed Sep 12, 2023
2 parents 885944e + 99a421e commit bab4a61
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
out/
out/logs
**/__pycache__
**/__pycache__
dist/
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[MESSAGES CONTROL]
disable = C0413, W1203, W0703, R1710, R0903, R1732,
R0201, W1508, R0801
R0201, W1508, R0801, R0902
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# gods_eye changelog

## 1.0.9
- Add one_sec_mail tool.
- Update README

## 1.0.8
- Add status badge Markdown

Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ pip install dist/gods_eye-<version>-py3-none-any.whl
pip install <downloaded_file>.whl
```

### 3. Installation from `PyPI`
```shell
pip install gods-eye
```

## Tools
1. Clickjacking - Checks if the clickjacking is possible on any Domain.
2. DnsLookup - Looks for dns lookup information for IP or Domain.
3. exec_shell_command - Common method to execute shell commands.
4. HttpHeadersGrabber - Looks for HTTP Headers.
5. GetHostname - Gets hostname and IP.
6. IpInfoFinder - Gets information by IP or Domain. Info: ip, status, region, country, country code, region, region name, city, zip, lat, lon,
timezone, isp, org, as.
7. Logger - Logger. The Logger has 2 handlers:
* stream handler into console;
* file handler into file.
8. OneSecMail - Creates one-time temporary mail.
9. PhoneInfo - Gets info by phone number.
10. PasswordPwned - Checks if password has been compromised in a data breach.
11. RobotsScanner - A robots.txt file tells search engine crawlers which URLs the crawler can access on your site. This class will search for this file, parse it and return the result.
12. WhoisLookup - Search for IP WHOIS information using the IP WHOIS lookup tool for any allocated IP address.

## How to use
Now you can use this library. To connect a module to your project, just import it.
All modules can be found in the `src` directory.
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = gods_eye
version = 1.0.8
version = 1.0.9
author = Pavel Dat
author_email = dats.pavel1999@gmail.com
description = A set of tools which should be used in Gods Eye
Expand All @@ -24,6 +24,7 @@ packages =
ip_info_finder
pwned
phone_info
one_sec_mail
install_requires =
requests >= 2.25.1
dnspython >= 2.2.1
Expand All @@ -36,7 +37,7 @@ install_requires =
where = src
include = clickjacking, dns_lookup, exec_shell_command, http_headers_grabber,
ip, logger, nmap_scanner, robots_scanner, whois_lookup, ip_info_finder,
pwned, phone_info
pwned, phone_info, one_sec_mail

[pycodestyle]
ignore = E402, W504, E123
Expand Down
2 changes: 1 addition & 1 deletion src/dns_lookup/dns_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DnsLookup:
def dns_lookup(target: str, record_type: str = 'A',
debug: bool = False) -> list:
"""
Search dns lookup information for IP or Domain.
Looks for dns lookup information for IP or Domain.
Args:
* target - Domain or IP address to search
Expand Down
Empty file added src/one_sec_mail/__init__.py
Empty file.
163 changes: 163 additions & 0 deletions src/one_sec_mail/one_sec_mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
"""
██▄██ ▄▀▄ █▀▄ █▀▀ . █▀▄ █░█
█░▀░█ █▄█ █░█ █▀▀ . █▀▄ ▀█▀
▀░░░▀ ▀░▀ ▀▀░ ▀▀▀ . ▀▀░ ░▀░
▒▐█▀█─░▄█▀▄─▒▐▌▒▐▌░▐█▀▀▒██░░░░▐█▀█▄─░▄█▀▄─▒█▀█▀█
▒▐█▄█░▐█▄▄▐█░▒█▒█░░▐█▀▀▒██░░░░▐█▌▐█░▐█▄▄▐█░░▒█░░
▒▐█░░░▐█─░▐█░▒▀▄▀░░▐█▄▄▒██▄▄█░▐█▄█▀░▐█─░▐█░▒▄█▄░
"""

import string
import random
from pathlib import Path
import requests


class OneSecMail:
"""
A class for creating one-time temporary mail.
It issues a temporary email address to which emails can be sent.
All emails are saved in the `mails/` folder (by default).
"""

def __init__(self,
username: str = None,
username_length: int = 10,
mails_save_path: [str, Path] = 'mails',
save_attachments: bool = True) -> None:
"""
Constructor.
Args:
* username - Username of the user (default: None).
* username_length - The length of the generated username
(default: 10).
* mails_save_path - Path to save messages (default: mails).
* save_attachments - Save attachments or not (default: True).
"""

self.__api = 'https://www.1secmail.com/api/v1/'
self.__domain_list = (
"1secmail.com",
"1secmail.org",
"1secmail.net"
)
self.__domain = random.choice(self.__domain_list)
self.username = username
self.__username_length = username_length
self.__mails_save_path = Path(mails_save_path)
self.__save_attachments = save_attachments
self.__id_list = []

@property
def domain(self) -> str:
"""
Domain property method.
"""
return self.__domain

def generate_username(self) -> str:
"""
Generates username.
Uses ascii lowercase letters and digits.
Returns:
* The generated user name if the username was not specified,
otherwise the entered username.
"""

if self.username is None:
print('[INFO] Username is not set. Generating...')
characters = string.ascii_lowercase + string.digits
username = ''.join(random.choice(characters)
for _ in range(self.__username_length))
self.username = username
else:
print('[INFO] Username was set manually.')
print(f'[+] Your username: {self.username}.')
print(f'[+] Your email address: {self.username}@{self.__domain}.')
return self.username

def check_mail(self) -> bool:
"""
Checks if there are new messages.
Returns:
* True - if there are new messages,
False - otherwise.
"""

login = f'login={self.username}&domain={self.__domain}'
req_url = f'{self.__api}?action=getMessages&{login}'
req = requests.get(req_url).json()

if len(req) == 0:
print('[INFO] No new messages.')
return False
print(f'You have {len(req)} unread message(s).')
print('[INFO] Saving messages\' id.')
for mail in req:
for key, value in mail.items():
if key == 'id':
self.__id_list.append(value)
return True

def save_messages(self) -> None:
"""
Saves messages.
"""

Path(self.__mails_save_path).mkdir(exist_ok=True, parents=True)
login = f'login={self.username}&domain={self.__domain}'
for i in self.__id_list:
read_msg = f'{self.__api}?action=readMessage&{login}&id={i}'
req = requests.get(read_msg).json()

mail_file_path = Path(self.__mails_save_path) / f'{i}' / f'{i}.txt'
mail_file_path.parent.mkdir(exist_ok=True, parents=True)
with open(mail_file_path, 'w', encoding="utf-8") as file:
file.write(f'Sender: {req.get("from")}\n' +
f'Subject: {req.get("subject")}\n' +
f'To: {self.username}@{self.__domain}\n' +
f'Date: {req.get("date")}\n' +
f'Content: {req.get("textBody")}')

if self.__save_attachments:
files_to_download = []
attachments = req.get('attachments')
for attachment in attachments:
for key, value in attachment.items():
if key == 'filename':
files_to_download.append(value)
if files_to_download:
print('[INFO] Saving attachments.')
with open(mail_file_path, 'a', encoding="utf-8") as file:
file.write('Attachments: ' +
f'{", ".join(files_to_download)}')
for file in files_to_download:
download_files = f'{self.__api}?action=download&'
download_files += f'{login}&id={i}&file={file}'
file_path = mail_file_path.parent / 'attachments'
file_path /= f'{file}'
file_path.parent.mkdir(exist_ok=True, parents=True)
response = requests.get(download_files)
with open(file_path, mode='wb') as file:
file.write(response.content)
else:
print('[INFO] No attachments found.')

def delete_mailbox(self) -> None:
"""
Removes created mailbox.
"""

url = 'https://www.1secmail.com/mailbox'
data = {
'action': 'deleteMailbox',
'login': self.username,
'domain': self.__domain
}

requests.post(url, data)
mailbox = f'{self.username}@{self.__domain}'
print(f'[X] Mailbox {mailbox} was removed.')

0 comments on commit bab4a61

Please sign in to comment.