From 49133a657192a7a6768c7a7d381b26b1a06a0146 Mon Sep 17 00:00:00 2001 From: n0p <0x90@n0p.cc> Date: Wed, 2 Oct 2013 19:04:39 +0200 Subject: Raw data of the section is added/removed correctly now if there is raw data after the last section. --- SectionDoubleP.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SectionDoubleP.py b/SectionDoubleP.py index 00b0ac1..f1a52f1 100644 --- a/SectionDoubleP.py +++ b/SectionDoubleP.py @@ -106,7 +106,9 @@ class SectionDoubleP: # Stripping the data of the section from the file. if self.pe.sections[-1].SizeOfRawData != 0: - self.pe.__data__ = self.pe.__data__[:-self.pe.sections[-1].SizeOfRawData] + self.pe.__data__ = (self.pe.__data__[:self.pe.sections[-1].PointerToRawData] + \ + self.pe.__data__[self.pe.sections[-1].PointerToRawData + \ + self.pe.sections[-1].SizeOfRawData:]) # Overwriting the section header in the binary with nulls. # Getting the address of the section table and manually overwriting @@ -214,7 +216,8 @@ class SectionDoubleP: # Appending the data of the new section to the file. if len(Data) > 0: - self.pe.__data__ = self.pe.__data__[:] + Data + self.pe.__data__ = (self.pe.__data__[:RawAddress] + Data + \ + self.pe.__data__[RawAddress:]) section_offset = section_table_offset + self.pe.FILE_HEADER.NumberOfSections*0x28 -- cgit v1.2.3