Class: Rex::ElfParsey::ElfBase::ElfHeader
- Inherits:
-
GenericHeader
- Object
- GenericStruct
- GenericHeader
- Rex::ElfParsey::ElfBase::ElfHeader
- Defined in:
- lib/rex/elfparsey/elfbase.rb
Instance Attribute Summary
Attributes inherited from GenericStruct
Instance Method Summary collapse
- #e_ident ⇒ Object
-
#initialize(rawdata) ⇒ ElfHeader
constructor
A new instance of ElfHeader.
Methods inherited from GenericStruct
#[], #keys, #method_missing, #v
Constructor Details
#initialize(rawdata) ⇒ ElfHeader
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/rex/elfparsey/elfbase.rb', line 154 def initialize(rawdata) # Identify the data encoding and parse ELF Header elf_header = ELF32_EHDR_LSB.make_struct if !elf_header.from_s(rawdata) raise ElfHeaderError, "Couldn't parse ELF Header", caller end if elf_header.v['e_ident'][EI_DATA,1].unpack('C')[0] == ELFDATA2MSB elf_header = ELF32_EHDR_MSB.make_struct if !elf_header.from_s(rawdata) raise ElfHeaderError, "Couldn't parse ELF Header", caller end end unless [ ELFDATA2LSB, ELFDATA2MSB ].include?( elf_header.v['e_ident'][EI_DATA,1].unpack('C')[0]) raise ElfHeaderError, "Invalid data encoding", caller end # Identify the file as an ELF object file unless elf_header.v['e_ident'][EI_MAG0, 4] == ELFMAG raise ElfHeaderError, 'Invalid magic number', caller end self.struct = elf_header end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rex::ElfParsey::ElfBase::GenericStruct
Instance Method Details
#e_ident ⇒ Object
184 185 186 |
# File 'lib/rex/elfparsey/elfbase.rb', line 184 def e_ident struct.v['e_ident'] end |