Removing DRM from B&N Books

Walkthru

This post owes much to Liberate Your (Legally Obtained) Nook Ebooks. The disclaimer there applies here equally. This process should only be done to move your books from the Nook app/ereader to another reader (e.g. iBook, Aquile, Kobo ereader, etc.). DO NOT ABUSE this process to pirate books.

There are steps in the link above that weren’t clear to me as I was following along. The following contents will elaborate on sections where I initially ran into problems.

Steps

These steps should work fine for both Windows and MacBooks.

The top-level steps are:

  • Set up a virtual device that can install the Nook app and allow me to log into my Nook account to see my books
  • Extracting the DRM-protected EPUB files for my books and store them on my local computer
  • Extracting the key to use to remove the DRM and save a copy on my local computer
  • Set up Calibre to open the DRM-protected EPUB files from my local computer and decrypting them using the extracted key

Setting up a virtual device

Install a copy of Android Studio. This can be done here: https://developer.android.com/studio

Once installed, running it will bring up a splash dialog. The “Android Virtual Device Manager” tool (AVD Manager) can be launched:

Once the Android Virtual Device Manager is up, clicking the “Create Virtual Device” will start the process to create a virtual device.

  • For the “device definition,” I select Phone > Nexus 4
  • For the “system image,” I select Nougat (Android 7.1.1)

IMPORTANT: More recent device definitions and/or system images may not work. Either the apps won’t install, or even if they are installed, I won’t be able to get to the files due to lack of root permissions (e.g. adb root does not work).

Once the virtual device is created, start it by double-clicking it or by using the “Actions” buttons:

Once the device is started, start the Chrome browser in the device, then install the Nook app by typing/pasting this into the address bar of the Chrome browser: https://apkpure.com/nook-read-ebooks-magazines/bn.ereader/versions

This brings up the download page of APKPure. Scroll down to find and click on the version 5.0.2.38. (Newer versions may not work.)

Clicking that box may bring up an ad that I can just close. Then I am asked whether to download the app or not.

Click DOWNLOAD.

Then I’m asked to Open the app. Click Open.

Then I am asked to Install. Click INSTALL.

The Nook app should then be started.

I sign in the Nook app as I normally do on a real device to get to my books.

All the books in my library are shown, but I need to click each book once to download it. I do this to all the books I want to download.

Extracting the DRM-protected EPUB files

Keep the virtual device running.

Find and run the ADB tool from Android Studio.

  • For Windows, the location should be %USERPROFILE%\AppData\Local\Android\Sdk\platform-tools
  • For Macs, the location should be ~/Library/Android/sdk/platform-tools

Find the EPUB files for the downloaded books (should be “/data/data/bn.ereader/files/B&N Downloads/Books“):

adb shell
generic_x86:/ # ls /data/data/bn.ereader/files/B\&N\ Downloads/Books

If there are more than a handful, it may be useful to zip them up before extracting them out of the virtual device:

generic_x86:/ # cd /data
generic_x86:/ # tar -czf epubs.tar.gz ./data/bn.ereader/files/B\&N\ Downloads/Books/*.epub

Exit the ADB shell.

To pulling an EPUB file individually:

adb pull /data/data/bn.ereader/files/B\&N\ Downloads/Books/xxxxxxxx.epub C:/temp/xxxxxxxx.epub

Or pulling the zipped up TAR file:

adb pull /data/epubs.tar.gz c:/temp/epubs.tar.gz

On Windows, *.tar.gz files can be opened by tools like 7-zip.

By now I should have a list of protected EPUB files. I can open them with EPUB readers, but they will be blank due to the DRM.

Extracting the key to use to remove the DRM

The key is embedded in an SQLite DB file inside the virtual device. Therefore, the ADB tool is used again. The location of the file should be /data/data/bn.ereader/databases/cchashdata.db:

adb pull /data/data/bn.ereader/databases/cchashdata.db C:/temp/cchashdata.db

Any SQLite browser (e.g. DB Browser for SQLite) can then be used to look into the cchashdata.db file.

Continuing with DB Browser for SQLite, start the tool, then open the pulled cchashdata.db file:

Open the cchashdata.db file pulled earlier

Once opened, use the “Browse Data” tab, then select the “cc_hash_data” table. There is only one record there, and its “hash” column will contain the key:

Copy the “hash” value

Create a new text file and place the copied hash value into it as the only line. Save the file as “bn_hash.b64” (use whatever name as desired, but use the “.b64” extension).

Set up Calibre to open the DRM-protected EPUB files

Download a ZIP (DeDRM_tools_x.y.z.zip) of the latest DeDRM_tools from here: https://github.com/apprenticeharper/DeDRM_tools/releases

Unzip the downloaded DeDRM_tools_x.y.z.zip (again, use 7-zip or similar tool for Windows) to extract the file DeDRM_plugin.zip. DO NOT unzip the DeDRM_plugin.zip file itself.

NOTE that DeDRM_plugin.zip is itself a zip file inside the DeDRM_tools_x.y.z zip.

Download a copy of the Calibre tool from here: https://calibre-ebook.com/download

Open and install the Calibre tool. Then start up Calibre.

From Calibre, click the “Preferences” icon on the top tool bar:

Scroll down the Preferences dialog and click on “Plugins“:

Then click “Load plugin from file” and open the file DeDRM_plugin.zip from above.

This will add a new entry “DeDRM (x.y.z)” under the “File type” section in the Plugins list.

Select the entry and click “Customize plugin.”

A small dialog will come up. Click “Barnes and Noble ebooks.”

Clicking “Barnes and Noble ebooks” will bring up another dialog.

Click “Import Existing Keyfiles” and select the bn_hash.b64 file (or whatever name used for the .b64 file) created earlier.

A new entry “bn_hash” (or whatever the name used for the .b64 file) is added.

Click Close. Then click “OK” on the “Customize DeDRM” dialog box. Then click “Apply” in the “Plugins” dialog box. Lastly, click “Close” on the Preferences dialog box.

Yes. That’s a total of FOUR dialog boxes.

Open and Save the EPUB files

With the plugin configured, I now can open the DRM-protected EPUB files.

I can then save the book. The copy that I save, however, will no longer have DRM protection. That copy can now be imported or opened by any EPUB reader.