-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.py
More file actions
118 lines (100 loc) · 3.29 KB
/
map.py
File metadata and controls
118 lines (100 loc) · 3.29 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import subprocess
import sys
import os
import time
from termcolor import colored
from tabulate import tabulate
import pandas as pd
import matplotlib.pyplot as plt
# Ensure Python version compatibility
if sys.version_info.major < 3 or sys.version_info.minor < 9:
print(colored('[!] Please install Python 3.9 or higher. Exiting.', 'yellow'))
sys.exit(1)
# Define theHarvester command parameters
domain = "https://enginueeur.com"
filename = "custom_results"
sources = "bing,anubis,brave"
limit = "2000"
dns_server = "1.1.1.1"
takeover_check = True
screenshots_dir = "screenshots_dir"
# Construct theHarvester command
command = [
"theHarvester",
"-d", domain,
"-f", filename,
"-b", sources,
"-l", limit,
"-vv",
"-e", dns_server,
"-t" if takeover_check else "",
"--virtual-host",
"--screenshot", screenshots_dir,
"-s"
]
# Print the script's objective
print(colored("Running theHarvester to gather open-source intelligence.", 'cyan'))
# Execute the theHarvester command
print(colored("Executing theHarvester command with the following options:", 'cyan'))
print(" " + " ".join(command)) # Display the command string
start_time = time.time()
subprocess.run(command)
end_time = time.time()
# Display completion message
print(colored("theHarvester script completed.", 'green'))
# Generate a report
execution_time = end_time - start_time
report_data = [
["Domain", domain],
["Output File", filename],
["Sources", sources],
["Limit", limit],
["DNS Server", dns_server],
["Takeover Check", "Enabled" if takeover_check else "Disabled"],
["Screenshots Dir", screenshots_dir],
]
report_table = tabulate(report_data, headers=["Parameter", "Value"], tablefmt="grid")
print(colored("\nReport:\n", 'cyan'))
print(report_table)
# Parse theHarvester output and extract source statistics
print(colored("\nParsing theHarvester output...\n", 'cyan'))
source_stats = {}
current_source = None
with open(filename + '.txt', 'r') as output_file:
lines = output_file.readlines()
for line in lines:
if line.startswith("[*] Searching"):
current_source = line.split()[2][:-1]
elif line.strip() == "":
current_source = None
elif current_source and line.startswith("[*]"):
key, value = line[4:].strip().split(": ")
source_stats.setdefault(current_source, {})[key] = value
# Generate a report
report_data = [
["Domain", domain],
["Output File", filename],
["Sources", sources],
["Limit", limit],
["DNS Server", dns_server],
["Takeover Check", "Enabled" if takeover_check else "Disabled"],
["Screenshots Dir", screenshots_dir],
]
report_table = tabulate(report_data, headers=["Parameter", "Value"], tablefmt="grid")
print(colored("\nReport:\n", 'cyan'))
print(report_table)
# Generate a bar graph depicting subdomains per source
plt.figure(figsize=(10, 6))
for source, stats in source_stats.items():
plt.bar(source, int(stats.get("Hosts", 0)), color='skyblue')
plt.title('Number of Subdomains from Each Source')
plt.xlabel('Source')
plt.ylabel('Number of Subdomains')
plt.xticks(rotation=45, ha='right')
plt.tight_layout()
# Save the graph as an image
graph_filename = 'subdomains_by_source.png'
plt.savefig(graph_filename)
print(colored(f"Bar graph saved as: {graph_filename}\n", 'green'))
# Display the graph
plt.show()