-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
executable file
·146 lines (129 loc) · 4.07 KB
/
main.sh
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env bash
# Automated Recon Tool with Cross-Platform Support (Linux and macOS)
# Colors for output
GREEN="\033[0;32m"
RED="\033[0;31m"
NC="\033[0m" # Reset color
# Detect operating system
detect_os() {
case "$OSTYPE" in
linux-gnu*) echo "linux" ;;
darwin*) echo "macos" ;;
*) echo "unsupported" ;;
esac
}
# Install dependencies
install_dependencies() {
local os="$1"
local tools=("nmap" "whois")
if [[ "$os" == "linux" ]]; then
tools+=("dnsutils")
echo -e "${GREEN}[+] Detected Linux. Installing dependencies...${NC}"
sudo apt update -y
for tool in "${tools[@]}"; do
if ! command -v "$tool" &> /dev/null; then
echo -e "${GREEN}[+] Installing $tool...${NC}"
sudo apt install -y "$tool"
else
echo -e "${GREEN}[+] $tool is already installed.${NC}"
fi
done
if ! command -v pip3 &> /dev/null; then
echo -e "${GREEN}[+] Installing pip3...${NC}"
sudo apt install -y python3-pip
fi
elif [[ "$os" == "macos" ]]; then
tools+=("bind")
echo -e "${GREEN}[+] Detected macOS. Installing dependencies...${NC}"
if ! command -v brew &> /dev/null; then
echo -e "${RED}[!] Homebrew is not installed. Please install Homebrew first: https://brew.sh/${NC}"
exit 1
fi
for tool in "${tools[@]}"; do
if ! brew list --formula "$tool" &> /dev/null; then
echo -e "${GREEN}[+] Installing $tool...${NC}"
brew install "$tool"
else
echo -e "${GREEN}[+] $tool is already installed.${NC}"
fi
done
if ! command -v pip3 &> /dev/null; then
echo -e "${GREEN}[+] Installing pip3...${NC}"
brew install python3
fi
else
echo -e "${RED}[!] Unsupported OS. Only Linux and macOS are supported.${NC}"
exit 1
fi
}
# Install Sublist3r
install_sublist3r() {
if ! pip3 show sublist3r &> /dev/null; then
echo -e "${GREEN}[+] Installing Sublist3r...${NC}"
pip3 install sublist3r
else
echo -e "${GREEN}[+] Sublist3r is already installed.${NC}"
fi
}
# Enumerate subdomains
enumerate_subdomains() {
local domain="$1"
echo -e "${GREEN}[+] Enumerating subdomains for: $domain${NC}"
python3 -m sublist3r -d "$domain" -o subdomains.txt
echo -e "${GREEN}[+] Subdomains saved to subdomains.txt${NC}"
}
# Resolve DNS
resolve_dns() {
echo -e "${GREEN}[+] Resolving subdomains...${NC}"
while read -r subdomain; do
dig +short "$subdomain" >> resolved.txt
done < subdomains.txt
echo -e "${GREEN}[+] Resolved IPs saved to resolved.txt${NC}"
}
# Scan ports
scan_ports() {
echo -e "${GREEN}[+] Scanning ports for resolved IPs...${NC}"
while read -r ip; do
nmap -Pn "$ip" >> nmap_results.txt
done < resolved.txt
echo -e "${GREEN}[+] Nmap results saved to nmap_results.txt${NC}"
}
# Fetch WHOIS information
fetch_whois() {
local domain="$1"
echo -e "${GREEN}[+] Fetching WHOIS information for: $domain${NC}"
whois "$domain" > whois_info.txt
echo -e "${GREEN}[+] WHOIS info saved to whois_info.txt${NC}"
}
# Clean up and prepare output files
prepare_output_files() {
local files=("subdomains.txt" "resolved.txt" "nmap_results.txt" "whois_info.txt")
for file in "${files[@]}"; do
> "$file"
done
}
# Main function
main() {
echo -e "${GREEN}Enter the domain name (without https or http):${NC}"
read -r domain
if [[ -z "$domain" ]]; then
echo -e "${RED}[!] Domain name cannot be empty.${NC}"
exit 1
fi
prepare_output_files
local os
os=$(detect_os)
if [[ "$os" == "unsupported" ]]; then
echo -e "${RED}[!] Unsupported OS.${NC}"
exit 1
fi
install_dependencies "$os"
install_sublist3r
enumerate_subdomains "$domain"
resolve_dns
scan_ports
fetch_whois "$domain"
echo -e "${GREEN}[+] Recon complete. Check the output files.${NC}"
}
# Run the script
main "$@"