Track the target host/workspace through the entire tree, expose to RPC, and use this telnet_login
git-svn-id: file:///home/svn/framework3/trunk@8583 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
1faec528de
commit
479f2939fc
|
@ -11,10 +11,6 @@ module Auxiliary::Report
|
||||||
|
|
||||||
def initialize(info = {})
|
def initialize(info = {})
|
||||||
super
|
super
|
||||||
|
|
||||||
register_options([
|
|
||||||
OptString.new('WORKSPACE', [ false, "The name of the workspace to report data into"])
|
|
||||||
], Auxiliary::Report)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Shortcut method for detecting when the DB is active
|
# Shortcut method for detecting when the DB is active
|
||||||
|
@ -24,7 +20,7 @@ module Auxiliary::Report
|
||||||
|
|
||||||
def myworkspace
|
def myworkspace
|
||||||
return @myworkspace if @myworkspace
|
return @myworkspace if @myworkspace
|
||||||
@myworkspace = Msf::DBManager::Workspace.find_by_name(datastore['WORKSPACE']) || framework.db.workspace
|
@myworkspace = self.workspace
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -190,11 +190,9 @@ protected
|
||||||
# Pass along the framework context
|
# Pass along the framework context
|
||||||
s.framework = framework
|
s.framework = framework
|
||||||
|
|
||||||
# Associate this session with this payload and with the
|
# Associate this system with the original exploit
|
||||||
# assoc_exploit, if this payload has one
|
# and any relevant information
|
||||||
s.set_via(
|
s.set_from_exploit(assoc_exploit)
|
||||||
'Exploit' => assoc_exploit ? assoc_exploit.refname : nil,
|
|
||||||
'Payload' => self.refname)
|
|
||||||
|
|
||||||
# If the session is valid, register it with the framework and
|
# If the session is valid, register it with the framework and
|
||||||
# notify any waiters we may have.
|
# notify any waiters we may have.
|
||||||
|
|
|
@ -138,6 +138,12 @@ class Module
|
||||||
|
|
||||||
self.privileged = module_info['Privileged'] || false
|
self.privileged = module_info['Privileged'] || false
|
||||||
self.license = module_info['License'] || MSF_LICENSE
|
self.license = module_info['License'] || MSF_LICENSE
|
||||||
|
|
||||||
|
# Allow all modules to track their current workspace
|
||||||
|
register_advanced_options(
|
||||||
|
[
|
||||||
|
OptString.new('WORKSPACE', [ false, "Specify the workspace for this module" ])
|
||||||
|
], Msf::Module)
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -279,6 +285,29 @@ class Module
|
||||||
module_info['Compat'] || {}
|
module_info['Compat'] || {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Returns the address of the last target host (rough estimate)
|
||||||
|
#
|
||||||
|
def target_host
|
||||||
|
if(self.respond_to?('rhost'))
|
||||||
|
return rhost()
|
||||||
|
end
|
||||||
|
|
||||||
|
if(self.datastore['RHOST'])
|
||||||
|
return self.datastore['RHOST']
|
||||||
|
end
|
||||||
|
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Returns the current workspace
|
||||||
|
#
|
||||||
|
def workspace
|
||||||
|
self.datastore['WORKSPACE'] ||
|
||||||
|
(framework.db and framework.db.workspace and framework.db.workspace.name)
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns whether or not this module is compatible with the supplied
|
# Returns whether or not this module is compatible with the supplied
|
||||||
# module.
|
# module.
|
||||||
|
|
|
@ -13,7 +13,9 @@ class Session < Base
|
||||||
'tunnel_peer' => s.tunnel_peer.to_s,
|
'tunnel_peer' => s.tunnel_peer.to_s,
|
||||||
'via_exploit' => s.via_exploit.to_s,
|
'via_exploit' => s.via_exploit.to_s,
|
||||||
'via_payload' => s.via_payload.to_s,
|
'via_payload' => s.via_payload.to_s,
|
||||||
'desc' => s.desc.to_s
|
'desc' => s.desc.to_s,
|
||||||
|
'workspace' => s.workspace.to_s,
|
||||||
|
'target_host' => s.target_host.to_s
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
res
|
res
|
||||||
|
|
|
@ -175,6 +175,19 @@ module Session
|
||||||
self.via = opts || {}
|
self.via = opts || {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#
|
||||||
|
# Configures via_payload, via_payload, workspace, target_host from an
|
||||||
|
# exploit instance.
|
||||||
|
#
|
||||||
|
def set_from_exploit(m)
|
||||||
|
self.via = {
|
||||||
|
'Exploit' => m.refname,
|
||||||
|
'Payload' => m.datastore['PAYLOAD'].to_s
|
||||||
|
}
|
||||||
|
self.target_host = m.target_host
|
||||||
|
self.workspace = m.workspace
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns the exploit module name through which this session was
|
# Returns the exploit module name through which this session was
|
||||||
# created.
|
# created.
|
||||||
|
@ -224,7 +237,14 @@ module Session
|
||||||
# The session name.
|
# The session name.
|
||||||
#
|
#
|
||||||
attr_accessor :sname
|
attr_accessor :sname
|
||||||
|
#
|
||||||
|
# The associated workspace name
|
||||||
|
#
|
||||||
|
attr_accessor :workspace
|
||||||
|
#
|
||||||
|
# The original target host address
|
||||||
|
#
|
||||||
|
attr_accessor :target_host
|
||||||
protected
|
protected
|
||||||
|
|
||||||
attr_accessor :via # :nodoc:
|
attr_accessor :via # :nodoc:
|
||||||
|
@ -232,3 +252,4 @@ protected
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -173,6 +173,7 @@ class Metasploit3 < Msf::Auxiliary
|
||||||
# seem to affect anything else.
|
# seem to affect anything else.
|
||||||
sock.extend(CRLFLineEndings)
|
sock.extend(CRLFLineEndings)
|
||||||
sess = Msf::Sessions::CommandShell.new(sock)
|
sess = Msf::Sessions::CommandShell.new(sock)
|
||||||
|
sess.set_from_exploit(self)
|
||||||
framework.sessions.register(sess)
|
framework.sessions.register(sess)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue