Class: Rex::ElfParsey::ElfBase

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/elfparsey/elfbase.rb

Direct Known Subclasses

Elf

Defined Under Namespace

Classes: ElfHeader, GenericHeader, GenericStruct, ProgramHeader

Constant Summary collapse

ELF_HEADER_SIZE =

ELF Header

52
EI_NIDENT =
16
ELF32_EHDR_LSB =
Rex::Struct2::CStructTemplate.new(
  [ 'string',  'e_ident',     EI_NIDENT, '' ],
  [ 'uint16v', 'e_type',      0 ],
  [ 'uint16v', 'e_machine',   0 ],
  [ 'uint32v', 'e_version',   0 ],
  [ 'uint32v', 'e_entry',     0 ],
  [ 'uint32v', 'e_phoff',     0 ],
  [ 'uint32v', 'e_shoff',     0 ],
  [ 'uint32v', 'e_flags',     0 ],
  [ 'uint16v', 'e_ehsize',    0 ],
  [ 'uint16v', 'e_phentsize', 0 ],
  [ 'uint16v', 'e_phnum',     0 ],
  [ 'uint16v', 'e_shentsize', 0 ],
  [ 'uint16v', 'e_shnum',     0 ],
  [ 'uint16v', 'e_shstrndx',  0 ]
)
ELF32_EHDR_MSB =
Rex::Struct2::CStructTemplate.new(
  [ 'string',  'e_ident',     EI_NIDENT, '' ],
  [ 'uint16n', 'e_type',      0 ],
  [ 'uint16n', 'e_machine',   0 ],
  [ 'uint32n', 'e_version',   0 ],
  [ 'uint32n', 'e_entry',     0 ],
  [ 'uint32n', 'e_phoff',     0 ],
  [ 'uint32n', 'e_shoff',     0 ],
  [ 'uint32n', 'e_flags',     0 ],
  [ 'uint16n', 'e_ehsize',    0 ],
  [ 'uint16n', 'e_phentsize', 0 ],
  [ 'uint16n', 'e_phnum',     0 ],
  [ 'uint16n', 'e_shentsize', 0 ],
  [ 'uint16n', 'e_shnum',     0 ],
  [ 'uint16n', 'e_shstrndx',  0 ]
)
ET_NONE =

e_type This member identifies the object file type

0
ET_REL =
1
ET_EXEC =
2
ET_DYN =
3
ET_CORE =
4
ET_LOPROC =
0xff00
ET_HIPROC =

No file type Relocatable file Executable file Shared object file Core file Processor-specific Processor-specific

0xffff
EM_M32 =

ET_NONE = 0 # No machine

1
EM_SPARC =
2
EM_386 =
3
EM_68K =
4
EM_88K =
5
EM_860 =
7
EM_MIPS =
8
EM_MIPS_RS4_BE =

AT&T WE 32100 SPARC Intel Architecture Motorola 68000 Motorola 88000 Intel 80860 MIPS RS3000 Big-Endian MIPS RS4000 Big-Endian

10
EV_NONE =

e_version This member identifies the object file version

0
EV_CURRENT =

Invalid version Current version

1
EI_MAG0 =

e_ident[] Identification indexes

0
EI_MAG1 =
1
EI_MAG2 =
2
EI_MAG3 =
3
EI_CLASS =
4
EI_DATA =
5
EI_VERSION =
6
EI_PAD =

File identification File identification File identification File identification File class Data encoding File version Start of padding bytes

7
ELFMAG0 =

EI_MAG0 to EI_MAG3 A file's first 4 bytes hold a “magic number”, identifying the file as an ELF object file.

0x7f
ELFMAG1 =
?E
ELFMAG2 =
?L
ELFMAG3 =
?F
ELFMAG =
ELFMAG0.chr + ELFMAG1.chr + ELFMAG2.chr + ELFMAG3.chr
ELFCLASSNONE =

EI_CLASS Identifies the file's class, or capacity

0
ELFCLASS32 =
1
ELFCLASS64 =

Invalid class 32-bit objects 64-bit objects

2
ELFDATANONE =

EI_DATA Specifies the data encoding of the processor-specific data in the object file. The following encodings are currently defined.

0
ELFDATA2LSB =
1
ELFDATA2MSB =

Invalid data encoding Least significant byte first Most significant byte first

2
PROGRAM_HEADER_SIZE =

Program Header

32
ELF32_PHDR_LSB =
Rex::Struct2::CStructTemplate.new(
  [ 'uint32v', 'p_type',   0 ],
  [ 'uint32v', 'p_offset', 0 ],
  [ 'uint32v', 'p_vaddr',  0 ],
  [ 'uint32v', 'p_paddr',  0 ],
  [ 'uint32v', 'p_filesz', 0 ],
  [ 'uint32v', 'p_memsz',  0 ],
  [ 'uint32v', 'p_flags',  0 ],
  [ 'uint32v', 'p_align',  0 ]
)
ELF32_PHDR_MSB =
Rex::Struct2::CStructTemplate.new(
  [ 'uint32n', 'p_type',   0 ],
  [ 'uint32n', 'p_offset', 0 ],
  [ 'uint32n', 'p_vaddr',  0 ],
  [ 'uint32n', 'p_paddr',  0 ],
  [ 'uint32n', 'p_filesz', 0 ],
  [ 'uint32n', 'p_memsz',  0 ],
  [ 'uint32n', 'p_flags',  0 ],
  [ 'uint32n', 'p_align',  0 ]
)
PT_NULL =

Segment Types

0
PT_LOAD =
1
PT_DYNAMIC =
2
PT_INTERP =
3
PT_NOTE =
4
PT_SHLIB =
5
PT_PHDR =
6
PT_LOPROC =
0x70000000
PT_HIPROC =
0x7fffffff