Skip to content

Commit dae114a

Browse files
committed
Document how to derive reference_name from ancestors
MSP-11145
1 parent 485860e commit dae114a

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

spec/support/shared/examples/payload_can_be_instantiated.rb

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@
33
# Tests that the `:ancestor_reference_names` can be loaded from `:modules_pathname` and once the ancestors are loaded
44
# that `:reference_name` can be instantiated.
55
#
6+
# # Payload Reference Name Derivation
7+
# You can see this naming logic [here](https://github.com/rapid7/metasploit-framework/blob/1508be6254f698f345616d14415bce164bf377f9/lib/msf/core/payload_set.rb#L132-L148).
8+
#
9+
# ## Single
10+
# 1. Remove the payload type prefix, `modules/payloads/singles`, from the path.
11+
# 2. Remove the file extension, `.rb` from the path
12+
#
13+
# This is <reference_name>
14+
#
15+
# ## Staged
16+
#
17+
# ### Stager
18+
# Determine if the stager module has a `handler_type_alias`
19+
# No) Use stager's handler's `handler_type` as `<handler_type>`.
20+
# Yes) Use the return value from `handler_type_alias` as `<handler_type>`.
21+
#
22+
# ### Stage
23+
# 1. Remove the payload type prefix, `modules/payloads/stages`, from the path.
24+
# 2. Remove the file extension, `.rb` from the path.
25+
#
26+
# This is <stage_reference_name>.
27+
#
28+
# ### Combining
29+
# The final staged module's combined `<reference_name>` is `<stage_reference_name>/<handler_type>`.
30+
#
631
# @example Using 'payload can be instantiated' with `Metasploit::Framework::Spec::UntestedPayloads.define_task` and 'untested payloads' shared context
732
# # Rakefile
833
# require 'metasploit/framework/spec/untested_payloads'
@@ -33,7 +58,11 @@
3358
#
3459
# @param options [Hash{Symbol => Array<String>, Pathname, String}]
3560
# @option options [Array<String>] :ancestor_reference_names The reference names of the payload modules that are included
36-
# in {Msf::Payload} to make the `:reference_name` payload.
61+
# in {Msf::Payload} to make the `:reference_name` payload. Ancestor reference names are the names of the files under
62+
# `modules/payloads` without the extension `.rb` that are mixed together to form a payload module `Class`. For
63+
# single payloads, there will be one ancestor reference name from `modules/payloads/singles`, while for staged
64+
# payloads there with be one ancestor reference name from `modules/payloads/stagers` and one ancestor reference name
65+
# from `modules/payloads/stages`.
3766
# @option options [Pathname] :modules_pathname The `modules` directory from which to load `:ancestor_reference_names`.
3867
# @option options [String] :reference_name The reference name for payload class that should be instantiated from mixing
3968
# `:ancestor_reference_names`.

0 commit comments

Comments
 (0)