Package pype32
[hide private]
[frames] | no frames]

Source Code for Package pype32

  1  #!/usr/bin/python 
  2  # -*- coding: utf-8 -*-  
  3   
  4  # Copyright (c) 2013, Nahuel Riva  
  5  # All rights reserved.  
  6  #  
  7  # Redistribution and use in source and binary forms, with or without  
  8  # modification, are permitted provided that the following conditions are met:  
  9  #  
 10  #     * Redistributions of source code must retain the above copyright notice,  
 11  #       this list of conditions and the following disclaimer.  
 12  #     * Redistributions in binary form must reproduce the above copyright  
 13  #       notice,this list of conditions and the following disclaimer in the  
 14  #       documentation and/or other materials provided with the distribution.  
 15  #     * Neither the name of the copyright holder nor the names of its  
 16  #       contributors may be used to endorse or promote products derived from  
 17  #       this software without specific prior written permission.  
 18  #  
 19  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
 20  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE  
 21  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE  
 22  # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE  
 23  # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR  
 24  # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF  
 25  # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  
 26  # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN  
 27  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  
 28  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  
 29  # POSSIBILITY OF SUCH DAMAGE.  
 30   
 31  """ 
 32  Yet another Python library to work with PE32 and PE64 file formats. 
 33   
 34  by Nahuel Riva (crackinglandia at gmail.com) 
 35   
 36  Project: U{http://code.google.com/p/pype32} 
 37   
 38  Blog: U{http://crackinglandia.blogspot.com} 
 39   
 40  @group PE: 
 41      PE, DosHeader, NtHeaders, OptionalHeader, SectionHeader, SectionHeaders, OptionalHeader64, FileHeader, Sections 
 42   
 43  @group Data type objects: 
 44      String, AlignedString, Array, BYTE, WORD, DWORD, QWORD 
 45   
 46  @group Utilities: 
 47      ReadData, WriteData 
 48       
 49  @group Exceptions: 
 50      PyPe32Exception,NotValidPathException,WrongOffsetValueException,DirectoryEntriesLengthException, 
 51      TypeNotSupportedException,ArrayTypeException,DataLengthException,ReadDataOffsetException, 
 52      WriteDataOffsetException,InstanceErrorException,DataMismatchException,SectionHeadersException, 
 53      DirectoryEntryException,InvalidParameterException 
 54       
 55  @group Directories: 
 56      Directory, DataDirectory, ImageBoundForwarderRefEntry, ImageBoundForwarderRef, 
 57      ImageBoundImportDescriptor, ImageBoundImportDescriptorEntry, TLSDirectory, TLSDirectory64, ImageBaseRelocationEntry,  
 58      ImageBaseRelocation, ImageDebugDirectory, ImageDebugDirectories, ImageImportDescriptorMetaData, ImageImportDescriptorEntry, 
 59      ImageImportDescriptor, ImportAddressTableEntry, ImportAddressTableEntry64, ImportAddressTable, ExportTable, ExportTableEntry,  
 60      ImageExportTable, NETDirectory, NetDirectory, NetMetaDataHeader, NetMetaDataStreamEntry, NetMetaDataStreams, NetMetaDataTableHeader,  
 61      NetMetaDataTables 
 62       
 63  @type version: str 
 64  @var version: This pype32 release version. 
 65  """ 
 66   
 67  __revision__ = "$Id$" 
 68   
 69  __all__ = [ 
 70             # Lirabry version 
 71             "version",  
 72             "version_number",  
 73              
 74             # from pype32 import * 
 75             "PE",  
 76             "DosHeader",  
 77             "NtHeaders",  
 78             "OptionalHeader", 
 79             "OptionalHeader64",   
 80             "SectionHeader",  
 81             "SectionHeaders", 
 82             "FileHeader",  
 83             "Sections",  
 84              
 85             # from datatypes import * 
 86              "String",  
 87              "AlignedString",  
 88              "Array",  
 89              "BYTE",  
 90              "WORD",  
 91              "DWORD",  
 92              "QWORD",  
 93               
 94              # from utils import * 
 95              "ReadData",   
 96              "WriteData",  
 97               
 98              # from excep import * 
 99              "PyPe32Exception",  
100              "NotValidPathException",  
101              "WrongOffsetValueException",  
102              "DirectoryEntriesLengthException",  
103              "TypeNotSupportedException",  
104              "ArrayTypeException",  
105              "DataLengthException",  
106              "ReadDataOffsetException",  
107              "WriteDataOffsetException",  
108              "InstanceErrorException", 
109              "DataMismatchException",  
110              "SectionHeadersException",  
111              "DirectoryEntryException",  
112              "InvalidParameterException",  
113               
114              # from datadirs import * 
115              "DataDirectory",  
116              "Directory",  
117               
118              # from directories import * 
119              "Directory", 
120              "DataDirectory", 
121              "ImageImportDescriptor", 
122              "ImageBoundForwarderRefEntry", 
123              "ImageBoundForwarderRef", 
124              "ImageBoundImportDescriptor", 
125              "ImageBoundImportDescriptorEntry", 
126              "TLSDirectory", 
127              "TLSDirectory64", 
128              "ImageBaseRelocationEntry", 
129              "ImageBaseRelocation", 
130              "ImageDebugDirectory", 
131              "ImageDebugDirectories", 
132              "ImageImportDescriptorMetaData", 
133              "ImageImportDescriptorEntry", 
134              "ImageImportDescriptor", 
135              "ImportAddressTableEntry", 
136              "ImportAddressTableEntry64", 
137              "ImportAddressTable", 
138              "ExportTable", 
139              "ExportTableEntry", 
140              "ImageExportTable", 
141              "NETDirectory", 
142              "NetDirectory", 
143              "NetMetaDataHeader", 
144              "NetMetaDataStreamEntry", 
145              "NetMetaDataStreams", 
146              "NetMetaDataTableHeader", 
147              "NetMetaDataTables",  
148             ] 
149   
150  from datadirs import Directory, DataDirectory 
151  from datatypes import String, AlignedString, Array, BYTE, WORD, DWORD, QWORD 
152  from directories import * 
153  from excep import * 
154  from utils import ReadData, WriteData 
155  from pype32 import * 
156   
157  # Library version 
158  version_number = 0.1 
159  version = "Version %s" % version_number 
160