Unfubar the threading for #service_list
Also makes the test for service_start a little more resilient in case W32Time is already startedunstable
parent
34bc92584b
commit
7a6ccb92ab
|
@ -91,22 +91,22 @@ module Services
|
|||
serviceskey = "HKLM\\SYSTEM\\CurrentControlSet\\Services"
|
||||
a =[]
|
||||
services = []
|
||||
registry_enumkeys(serviceskey).each do |s|
|
||||
1.upto 10 do
|
||||
a.push(::Thread.new(s) { |sk|
|
||||
keys = registry_enumkeys(serviceskey)
|
||||
keys.each do |s|
|
||||
if a.length >= 10
|
||||
a.first.join
|
||||
a.delete_if {|x| not x.alive?}
|
||||
end
|
||||
t = framework.threads.spawn(self.refname+"-ServiceRegistryList",false,s) { |sk|
|
||||
begin
|
||||
srvtype = registry_getvaldata("#{serviceskey}\\#{sk}","Type").to_s
|
||||
if srvtype =~ /32|16/
|
||||
if srvtype == "32" or srvtype == "16"
|
||||
services << sk
|
||||
end
|
||||
rescue
|
||||
end
|
||||
})
|
||||
end
|
||||
until a.empty?
|
||||
a.first.join
|
||||
a.delete_if {|x| not x.alive?}
|
||||
end
|
||||
}
|
||||
a.push(t)
|
||||
end
|
||||
|
||||
return services
|
||||
|
|
|
@ -6,11 +6,9 @@ require 'msf/core'
|
|||
require 'rex'
|
||||
require 'msf/core/post/windows/services'
|
||||
|
||||
load 'lib/msf/core/post/windows/services.rb'
|
||||
|
||||
class Metasploit3 < Msf::Post
|
||||
|
||||
include Msf::Post::Windows::WindowsServices
|
||||
include Msf::Post::Windows::Services
|
||||
|
||||
include Msf::ModuleTest::PostTest
|
||||
|
||||
|
@ -42,6 +40,11 @@ class Metasploit3 < Msf::Post
|
|||
it "should start #{datastore["SSERVICE"]}" do
|
||||
ret = true
|
||||
results = service_start(datastore['SSERVICE'])
|
||||
if results != 0
|
||||
# Failed the first time, try to stop it first, then try again
|
||||
service_stop(datastore['SSERVICE'])
|
||||
results = service_start(datastore['SSERVICE'])
|
||||
end
|
||||
ret &&= (results == 0)
|
||||
|
||||
ret
|
||||
|
|
Loading…
Reference in New Issue