clean up multi delete
parent
21190cd864
commit
a60a4e518a
|
@ -140,7 +140,8 @@ class Plugin::Wmap < Msf::Plugin
|
||||||
when '-d'
|
when '-d'
|
||||||
del_idx = args
|
del_idx = args
|
||||||
if del_idx
|
if del_idx
|
||||||
delete_site(del_idx.split(/\s|,|\;/).map(&:to_i).uniq)
|
delete_sites(del_idx.map(&:to_i).uniq)
|
||||||
|
return
|
||||||
else
|
else
|
||||||
print_error("Provide index of site to delete")
|
print_error("Provide index of site to delete")
|
||||||
end
|
end
|
||||||
|
@ -204,7 +205,7 @@ class Plugin::Wmap < Msf::Plugin
|
||||||
print_status("Usage: wmap_sites [options]")
|
print_status("Usage: wmap_sites [options]")
|
||||||
print_line("\t-h Display this help text")
|
print_line("\t-h Display this help text")
|
||||||
print_line("\t-a [url] Add site (vhost,url)")
|
print_line("\t-a [url] Add site (vhost,url)")
|
||||||
print_line("\t-d [ids] Delete sites (separate ids by ',|\\s|;')")
|
print_line("\t-d [ids] Delete sites (separate ids with \\s )")
|
||||||
print_line("\t-l List all available sites")
|
print_line("\t-l List all available sites")
|
||||||
print_line("\t-s [id] Display site structure (vhost,url|ids) (level)")
|
print_line("\t-s [id] Display site structure (vhost,url|ids) (level)")
|
||||||
|
|
||||||
|
@ -1233,22 +1234,27 @@ class Plugin::Wmap < Msf::Plugin
|
||||||
print_status tbl.to_s + "\n"
|
print_status tbl.to_s + "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_site(wmap_index)
|
def delete_sites(wmap_index)
|
||||||
print_status("Deleting site #{wmap_index}")
|
|
||||||
idx = 0
|
idx = 0
|
||||||
|
to_del = {}
|
||||||
|
# Rebuild the index from wmap_sites -l
|
||||||
self.framework.db.hosts.each do |bdhost|
|
self.framework.db.hosts.each do |bdhost|
|
||||||
bdhost.services.each do |serv|
|
bdhost.services.each do |serv|
|
||||||
serv.web_sites.each do |web|
|
serv.web_sites.each do |web|
|
||||||
if wmap_index.any? {|w| w == idx}
|
# If the index of this site matches any deletion index,
|
||||||
web.delete
|
# add to our hash, saving the index for later output
|
||||||
print_status("Deleted #{web.vhost} on #{bdhost.address} at index #{idx}")
|
to_del[idx] = web if wmap_index.any? {|w| w.to_i == idx}
|
||||||
return
|
idx += 1
|
||||||
else
|
|
||||||
idx += 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
to_del.each do |widx,wsite|
|
||||||
|
if wsite.delete
|
||||||
|
print_status("Deleted #{wsite.vhost} on #{wsite.service.host.address} at index #{widx}")
|
||||||
|
else
|
||||||
|
print_error("Could note delete {wsite.vhost} on #{wsite.service.host.address} at index #{widx}")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue