Class: CTF::Rop::RelocatableELF
- Inherits:
-
Object
- Object
- CTF::Rop::RelocatableELF
- Defined in:
- lib/ctf/rop.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#elf ⇒ Object
readonly
Returns the value of attribute elf.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Instance Method Summary collapse
- #function(name) ⇒ Object
-
#initialize(filename, offset = 0) ⇒ RelocatableELF
constructor
A new instance of RelocatableELF.
Constructor Details
#initialize(filename, offset = 0) ⇒ RelocatableELF
Returns a new instance of RelocatableELF.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/ctf/rop.rb', line 7 def initialize(filename, offset = 0) @offset = offset @elf = ::Metasm::ELF.decode_file(filename) @functions = {} @elf.symbols.find_all do |s| s.name and s.type == 'FUNC' && s.shndx != 'UNDEF' && s.bind == 'GLOBAL' end.each do |s| @functions[s.name] = s.value end end |
Instance Attribute Details
#elf ⇒ Object (readonly)
Returns the value of attribute elf.
6 7 8 |
# File 'lib/ctf/rop.rb', line 6 def elf @elf end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
5 6 7 |
# File 'lib/ctf/rop.rb', line 5 def offset @offset end |
Instance Method Details
#function(name) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/ctf/rop.rb', line 18 def function(name) if @functions.include? name.to_s @functions[name.to_s] + offset else raise RuntimeError.new("No such function #{name}") end end |