-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendid.rb
executable file
·98 lines (72 loc) · 2.25 KB
/
sendid.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
require 'socket'
require 'timeout'
require 'net/telnet'
require './lib_trollop.rb'
require './func.rb'
args = Trollop::options do
opt :ip_addrs , "IP address singel or a range", :type => :string
opt :verbose , "Activate the verbose mode"
opt :timeout , "Set time out", :default => 1
opt :threads , "Set the number of threads", :default =>10
opt :export , "Export the results to file", :type => :string
end
Trollop::die :ip_addrs,"Argument missing" if args[:ip_addrs] == nil
Trollop::die :timeout, "Must be non-negative" if args[:timeout] <= 0
Trollop::die :threads, "Must be non-negative" if args[:threads] <= 0
Trollop::die :export , "Argument missing" if args[:export] == nil
$alive_hosts = Array.new
$verbose = args[:verbose]
$timeout = args[:timeout]
$threads_num = args[:threads]
ip_in = args[:ip_addrs]
begin
time_start=Time.now
hosts=ipgen(ip_in)
time_end=Time.now
puts "[*] #{hosts.count} Ip adress generated in #{time_end - time_start} seconds" if $verbose && hosts.count > 1
_ = "[*] starting the scan of #{hosts.count} hosts"
_ = "[*] starting the scan of one host" if hosts.count == 1
puts _
time_start=Time.now
threads=[]
hosts.each do |host|
if(Thread.list.count % $threads_num != 0)
mythread = Thread.new do
scan(host)
end
threads << mythread
else
threads.each do |thread|
thread.join
end
mythread = Thread.new do
scan(host)
end
threads << mythread
end
end
threads.each do |thread|
thread.join
end
time_end=Time.now
_ = "[*] found #{$alive_hosts.count} alive hosts in #{time_end - time_start} seconds"
_ = "[*] found one alive host in #{time_end - time_start} seconds" if $alive_hosts.count == 1
puts _
puts "[*] alive hosts:" if $verbose && $alive_hosts.count != 0
puts "[*] start checking for hosts with weak password"
time_start = Time.now
$alive_hosts.each do |host|
host_crd = checkpwd(host)
if host_crd != nil
output= "[*] the host:#{host}\n[+] #{host_crd["usr"]}\n[+] #{host_crd["pwd"]}\n"
print output
export(args[:export],output)
else
puts "[D] empty host_crd"
end
end
time_end = Time.now
puts "finished checking host in #{time_end - time_start} seconds"
rescue (Interrupt)
puts "\n[*] Interrupted !!"
end