Set a limit to how many times we can retry

unstable
sinn3r 2012-03-31 02:38:46 -05:00
parent 62a54e0ad6
commit 4215030eb3
4 changed files with 44 additions and 16 deletions

View File

@ -224,16 +224,23 @@ class Metasploit3 < Msf::Post
# and retry under certain conditions. # and retry under certain conditions.
# #
def exec(cmd) def exec(cmd)
tries = 0
begin begin
out = cmd_exec(cmd).chomp out = cmd_exec(cmd).chomp
rescue ::Timeout::Error => e rescue ::Timeout::Error => e
tries += 1
if tries < 3
vprint_error("#{@peer} - #{e.message} - retrying...") vprint_error("#{@peer} - #{e.message} - retrying...")
retry retry
end
rescue EOFError => e rescue EOFError => e
tries += 1
if tries < 3
vprint_error("#{@peer} - #{e.message} - retrying...") vprint_error("#{@peer} - #{e.message} - retrying...")
retry retry
end end
end end
end
# #
# We're not sure the exact name of the folder becuase it contains a version number. # We're not sure the exact name of the folder becuase it contains a version number.

View File

@ -28,16 +28,23 @@ class Metasploit3 < Msf::Post
end end
def exec(cmd) def exec(cmd)
tries = 0
begin begin
out = cmd_exec(cmd).chomp out = cmd_exec(cmd).chomp
rescue ::Timeout::Error => e rescue ::Timeout::Error => e
tries += 1
if tries < 3
vprint_error("#{@peer} - #{e.message} - retrying...") vprint_error("#{@peer} - #{e.message} - retrying...")
retry retry
end
rescue EOFError => e rescue EOFError => e
tries += 1
if tries < 3
vprint_error("#{@peer} - #{e.message} - retrying...") vprint_error("#{@peer} - #{e.message} - retrying...")
retry retry
end end
end end
end
def get_air_preferences def get_air_preferences

View File

@ -40,16 +40,23 @@ class Metasploit3 < Msf::Post
# and retry under certain conditions. # and retry under certain conditions.
# #
def exec(cmd) def exec(cmd)
tries = 0
begin begin
out = cmd_exec(cmd).chomp out = cmd_exec(cmd).chomp
rescue ::Timeout::Error => e rescue ::Timeout::Error => e
tries += 1
if tries < 3
vprint_error("#{@peer} - #{e.message} - retrying...") vprint_error("#{@peer} - #{e.message} - retrying...")
retry retry
end
rescue EOFError => e rescue EOFError => e
tries += 1
if tries < 3
vprint_error("#{@peer} - #{e.message} - retrying...") vprint_error("#{@peer} - #{e.message} - retrying...")
retry retry
end end
end end
end
def dir(path) def dir(path)
subdirs = exec("ls -l #{path}") subdirs = exec("ls -l #{path}")

View File

@ -127,16 +127,23 @@ class Metasploit3 < Msf::Post
end end
def exec(cmd) def exec(cmd)
tries = 0
begin begin
out = cmd_exec(cmd).chomp out = cmd_exec(cmd).chomp
rescue ::Timeout::Error => e rescue ::Timeout::Error => e
tries += 1
if tries < 3
vprint_error("#{@peer} - #{e.message} - retrying...") vprint_error("#{@peer} - #{e.message} - retrying...")
retry retry
end
rescue EOFError => e rescue EOFError => e
tries += 1
if tries < 3
vprint_error("#{@peer} - #{e.message} - retrying...") vprint_error("#{@peer} - #{e.message} - retrying...")
retry retry
end end
end end
end
def run def run
if action.nil? if action.nil?