Skip to content

Commit c30dcf5

Browse files
committed
prepend_nops: Return unmodified shellcode if no compatible nops for arch
1 parent 7d3bff6 commit c30dcf5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/msf/core/payload_generator.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -548,18 +548,18 @@ def platform_list
548548
# @param shellcode [String] The shellcode to prepend the NOPs to
549549
# @return [String] the shellcode with the appropriate nopsled affixed
550550
def prepend_nops(shellcode)
551-
if nops > 0
552-
framework.nops.each_module_ranked('Arch' => [arch]) do |name, mod|
553-
nop = framework.nops.create(name)
554-
raw = nop.generate_sled(nops, {'BadChars' => badchars, 'SaveRegisters' => [ 'esp', 'ebp', 'esi', 'edi' ] })
555-
if raw
556-
cli_print "Successfully added NOP sled of size #{raw.length} from #{name}"
557-
return raw + shellcode
558-
end
551+
return shellcode unless nops > 0
552+
553+
framework.nops.each_module_ranked('Arch' => [arch]) do |name, mod|
554+
nop = framework.nops.create(name)
555+
raw = nop.generate_sled(nops, {'BadChars' => badchars, 'SaveRegisters' => [ 'esp', 'ebp', 'esi', 'edi' ] })
556+
if raw
557+
cli_print "Successfully added NOP sled of size #{raw.length} from #{name}"
558+
return raw + shellcode
559559
end
560-
else
561-
shellcode
562560
end
561+
562+
shellcode
563563
end
564564

565565
# This method runs a specified encoder, for a number of defined iterations against the shellcode.

0 commit comments

Comments
 (0)