From 99a421eb93dcc47d6773f17f25834444758558a2 Mon Sep 17 00:00:00 2001 From: Pavel Dat Date: Tue, 12 Sep 2023 20:41:57 +0300 Subject: [PATCH] - Add one_sec_mail tool. - Update README --- .gitignore | 4 +- .pylintrc | 2 +- CHANGELOG.md | 4 + README.md | 22 +++++ setup.cfg | 5 +- src/dns_lookup/dns_lookup.py | 2 +- src/one_sec_mail/__init__.py | 0 src/one_sec_mail/one_sec_mail.py | 163 +++++++++++++++++++++++++++++++ 8 files changed, 197 insertions(+), 5 deletions(-) create mode 100644 src/one_sec_mail/__init__.py create mode 100644 src/one_sec_mail/one_sec_mail.py diff --git a/.gitignore b/.gitignore index bc2cb1b..2afdf30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +out/ out/logs -**/__pycache__ \ No newline at end of file +**/__pycache__ +dist/ diff --git a/.pylintrc b/.pylintrc index 07c69cb..6b37134 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,3 +1,3 @@ [MESSAGES CONTROL] disable = C0413, W1203, W0703, R1710, R0903, R1732, - R0201, W1508, R0801 + R0201, W1508, R0801, R0902 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e02ca4..29b4728 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # gods_eye changelog +## 1.0.9 +- Add one_sec_mail tool. +- Update README + ## 1.0.8 - Add status badge Markdown diff --git a/README.md b/README.md index a1ae1db..63253c4 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,28 @@ pip install dist/gods_eye--py3-none-any.whl pip install .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. diff --git a/setup.cfg b/setup.cfg index ed8dc6f..f16bacf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 @@ -24,6 +24,7 @@ packages = ip_info_finder pwned phone_info + one_sec_mail install_requires = requests >= 2.25.1 dnspython >= 2.2.1 @@ -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 diff --git a/src/dns_lookup/dns_lookup.py b/src/dns_lookup/dns_lookup.py index f102252..03772a0 100644 --- a/src/dns_lookup/dns_lookup.py +++ b/src/dns_lookup/dns_lookup.py @@ -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 diff --git a/src/one_sec_mail/__init__.py b/src/one_sec_mail/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/one_sec_mail/one_sec_mail.py b/src/one_sec_mail/one_sec_mail.py new file mode 100644 index 0000000..567d67f --- /dev/null +++ b/src/one_sec_mail/one_sec_mail.py @@ -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.')