added the concept of payload convention

git-svn-id: file:///home/svn/incoming/trunk@2925 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-10-01 06:09:46 +00:00
parent dd20214f32
commit 17a596186e
2 changed files with 48 additions and 3 deletions

View File

@ -96,6 +96,39 @@ class Payload < Msf::Module
return module_info['Payload']['Offsets']
end
#
# Returns the staging convention that the payload uses, if any. This is
# used to make sure that only compatible stagers and stages are built
# (where assumptions are made about register/environment initialization
# state and hand-off).
#
def convention
module_info['Convention']
end
#
# Checks to see if the supplied convention is compatible with this
# payload's convention.
#
def compatible_convention?(conv)
# If we ourself don't have a convention or our convention is equal to
# the one supplied, then we know we are compatible.
if ((self.convention == nil) or
(self.convention == conv))
true
# On the flip side, if we are a stager and the supplied convention is
# nil, then we know it's compatible.
elsif ((payload_type == Type::Stager) and
(conv == nil))
true
# Otherwise, the conventions don't match in some way or another, and as
# such we deem ourself as not being compatible with the supplied
# convention.
else
false
end
end
#
# Return the connection associated with this payload, or none if there
# isn't one.

View File

@ -91,11 +91,11 @@ class PayloadSet < ModuleSet
# Recalculate stagers and stages
_stagers.each_pair { |stager_name, p|
stager_mod, handler, stager_platform, stager_arch = p
stager_mod, handler, stager_platform, stager_arch, stager_conv = p
# Walk the array of stages
_stages.each_pair { |stage_name, p|
stage_mod, junk, stage_platform, stage_arch = p
stage_mod, junk, stage_platform, stage_arch, stage_conv = p
# No intersection between architectures on the payloads?
if ((stager_arch) and
@ -119,6 +119,17 @@ class PayloadSet < ModuleSet
next
end
# If the stage has a convention, make sure it's compatible with
# the stager's
if ((stage_conv) and
(stager_conv != stage_conv))
dlog("Stager #{stager_name} and stage #{stage_name} have incompatible conventions:",
'core', LEV_3)
dlog(" Stager: #{stager_conv}.", 'core', LEV_3)
dlog(" Stage: #{stage_conv}.", 'core', LEV_3)
next
end
# Build the payload dupe using the handler, stager,
# and stage
p = build_payload(handler, stager_mod, stage_mod)
@ -173,7 +184,8 @@ class PayloadSet < ModuleSet
pmodule,
instance.handler,
instance.platform,
instance.arch
instance.arch,
instance.convention
]
# Use the module's preferred alias if it has one