summaryrefslogtreecommitdiff
path: root/SectionDoubleP.py
diff options
context:
space:
mode:
authorn0p <0x90@n0p.cc>2013-10-02 19:04:39 +0200
committern0p <0x90@n0p.cc>2013-10-02 19:04:39 +0200
commit49133a657192a7a6768c7a7d381b26b1a06a0146 (patch)
treede45a92211c589b0e1abf4abbf200ca031b8aa75 /SectionDoubleP.py
parent880c9c8f4cd964a8b5eaffb824703367303a3d11 (diff)
downloadSectionDoubleP-49133a657192a7a6768c7a7d381b26b1a06a0146.tar.gz
SectionDoubleP-49133a657192a7a6768c7a7d381b26b1a06a0146.zip
Raw data of the section is added/removed correctly now if there is raw data after the last section.
Diffstat (limited to 'SectionDoubleP.py')
-rw-r--r--SectionDoubleP.py7
1 files 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