82 Commits

Author SHA1 Message Date
Aorimn c67157c6d5 Merge pull request #333 from robert-scheck/multibyte-passwords
Support for multibyte characters in passwords (fixes #323, #113)
2025-09-07 20:28:27 +02:00
Azamat H. Hackimov e749eade55 Use MbedTLS 3, remove support for outdated versions
PolarSSL no longer supported and should not be used as dependency. MbedTLS 2 reached EOL, upstream recommends to use MbedTLS 3 branch.

After dropping outdated versions, configuration of dislocker is greatly simplified.
2025-05-29 14:55:45 +03:00
Robert Scheck 817116a77c Support for multibyte characters in passwords (fixes #323, #113)
Using iconv() to convert the password from the local character set to UTF-16LE used by BitLocker.

Ported https://github.com/Aorimn/dislocker/pull/118 from develop (merged) to the master branch.

Co-authored-by: José Luis González García <jose-luis.gonzalez-garcia@gwdg.de>
2025-01-05 22:34:35 +01:00
Julio C. Rocha 2cfbba2c8c Support mbedtls 3 2023-09-13 19:07:27 -07:00
Aorimn a6d77dc3ea Revert "fix: Make compatible with macOS 12 Monterey & mbedtls 3" 2023-04-20 12:29:01 +02:00
Aorimn 62c185c2a2 Merge pull request #280 from jamfor352/master
fix: Make compatible with macOS 12 Monterey & mbedtls 3
2023-04-09 10:29:06 +02:00
Gabriel Kihlman 95e2483dfe Avoid indexing out of bounds of value_type_str and value_types_prop
They have 20 entries, not 22.

Found when trying to mount an image and getting a segfault:

$ sudo losetup -P /dev/loop100 /user/src_image.img.ntfs_aes_xts.bitlocker
$ sudo ./src/dislocker-fuse -v -V /dev/loop100p1 -upassword -- /mnt
/user/kode/dislocker/src/metadata/datums.c:288:5: runtime error: index 21 out of bounds for type 'const char *[20]'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /user/kode/dislocker/src/metadata/datums.c:288:5 in
=================================================================
==147051==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7fa609c9d4e8 at pc 0x7fa609c5c1fd bp 0x7ffc711f22e0 sp 0x7ffc711f22d8
READ of size 8 at 0x7fa609c9d4e8 thread T0
    #0 0x7fa609c5c1fc in print_header /user/kode/dislocker/src/metadata/datums.c:288:5
    #1 0x7fa609c5b92e in print_one_datum /user/kode/dislocker/src/metadata/datums.c:260:2
    #2 0x7fa609c5d4c1 in print_datum_vmk /user/kode/dislocker/src/metadata/datums.c:447:3
    #3 0x7fa609c5b993 in print_one_datum /user/kode/dislocker/src/metadata/datums.c:265:3
    #4 0x7fa609c6e20c in print_data /user/kode/dislocker/src/metadata/print_metadata.c:247:3
    #5 0x7fa609c60eaf in dis_metadata_initialize /user/kode/dislocker/src/metadata/metadata.c:265:2
    #6 0x7fa609c4fa30 in dis_initialize /user/kode/dislocker/src/dislocker.c:188:8
    #7 0x55e435d92d6e in main /user/kode/dislocker/src/dislocker-fuse.c:222:5
    #8 0x7fa60986d54f in __libc_start_call_main (/lib64/libc.so.6+0x2954f) (BuildId: ad65a880a208f9831f1031675a3ef1792e67c2fc)
    #9 0x7fa60986d608 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x29608) (BuildId: ad65a880a208f9831f1031675a3ef1792e67c2fc)
    #10 0x55e435c9d424 in _start (/user/kode/dislocker/src/dislocker-fuse+0x1f424) (BuildId: 46d2c626e01bf3feeb7f40039b1af5bf2ed51062)

0x7fa609c9d4e8 is located 8 bytes to the right of global variable 'value_type_str' defined in '/user/kode/dislocker/src/metadata/datums.c:34:20' (0x7fa609c9d440) of size 160
SUMMARY: AddressSanitizer: global-buffer-overflow /user/kode/dislocker/src/metadata/datums.c:288:5 in print_header
Shadow bytes around the buggy address:
  0x0ff54138ba40: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x0ff54138ba50: f9 f9 f9 f9 f9 f9 00 00 00 00 f9 f9 f9 f9 f9 f9
  0x0ff54138ba60: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 f9
  0x0ff54138ba70: f9 f9 f9 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00
  0x0ff54138ba80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0ff54138ba90: 00 00 00 00 00 00 00 00 00 00 00 00 f9[f9]f9 f9
  0x0ff54138baa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ff54138bab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ff54138bac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ff54138bad0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ff54138bae0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==147051==ABORTING
2022-06-21 21:32:01 +02:00
jamfor352 f000aa1612 fix: Various patches to be compatible with the latest versions of the library (dislocker is tested and working on Monterey with this patch) 2022-04-30 18:29:28 +01:00
Aorimn 2185496308 Merge pull request #268 from haobinnan/master
Fixed an error that "virtualization datum's" struct did not align by …
2021-12-07 12:02:17 +01:00
haobinnan 515b6d91fa Fixed an error that "virtualization datum's" struct did not align by bytes.
Fixed an error that relates to the support of BitLocker created by Windows Vista.
2021-12-01 16:29:01 +08:00
a1346054 5232009fad trim excess whitespace 2021-09-12 20:34:12 +00:00
jichan c3d4dbcba4 Make mountable of the decrypted volume 2021-04-13 14:13:08 +09:00
Didi Kohen 4e36b244e3 Check for additional recovery passwords if failing 2020-11-24 23:19:56 +02:00
Romain Coltel aa860cec9f Update sha256 function used in mbedtls >= 2.7.0 2020-11-06 17:04:25 +01:00
Romain Coltel 40fe0fa807 Fix ruby userpass incompatible pointer without breaking using user pwd when bl doesn't have one 2020-11-06 15:06:50 +01:00
Romain Coltel f12debaf2d Remove signconv warn for GCC on Ruby's ruby.h 2020-11-06 13:20:08 +01:00
Romain Coltel a4b5e02914 Remove unused parameter on imported ruby.h from Ruby 2020-11-06 11:30:23 +01:00
Aorimn 5c00fc168d Merge pull request #226 from haobinnan/master
Fixed some issues
2020-10-16 17:12:37 +02:00
haobinnan 5e629b8a66 Fixed an issue that the decryption process got corrupted when using password to unlock a BitLocker partition which does not have a password.
Note: A BitLocker partition that does not have a password, e.g. it is encrypted via TPM instead of a password.
2020-10-16 11:25:35 +08:00
Aorimn 339733f0bd Merge pull request #182 from kkamagui/master
add ability to read VMK from the VMK file directly
2019-11-20 11:36:56 +01:00
haobinnan f778706e72 Fixed an issue that dislocker corrupted when unlocking BitLocker drive created in Windows 10 1903.
Fixed an issue that it failed to unlock exFAT BitLocker drive created in Windows 10 1903.
2019-07-24 10:38:04 +08:00
Seunghun Han b5a59c6dc1 add ability to read VMK from the VMK file directly 2019-06-26 02:15:21 +09:00
Aorimn c539432bd6 Add getopt function
The getopt function can be used to get the value of a parsed option from
getopts (note the difference between singular and plural).
2016-04-20 23:09:20 +02:00
Aorimn 99e9e1f4b5 Use AES-XTS for decryption
While the previous commit includes an implementation of AES-XTS, it
didn't "link" it with dislocker. This commit is here to do just that.
2016-03-05 12:41:01 +01:00
Aorimn 5895934107 Add real AES-XTS implementation
The previous implementation was only an AES-XEX one, without support for
not-divisible-by-16 sectors. We now support this through a real - if not
entirely complete in the test vectors point of vue - implementation.
Note that we don't support sectors not aligned on the byte limit, as
should be the case in a real AES-XTS implementation. But so far, I
didn't see it implemented anywhere, so I think we're good.
2016-03-05 12:37:49 +01:00
Aorimn 0f14ed5baa Change crc32 to our own implementation
Although we use the table from the previous implementation, this enables
us to use our own license.
2016-01-31 16:42:11 +01:00
Aorimn 2eb0c610e3 Add fallback for AES-XEX calling functions
This commit binds our own AES-XEX implementation in the curent code if
the one from mbedTLS is missing (as is currently the case).
2016-01-31 16:04:52 +01:00
Aorimn 994e2bfbd6 Add AES-XEX implementation within dislocker
This is done in case the function isn't available in the mbedTLS
library.
2016-01-31 16:04:52 +01:00
Aorimn 72a9280550 Add AES-XTS enc/decryption implementation
This adds functions which call the mbedtls_aes_crypt_xex function. This
function isn't available yet in mbedTLS, so this is of no use for common
users.
The bright side is, when it's available, it will be supported in
dislocker. A future commit will test for the maybe-existing function and
use our own implementation if it's not existing.
2016-01-31 16:04:52 +01:00
Aorimn 0b0e49cd15 Adding support for AES-XTS algorithms
This extends supported algorithms to AES-XTS ones.
2016-01-31 16:04:52 +01:00
Aorimn 545fd05a2b Merge pull request #58 from robert-scheck/assert
Replace C++11 syntax by something that GCC 4.1 compatible

Thank you @robert-scheck
2016-01-07 21:07:16 +01:00
Robert Scheck 2eeea8f677 Replace C++11 syntax by something that GCC 4.1 on RHEL 5 is able to understand 2016-01-06 03:46:36 +01:00
Robert Scheck eddf520ddb Avoid "error: expected declaration specifiers or '...' before 'off_t'" build failure on RHEL 5 2016-01-06 03:27:24 +01:00
Aorimn 909f4b7592 Give the real size to decrypt the keys
When decrypting keys (VMK or FVEK mainly), we gave 256 as of the key
size. This worked until now but I suspect that was mainly by the chance
that the current keys always are 256 bits long.
With the XTS mode, it seems the keys sizes have to be doubled, so that
would also prepare for the AES-XTS-256 mode, where keys could be 512
(I'm not sure yet).
2015-11-25 23:20:06 +01:00
Aorimn 36277c0a3b Add cipher numbers for AES-XTS
Looking at Windows 10 (v1511) encrypted partitions with AES-XTS, both
128 and 256, shows that the new cipher numbers are 0x8004 and 0x8005
respectively.
2015-11-25 19:55:47 +01:00
Aorimn 455653e55f Begin to prepare for AES-XTS encryption
AES-XTS is the new encryption scheme available on Windows 10 (from the
1511 version).
Moreover, this commit remove a branching case which often happens, which
should give beter performances (not tested though).
2015-11-19 00:07:38 +01:00
Aorimn 4d9a91617e Adding inttypes.h header for old systems
Ubuntu 12.04 for example doesn't seem to have inttypes.h included, but
my fedora has.
2015-10-08 15:28:25 +02:00
Aorimn 87c80cfbd3 Add Ruby functions when they're not defined
Ruby 1.8 doesn't seem to have rb_str_catf, so we provide an
implementation of this function when it's not defined.
2015-10-08 15:27:58 +02:00
Aorimn dfbcdc5e19 Use PRI* macros
Use PRI macros, instead of custom defined ones, to print specific
formats.
2015-10-08 14:49:28 +02:00
Aorimn ce2eef7000 Implement datums to_s functions
This implementation return Ruby strings suitable for printing datums.
2015-10-08 13:52:16 +02:00
Aorimn 1231375b50 Change a bunch of field names
In a datum, the entry and datum_type fields are now respectively called
entry_type and value_type. So every field using the former names have
been changed and consistency has (tried to) be preserved.
2015-10-04 19:06:52 +02:00
Aorimn 45dce08b0e Improve compiler compatibility again
Make clang statements only for clang.
2015-10-04 16:16:22 +02:00
Aorimn 8448a5ed5a Improve compilation compatibility
The `-Wno-unknown-attributes' clang warning option wasn't supported for
all platforms so we now get through the #pragma directive of the
preprocessor to tell clang not to consider `-Wunknown-attributes' for
the Ruby headers.
As this doesn't seem to be known for all versions of clang (at least for
version 3.0-6ubuntu3 from Ubuntu 12.04), we also add a pragma for clang
not to consider `-Wunknown-pragmas'.
2015-10-04 13:50:29 +02:00
Aorimn cfe4ed1c63 Improve Ruby bindings
One can now use libdislocker to read metadata and get access to keys.
One cannot yet fully decrypt the drive.
Next commit will present some samples of the use of the API.
2015-09-25 10:29:28 +02:00
Aorimn 3d26b2f47c Add new functions to accesses api
These functions permit to be used directly, without having to create a
dis_config_t structure.
2015-09-22 00:10:38 +02:00
Aorimn daaa1c1df1 Finish removing the dis_ctx dependency in metadata
This introduces a sort of configuration for the metadata unit, but get
rid of the dis_ctx dependency.
2015-09-20 15:12:53 +02:00
Aorimn f9c8b7f243 Change information metadata field name
The previously unknown_size field in the information structure seemed to
indicate the size of a "convertlog", during conversion of the volume. We
thus renamed this field for "convert_size".
2015-08-13 19:30:50 +02:00
Aorimn 4997b2d416 Merge branch 'cmake' into develop 2015-08-08 19:22:11 +02:00
Aorimn 4701b28497 Changes according to mbedtls modifications
The mbedtls headers seem to change every name by prepending mbedtls_ to
functions names, MBEDTLS_ to #define-d, and so on. We thus put #define
to change the names.
2015-08-06 13:22:11 +02:00
Aorimn 0d10e00c1e Export the PolarSSL real installed name
Every #define-d variable in PolarSSL has been renamed with
s/POLARSSL/MBEDTLS/, so we now export POLARSSL_REAL_NAME out of the
FindPolarSSL.cmake file so that dislocker may use the correct name when
looking at the POLARSSL/MBEDTLS_VERSION_STRING or others.
2015-08-06 11:53:41 +02:00