Fixes #250. Solves an old bug with background jobs not working right, fixes the 'background modules dont work' bug as well.
git-svn-id: file:///home/svn/framework3/trunk@5926 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
42c80b5018
commit
a7595fce6c
|
@ -54,27 +54,22 @@ module Auxiliary
|
|||
mod.options.validate(mod.datastore)
|
||||
|
||||
# Initialize user interaction
|
||||
mod.init_ui(opts['LocalInput'],opts['LocalOutput'])
|
||||
if(not opts['Quiet'])
|
||||
mod.init_ui(opts['LocalInput'],opts['LocalOutput'])
|
||||
else
|
||||
mod.init_ui(nil, nil)
|
||||
end
|
||||
|
||||
if(mod.passive?)
|
||||
if(mod.passive? or opts['RunAsJob'])
|
||||
mod.framework.jobs.start_bg_job(
|
||||
"Auxiliary: #{mod.refname}",
|
||||
mod,
|
||||
Proc.new { |mod| self.job_run_proc(mod) },
|
||||
Proc.new { |mod| self.job_cleanup_proc(mod) }
|
||||
)
|
||||
else
|
||||
if (opts['RunAsJob'])
|
||||
mod.framework.jobs.start_job(
|
||||
"Auxiliary: #{mod.refname}",
|
||||
mod,
|
||||
Proc.new { |mod| self.job_run_proc(mod) },
|
||||
Proc.new { |mod| self.job_cleanup_proc(mod) }
|
||||
)
|
||||
else
|
||||
self.job_run_proc(mod)
|
||||
self.job_cleanup_proc(mod)
|
||||
end
|
||||
else
|
||||
self.job_run_proc(mod)
|
||||
self.job_cleanup_proc(mod)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,7 +98,7 @@ protected
|
|||
mod.print_error(" #{line}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
elog("Auxiliary failed: #{e.class} #{e}", 'core', LEV_0)
|
||||
dlog("Call stack:\n#{$@.join("\n")}", 'core', LEV_3)
|
||||
|
||||
|
|
|
@ -269,9 +269,15 @@ module Exploit::Remote::TcpServer
|
|||
# service that corresponds with what the client has requested.
|
||||
#
|
||||
def exploit
|
||||
|
||||
start_service()
|
||||
print_status("Server started.")
|
||||
|
||||
# Call the exploit primer
|
||||
primer
|
||||
|
||||
# Wait on the service to stop
|
||||
self.service.wait
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -334,8 +340,9 @@ module Exploit::Remote::TcpServer
|
|||
on_client_close(client)
|
||||
}
|
||||
|
||||
# Start the listening service
|
||||
self.service.start
|
||||
|
||||
|
||||
rescue ::Errno::EACCES => e
|
||||
if (srvport.to_i < 1024)
|
||||
print_line(" ")
|
||||
|
@ -361,9 +368,12 @@ module Exploit::Remote::TcpServer
|
|||
#
|
||||
def stop_service
|
||||
if (service)
|
||||
self.service.deref if self.service.kind_of?(Rex::Service)
|
||||
self.service.close if self.service.kind_of?(Rex::Socket)
|
||||
self.service = nil
|
||||
begin
|
||||
self.service.deref if self.service.kind_of?(Rex::Service)
|
||||
self.service.close if self.service.kind_of?(Rex::Socket)
|
||||
self.service = nil
|
||||
rescue ::Exception
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -446,4 +456,4 @@ protected
|
|||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,7 +17,8 @@ class Auxiliary
|
|||
"-h" => [ false, "Help banner." ],
|
||||
"-j" => [ false, "Run in the context of a job." ],
|
||||
"-o" => [ true, "A comma separated list of options in VAR=VAL format." ],
|
||||
"-a" => [ true, "The action to use. If none is specified, ACTION is used." ]
|
||||
"-a" => [ true, "The action to use. If none is specified, ACTION is used." ],
|
||||
"-q" => [ false, "Run the module in quiet mode with no output" ]
|
||||
)
|
||||
|
||||
#
|
||||
|
@ -101,7 +102,8 @@ class Auxiliary
|
|||
opt_str = nil
|
||||
action = mod.datastore['ACTION']
|
||||
jobify = false
|
||||
|
||||
quiet = false
|
||||
|
||||
@@auxiliary_opts.parse(args) { |opt, idx, val|
|
||||
case opt
|
||||
when '-j'
|
||||
|
@ -110,6 +112,8 @@ class Auxiliary
|
|||
opt_str = val
|
||||
when '-a'
|
||||
action = val
|
||||
when '-q'
|
||||
quiet = true
|
||||
when '-h'
|
||||
print(
|
||||
"Usage: run [options]\n\n" +
|
||||
|
@ -130,7 +134,8 @@ class Auxiliary
|
|||
'OptionStr' => opt_str,
|
||||
'LocalInput' => driver.input,
|
||||
'LocalOutput' => driver.output,
|
||||
'RunAsJob' => jobify
|
||||
'RunAsJob' => jobify,
|
||||
'Quiet' => quiet
|
||||
)
|
||||
rescue ::Exception => e
|
||||
print_error("Auxiliary failed: #{e.class} #{e}")
|
||||
|
|
|
@ -96,6 +96,13 @@ module StreamServer
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# This method waits on the server listener thread
|
||||
#
|
||||
def wait
|
||||
self.listener_thread.join if self.listener_thread
|
||||
end
|
||||
|
||||
##
|
||||
#
|
||||
|
@ -131,7 +138,7 @@ protected
|
|||
def monitor_listener
|
||||
|
||||
begin
|
||||
sd = Kernel.select([ fd ], nil, nil, 0)
|
||||
sd = Kernel.select([ fd ], nil, nil, 0.25)
|
||||
|
||||
# Accept the new client connection
|
||||
if (sd and sd[0].length > 0)
|
||||
|
|
|
@ -26,15 +26,10 @@ class Job
|
|||
#
|
||||
def start(async = false)
|
||||
if (async)
|
||||
begin
|
||||
run_proc.call(ctx)
|
||||
rescue ::Exception
|
||||
container.stop_job(jid)
|
||||
|
||||
raise $!
|
||||
end
|
||||
else
|
||||
self.job_thread = Thread.new {
|
||||
# Deschedule our thread momentarily
|
||||
select(nil, nil, nil, 0.01)
|
||||
|
||||
begin
|
||||
run_proc.call(ctx)
|
||||
ensure
|
||||
|
@ -42,6 +37,13 @@ class Job
|
|||
container.remove_job(self)
|
||||
end
|
||||
}
|
||||
else
|
||||
begin
|
||||
run_proc.call(ctx)
|
||||
rescue ::Exception
|
||||
container.stop_job(jid)
|
||||
raise $!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -167,4 +169,4 @@ protected
|
|||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue