vamtic a révisé ce gist 2 months ago. Aller à la révision
1 file changed, 114 insertions
domain.py(fichier créé)
| @@ -0,0 +1,114 @@ | |||
| 1 | + | #!/usr/bin/env python3 | |
| 2 | + | ||
| 3 | + | import socket | |
| 4 | + | import requests | |
| 5 | + | import concurrent.futures | |
| 6 | + | ||
| 7 | + | def domain_ipre_alakitas(domain): | |
| 8 | + | try: | |
| 9 | + | eredmeny = socket.getaddrinfo(domain, None, socket.AF_INET6) | |
| 10 | + | if eredmeny: | |
| 11 | + | return eredmeny[0][4][0] | |
| 12 | + | except socket.gaierror: | |
| 13 | + | pass | |
| 14 | + | ||
| 15 | + | try: | |
| 16 | + | return socket.gethostbyname(domain) | |
| 17 | + | except socket.gaierror: | |
| 18 | + | print("Hiba: A domain feloldása sikertelen.") | |
| 19 | + | return None | |
| 20 | + | ||
| 21 | + | def ip_informacio_lekerese(ip): | |
| 22 | + | try: | |
| 23 | + | valasz = requests.get(f"https://ipinfo.io/{ip}/json") | |
| 24 | + | return valasz.json() | |
| 25 | + | except requests.RequestException: | |
| 26 | + | print("Hiba: Az IP információk lekérése sikertelen.") | |
| 27 | + | return None | |
| 28 | + | ||
| 29 | + | def portszkenneles(cel, portok): | |
| 30 | + | print(f"\nPortszkennelés folyamatban a(z) {cel} címen...") | |
| 31 | + | nyitott_portok = [] | |
| 32 | + | ||
| 33 | + | def port_ellenorzese(port): | |
| 34 | + | try: | |
| 35 | + | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
| 36 | + | s.settimeout(1) | |
| 37 | + | eredmeny = s.connect_ex((cel, port)) | |
| 38 | + | if eredmeny == 0: | |
| 39 | + | nyitott_portok.append(port) | |
| 40 | + | print(f"A {port} port nyitva van") | |
| 41 | + | except Exception: | |
| 42 | + | pass | |
| 43 | + | ||
| 44 | + | with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor: | |
| 45 | + | executor.map(port_ellenorzese, portok) | |
| 46 | + | ||
| 47 | + | return nyitott_portok | |
| 48 | + | ||
| 49 | + | def subdomain_kereses(domain): | |
| 50 | + | print(f"\nSubdomain keresés folyamatban a(z) {domain} domainhez...") | |
| 51 | + | talalt_subdomainek = [] | |
| 52 | + | ||
| 53 | + | try: | |
| 54 | + | valasz = requests.get(f"https://api.subdomain.center/?domain={domain}") | |
| 55 | + | subdomainek = valasz.json() | |
| 56 | + | ||
| 57 | + | for subdomain in subdomainek: | |
| 58 | + | try: | |
| 59 | + | ip = socket.gethostbyname(subdomain) | |
| 60 | + | talalt_subdomainek.append(subdomain) | |
| 61 | + | print(f"Talált: {subdomain} -> {ip}") | |
| 62 | + | except socket.gaierror: | |
| 63 | + | pass | |
| 64 | + | ||
| 65 | + | except requests.RequestException: | |
| 66 | + | print("Hiba: Az API nem elérhető") | |
| 67 | + | except Exception as e: | |
| 68 | + | print(f"Hiba: {str(e)}") | |
| 69 | + | ||
| 70 | + | return talalt_subdomainek | |
| 71 | + | ||
| 72 | + | def main(): | |
| 73 | + | print("Válassz műveletet:") | |
| 74 | + | print("1. Domain -> IP átalakítás és IP információk") | |
| 75 | + | print("2. Portszkennelés") | |
| 76 | + | print("3. Subdomain keresés") | |
| 77 | + | ||
| 78 | + | valasztas = input("Add meg a választásod (1-3): ") | |
| 79 | + | ||
| 80 | + | if valasztas not in ['1', '2', '3']: | |
| 81 | + | print("Érvénytelen választás!") | |
| 82 | + | return | |
| 83 | + | ||
| 84 | + | cel = input("Add meg a domain nevet vagy IP címet: ") | |
| 85 | + | ||
| 86 | + | if valasztas == '1': | |
| 87 | + | ip = domain_ipre_alakitas(cel) | |
| 88 | + | if ip: | |
| 89 | + | print(f"\nFeloldott IP-cím: {ip}") | |
| 90 | + | info = ip_informacio_lekerese(ip) | |
| 91 | + | if info: | |
| 92 | + | print("\nIP információk:") | |
| 93 | + | for kulcs, ertek in info.items(): | |
| 94 | + | print(f"{kulcs}: {ertek}") | |
| 95 | + | ||
| 96 | + | elif valasztas == '2': | |
| 97 | + | port_bemenet = input("Add meg a portokat (pl. '80-100' vagy '22 80 443'): ") | |
| 98 | + | if '-' in port_bemenet: | |
| 99 | + | kezdo, vegso = map(int, port_bemenet.split('-')) | |
| 100 | + | portok = range(kezdo, vegso + 1) | |
| 101 | + | else: | |
| 102 | + | portok = list(map(int, port_bemenet.split())) | |
| 103 | + | ||
| 104 | + | ip = domain_ipre_alakitas(cel) if not cel.replace('.', '').isdigit() else cel | |
| 105 | + | if ip: | |
| 106 | + | nyitott = portszkenneles(ip, portok) | |
| 107 | + | print(f"\nSzkennelés kész. Nyitott portok: {nyitott}") | |
| 108 | + | ||
| 109 | + | elif valasztas == '3': | |
| 110 | + | talaltak = subdomain_kereses(cel) | |
| 111 | + | print(f"\nKeresés kész. Talált subdomainek: {len(talaltak)} db") | |
| 112 | + | ||
| 113 | + | if __name__ == "__main__": | |
| 114 | + | main() | |
Plus récent
Plus ancien