-
Notifications
You must be signed in to change notification settings - Fork 1
/
lookup.py
75 lines (66 loc) · 6.39 KB
/
lookup.py
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
# Author: Pari Malam
import argparse
import requests
import sys
import os
from sys import stdout
from colorama import Fore, Style
def banners():
os.system('clear' if os.name == 'posix' else 'cls')
stdout.write(" \n")
stdout.write(""+Fore.LIGHTRED_EX +"██████╗ ██████╗ █████╗ ██████╗ ██████╗ ███╗ ██╗███████╗ ██████╗ ██████╗ ██████╗███████╗ ██╗ ██████╗ \n")
stdout.write(""+Fore.LIGHTRED_EX +"██╔══██╗██╔══██╗██╔══██╗██╔════╝ ██╔═══██╗████╗ ██║██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔════╝ ██║██╔═══██╗\n")
stdout.write(""+Fore.LIGHTRED_EX +"██║ ██║██████╔╝███████║██║ ███╗██║ ██║██╔██╗ ██║█████╗ ██║ ██║██████╔╝██║ █████╗ ██║██║ ██║\n")
stdout.write(""+Fore.LIGHTRED_EX +"██║ ██║██╔══██╗██╔══██║██║ ██║██║ ██║██║╚██╗██║██╔══╝ ██║ ██║██╔══██╗██║ ██╔══╝ ██║██║ ██║\n")
stdout.write(""+Fore.LIGHTRED_EX +"██║ ██║██╔══██╗██╔══██║██║ ██║██║ ██║██║╚██╗██║██╔══╝ ██║ ██║██╔══██╗██║ ██╔══╝ ██║██║ ██║\n")
stdout.write(""+Fore.LIGHTRED_EX +"██████╔╝██║ ██║██║ ██║╚██████╔╝╚██████╔╝██║ ╚████║██║ ╚██████╔╝██║ ██║╚██████╗███████╗██╗██║╚██████╔╝\n")
stdout.write(""+Fore.LIGHTRED_EX +"╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝╚═╝ ╚═════╝ \n")
stdout.write(""+Fore.YELLOW +"═════════════╦═════════════════════════════════╦════════════════════════════════════════════════════════════\n")
stdout.write(""+Fore.YELLOW +"╔════════════╩═════════════════════════════════╩═════════════════════════════╗\n")
stdout.write(""+Fore.YELLOW +"║ \x1b[38;2;255;20;147m• "+Fore.GREEN+"AUTHOR "+Fore.RED+" |"+Fore.LIGHTWHITE_EX+" PARI MALAM "+Fore.YELLOW+"║\n")
stdout.write(""+Fore.YELLOW +"║ \x1b[38;2;255;20;147m• "+Fore.GREEN+"GITHUB "+Fore.RED+" |"+Fore.LIGHTWHITE_EX+" GITHUB.COM/PARI-MALAM "+Fore.YELLOW+"║\n")
stdout.write(""+Fore.YELLOW +"╔════════════════════════════════════════════════════════════════════════════╝\n")
stdout.write(""+Fore.YELLOW +"║ \x1b[38;2;255;20;147m• "+Fore.GREEN+"OFFICIAL FORUM "+Fore.RED+" |"+Fore.LIGHTWHITE_EX+" DRAGONFORCE.IO "+Fore.YELLOW+"║\n")
stdout.write(""+Fore.YELLOW +"║ \x1b[38;2;255;20;147m• "+Fore.GREEN+"OFFICIAL TELEGRAM "+Fore.RED+" |"+Fore.LIGHTWHITE_EX+" TELEGRAM.ME/DRAGONFORCEIO "+Fore.YELLOW+"║\n")
stdout.write(""+Fore.YELLOW +"╚════════════════════════════════════════════════════════════════════════════╝\n")
print(f"{Fore.YELLOW}[HackerTarget] - {Fore.GREEN}Perform With DNS, Reverse, Port Lookup\n")
banners()
parser = argparse.ArgumentParser(description='Perform a DNS & Reverse lookup on a domain using the Hackertarget API')
parser.add_argument('-D', '--domain', help='The domain name to lookup', required=True)
parser.add_argument('-R', '--reverse', action='store_true', help='Include reverse in the lookup')
parser.add_argument('-O', '--output', help='The output file name', default=None)
args = parser.parse_args()
if args.output is not None:
f = open(args.output, 'w')
sys.stdout = f
try:
if args.reverse:
check_url = f'https://api.hackertarget.com/reverseiplookup/?q={args.domain}'
else:
check_url = f'https://api.hackertarget.com/dnslookup/?q={args.domain}'
r = requests.get(check_url)
r.raise_for_status()
result_lines = r.text.split('\n')
for line in result_lines:
if line.startswith('#'):
print(Fore.LIGHTBLACK_EX + line + Style.RESET_ALL)
elif not line:
continue
else:
parts = line.split()
if len(parts) == 4:
text = ' '.join(parts[1:])
if parts[3] == 'CNAME':
print(Fore.GREEN + f'{parts[0]} {parts[3]} -> {text}' + Style.RESET_ALL)
elif parts[3] == 'MX':
print(Fore.YELLOW + f'{parts[0]} {parts[3]} -> {text}' + Style.RESET_ALL)
else:
print(Fore.WHITE + f'{parts[0]} {parts[3]} -> {text}' + Style.RESET_ALL)
else:
print(Fore.WHITE + line + Style.RESET_ALL)
except:
print("An error occurred while processing the request")
if args.output is not None:
f.close()
sys.stdout = sys.__stdout__
print(f'Results saved to {args.output}')