Giter Club home page Giter Club logo

pe-bear's Introduction

PE-bear

PE-bear logo

Build status Codacy Badge License: GPL v2 Last Commit

GitHub release Github All Releases Github Latest Release

PE-bear is a multiplatform reversing tool for PE files. Its objective is to deliver fast and flexible “first view” for malware analysts, stable and capable to handle malformed PE files.

Signatures for PE-bear:

Builds

📦 ⚙️ Download the latest release.

Windows Packaging

Available also via Chocolatey

Available also via Scoop

Test Builds

🧪 Fresh test builds (ahead of the official release) can be downloaded from the AppVeyor build server. They are created on each commit to the main branch. You can download them by clicking on the build version, then choosing the tab Artifacts. WARNING: those builds may be unstable.

An archive of old releases is available here: https://github.com/hasherezade/pe-bear-releases

Available releases

The Linux build requires appropriately Qt_5.14 or Qt_5.15 to be installed.

The Windows build with vs13 suffix(built with Visual Studio 2013) has no external dependencies.

The Windows build with vs19 suffix (built with Visual Studio 2019) requires the redistributable package for Visual Studio 2015 - 2022.

The Windows build with vs10 suffix is built with Qt4 (legacy) - in contrast to the other builds that are with Qt5 (recommended). It is prepared for the purpose of backward compatibility with old versions of Windows (i.e. XP).

How to build

Requires:

  • git
  • cmake
  • Qt5 (optionally Qt4)
  • bearparser (submodule of the current repository)
  • capstone (submodule of the current repository)

Clone

Use recursive clone to get the repo together with submodules:

git clone --recursive https://github.com/hasherezade/pe-bear.git

Building on Windows

Use CMake to generate a Visual Studio project. Open in Visual Studio and build.

Building on Linux and MacOS

To build it on Linux or MacOS you can use the given scripts:

To generate the .app bundle on MacOS you can use:


If you like PE-bear, you can support it:

paypal

pe-bear's People

Contributors

fairycn avatar hasherezade avatar rizwan3d avatar simonsan avatar visuve avatar wesinator avatar xvitaly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pe-bear's Issues

How to inspect sections on object code

I tried to compile my source code into object code, and I'm following this tutorial to read the sections in the object file, but it seems that the object file generated by gcc on the windows platform will end up with the PE format (?)

which makes me unable to parse it: readelf: Error: Not an ELF file - it has the wrong magic bytes at the start

then I tried to install the pe-bear tool instead of readelf but the error not supported filetype seems to be not working properly?

please enlighten me.

cannot see the imported dll whether is existed

I want to analyze a dll's importer dependency, only see it calls which dll,but cannot find whether the dll is existed or not.
Hope add tree view to the imported dll and show a icon whether it is existed in my Windows.
thank you.

it can't be installed on Mac M1

The Mac release doesn't work and when I open it there is a just a blank screen like this :-

Screenshot 2023-02-26 at 12 50 30 AM

and when I try to build it it gives this error :-

Trying to build PE-bear...
QMake version 3.1 Using Qt version 5.15.8 in /opt/homebrew/Cellar/qt@5/5.15.8_2/lib
[+] Qt5 found!
[+] CMake found!
cmake version 3.25.1 CMake suite maintained and supported by Kitware (kitware.com/cmake).
mkdir: build_qt5: File exists
[+] build directory created
CMake Error at CMakeLists.txt:65 (add_subdirectory):
The source directory

/Users/aviralsrivastava/pe-bear/capstone

does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:68 (add_subdirectory):
add_subdirectory given source "bearparser/parser" which is not an existing
directory.

