Skip to content

Commit 21f8e19

Browse files
committed
Single Payloads Cache Assembled Payload Improperly
An earlier change to the framework (prepend_migrate) forced single payloads to use the internal_generate method of payload.rb. internal_generate calls build which has a cache to track assembled payloads. This method assumes that a payload only needs to be assembled once, with optional values patched in later. Single payloads do not work this way. Each time they are generated new assembly source is created with the options hardcoded in. This fix updates build to use the hashcode of the assembly code as part of the cache key. This fixes rapid7#7898 -- a bug that prevents a user from generating multiple variations of a single payload without a restart.
1 parent 1d9a695 commit 21f8e19

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/msf/core/payload.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,10 @@ def build(x, asm, off, suffix = '')
515515
return x.dup
516516
end
517517

518-
cache_key = refname + suffix
518+
# single payloads generate new assembly each time with the options
519+
# substituted in already. It's not appropriate to just use the module
520+
# as the cache key.
521+
cache_key = refname + suffix + asm.hash.to_s
519522
cache_entry = framework.payloads.check_blob_cache(cache_key)
520523

521524
off.each_pair { |option, val|

0 commit comments

Comments
 (0)