-
Notifications
You must be signed in to change notification settings - Fork 0
/
whoweb.rb
329 lines (283 loc) · 8.58 KB
/
whoweb.rb
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
require 'whois'
require 'colorize'
require 'net/http'
require 'resolv'
def banner
banner_text = <<-'BANNER'
.-'''-.
' _ \
. / /` '. \ __.....__ /|
_ _ .'| . | \ ' _ _ .-'' '. ||
/\ \\ //< | | ' | '/\ \\ /// .-''"'-. `. ||
`\\ //\\ // | | \ \ / / `\\ //\\ /// /________\ \|| __
\`// \'/ | | .'''-.`. ` ..' / \`// \'/ | |||/'__ '.
\| |/ | |/.'''. \ '-...-'` \| |/ \ .-------------'|:/` '. '
' | / | | ' \ '-.____...---.|| | |
| | | | `. .' ||\ / '
| | | | `''-...... -' |/\'..' /
| '. | '. ' `'-'`
'---' '---'
---------------------------- Author: Bunjo ---------------------------------
-------------------- Github: https://github.com/thebunjo -----------------------
BANNER
puts banner_text.cyan
end
def check_firewall(url)
url1 = URI.parse(url)
response = Net::HTTP.get_response(url1)
server_header = response['Server']
puts "Server Header: #{server_header}"
end
def dns_enum(domain)
resolver = Resolv::DNS.new
begin
nameservers = resolver.getresources(domain, Resolv::DNS::Resource::IN::NS)
puts "Nameservers for #{domain}:"
nameservers.each do |ns|
puts " #{ns.name}"
end
mx_records = resolver.getresources(domain, Resolv::DNS::Resource::IN::MX)
puts "MX records for #{domain}:"
mx_records.each do |mx|
puts " #{mx.exchange} (priority #{mx.preference})"
end
a_records = resolver.getresources(domain, Resolv::DNS::Resource::IN::A)
puts "A records for #{domain}:"
a_records.each do |a|
puts " #{a.address}"
end
cname_records = resolver.getresources(domain, Resolv::DNS::Resource::IN::CNAME)
puts "CNAME records for #{domain}:"
cname_records.each do |cname|
puts " #{cname.name}"
end
rescue Resolv::ResolvError => e
puts "Error resolving DNS records for #{domain}: #{e}"
end
end
def subdomain_resolver(target)
resolver = Resolv::DNS.new
subdomains = []
resolver.each_resource(target, Resolv::DNS::Resource::IN::NS) do |resource|
subdomains << resource.name.to_s
end
if subdomains.any?
puts "Subdomains found for #{target}:"
subdomains.each { |subdomain| puts subdomain }
else
puts "No subdomains found for #{target}."
end
end
def reverse_ip_scan(ip)
puts "Reverse IP Scanner Results for IP: #{ip}"
resolver = Resolv::DNS.new
begin
ptr_results = resolver.getresources(ip, Resolv::DNS::Resource::IN::PTR)
ptr_results.each do |ptr|
puts ptr.name.to_s
end
rescue Resolv::ResolvError
puts "No PTR records found for IP: #{ip}"
end
end
def send_request(url, prt)
url2 = URI.parse(url)
http = Net::HTTP.new(url2.host, prt)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts "HTTP Response Code: #{response.code}"
puts "HTTP Response Text: #{response.message}"
puts "HTTP Response Body:"
puts response.body
end
def banner_grabber(host, port)
s = TCPSocket.open(host, port)
s.puts("GET / HTTP/1.1\r\n\r\n")
while line = s.gets
puts line.chop
end
s.close
end
def find_whois(url)
whois_client = Whois::Client.new
result = whois_client.lookup(url)
if result.available?
puts "Domain '#{url}' is available.".red
else
output = "Domain Name: #{result.properties["Domain Name"]}\n" \
"Registrar: #{result.properties["Registrar"]}\n" \
"Registrant: #{result.properties["Registrant"]}\n" \
"Created Date: #{result.properties["Creation Date"]}\n" \
"Updated Date: #{result.properties["Updated Date"]}\n" \
"Expires Date: #{result.properties["Expiration Date"]}"
puts output
end
rescue Whois::Error => e
puts "Whois Error: #{e.message}".red
rescue StandardError => e
puts "Error: #{e.message}".red
end
def find_ip_address(url)
ip_address = Socket.getaddrinfo(url, nil, Socket::AF_INET)
return ip_address[0][3]
rescue
puts "{!} Something went wrong."
end
def options
puts "{1} - Website IP Finder".colorize(:yellow).bold
puts "{2} - Website Whois Information".colorize(:yellow)
puts '{3} - Website Send "GET" Request'.colorize(:green).bold
puts "{4} - Website TCP Port Scanner".colorize(:green)
puts "{5} - DNS Enumeration".colorize(:magenta).bold
puts "{6} - Banner Grabber (HTTP/GET)".colorize(:magenta)
puts "{7} - Reverse IP Scanner".colorize(:cyan).bold
puts "{8} - Subdomain Resolver".colorize(:cyan)
puts "{9} - Website Firewall Header Scan".colorize(:red)
puts "{99} - Exit Program".colorize(:red).bold
end
def clear_screen
system Gem.win_platform? ? 'cls' : 'clear'
end
def get_options
print "\nwh0wEb > ".colorize(:blue).bold.underline
opt = gets.chomp.to_i
if opt.to_s.empty?
clear_screen
puts "Invalid input. Please enter a valid option.".red
return get_options
end
case opt
when 99 # Exit
puts "Bye!".red
exit(0)
when 1 # IP Finder
while true
print 'Enter Target Domain (Press "q" for return): '.yellow.bold
inpt_url = gets.chomp
if inpt_url == "q"
clear_screen
break
else
ip_result = find_ip_address(inpt_url)
puts "[+] Result: #{ip_result}".green.bold
inpt_url = ""
end
end
when 2 # Whois
while true
print 'Enter Target Domain (Press "q" for return): '.yellow.bold
inpt_url = gets.chomp
if inpt_url == "q"
clear_screen
break
else
find_whois(inpt_url)
inpt_url = ""
end
end
when 3 # Send Get Request
while true
print 'Enter Target URL (ex: https://example.com ) (Press "q" for return): '.yellow.bold
inpt_url = gets.chomp
if inpt_url == "q"
clear_screen
break
else
print 'Enter Port: '.yellow.bold
port = gets.chomp.to_i
send_request(inpt_url, port)
inpt_url = ""
end
end
when 4 # Port Scan
while true
print 'Enter Target Domain (Press "q" for return): '.yellow.bold
trgt = gets.chomp
if trgt == "q"
clear_screen
break
else
print "Enter Ports (ex: 21,22,3306): ".cyan.bold
ports = gets.chomp
port_list = ports.split(',')
$threads = []
port_list.each do |port|
$threads << Thread.new do
begin
$socket = TCPSocket.new(trgt, port.to_i)
puts "{+} Port #{port} is open.".green.bold
rescue
puts "{-} Port #{port} is closed/filtered.".red.bold
ensure
$socket.close if $socket
end
end
$threads.each(&:join)
end
end
end
when 5 # Dns Enumeration
while true
print 'Enter Target Domain (Press "q" for return): '.yellow.bold
inpt_url = gets.chomp
if inpt_url == "q"
clear_screen
break
else
dns_enum(inpt_url)
inpt_url = ""
end
end
when 6 # Banner Grabber
while true
print 'Enter Target Host (Press "q" for return): '.yellow.bold
inpt_url = gets.chomp
if inpt_url == "q"
clear_screen
break
else
print "Enter Port: ".cyan.bold
port = gets.chomp.to_i
banner_grabber(inpt_url, port)
inpt_url = ""
end
end
when 7 # Reverse IP Scanner
while true
print 'Enter Target IP Address (Press "q" for return): '.yellow.bold
target_ip = gets.chomp
break if target_ip == "q"
reverse_ip_scan(target_ip)
end
when 8 # Subdomain Resolver
while true
print 'Enter Target Domain (Press "q" for return): '.yellow.bold
inpt_url = gets.chomp
if inpt_url == "q"
clear_screen
break
else
subdomain_resolver(inpt_url)
inpt_url = ""
end
end
when 9 # Firewall
while true
print 'Enter Target URL (ex: https://www.example.com/) (Press "q" for return): '.yellow.bold
inpt_url = gets.chomp
if inpt_url == "q"
break
else
check_firewall(inpt_url)
end
end
else
clear_screen
puts "Invaild selection!".red.bold
end
end
while true
banner
options
get_options
end