pefile | Python module to read and work with PE ( Portable Executable | Dataset library

 by   erocarrera Python Version: 2023.2.7 License: MIT

kandi X-RAY | pefile Summary

kandi X-RAY | pefile Summary

pefile is a Python library typically used in Artificial Intelligence, Dataset applications. pefile has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. However pefile has 3 bugs. You can install using 'pip install pefile' or download it from GitHub, PyPI.

pefile is a multi-platform Python module to parse and work with Portable Executable (PE) files. Most of the information contained in the PE file headers is accessible, as well as all the sections' details and data. The structures defined in the Windows header files will be accessible as attributes in the PE instance. The naming of fields/attributes will try to adhere to the naming scheme in those headers. Only shortcuts added for convenience will depart from that convention. pefile requires some basic understanding of the layout of a PE file — with it, it's possible to explore nearly every single feature of the PE file format.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              pefile has a medium active ecosystem.
              It has 1637 star(s) with 512 fork(s). There are 76 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 66 open issues and 160 have been closed. On average issues are closed in 103 days. There are 10 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of pefile is 2023.2.7

            kandi-Quality Quality

              pefile has 3 bugs (0 blocker, 0 critical, 2 major, 1 minor) and 177 code smells.

            kandi-Security Security

              pefile has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              pefile code analysis shows 0 unresolved vulnerabilities.
              There are 19 security hotspots that need review.

            kandi-License License

              pefile is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              pefile releases are available to install and integrate.
              Deployable package is available in PyPI.
              Build file is available. You can build the component from source.
              Installation instructions are available. Examples and code snippets are not available.
              pefile saves you 2150 person hours of effort in developing the same functionality from scratch.
              It has 4711 lines of code, 189 functions and 8 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed pefile and discovered the below as its top functions. This is intended to give you an instant insight into pefile implemented functionality, and help decide if they suit your requirements.
            • Dump information about this image
            • Add text to the text
            • Add a line of text
            • Add a list of lines
            • Parse the export directory
            • Return the data at the given RVA
            • Unpack data
            • Unpack a PE file
            • Check if the file is packed
            • Parse a TLS directory Tls
            • Return the first matching match
            • Parse a directory load configuration
            • Check if the image is an exe
            • Merge modified section data
            • Return the name for the given ordinal
            • Read attribute from file
            • Generate signatures for a section
            • Parse an import directory
            • Parse debug directory
            • Parse a directory bound imports
            • Parse the Delay import directory
            • Match code data
            • Parse exceptions directory
            • Set the bitfield format
            • Parse relocation directory
            • Check if the given section of the file is suspicious
            Get all kandi verified functions for this library.

            pefile Key Features

            No Key Features are available at this moment for pefile.

            pefile Examples and Code Snippets

            Usage
            Pythondot img1Lines of Code : 21dot img1License : Permissive (MIT)
            copy iconCopy
            $ python ta505_unpacker.py -h
            ▄▄▄█████▓▄▄▄       █████▒█████   █████▒    █    ██ ███▄    █ ██▓███  ▄████▄  ██ ▄█▀██▀███
            ▓  ██▒ ▓▒████▄   ▓██   ▒██▒  ██▓██   ▒     ██  ▓██▒██ ▀█   █▓██░  ██▒██▀ ▀█  ██▄█▒▓██ ▒ ██▒
            ▒ ▓██░ ▒▒██  ▀█▄ ▒████ ▒██░  ██▒████ ░  
            pefile,Usage
            Pythondot img2Lines of Code : 21dot img2License : Permissive (MIT)
            copy iconCopy
            	pefile, err := pe.NewPEFile(args[0])
            	if err != nil {
            		log.Println("Ooopss looks like there was a problem")
            		log.Println(err)
            		return
            	}
            
            	log.Println("Imphash : ", pefile.GetImpHash())
            
            	for _, section := range pefile.Sections {
            		fmt.Println("-  
            dll-exports
            C++dot img3Lines of Code : 17dot img3no licencesLicense : No License
            copy iconCopy
            #pragma comment(linker, "/export:GetFileVersionInfoA=\"C:\\Windows\\System32\\version.GetFileVersionInfoA\"")
            #pragma comment(linker, "/export:GetFileVersionInfoByHandle=\"C:\\Windows\\System32\\version.GetFileVersionInfoByHandle\"")
            #pragma comment(  
            Pyinstaller: QWebEngineView doesn't play nicely with other modules
            Pythondot img4Lines of Code : 2dot img4License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            pip list
            
            Can't upgrade pip on Elastic Beanstalk
            Pythondot img5Lines of Code : 13dot img5License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            files:
              "/opt/elasticbeanstalk/hooks/appdeploy/pre/02a_upgrade_pip.sh":
                mode: "000755"
                owner: root
                group: root
                content: |
                  #!/usr/bin/env bash
                  source /opt/python/run/venv/bin/activate
                  python3 -m pip instal
            capstone disassembler python returns same instructions on every offset
            Pythondot img6Lines of Code : 24dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import pefile
            from capstone import *
            
            exe_file = 'C:\\Users\\Philip\\file.exe'
            pe = pefile.PE(exe_file)
            
            # find text section
            offset = False
            for section in pe.sections:
                if section.Name == b'.text\x00\x00\x00':
                    offset = section.V
            ModuleNotFoundError: No module named 'flake8'
            Pythondot img7Lines of Code : 26dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            # This alows for packages to be accessed from the **globally** installed Python (NOT the tox env). 
            sitepackages = True
            # This alows for commands to be used available outside tox. Typically used for non-python callables. 
            whitelist_externa
            How to solve error when installing auto-py-to-exe?
            Pythondot img8Lines of Code : 3dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio":
            https://visualstudio.microsoft.com/downloads/
            
            copy iconCopy
            cd dist/cefapp/cefpython3
            ln -s ../* .
            
            copy iconCopy
            pip install -r requirement.txt
            
            #requirement.txt
            
            numpy==1.18.4
            openpyxl==3.0.3
            pandas==1.0.3
            pefile==2019.4.18
            PyInstaller==3.6
            pylint==2.5.3
            

            Community Discussions

            QUESTION

            import "Sympy" couldn't be resolved
            Asked 2021-May-22 at 12:55

            Line:3 Import "sympy" couldn't be resolved

            I have installed sympy using pip in my virtual environment. Why am I getting this error? When I run this code I am am getting the following error:

            ...

            ANSWER

            Answered 2021-May-22 at 12:44

            The first step is to check whether you are running the code in the virtual environment, to verify that refer the below image

            If you are not in a virtual environment that you have created just click that red box that I have marked in that pic and select the respective virtual environment Interpreter (python.exe).

            Source https://stackoverflow.com/questions/67649261

            QUESTION

            Can't upgrade pip on Elastic Beanstalk
            Asked 2021-May-18 at 18:55

            I've been having this problem for a couple of days now, I'm trying to deploy a django app in Elastic Beanstalk but every time I try to do it this particular error shows up:

            ...

            ANSWER

            Answered 2021-May-18 at 18:55

            UPDATE:

            adding a file to my .ebextensions directory with this command fixed my issue:

            Source https://stackoverflow.com/questions/67561759

            QUESTION

            capstone disassembler python returns same instructions on every offset
            Asked 2021-Feb-10 at 16:19

            I am trying to disassambe a PE file using capstone with python bindings.

            ...

            ANSWER

            Answered 2021-Feb-10 at 16:19

            Disasm will disassemble from start of code. You should pass raw data corresponding to code section, not the beginning of PE file, where PE headers reside:

            Source https://stackoverflow.com/questions/66138668

            QUESTION

            creating / deleting sections using the PeNet library
            Asked 2021-Feb-09 at 15:41

            I am using the PeNet nuget package to work with a pe file, there was a problem when creating or deleting a section, I take the code from the author's example, but nothing works. (No errors appear, but no files are written/overwritten.)

            Using a C # console application, here's the code:

            ...

            ANSWER

            Answered 2021-Feb-09 at 15:21

            From this GitHub issue about a similar topic:

            PeNet works internally by loading the whole PE file into a buffer. All changes you make are done to this buffer in memory. If you want to save your changes, you just have to save the buffer.

            Unfortunately, the code offered there is incorrect. PEFile has no Buff property. So use:

            Source https://stackoverflow.com/questions/66119541

            QUESTION

            windows - how to link against API sets (*ms-win*) instead kernel32.dll, ntdll.dll etc.?
            Asked 2021-Jan-11 at 08:51

            How do I specify explicitly to MSVC compiler / linker to link against API sets (*ms-win* pattern matcing dlls) instead kernel32.dll, ntdll.dll etc.?

            For example, I've created a simple dll, which just calls a few basic WinAPIs. When examining it's IAT (via CFF Explorer, python pefile library etc.) there's only kernel32.dll. What I'd like to happen, is to see *ms-win* dlls instead.

            ...

            ANSWER

            Answered 2021-Jan-11 at 08:51

            API sets are used internally even with the 'legacy' system DLLs on Windows 8/Windows 10, so there's no reason you need to use them directly.

            That said, there are a number of 'umbrella' libraries you can use instead of linking against classic KERNEL32.DLL, etc.:

            • onecore.lib
            • onecoreuap.lib
            • onecore_apiset.lib

            Keep in mind that these are intended to match the same Windows build as the Windows 10 SDK they ship in (i.e. they are forward compatible, not backward). There are *_downlevel.lib versions as well which support older builds of Windows. These are all mostly intended for consumption by driver developers per Microsoft Docs

            UWP apps use their own umbrella library WindowsApps.lib / WindowsApps_downlevel.lib.

            See Microsoft Docs for more on umbrella libraries.

            Not that you should not link with more than one umbrella library, and you shouldn't mix kernel32.lib with umbrella libraries in the same link.

            Source https://stackoverflow.com/questions/65662707

            QUESTION

            ModuleNotFoundError: No module named 'flake8'
            Asked 2020-Dec-15 at 20:12

            here is the part of the files that are important for this question:

            ...

            ANSWER

            Answered 2020-Jul-21 at 20:31

            My compliments on such an extensive report. Your issue lies probably in this weird setup you've got going on.

            Source https://stackoverflow.com/questions/62667763

            QUESTION

            How to solve error when installing auto-py-to-exe?
            Asked 2020-Oct-22 at 13:47

            I am trying to pip install auto-py-to-exe, but got following error.

            ...

            ANSWER

            Answered 2020-Oct-22 at 10:58

            Try to install Microsoft Visual C++ 14.0.

            Source https://stackoverflow.com/questions/64480598

            QUESTION

            failed to create executable with pyinstaller and cefpython on Linux (Invalid file descriptor to ICU data)
            Asked 2020-Oct-15 at 09:58

            I have some simple cefpython code opening a url and am trying to create a stand alone executable with pyinstaller:

            I copied files from https://github.com/cztomczak/cefpython/tree/master/examples/pyinstaller to a a directry named pyinstaller

            I made following minor changes to pyinstaller.spec

            ...

            ANSWER

            Answered 2020-Oct-14 at 11:32

            This is not really the answer I would like to accept, but it is at least one solution and contains information, that might lead to a better fix, a better answer.

            After debugging with strace I found out, that the executable searches many files like for example icudtl.dat, v8_context_snapshot.bin, locales/* were searched in 'dist/cefapp/cefpython3but were copied todist/cefapp/`

            An ugly work around is to do following after compilation

            Source https://stackoverflow.com/questions/64339096

            QUESTION

            push rejected Heroku Python Flask requirements failing exiv2==0.3.1
            Asked 2020-Aug-23 at 20:03

            I am attempting to push my flask app to heroku for hosting. All was going well until the PUSH to heroku. I am receiving an error during remote:Building source: and the requirement for exiv2==0.3.1 cannot be satisfied. exiv2==0.3.1 I understand that the requirements section is usually where errors occur, based on the reading I've been doing. However, I am unsure how to proceed besides removing the exiv2 reliant code and losing some functionality...???

            requirements.txt

            ...

            ANSWER

            Answered 2020-Aug-23 at 20:03

            exiv2 only works on Windows while Heroku runs Linux.

            You need to replace it completely. Try exif.

            Source https://stackoverflow.com/questions/63551343

            QUESTION

            ibm_db, pyinstaller, DLL issue
            Asked 2020-Jul-24 at 13:02

            My Question Is:
            I am trying to package a simple code which is mentioned below that has import ibm_db, but I am not able to do it, as it is giving me the below-mentioned error. I have researched a lot on SO and other websites, but most of the solutions that I have encountered say to add the DLL's using --add-binary, I have tried that as well, but still, I am getting the below-mentioned error.
            I am using a Windows 10 64-Bit OS, x64-based processor.
            I am using a virtual environment created using python -m venv env
            The packages mentioned below are installed in my virtual environment.
            I hope all these details are enough and qualify as a question.

            -- PYTHON VERSION --
            Python 3.7.8

            -- PYTHON PACKAGES INSTALLED --
            altgraph 0.17
            future 0.18.2
            ibm-db 3.0.2
            pefile 2019.4.18
            pip 20.1.1
            PyInstaller 3.6
            pywin32-ctypes 0.2.0
            setuptools 47.1.0

            -- MY CODE --

            ...

            ANSWER

            Answered 2020-Jul-24 at 12:51

            Your question does not mention whether the build hostname is the same as the run hostname.

            This answer assumes you are running the built executable (output of pyinstaller) on an Microsoft-Windows hostname different from the build hostname.

            If you are using the IBM supplied clidriver (which is the default for python ibm_db) , and if this is not already installed on the target environment, and if an alternative IBM supplied Db2 CLI driver is also not preinstalled on the target environment then you must bundle clidriver with your pyinstaller output at build time.

            You can include the clidriver tree contents with the following additional argument to pyinstaller:

            --add-data="c:\path\to\clidriver;.\clidriver" ^

            You can find the path to the clidriver with pip show ibm_db and append clidriver to the Location: name.

            If you do bundle like this, there are some considerations:

            • your bundle is "frozen in time". When IBM updates its clidriver then your previously built executables won't benefit from the security fixes ,defect fixes and enhancements until and unless you re-run pystaller to include the latest clidriver, and redistribute. IBM typically updates this clidriver at least twice per year. This is particularly important if you are using encrypted connections (TLS/SSL).

            • your bundle size will increase in size due to the inclusion of clidriver within it.

            • on the target Microsoft-Windows environment, after you unzip your dist\$name , you may need to run the clidriver\bin\db2cli install -setup to register the component with Microsoft Windows. This allows the odbcad32 to be aware of the driver and allow some configuration functionality via the odbcad32 GUI.

            • Any dependencies of clidriver must also be met on each target hostname.

            Source https://stackoverflow.com/questions/63061992

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install pefile

            To install pefile through pip:.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install pefile

          • CLONE
          • HTTPS

            https://github.com/erocarrera/pefile.git

          • CLI

            gh repo clone erocarrera/pefile

          • sshUrl

            git@github.com:erocarrera/pefile.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link