From 88cacd000e6935aaa78284bac174b597f125f3d9 Mon Sep 17 00:00:00 2001 From: Sascha Schirra Date: Thu, 11 Sep 2014 12:31:44 +0200 Subject: [PATCH 1/2] flags for phdr.p_flags added --- lib/rex/elfparsey/elfbase.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/rex/elfparsey/elfbase.rb b/lib/rex/elfparsey/elfbase.rb index 3652333bb1..e950bdb69d 100644 --- a/lib/rex/elfparsey/elfbase.rb +++ b/lib/rex/elfparsey/elfbase.rb @@ -214,6 +214,15 @@ class ElfBase [ 'uint32n', 'p_align', 0 ] ) + # p_flags This member tells which permissions should have the segment + + # Flags + + PF_EXEC = 1 + PF_WRITE = 2 + PF_READ = 4 + + # # p_type This member tells what kind of segment this array element # describes or how to interpret the array element's information. From be0c68d8bbf61e42334eca915ec0c9edc4b69231 Mon Sep 17 00:00:00 2001 From: Sascha Schirra Date: Thu, 11 Sep 2014 12:33:09 +0200 Subject: [PATCH 2/2] BUGFIX: wrong imagebase used --- lib/rex/elfparsey/elf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rex/elfparsey/elf.rb b/lib/rex/elfparsey/elf.rb index 51c7fcc5f7..4652c27f0b 100644 --- a/lib/rex/elfparsey/elf.rb +++ b/lib/rex/elfparsey/elf.rb @@ -34,7 +34,7 @@ class Elf < ElfBase isource.read(offset, PROGRAM_HEADER_SIZE), ei_data ) - if program_header[-1].p_type == PT_LOAD && base_addr == 0 + if program_header[-1].p_type == PT_LOAD && program_header[-1].p_flags & PF_EXEC > 0 base_addr = program_header[-1].p_vaddr end