Загрузка данных
import os
import sys
import socket
import requests
from bs4 import BeautifulSoup
import whois
import pygeoip
import dns.resolver
from dns import reversename, resolver
from nslookup import Nslookup
# ==================== ВСПОМОГАТЕЛЬНЫЕ ФУНКЦИИ ====================
def check_internet():
try:
requests.get("http://www.google.com", timeout=3)
return True
except requests.ConnectionError:
return False
def get_input(prompt, default=None):
try:
val = input(prompt).strip()
if not val and default is not None:
return default
return val
except (KeyboardInterrupt, EOFError):
print("\n[!] Ввод прерван пользователем.")
return None
def load_logo():
if os.path.exists('logo.txt'):
with open('logo.txt', 'r') as f:
return f.read()
return "OSINT FRAMEWORK"
# ==================== ОСНОВНЫЕ ФУНКЦИИ ====================
def address():
host = get_input('Enter host: ')
if not host:
return
try:
if '://' in host:
host = host.split('://')[1]
host = host.replace('/', '')
remote_ip = socket.gethostbyname(host)
print(f"IP Address of {host} is {remote_ip}")
except socket.gaierror:
print("[!] Не удалось разрешить имя хоста.")
except Exception as e:
print(f"[!] Ошибка: {e}")
def geo_ip():
ip = get_input('Enter ip: ')
if not ip:
return
try:
gi = pygeoip.GeoIP('GeoIPCity.dat')
city = gi.record_by_addr(ip)
if city:
for key in city:
if city[key] is None or city[key] == 0:
continue
print(f"{key}: {city[key]}")
else:
print("[!] Данные для этого IP не найдены.")
except FileNotFoundError:
print("[!] Файл GeoIPCity.dat не найден!")
except Exception as e:
print(f"[!] Ошибка: {e}")
def whois_add():
domain_name = get_input('Enter domain: ')
if not domain_name:
return
try:
domain = whois.query(domain_name)
if domain:
res = domain.__dict__
for i in res:
print(f"{i}: {res[i]}")
else:
print("[!] Информация WHOIS не найдена.")
except Exception as e:
print(f"[!] Ошибка WHOIS: {e}")
def site_nslookup():
domain = get_input('Enter host: ')
if not domain:
return
try:
dns_query = Nslookup(dns_servers=["1.1.1.1"])
ips_record = dns_query.dns_lookup(domain)
for i in ips_record.response_full:
print(i)
try:
soa_record = dns_query.soa_lookup(domain)
for i in soa_record.response_full:
print('\n'.join(i.split('. ')))
except Exception:
pass
except Exception as e:
print(f"[!] Ошибка NSlookup: {e}")
def dns_resolver():
address = get_input('Enter host: ')
if not address:
return
try:
my_resolver = dns.resolver.Resolver(configure=False)
my_resolver.nameservers = ['8.8.8.8', '1.1.1.1']
answers = my_resolver.query(address, 'MX')
for rdata in answers:
print('MX Record:', rdata.exchange)
except dns.resolver.NoAnswer:
print("[!] MX-записи не найдены.")
except Exception as e:
print(f"[!] Ошибка MX: {e}")
def reversed_dns():
ip = get_input('Enter ip: ')
if not ip:
return
try:
rev_name = reversename.from_address(ip)
reversed_dns_res = str(resolver.query(rev_name, "PTR")[0])
print(reversed_dns_res)
except Exception as e:
print(f"[!] Ошибка Reverse DNS: {e}")
def robots_txt():
url = get_input('Enter host [https://site.com]: ', default='https://site.com')
if not url:
return
try:
head = {"User-Agent": "Mozilla/5.0"}
if url[-1] == '/':
full_url = url + 'robots.txt'
else:
full_url = url + '/robots.txt'
page = requests.get(full_url, headers=head, timeout=5)
if page.status_code != 404:
print(page.text)
else:
print('File "robots.txt" not found!')
except Exception as e:
print(f"[!] Ошибка: {e}")
def sitemap_xml():
url = get_input('Enter host [https://site.com]: ', default='https://site.com')
if not url:
return
try:
if url[-1] == '/':
full_url = url + 'sitemap.xml'
else:
full_url = url + '/sitemap.xml'
page = requests.get(full_url, timeout=5)
if page.status_code == 200:
soup = BeautifulSoup(page.text, 'lxml')
for loc in soup.find_all("loc"):
print(loc.text)
else:
print('File "sitemap.xml" not found!')
except Exception as e:
print(f"[!] Ошибка: {e}")
def reverse_ip_lookup():
ip = get_input('Enter ip: ')
if not ip:
return
try:
url = f"https://api.hackertarget.com/reverseiplookup/?q={ip}"
response = requests.get(url, timeout=10)
if response.status_code == 200:
print(response.text)
else:
print(f"[!] Сервис вернул код {response.status_code}")
except Exception as e:
print(f"[!] Ошибка запроса: {e}")
# ==================== ГЛАВНЫЙ ЦИКЛ ====================
def main():
print(load_logo())
if not check_internet():
print("[!] Нет доступа в интернет. Проверьте подключение.")
sys.exit(1)
menu = """
0. Exit the program
1. Host IP
2. Site location
3. Whois
4. Nslookup
5. DNS MX-Record
6. Reverse DNS
7. robots.txt
8. sitemap.xml
9. Reverse IP Lookup
"""
while True:
print(menu)
try:
num_str = input('Enter the option number: ')
if not num_str:
continue
num = int(num_str)
print('-'*35)
if num == 0:
print('The program is complete!')
break
elif num == 1: address()
elif num == 2: geo_ip()
elif num == 3: whois_add()
elif num == 4: site_nslookup()
elif num == 5: dns_resolver()
elif num == 6: reversed_dns()
elif num == 7: robots_txt()
elif num == 8: sitemap_xml()
elif num == 9: reverse_ip_lookup()
else:
print("[!] Неверный номер опции.")
print('-'*35 + '\n')
except ValueError:
print("[!] Введите корректное число.")
except (KeyboardInterrupt, EOFError):
print("\nThe program is complete!")
break
except Exception as e:
print(f"[!] Непредвиденная ошибка: {e}")
if __name__ == "__main__":
main()