@@ -503,22 +503,22 @@ def on_session(session)
503
503
504
504
#
505
505
# If the payload has assembly that needs to be compiled, do so now.
506
- # This method takes the raw payload (p), the assembly text (asm), and the
507
- # offsets hash for variables that need to be substituted (off). The suffix
508
- # is used to localize the way the generated payload is cached (whether the
509
- # blob is part of a single, stager, or stage, for example).
510
- #
511
- def build ( x , asm , off , suffix = '' )
512
- # If there is no assembly to be compiled, then we return a duplicated
513
- # copy of the raw payload blob
506
+ #
507
+ # Blobs will be cached in the framework's PayloadSet
508
+ #
509
+ # @see PayloadSet#check_blob_cache
510
+ # @param asm [String] Assembly code to be assembled into a raw payload
511
+ # @return [String] The final, assembled payload
512
+ # @raise ArgumentError if +asm+ is blank
513
+ def build ( asm , off = { } )
514
514
if ( asm . nil? or asm . empty? )
515
- return x . dup
515
+ raise ArgumentError , "Assembly must not be empty"
516
516
end
517
517
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
518
+ # Use the refname so blobs can be flushed when the module gets
519
+ # reloaded and use the hash value to ensure that we're actually
520
+ # getting the right blob for the given assembly .
521
+ cache_key = refname + asm . hash . to_s
522
522
cache_entry = framework . payloads . check_blob_cache ( cache_key )
523
523
524
524
off . each_pair { |option , val |
@@ -576,7 +576,11 @@ def build(x, asm, off, suffix = '')
576
576
def internal_generate
577
577
# Build the payload, either by using the raw payload blob defined in the
578
578
# module or by actually assembling it
579
- raw = build ( payload , assembly , offsets , '-stg0' )
579
+ if assembly and !assembly . empty?
580
+ raw = build ( assembly , offsets )
581
+ else
582
+ raw = payload . dup
583
+ end
580
584
581
585
# If the payload is generated and there are offsets to substitute,
582
586
# do that now.
0 commit comments