apprenticeharper / DeDRM_tools

DeDRM tools for ebooks
14.36k stars 1.47k forks source link

Reverse Engineering the ADEPT auth protocol #1740

Open JJTech0130 opened 3 years ago

JJTech0130 commented 3 years ago

I found very few details on how the authorization part of the protocol works, so I decided to investigate. I read the ADE Engineering docs, but they were vague. So I installed MITMProxy to begin examining packets. Most of it was encrypted, so I wanted to try giving it self-signed certs so that I could intercept the data. I have attached the certs I generated along with their private keys. But when I use MITM proxy to replace them in the certificate exchange, it always complains that the certs are invalid. I presume the root adobe cert must be hardcoded. Does anyone have any idea what to do next? I will try and analyze the exe, but I am not very skilled in decompiliation. Perhaps a simple bytecode patch could work? Not sure what to search for in it. keys.zip EDIT: Also, why are all of adobe's certs expired??? EDIT2: Eventually, I want to create a linux script for downloading ascm files, that's why I'm doing this.

ElleKayEm commented 3 years ago

This is beyond me, but are you looking at the newer "hardened" Adobe DRM?

JJTech0130 commented 3 years ago

Not sure- I'm using ADE 4.5 I also discovered (like 10s ago ;) that it doesn't check the keys in it's registry, so if you just pre-insert them it doesn't seem to replace them. EDIT: And I have used DeDrm the normal way with it in the past

ElleKayEm commented 3 years ago

ADE 4.5 can handle both old and new Adobe DRM. ADE 2.0.1 and DeDRM can only handle the older DRM.

JJTech0130 commented 3 years ago

Well it must be the older version then as it worked with DeDrm And actually it must check the keys when attempting to add a book :( It says "please check activation" EDIT: running strings on the exe shows what appear to be several hardcoded DigiCert certificates. I wonder if they are signed with that somewhere up the chain? EDIT: I extracted ACS3Compat.pem from rmsdk_wrapper.dll, and I'm looking for other Adobe-specific ones. EDIT: The exe appears to only contain code signatures for ADE and Shockwave signed by Digicert, will keep looking and try to extract them EDIT: Decompiling binaries with Ghidra, noticed something interesting: ADE.exe has all of the function names, arguments and return values intact, whereas RMSDK_Wrapper.dll has been completely obfuscated. Trying to so how one might disable the key checking, but I don't understand Assembly that well and (obviously) the decompiled C is a mess of goto's and bitshifts and weird things. Also there are large areas of zeros, and some areas Ghidra has nothing to do with. I'm going to try something else if I don't discover anything today.

JJTech0130 commented 3 years ago

Adobe Digital Editions 2.0.app.zip Used darling to get app files for mac, they look less obfuscated. Not sure if they will help. EDIT: The MacOS binary appears to be standalone (there are no libraries), and mostly unobfuscated, including lots of interesting thinks like it's RSA impl.

JJTech0130 commented 2 years ago

Got macOS Big Sur today, decompiling with IDA Free and Ghidra. Will try to modify certificate checking. Had to use latest version as older would not run. Just in case anyone wants it: ContentServer_UserManual1.0.pdf

[EDIT 8/20/21]: So, by looking at IDA's Exports section, we can see it provides lots of functions starting with _d2i_, which reveals that it probably includes a bundled release of OpenSSL, which is why it ignores self-trusted roots in the macOS keychain. [EDIT 8/20/21 B]: Discovered Frida, will try and hook into verification functions. Best guess is that ADE uses a technique similar to SSL pinning, as the certificates are not signed by a trusted authority, or even valid. [EDIT 9/14/21]: Have lots of other stuff to do, so progress is slow, but my idea is to use the Android version (because Java should be easier to RE) with Frida and mitmproxy in an emulator.

JJTech0130 commented 2 years ago

Can't work on this project now, closing.

JJTech0130 commented 2 years ago

https://github.com/Leseratte10/acsm-calibre-plugin Looks like someone else did it!