Fixes up msfpescan/msfelfscan to work with both 1.8.6 and 1.9.1
git-svn-id: file:///home/svn/framework3/trunk@6615 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
f7a7a528be
commit
90af8f03db
|
@ -20,7 +20,7 @@ class Elf < ElfBase
|
|||
elf_header = ElfHeader.new(isource.read(offset, ELF_HEADER_SIZE))
|
||||
|
||||
# Data encoding
|
||||
ei_data = elf_header.e_ident[EI_DATA]
|
||||
ei_data = elf_header.e_ident[EI_DATA,1].unpack("C")[0]
|
||||
|
||||
e_phoff = elf_header.e_phoff
|
||||
e_phentsize = elf_header.e_phentsize
|
||||
|
@ -71,11 +71,11 @@ class Elf < ElfBase
|
|||
#
|
||||
def ptr_64?
|
||||
unless [ ELFCLASS32, ELFCLASS64 ].include?(
|
||||
elf_header.e_ident[EI_CLASS])
|
||||
elf_header.e_ident[EI_CLASS,1].unpack("C*")[0])
|
||||
raise ElfHeaderError, 'Invalid class', caller
|
||||
end
|
||||
|
||||
elf_header.e_ident[EI_CLASS] == ELFCLASS64
|
||||
elf_header.e_ident[EI_CLASS,1].unpack("C*")[0] == ELFCLASS64
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -120,4 +120,4 @@ class Elf < ElfBase
|
|||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -162,7 +162,7 @@ class ElfBase
|
|||
raise ElfHeaderError, "Couldn't parse ELF Header", caller
|
||||
end
|
||||
|
||||
if elf_header.v['e_ident'][EI_DATA] == ELFDATA2MSB
|
||||
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)
|
||||
|
@ -171,8 +171,8 @@ class ElfBase
|
|||
end
|
||||
|
||||
unless [ ELFDATA2LSB, ELFDATA2MSB ].include?(
|
||||
elf_header.v['e_ident'][EI_DATA])
|
||||
raise ElfHeaderError, 'Invalid data encoding', caller
|
||||
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
|
||||
|
@ -237,14 +237,13 @@ class ElfBase
|
|||
|
||||
class ProgramHeader < GenericHeader
|
||||
def initialize(rawdata, ei_data)
|
||||
|
||||
# Identify the data encoding and parse Program Header
|
||||
if ei_data == ELFDATA2LSB
|
||||
program_header = ELF32_PHDR_LSB.make_struct
|
||||
elsif ei_data == ELFDATA2MSB
|
||||
program_header = ELF32_PHDR_MSB.make_struct
|
||||
else
|
||||
raise ElfHeaderError, 'Invalid data encoding', caller
|
||||
raise ElfHeaderError, "Invalid data encoding", caller
|
||||
end
|
||||
|
||||
if !program_header.from_s(rawdata)
|
||||
|
@ -258,4 +257,4 @@ class ElfBase
|
|||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -99,10 +99,10 @@ class JmpRegScanner < Generic
|
|||
|
||||
parse_ret = false
|
||||
|
||||
byte1 = elf.read(offset, 1)[0]
|
||||
byte1 = elf.read(offset, 1).unpack('C')[0]
|
||||
|
||||
if byte1 == 0xff
|
||||
byte2 = elf.read(offset+1, 1)[0]
|
||||
byte2 = elf.read(offset+1, 1).unpack('C')[0]
|
||||
regname = Rex::Arch::X86.reg_name32(byte2 & 0x7)
|
||||
|
||||
case byte2 & 0xf8
|
||||
|
@ -204,4 +204,4 @@ end
|
|||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -73,7 +73,7 @@ module Scanner
|
|||
return 3
|
||||
end
|
||||
|
||||
raise RuntimeError, "invalid return opcode: #{"0x%.2x" % d[0].ord}"
|
||||
raise RuntimeError, "invalid return opcode"
|
||||
end
|
||||
|
||||
def _parse_ret(data)
|
||||
|
@ -96,10 +96,10 @@ module Scanner
|
|||
|
||||
parse_ret = false
|
||||
|
||||
byte1 = section.read(index, 1)[0,1].ord
|
||||
byte1 = section.read(index, 1).unpack("C*")[0]
|
||||
|
||||
if byte1 == 0xff
|
||||
byte2 = section.read(index+1, 1)[0,1].ord
|
||||
byte2 = section.read(index+1, 1).unpack("C*")[0]
|
||||
regname = Rex::Arch::X86.reg_name32(byte2 & 0x7)
|
||||
|
||||
case byte2 & 0xf8
|
||||
|
@ -148,8 +148,8 @@ module Scanner
|
|||
message = ''
|
||||
|
||||
pops = section.read(index, 2)
|
||||
reg1 = Rex::Arch::X86.reg_name32(pops[0,1].ord & 0x7)
|
||||
reg2 = Rex::Arch::X86.reg_name32(pops[1,1].ord & 0x7)
|
||||
reg1 = Rex::Arch::X86.reg_name32(pops[0,1].unpack("C*")[0] & 0x7)
|
||||
reg2 = Rex::Arch::X86.reg_name32(pops[1,1].unpack("C*")[0] & 0x7)
|
||||
|
||||
message = "pop #{reg1}; pop #{reg2}; "
|
||||
|
||||
|
|
Loading…
Reference in New Issue