-
Notifications
You must be signed in to change notification settings - Fork 0
/
nscan.rb
75 lines (64 loc) · 2.06 KB
/
nscan.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
#!//usr/bin/env ruby
require 'colorize'
require 'fileutils'
# Check if colorize gem is installed
unless Gem::Specification.find_all_by_name('colorize').any?
puts "Installing 'colorize' gem..."
system('gem install colorize')
Gem.clear_paths
end
require 'colorize'
# Animation method for loading
def loading_animation
chars = ['|', '/', '-', '\\']
i = 0
while true
print "\rScanning " + chars[i].colorize(:green) + " "
i = (i + 1) % chars.length
sleep(0.1)
end
end
def run_nmap_scan(domain)
output_folder = "Results"
FileUtils.mkdir_p(output_folder) unless Dir.exist?(output_folder)
output_file = File.join(output_folder, "#{domain}_scan.txt")
command = "nmap -sV -F -sS -T4 #{domain} -oN #{output_file}"
system(command)
end
# Colored and stylized prompt
puts ""
puts "[Created By Anonre]".colorize(:yellow)
prompt = "" + "[ 1 ]".colorize(:yellow) + " Scan a single target domain\n" +
"[ 2 ]".colorize(:yellow) + " Scan a list of domains from a file\n" +
"Enter your choice: "
print prompt
begin
user_choice = gets.chomp
if user_choice == '1'
# Single target domain
print "Enter the target domain: "
target_domain = gets.chomp
Thread.new { loading_animation } # Start animation in a separate thread
run_nmap_scan(target_domain)
puts "\nScan completed for domain: #{target_domain}"
elsif user_choice == '2'
# File input for domain list
print "Enter the file path containing the list of target domains: "
file_path = gets.chomp
begin
domains = File.readlines(file_path, chomp: true)
Thread.new { loading_animation } # Start animation in a separate thread
domains.each_with_index do |domain, index|
run_nmap_scan(domain)
puts "Scan completed for domain #{index + 1}: #{domain}"
end
puts "Scanning completed for all domains."
rescue Errno::ENOENT
puts "File not found. Please provide a valid file path."
end
else
puts "Invalid choice. Please enter either '1' or '2'."
end
rescue Interrupt
puts "\nScanning interrupted by the user."
end