Skip to content

Commit 8c5847a

Browse files
author
jvazquez-r7
committed
Make output compatible with an scanner module
1 parent 0e95099 commit 8c5847a

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

modules/auxiliary/scanner/http/wordpress_pingback_access.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def setup()
5757

5858
def get_xml_rpc_url(ip)
5959
# code to find the xmlrpc url when passed in IP
60-
vprint_status("Enumerating XML-RPC URI for #{ip}...")
60+
vprint_status("#{ip} - Enumerating XML-RPC URI...")
6161

6262
begin
6363

@@ -74,23 +74,23 @@ def get_xml_rpc_url(ip)
7474
if res['X-Pingback']
7575
return res['X-Pingback']
7676
else
77-
vprint_status("X-Pingback header not found at #{ip}")
77+
vprint_status("#{ip} - X-Pingback header not found")
7878
return nil
7979
end
8080
else
8181
return nil
8282
end
8383
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
84-
print_error("Unable to connect to #{ip}")
84+
vprint_error("#{ip} - Unable to connect")
8585
return nil
8686
rescue ::Timeout::Error, ::Errno::EPIPE
87-
print_error("Unable to connect to #{ip}")
87+
vprint_error("#{ip} - Unable to connect")
8888
return nil
8989
end
9090
end
9191

9292
# Creates the XML data to be sent
93-
def generate_pingback_xml (target, valid_blog_post)
93+
def generate_pingback_xml(target, valid_blog_post)
9494
xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"
9595
xml << "<methodCall>"
9696
xml << "<methodName>pingback.ping</methodName>"
@@ -104,15 +104,15 @@ def generate_pingback_xml (target, valid_blog_post)
104104

105105
def get_blog_posts(xml_rpc, ip)
106106
# find all blog posts within IP and determine if pingback is enabled
107-
vprint_status("Enumerating Blog posts on #{ip}...")
107+
vprint_status("#{ip} - Enumerating Blog posts on...")
108108
blog_posts = nil
109109

110110
uri = target_uri.path
111111
uri << '/' if uri[-1,1] != '/'
112112

113113
# make http request to feed url
114114
begin
115-
vprint_status("Resolving #{ip}#{uri}?feed=rss2 to locate wordpress feed...")
115+
vprint_status("#{ip} - Resolving #{uri}?feed=rss2 to locate wordpress feed...")
116116
res = send_request_cgi({
117117
'uri' => "#{uri}?feed=rss2",
118118
'method' => 'GET'
@@ -122,7 +122,7 @@ def get_blog_posts(xml_rpc, ip)
122122

123123
# Follow redirects
124124
while (res.code == 301 || res.code == 302) and res.headers['Location'] and count != 0
125-
vprint_status("Web server returned a #{res.code}...following to #{res.headers['Location']}")
125+
vprint_status("#{ip} - Web server returned a #{res.code}...following to #{res.headers['Location']}")
126126

127127
uri = res.headers['Location'].sub(/(http|https):\/\/.*?\//, "/")
128128
res = send_request_cgi({
@@ -131,30 +131,30 @@ def get_blog_posts(xml_rpc, ip)
131131
})
132132

133133
if res.code == 200
134-
vprint_status("Feed located at http://#{ip}#{uri}")
134+
vprint_status("#{ip} - Feed located at #{uri}")
135135
else
136-
vprint_status("#{ip} returned a #{res.code}...")
136+
vprint_status("#{ip} - Returned a #{res.code}...")
137137
end
138138
count = count - 1
139139
end
140140
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
141-
print_error("Unable to connect to #{ip}")
141+
vprint_error("#{ip} - Unable to connect")
142142
return nil
143143
rescue ::Timeout::Error, ::Errno::EPIPE
144-
print_error("Unable to connect to #{ip}")
144+
vprint_error("#{ip} - Unable to connect")
145145
return nil
146146
end
147147

148148
if res.nil? or res.code != 200
149-
vprint_status("Did not recieve HTTP response from #{ip}")
149+
vprint_status("#{ip} - Did not recieve HTTP response from #{ip}")
150150
return blog_posts
151151
end
152152

153153
# parse out links and place in array
154154
links = res.body.scan(/<link>([^<]+)<\/link>/i)
155155

156156
if links.nil? or links.empty?
157-
vprint_status("Feed at #{ip} did not have any links present")
157+
vprint_status("#{ip} - Feed at #{ip} did not have any links present")
158158
return blog_posts
159159
end
160160

@@ -164,11 +164,11 @@ def get_blog_posts(xml_rpc, ip)
164164
if pingback_response
165165
pingback_disabled_match = pingback_response.body.match(/<value><int>33<\/int><\/value>/i)
166166
if pingback_response.code == 200 and pingback_disabled_match.nil?
167-
print_good("Pingback enabled: #{link.join}")
167+
print_good("#{ip} - Pingback enabled: #{link.join}")
168168
blog_posts = link.join
169169
return blog_posts
170170
else
171-
vprint_status("Pingback disabled: #{link.join}")
171+
vprint_status("#{ip} - Pingback disabled: #{link.join}")
172172
end
173173
end
174174
end
@@ -189,10 +189,10 @@ def get_pingback_request(xml_rpc, target, blog_post)
189189
'data' => "#{pingback_xml}"
190190
})
191191
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
192-
print_error("Unable to connect to #{uri}")
192+
vprint_error("Unable to connect to #{uri}")
193193
return nil
194194
rescue ::Timeout::Error, ::Errno::EPIPE
195-
print_error("Unable to connect to #{uri}")
195+
vprint_error("Unable to connect to #{uri}")
196196
return nil
197197
end
198198
return res
@@ -217,14 +217,14 @@ def run_host(ip)
217217

218218
# once xmlrpc url is found, get_blog_posts
219219
if xmlrpc.nil?
220-
print_error("#{ip} does not appear to be vulnerable")
220+
vprint_error("#{ip} - It doesn't appear to be vulnerable")
221221
else
222222
hash = get_blog_posts(xmlrpc, ip)
223223

224224
if hash
225225
store_vuln(ip, hash) if @db_active
226226
else
227-
print_status("X-Pingback enabled but no vulnerable blogs found on #{ip}...")
227+
vprint_status("#{ip} - X-Pingback enabled but no vulnerable blogs found")
228228
end
229229
end
230230
end

0 commit comments

Comments
 (0)