• Stars
    star
    214
  • Rank 184,678 (Top 4 %)
  • Language
    Go
  • License
    GNU General Publi...
  • Created almost 10 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WD MyBook encrypted hard drive decryption (still WIP).

reallymine: Western Digital MyBook/MyPassport decryption

reallymine is a program that decrypts the encrypted hard drives of Western Digital MyBook and MyPassport external hard drives (and some rebranded derivatives).

Currently, it can only decrypt JMicron, Initio, and Symwave bridge chip-based devices tht use AES-256-ECB encryption. I'd love to expand this to cover PLX/Oxford Semiconductor bridge chips and the other known encryption modes, but I need your help; see below.

The program is command-based, with two main commands (one to get the decryption key and one to decrypt the drive automatically) and several helper commands that will facilitate research in expanding reallymine. The general usage is thus

$ reallymine [options] command [args...]

Pass --help for more detailed explanations.

Installing

Stable versions of reallymine are available from the Releases page on GitHub.

reallymine is written in Go. If you want to build it from source, install Go and then simply run

$ go get github.com/andlabs/reallymine

This will get reallymine and its dependencies and place the resultant binary in your $GOPATH/bin.

If you want to manually download reallymine, you will need to have the dependencies installed separately:

github.com/mendsley/gojwe
	for the AES key-unwrapping code used to extract the DEK from Symwave chips
github.com/hashicorp/vault/helper/password
	for password entry

Decrypting a Drive

The most common operation is decrypting an entire drive. Let's say the drive is at /dev/sdb and you want to decrypt it to a file decrypted.img. You would just say

$ reallymine decrypt /dev/sdb decrypted.img

reallymine will automatically find the sector on the drive that holds the encryption information, referred to by the program as the "key sector", and attempts to extract the decryption key without a password. If that fails, reallymine will ask you for a password. Once the right password is entered and the decryption key is extracted, reallymine will start decrypting the drive. This will take a while; sit tight.

reallymine never overwrites a file that already exists; by extension, it does not allow in-place decryption.

Note that I make no guarantees about whether running reallymine off an existhing hard drive will wear the drive out. It does not replace GNU ddrescue as a damaged-disk recovery tool. If in doubt, run GNU ddrescue first, then run reallymine with the rescued image.

Getting the Decryption Key

You may want to perform decryption yourself, or do other things with the decryption key. For that, use the getdek command.

$ reallymine getdek /dev/sdb

In addition to printing the type of bridge chip your drive uses and the encryption key, which reallymine calls the DEK, reallymine will also print the steps needed to properly decrypt the data on the drive for every AES cipher block. For example, an Initio drive will say

bridge type Initio
DEK: A5DC4A231E88162A7066B063C2C31F1BDF248AF53F4F86F432C9E5414F88D280
decryption steps: swaplongs decrypt swaplongs

indicating that you first need to reverse all the 4-byte groups in each 16-byte block, then decrypt with the DEK, and then reverse the 4-byte groups again to get the final data.

Researching with reallymine

reallymine has several research-oriented commands built in in addition to the two above. When contributing, I may ask you to run these commands to find out more about your specific scenario. You may also run them yourselves.

First are dumplast and dumpkeysector. dumpkeysector will try to find and dump the key sector on your drive as it is stored on disk. If that fails to detect the key sector, you can try dumplast, which gets the last sector on the drive that isn't all zero bytes; we can look at it to see what key sector you have. Both have the same syntax

$ reallymine dumplast /dev/sdb outfile.bin
$ reallymine dumpkeysector /dev/sdb outfile.bin

Alternatively, you can use - as an output filename to perform a hexdump on standard output.

The decryptkeysector command is like the dumpkeysector command, except it also decrypts the key sector with the encryption key that is used to encrypt that specific sector, which reallymine calls the KEK. The KEK changes when you change your password; the DEK never changes. Consequently, the KEK is used to encrypt the DEK to ensure the DEK doesn't leak out.

decryptkeysector has the same form as dumpkeysector, except it takes a third argument to specify the KEK. This can be a hexadecimal string to use a specific KEK, or one of the following special values:

-real    - behave like the decrypt command
-askonce - ask for a password once and only use the resultant KEK
-onlyask - only ask for a password until the right one is used
-default - use the default KEK (no password) only

The DEK can likely be read out of the decrypted key sector.

The dumpfirst command, which takes the same form as the dumplast command, dumps the first few sectors of your hard drive without decrypting them. This will likely contain the partition map of your drive, allowing it to be used to verify that a DEK is correct without leaking any of your sensitive data.

But simply knowing the DEK is not enough; you also need to know how to transform the data before and after decrypting to get the data back out properly. This is done with the decryptfile command, which does not deal with a disk at all. It takes four parameters: an input file to decrypt (or - for standard input), an output file to decrypt to (or - for a hexdump to stdout), the DEK as a hexadecimal string, and then a space-delimited string containing the decryption steps, such as those shown in the example output of the getdek command. Use --help for a full list of possible steps.

More specific usage information can be seen with --help.

Contributing

