-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshodan_email.py
More file actions
88 lines (70 loc) · 3.13 KB
/
Copy pathshodan_email.py
File metadata and controls
88 lines (70 loc) · 3.13 KB
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
import os
try:
import requests, re
from bs4 import BeautifulSoup
from colorama import Fore, Style
except:
os.system('pip install requests beautifulsoup4 colorama')
class color:
RED = Fore.RED + Style.BRIGHT
WHITE = Fore.WHITE + Style.BRIGHT
RESET = Fore.RESET + Style.RESET_ALL
url = 'https://www.shodan.io/search?query='
ip_api = 'https://api.techniknews.net/ipgeo/'
def error(text):
print(color.WHITE + '\n[*] Error: ' + color.WHITE + text)
main()
def ret():
print(color.WHITE + f'\n[*] Finished to write the {color.RED}results.txt{color.WHITE} file')
choice = input(color.WHITE + '[*] Press ENTER to return the menu: ')
main()
def main():
query = input(color.WHITE + '[*] Enter the query to search: ')
if not '@' in query:
error('No email detected')
res = requests.get(str(url + query))
html_content = res.text
soup = BeautifulSoup(html_content, 'html.parser')
with open('results.txt', 'a') as file:
result_divs = soup.find_all('div', class_='result')
if result_divs:
for div in result_divs:
ip_element = div.find('pre')
if ip_element:
file.write(f'Result Data:\n{ip_element.text}\n')
ip_pattern = r'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'
ip_text = div.get_text()
result = re.search(ip_pattern, ip_text)
if result:
address = result.group(0)
file.write(f'IP found: {address}\n')
file.write(f'Result: {div.text.strip()}\n')
file.write('-' * 50 + '\n')
res = requests.get(str(ip_api + address))
headers = res.headers
for key, value in headers.items():
file.write(f'{key}: {value}\n')
file.write('\n' + '=' * 50 + '\n')
else:
file.write('No results found.\n')
error('No results found')
def clear():
if os.name == 'nt':
os.system('cls')
else:
os.system('clear')
def print_title():
clear()
title = '''
███████╗██╗ ██╗ ██████╗ ██████╗ █████╗ ███╗ ██╗
██╔════╝██║ ██║██╔═══██╗██╔══██╗██╔══██╗████╗ ██║
███████╗███████║██║ ██║██║ ██║███████║██╔██╗ ██║
╚════██║██╔══██║██║ ██║██║ ██║██╔══██║██║╚██╗██║
███████║██║ ██║╚██████╔╝██████╔╝██║ ██║██║ ╚████║
╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝
'''
print(color.RED + title)
if __name__ == '__main__':
print_title()
main()
ret()