Commit Graph

74 Commits

Author SHA1 Message Date
Romain Thomas 969411f8ef Welcome 2023 2023-01-03 10:38:09 +01:00
Romain Thomas 2a10494b8a Enhance the Python IO interface
Related to #832
2022-12-09 10:22:53 +01:00
Romain Thomas 81fd78e81e Use the span/bytes interface (#833) 2022-12-07 08:22:25 +01:00
Romain Thomas 85ce881011 Process #833 2022-12-07 08:22:25 +01:00
Wilson Martin 7e624c997a Bugfix for ImportEntry to accept PE_TYPE
In the Python bindings, a new instance of ImportEntry
has it's type hard-coded to PE_TYPE::PE32, with no
way to change the type once created.

This prevents adding new ordinal imports to PE32+,
aka 64-bit, binaries.

The fix is to allow ImportEntry to also accept PE_TYPE.
In addition, the unittest also documents how to add an ordinal
using LIEF.

* Update ImportEntry to accept PE_TYPE
* Update python bindings for ImportEntry
* Add unittest for ImportEntry and ordinals
2022-10-12 14:38:56 -04:00
ζeh Matt 6085bbc949 Use explicit function signature for python bindings on write function 2022-07-22 06:36:35 +02:00
David Sanders 06d492b8f6 Fix ordering of resource node childs in PE 2022-06-17 05:07:57 +00:00
Romain Thomas baa023b914 Remove exceptions 2022-04-01 05:38:30 +02:00
Romain Thomas 946b66550c Fix Python life time issue
Resolve #688
2022-03-31 07:15:46 +02:00
Romain Thomas b421535b8e Re-compute the OptionalHeader's checksum
Resolve #660
2022-03-07 07:44:28 +01:00
Romain Thomas 7f878f40ee Enable to re-compute the PE rich header
Resolve #587
2022-03-05 21:29:53 +01:00
Romain Thomas 9511d9fccf Update doc according to #675 2022-03-05 10:19:12 +01:00
Romain Thomas ba54ea632b Add support for PE delayed imports
Resolve #664
2022-03-01 06:18:44 +01:00
Romain Thomas 8fcff6e8e3 Proprify PE resources handling 2022-02-16 05:32:25 +01:00
Romain Thomas 274d887e17 Update PE parser interface 2022-02-14 06:40:06 +01:00
Romain Thomas 05e3c6eb7c Fix memory issues 2022-02-12 17:10:23 +01:00
Romain Thomas 77328b0071 Bump year 2022-02-08 21:16:25 +01:00
Romain Thomas e9782c5927 Clean & modernize LIEF code base
This commit (obviously non-atomic) cleans LIEF's code base by:
  - Using pointer semantics (`std::unique_ptr<>`)
  - Using LEAF boost error in the binary stream
  - Reducing the scope of the iterators (`it_section`, ...)
  - Removing `Structures.hpp` from the public headers
  - etc
2022-02-05 06:09:06 +01:00
rthomas a615adbee4 This commit cleans and modernizes the code base of LIEF.
Among the changes:

- It removes the ``and, or, not`` keywords
- It updates the Documentation
- It moves the internal structures in the ``details::`` namespace
2022-01-27 20:18:54 +01:00
Romain Thomas b2fc5ba9be Update fields in PE::LoadConfiguration
It seems that on recent version on the SDK, Microsoft renamed the
field LoadConfiguration::reserved1 into DependentLoadFlags.

This commit create an alias on this field

Resolve #621
2021-10-19 05:27:33 +02:00
Romain Thomas ddf5f4b82d Add PE imports/exports as abstracted symbols 2021-06-06 08:18:27 +02:00
Romain Thomas d0c30970eb Resolve #551 2021-02-24 07:00:17 +01:00
Romain Thomas bb7a898eee Improve the way we access the list of flags 2021-01-31 16:00:41 +01:00
Romain Thomas e453b535a3 Add more information than just BAD_SIGNATURE 2021-01-30 21:34:29 +01:00
Romain Thomas 6720ed2385 Update copyright 2021-01-16 18:17:17 +01:00
Romain Thomas d29a74996b Process PKCS #9 counter signature and enhance signature verification 2021-01-16 09:44:51 +01:00
Romain Thomas bdf1264df9 Update doc & tests 2021-01-16 09:44:51 +01:00
Romain Thomas 53ce0cd7d4 Fix Windows issues 2021-01-16 09:44:51 +01:00
rthomas 634c2fc98e Enhance PE Authenticode 2021-01-16 09:44:51 +01:00
Romain Thomas c365a533bc Update links 2020-12-20 14:19:04 +01:00
rthomas 44e072da15 Handle python utf-16 conversion in LangCodeItem values 2020-11-17 18:18:48 +01:00
rthomas 9f1bebb0ff Fix UTF8 (by @tacesrever) 2020-08-25 11:20:16 +02:00
Koh M. Nakagawa 1fd42b4ebf Add parser for resource accelerator
Signed-off-by: Koh M. Nakagawa <tsunekou1019@gmail.com>
2020-08-24 07:15:04 +02:00
Koh M. Nakagawa eb87ca6ef6 fix to parse html resource
Signed-off-by: Koh M. Nakagawa <tsunekou1019@gmail.com>
2020-07-06 22:01:47 +09:00
Koh M. Nakagawa 96e6fc66ad fix ResourcesManager to parse string table entry
Signed-off-by: Koh M. Nakagawa <tsunekou1019@gmail.com>
2020-06-26 01:18:58 +09:00
Romain Thomas eeddc38393 Handle PE forwarded exports
Resolve: #307
2019-12-10 06:33:48 +01:00
Andrew 08d31be932 Authenticode-related bug fixes and improvements
Part of Authenticode verification consists of:
 - Comparing the computed Authenticode hash to the digest
   stored in the ContentInfo section
 - Comparing hash(ContentInfo) to the digest stored in the
   AuthenticatedAttributes section
 - Verifying signed(hash(AuthenticatedAttributes)) using a
   certificate identified by the issuer and serial number
   specified in the SignerInfo section

This commit makes it so that the raw bytes needed to
calculate hash(ContentInfo) and hash(AuthenticatedAttributes)
are available for use.

============================================================

Allow missing [0] in SpcSpOpusInfo

Some executables have MoreInfo but not a ProgramName (and the documentation
lists both as OPTIONAL), so handle this case correctly.

Example:

```
01416b1730218454c99b13592650cb170402b86742b4bab971565903b841829b

SEQUENCE(2 elem)
OBJECT IDENTIFIER1.3.6.1.4.1.311.2.1.12spcSpOpusInfo(Microsoft code signing)
SET(1 elem)
  SEQUENCE(1 elem)
  [1](1 elem)
   [0]http://www.mozilla.com
```

============================================================

Improve consistency of parsed serial numbers

When parsing the issuer serial number, call mbedtls_x509_get_serial instead of
parsing it as an integer directly with mbedtls_asn1_get_mpi. These two functions
differ in how they treat serial numbers prepended with '00' to prevent them from
being negative (the former preserves the '00', and the latter discards it). The
embedded certs are parsed via a call to mbedtls_x509_crt_parse_der, which uses
mbedtls_x509_get_serial behind the scenes, so there was an inconsistency between
lief_obj.signature.signer_info.issuer[1] and
lief_obj.signature.certificates[x].serial_number.  Example:

8bf57d97dd917c4f823659266caaa33e7398406daf11ba8318e3f7414ee3fb24

============================================================

Handle SpcLink and SpcString CHOICEs in SpcSpOpusInfo

The Authenticode spec doc says that these can be CHOICES, so
handle the easy ones and safely skip the others.

============================================================

Allow Authenticode sig to be parsed even if cert parsing fails

By default, mbedtls doesn't support MD2 certs, which are fairly
common in older signed executables.  Ex:

1cb16f94cebdcad7dd05c8537375a6ff6379fcdb08528fc83889f26efaa84e2a

============================================================

Enable mbed TLS MD2 and MD4 support; add Unix debug options

By default, mbedtls doesn't support MD2 certs, which are fairly
common in older signed executables.  Ex:

1cb16f94cebdcad7dd05c8537375a6ff6379fcdb08528fc83889f26efaa84e2a

============================================================

Set MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION flag

Some older signed executables use certs with the SpcSpAgencyInfo
Critical Extension, which mbed TLS doesn't support, so set
MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION to have it
skip this extension.  Example:

781ca31416ec708a587851dafd90c661b86f244ab8b8475c4185e958e54ff838

============================================================

Support accessing non-utf8 issuer names via Python

For a few signatures where the issuer name contained non-utf8
characters, accessing the issuer name field in Python would raise
a UnicodeDecodeError exception. Now this field is handled the
same way the names in the individual certs are (I'm not sure if
they get represented 100% correctly, but at least they are
consistent, which is good enough for me). Example:

048f91b9302c88380fc66adac1e314d82733089ef3a31eadca5f0cb4169b195f
2019-10-07 00:58:40 -04:00
Andrew Williams fcb9c76be6 Expose the raw bytes backing each PE Authenticode cert (#320) 2019-07-26 19:26:13 +02:00
Romain Thomas 90867193b5 Fix #271 2019-03-10 17:49:21 +01:00
1orenz0 3537440b8d Add support to parse POGO debug entries 2018-12-16 16:34:12 +01:00
1orenz0 fcc75dd879 Parse PE debug data directory as a list of debug entries
PE's DATA_DIRECTORY_DEBUG does not define a single debug entry, but
a list of struct pe_debug entries (the number of entries is determined
by the data directory's size).

This commit reflect this layout by returning a vector<> when calling
PE.debug()
2018-11-29 09:16:34 +01:00
Romain Thomas b5a08463ad Expose API to list functions found in a binary 2018-09-12 14:44:18 +02:00
Romain Thomas 04dddd3710 Fix alignment issue when removing a PE section 2018-08-10 15:16:29 +02:00
Romain Thomas 918438c6be Enable to remove sections using the abstract layer 2018-07-09 15:08:39 +02:00
Romain Thomas 33a2af4b18 Enhance Python binding 2018-06-08 14:58:00 +02:00
Romain Thomas cd1cc457cf Resolve #119 and enhance ELF Python bindings 2018-06-08 10:48:33 +02:00
Romain Thomas 4ef1bb845f Add new formats: OAT, DEX, VDEX, ART 2018-05-04 12:46:28 +02:00
Romain Thomas 4ef839c3d8 Enhance BinaryStream Interface 2018-04-15 08:55:23 +02:00
Romain Thomas 46fa0e9747 Fix #139
API added:
  * PE::ResourceDialog::lang
  * PE::ResourceDialog::sub_lang
2018-03-18 18:16:19 +01:00
Romain Thomas 3b17aba10e Refactor some parts of the Architecture:
* JSON visitor are located in the format namespace
  * Visitor are *real* visitor
  * Visitable class has been renamed to Object
  * Due to a bug in Visual Studio 2015, we move to VS2017
2018-03-13 16:49:02 +01:00