-- capstone_includes='/Users/aviralsrivastava/pe-bear/capstone/include'
-- capstone_lib='$<TARGET_FILE:capstone>'
-- sigfind_dir='/Users/aviralsrivastava/pe-bear/sig_finder'
-- sigfind_lib='$<TARGET_FILE:sig_finder>'
-- parser_dir='/Users/aviralsrivastava/pe-bear/bearparser/parser'
-- parser_lib='$<TARGET_FILE:bearparser>'
-- disasm_dir='/Users/aviralsrivastava/pe-bear/disasm'
-- disasm_lib='/Users/aviralsrivastava/pe-bear/disasm'
-- Configuring incomplete, errors occurred!
See also "/Users/aviralsrivastava/pe-bear/build_qt5/CMakeFiles/CMakeOutput.log".
See also "/Users/aviralsrivastava/pe-bear/build_qt5/CMakeFiles/CMakeError.log".
make: Makefile: No such file or directory
make: *** No rule to make target `Makefile'. Stop.
make: *** No targets specified and no makefile found. Stop.

I tried with build.sh and build_qt5 but it gives same error.

PE-bear is having very hard time with browsing Exceptions info

browsing in Exceptions tab is super slow on big exe (60 MB - it takes seconds to scroll up or down, sometimes GUI even freezes)

BTW, I dont know how many records are in Exception table
could you think about adding count number in the GUI?

thanks

NumberOfRvaAndSizes is ignored when reading data directories

Always reads 16 data directories, even when NumberOfRvaAndSizes is lower (SizeOfOptionalHeader is adjusted accordingly)

From the PE documentation:

Note that the number of directories is not fixed. Before looking for a specific directory, check the NumberOfRvaAndSizes field in the optional header.

Here's a simple executable showing the problem: test.exe (I had to add .txt to upload it here)

This file has two data directories. The rest are being interpreted from the section header, which starts at 0xD8 (notice how Resource Directory also thinks it's located at 0xD8).

image

Thanks for reading - this is a really nice tool!

Feature request - allow files with a non .exe/.DLL in the file name to be opened

Hello,

Often times I need to open PE files with PeBear where the file name does not end in a .exe or .DLL extension, e.g. the file name may just be a file hash/.bin/.virus etc.

Currently trying to open these in PEBear generates an error that it cannot open the file. The file needs to be renamed to have a .exe or .DLL extension in order for it to be opened.

It would be great to have the ability to open PE files where the file extension in the file name need not be .exe/.dll

Shellcode support

Thanks for the amazing tool!
It'll be nice to have support for viewing hex and disassembly of shellcode files.

It'll be also a lot useful if one could set a "parsing point" manually into the shellcode, let's say, if we have a shellcode wich has an embedded PE in it, it'll be nice to set the "parsing pont" of the PE manually on the MZ header to be found manually, then obtain a classic valid PE-bear view of the embedded PE, keeping the unparsed previous shellcode part above, for example under a tag "invalid PE data".

Thanks again for PE-bear!!

ReproChecksum instead of TimeDateStamp

When I load a PE file, in the NT Header -> File Header, in the place where I should see TimeDateStamp, I see "ReproChecksum" in it's place and the value doesn't make sense.

Any idea why? And how to show the actual compilation date?

GuardCFFunctionTable bug

I checked the issue history and found that this bug has been fixed, but it seems that it has not been completely fixed. The length of metadata should be determined according to GuardFlags
image

CMake version warnings

./CMakeLists.txt:

CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

./bearparser/parser/CMakeLists.txt

CMake Deprecation Warning at bearparser/parser/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

./disasm/CMakeLists.txt:

CMake Deprecation Warning at disasm/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

./pe-bear/CMakeLists.txt:

CMake Deprecation Warning at pe-bear/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

./sig_finder/CMakeLists.txt:

CMake Deprecation Warning at sig_finder/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

Please set the correct minimal CMake versions in all CMakeLists.txt files.

Make large tables sortable

Hi, and first of all thank you for this awesome tool! I switched over from CFF Explorer with the release of PE-bear 0.5.0 and I'm not looking back. :)

I'd just like to suggest a minor GUI enhancement: make some tables sortable, particularly the GuardCFFunctionTable and Exported Functions tables. These tables may contain upwards of 2k entries for e.g. ntdll.dll, and are presented in Offset order.
It would make looking things up inside those tables that much easier if they could be sorted by any of their other columns.

Cannot view imports/exports of nt 3.1 executables/dlls

Opening nt 3.1 pe32 files results in the following warning,
image
And the import/export tabs are missing.
This happens with all the nt 3.1 executables and dlls in the SYSTEM32 folder (that I've tested), including NOTEPAD.EXE.
These executables are able to be ran on the latest version of Windows (they are the same executable type) and the imports/exports appear in programs like ida.
image
PE-bear version: v0.6.7.3

Borland IMAGE_RESOURCE_DIRECTORY TimeDateStamp incorrectly decoded

The IMAGE_RESOURCE_DIRECTORY TimeDateStamp of a Borland C++ compiled DLL is not decoded as MS DOS Timedatestamp. The IMAGE_FILE_HEADER TimeDateStamp is decoded correctly, 0x42db5dac (2005/07/18 07:43:40), but the IMAGE_RESOURCE_DIRECTORY TimeDateStamp value 0x32f26d74 is decoded as 1997/01/31 22:08:52 instead of 2005/07/18 13:43:40.
As far as I know Visual Studio never sets the IMAGE_RESOURCE_DIRECTORY TimeDateStamp so I suggest either always decode that value as MS DOS Timestamp or show both decodings, Epoch and MS DOS.
File: unrar.dll (SHA1: 1195ee4a5e1c19daf13ded219ba874e903f49a48)
https://www.virustotal.com/gui/file/f0055ca904b9641f889c81ca72a485c92305363dfef12edc569cf2ca0e4bb0d0/details

Does not parse Debug directory as array of debug entries

pe bear seems to interpret the debug directory as a single entry, when in reality its a array who's size is determined by the size in the optional header debug data directory
this is part of the spec as mentioned here https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#debug-directory-image-only\
> Image files contain an optional debug directory that indicates what form of debug information is present and where it is. This directory consists of an array of debug directory entries whose location and size are indicated in the image optional header.

image
the blue bytes represent the codeview directory which is usually the first and is parsed, the binary from the example has 2 additional entries it misses here marked red.

this is rather not critical but just a small oversight, would be nice as an enhancement tho

CMake Error at CMakeLists.txt:65 (add_subdirectory):

I am trying to download this great tool but I got this error, how I can solve it?
CMake Error at CMakeLists.txt:65 (add_subdirectory):
The source directory

/home/kawkab/pe-bear/capstone

does not contain a CMakeLists.txt file.

CMake Error at CMakeLists.txt:68 (add_subdirectory):
add_subdirectory given source "bearparser/parser" which is not an existing
directory.

Error in signatures detection

Example (from unpacking by Athracene):

Both files have been packed with UPX.

comparison

Signature that should match:

UPX_old
48
60 BE 00 ?? ?? ?? 8D BE 00 ?? ?? FF 57 83 CD FF
EB 10 90 90 90 90 90 90 8A 06 46 88 07 47 01 DB
75 07 8B 1E 83 EE FC 11 DB 72 ED B8 01 00 00 00

If this is the only signature loaded, both are detected properly. But in case if there are other signatures, only one is detected.

The reason is, there is another signature that overshadows the matching one.

overshadowed

Once the character that is not a wildcard is matched (here at position 3: 60 BE 00 _A0_), the signature with the wildcard is completely dropped.
This is an invalid behavior, and the signature with the wildcards should be still kept for the comparisons.

Windows Compilation Feedback

Encountered some errors while compiling, documenting the solution

Visual studio 2013

QT

qt-opensource-windows-x86-msvc2013-5.8.0

Cmake:

  • qt-opensource-windows-x86-msvc2013-5.8.0
    image

Qt5Core_DIR C:\Qt\Qt5.8.0\5.8\msvc2013\lib\cmake\Qt5Core
Qt5Widgets_DIR C:\Qt\Qt5.8.0\5.8\msvc2013\lib\cmake\Qt5Widgets
Qt5Gui_DIR C:/Qt/Qt5.8.0/5.8/msvc2013/lib/cmake/Qt5Gui

ALL build Debug version
image

Visual studio 2022

qt-opensource-windows-x86-5.12.12
image

Note: msvc2017_64 msvc version information = Cmake Optional
image

There are no errors.
image

Error in Checksum calculation

reported by Matthew (x86matthew):

The issue relates to the checksum field within the NT Optional Header. I have recently been generating some custom binaries and noticed that PE-Bear was reporting the checksum being incorrect (highlighted in red). Microsoft's MapFileAndCheckSum function confirmed that my original checksum was correct, so I did some investigating.

My results showed that PE-Bear was validating the checksum incorrectly when the total file size was not a multiple of 2. I have uploaded a simple set of minimal PE files to reproduce the issue at the following URL:

http://www.x86matthew.com/other/PeBearChecksum.zip

Checksum_0_Byte_Overlay.exe -> Basic PE file with 1024 total bytes, PE-Bear validates checksum correctly (0xAB91)

Checksum_1_Byte_Overlay.exe -> Basic PE file with 1025 total bytes, PE-Bear says checksum is invalid despite being correct (correct checksum: 0xAC0A)

Checksum_2_Byte_Overlay.exe -> Basic PE file with 1026 total bytes, PE-Bear validates checksum correctly (0x240C)

I believe the problem originates within the following function:

https://github.com/hasherezade/bearparser/blob/c059bcb25c6e9137cd1a4f1a97ae53f1a0a250b8/parser/pe/PEFile.cpp#L50

The code appears to be dividing the file size by 2 and discarding the additional byte if it exists. Of course, PE file sizes are usually multiples of 2 already so this will rarely be an issue in the real world.

Section data view disregards FileAlignment

When displaying section data, PE-Bear uses IMAGE_SECTION_HEADER.PointerToRawData to find the section data in the file. In reality, when Windows loads the file, if the section file offset is not aligned to IMAGE_OPTIONAL_HEADER.FileAlignment, it will be rounded up to the next aligned address and loaded there. A malicious binary can use this inconsistency to display incorrect section data.

Btw, CFF Explorer falls for this too. IDA Pro displays a warning that it has detected a section that is not aligned and refuses to handle the section header.

Screenshot demonstrating the difference in section contents between section data in PE-Bear and what is actually loaded in memory (x64dbg):
Screenshot 2022-10-22 024856

EXE for reproduction: packed.zip

Update readme with build steps

Hey
Many thanks for opensourcing your great stuff!
Would like to ask about putting some minimalistic steps for the community regarding how to build the tool on different OSes like

  • Windows
  • Linux
  • Mac

and what are the prerequsites (if any), etc

Thank you in advance

Interface multilingual support function.

Hello!
At present, the software only supports English interface. Can you use the language pack to customize the interface language of the program? If this is considered, I can provide help in simplified Chinese translation.

Can you show this error to the user in another way?

I'm trying to edit any value, I know it's wrong, but I'm having trouble editing the value because of this error. If you show this error to the user in a different way, showing a messagebox in this way restricts the action the user is trying to do.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.