reallymine is already quite capable, but is still in need of improvement to handle every possible case. If your drive isn't handled already, feel free to open an issue on GitHub to contribute your key sectors and partition maps, either by following the steps above or with our help. (Don't worry; I only need the boot sectors and decryption key; I won't need any of your actual data. The sectors won't go into the source repository either.)

Code contributions are also welcome.

License

This project is licensed under the GPL version 3. This is to ensure that the research that went into reallymine stays open.

TODO should I switch to Affero GPL, just to be safe?

Thanks (TODO)

  • Xenesis (minor THUMB help)
  • Sik (minor documentation fixes)
  • FraGag (minor 68020 information)
  • fd0 (irc.freenode.net #go-nuts; help with dealing with decryption keys)
  • Everyone else from IRC and the GitHub issues I forgot to thank

More Repositories

1

libui

Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
C
10,723
star
2

ui

Platform-native GUI library for Go.
Go
8,336
star
3

qo

Another build system for C/C++, I guess? Inspired by 'go build'
Go
307
star
4

wakeup

Simple alarm clock program; also a demonstration of andlabs/ui.
Go
54
star
5

utf

[development paused; issues and PRs still welcome] Portable UTF-8 and UTF-16 routines in a single C source file.
C
46
star
6

65816disasm

A disassembler for WDC 65816 binaries, specifically SNES ROMs for now.
Go
33
star
7

ews

quick and dirty Go package to send emails via Exchange using EWS instead of SMTP
Go
27
star
8

screentext

Go API for rendering text for on-screen display, using native APIs and system fonts.
Go
13
star
9

idapyscripts

Assorted IDAPython scripts for ROM hacking/research.
Python
13
star
10

a68

A simple, sane Motorola MC68000 assembler.
Go
9
star
11

pcmio

Raw PCM I/O library for Go.
Go
9
star
12

dl

libdl wrapper for Go.
Go
8
star
13

mamefuse

A FUSE filesystem that serves MAME ROMs from various places on your hard disk.
Go
8
star
14

huc6280disasm

A disassembler for HuC6280 binaries, specifically TurboGrafx-16/PC Engine ROMs for now.
Go
7
star
15

dumpattachments

Program to bulk-dump attachments from an IMAP account.
Go
7
star
16

barspy

[development paused; issues and PRs still welcome] Spy++-like program for inspecting Toolbars and Rebars.
C++
6
star
17

misctestprogs

Some miscellaneous test programs.
C
6
star
18

tms34010disasm

A disassembler for Texas Instruments TMS34010 binaries.
Go
5
star
19

mdlist

Mega Drive/Genesis game info list
Go
5
star
20

wintable

Windows API Table control, split from package ui. Not ready for general use.
C
5
star
21

e4jexamine

manual ext4 journal examining and data block extraction
Go
5
star
22

fmux

File multiplexer/interleaver.
Go
5
star
23

pgidl

small custom interface description language package and tools
Go
5
star
24

e4itblcmp

compares ext4 inode table blocks in a bunch of ways
Go
5
star
25

irksome

personal chat client
C
4
star
26

nointrochk

ROM set verifier for clrmamepro datfiles from no-intro dat-o-matic
Go
4
star
27

winiconview

Windows bulk icon resource viewer toy project.
C
4
star
28

enpipe

Force Unix programs to work in pipelines.
C
4
star
29

ohv

Oh! V, or the Omniscient Help Viewer, or the Offline Help Viewer, or whatever other thing you can think of...
C
4
star
30

macgetalbums

[development paused; issues and PRs still welcome] List all the albums you have in iTunes as a text file with the year of earliest release, among other things.
Objective-C
4
star
31

gtkcontrolspy

A silly thing to play around with GTK+ widgets in a sandbox. Inspired by Microsoft's Control Spy (http://msdn.microsoft.com/en-us/library/windows/desktop/bb773165(v=vs.85).aspx).
C
4
star
32

segaret_scans

The scan tracker used by Sega Retro; might be useful to you too
Go
3
star
33

simplesale

Dead-simple point of sale system. Because seriously. [IN ITS INFANCY, BEING REWRITTEN AGAIN]
C
3
star
34

mmbnmapdump

Shell
3
star
35

gogir

GObject Introspection-based bindings generator for Go [IN ITS INFANCY; WILL NOT ACTUALLY PRODUCE USABLE CODE NOW]
Go
3
star
36

windlgunits

An attempt at trying to make sense of the Windows API's dialog base units.
C
2
star
37

gcdown

Google Code scraping file downloader (for the Downloads tab)
Go
2
star
38

mshc2devhelp

Converts Microsoft Help Viewer mshc databases to devhelp files.
Go
2
star
39

ctlineboundstest

[development paused; issues and PRs still welcome] Core Text line height playground
Objective-C
2
star
40

gtkdatetimepicker

GTK+ Date-Time Picker control. Still in its infancy.
C
2
star
41

mwuploadbulk

Simple command-line MediaWiki bulk file uploader.
Go
2
star
42

ym2612

A hardware-accurate Yamaha YM2612 sound chip emulator, written in C and Go and using its concurrency features.
1
star