Skip to content

Commit ca7d6ec

Browse files
committed
Account registers correctly on geteip_fpu
1 parent 34d83f3 commit ca7d6ec

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/rex/arch/x86.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,22 @@ def self.geteip_fpu(badchars, modified_registers = [])
476476
# If the register is not ESP, copy ESP
477477
if (dst != ESP)
478478
mod_registers.push(dst)
479-
next if badchars.index( (0x70 + dst).chr )
479+
if badchars.index( (0x70 + dst).chr )
480+
mod_registers.pop(dst)
481+
next
482+
end
480483

481484
if !(badchars.index("\x89") or badchars.index( (0xE0+dst).chr ))
482485
buf << "\x89" + (0xE0 + dst).chr
483486
else
484-
next if badchars.index("\x54")
485-
next if badchars.index( (0x58+dst).chr )
487+
if badchars.index("\x54")
488+
mod_registers.pop(dst)
489+
next
490+
end
491+
if badchars.index( (0x58+dst).chr )
492+
mod_registers.pop(dst)
493+
next
494+
end
486495
buf << "\x54" + (0x58 + dst).chr
487496
end
488497
end
@@ -519,6 +528,7 @@ def self.geteip_fpu(badchars, modified_registers = [])
519528
modified_registers.concat(mod_registers)
520529
return [out, REG_NAMES32[reg].upcase, gap]
521530
end
531+
mod_registers.pop(dst)
522532
end
523533

524534
return nil

0 commit comments

Comments
 (0)