SlideShare una empresa de Scribd logo
1 de 37
Your money, your media
A DRMtastic (reverse|re)engineering tutorial
Who dat dude with the mic?
●   Hi, I'm Manuel. An academic researcher without
    academic title.
What's this talk about
Kobo
●   Global eBook retailer
●   “We believe consumers should be able to read any book, anytime,
    anywhere, and on the device of their choice”

●   “We believe open standards for eBooks are best for consumers,
    publishers, retailers and hardware manufacturers. Closed systems
    stifle innovation and growth. Kobo proudly supports EPUB and
    encourages our users to read a Kobo-purchased eBook on their
    smartphone, Sony Reader, laptop, or whichever device they
    choose.”
No problem, then!
fbreader
I AM DISAPPOINT
trollface.jpg
●   I BUY books. I don't
    “lend them under
    certain terms”.
●   $10 for a digital copy,
    and you restrict how I
    use it?
NOTICE
●   I ONLY WANTED TO ACHIEVE
    INTEROPABILITY WITH OTHER PROGRAMS
    ●   THAT ARE NOT COMPETING WITH THE KOBO
        READER

●   KOBOPIER ONLY REPRODUCES THE
    DECRYPTION INTERFACE
●   DON'T PIRATE XOR DON'T GET CAUGHT
Whoo, look at my ePenis!
Android reversing
●   Dalvik
●   Smali
    ●   Can haz apktool?
smali example code
Workflow example
●   adb pull /data/app/com.MyLittlePony.apk /tmp/



●   java -jar baksmali.jar -o /tmp/pony MyLittlePony.apk



●   OR apktool d MyLittlePony.apk /tmp/pony



●   vim /tmp/pony/smali/com/mylilpony/Main.smali
MOAR DATA
●   adb pull /data/data/com.kobobooks.android/ kobothings
OMG Obfuscation
OMG Obfuscation
Your reaction: Anger
Your reaction: Resignation
Your reaction: The Right One
Java/smali is hard to obfuscate
●   MADE to be readable
●   invoke-static {p0, v1, v0}, Lcom/kobobooks/android/f/i;-
    > a([BLjavax/crypto/Cipher;Ljavax/crypto/SecretKey;)[B
The search begins
grep -Ri javax.crypto...?




...Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-
cbc"/>


...so I'm searching for “AES”.
Bingo!...FAIL.
●   Found a decryption!
●   sqlite3 <kobo
    datadir>/databases/Kobo


●   '.tables' + '.headers   on   '
●   ParentContentID|...|

    DecryptKey|...
BUT I WANNA!!!!! ;_;
Moar reversing
●   Who's calling my decryption?
●   What other methods is it calling?
    ●   Learn to read smali. It's a somewhat neat language.

●   What data is it using?
    ●   ...remote Dalvik debugging?
apktool
●   Disassemble
●   Modify (theme, patch, break...)
●   Build (apktool b...)
●   Sign (jarsigner)
●   adb install hax.apk

    ●   Uninstall the old version first
Bingo!...FAIL...ish.
On the right track!
●   Then: “Is it possible?”
●   Now: “How to make it practical?”
●   More patching: Dumping all parts of the key
    ●   Caller of the decryption method creates the key
    ●   Three strings as input
    ●   Does some weirdass stuff, more on that later
Key parts
/OzEca8ESalQNvd/xknj8g==

ee13373-bb8a-5a09-ccdd-af9c4fbgf844

503668452247539



May the logs be with you.
Hashing IDs && Base64 decode
●   H(DeviceID || UserID).substring(15);



●   Algorithms (hardcoded arrays/tables) look
    intimidating in smali
●   Public Domain Base64.java :)
Part Three: WTF Crypto?
Part Three: WTF Crypto
Hardcoded Strings, again!
Part Three: WTF Crypto
●   Rijndael
●   BouncyCastle AND own implementation
    ●   I'm here to break, not question it.
●
    encrypt()   and decrypt() have the same signature...
Putting the parts together
●   Read chapter    (cp /sdcard/Kobo/epubs ...)


●   H(DeviceID || UserID)
●   base64_decode(DecryptKey)
●   D(encoded_decryptkey, hash_part)
    ●   Clever (and common) from a DRM perspective

●   D(chapter, decrypted_key)
BINGO!
Result: Kobopier
           http://sporkbomb.eu/kobopier/
* Kobopier - a Kobo Android ePub DRM stripper

*

* You can reach the author at kobopier@acanthephyra.net.

* New versions of Kobopier will be made available at http://sporkbomb.eu/kobopier/.

*

* Important note: Kobopier is not made for piracy. It does not break any encryption,

* it simply replicates a few steps the original Android Kobo reader does.

* Please read the license below. Also, consider that it is YOUR responsibility to deal

* with any legal issues that arise from YOU using this tool.

* If you buy one copy of an ebook, decrypt it with this tool and then give it away,

* that's fine with me - but you alone are responsible if Kobo sues you.

*

* Copyright (C) 2011 sporkbomb
●   Questions?
●   Complaints?
●   Compliments?
●   Suggestions?

      @__sporkbomb

Más contenido relacionado

La actualidad más candente (6)

Moving to PHP from Java
Moving to PHP from JavaMoving to PHP from Java
Moving to PHP from Java
 
Joi ETech 2009 - Creative Commons
Joi ETech 2009 - Creative CommonsJoi ETech 2009 - Creative Commons
Joi ETech 2009 - Creative Commons
 
Fall 2011 PHP Class - Session 1
Fall 2011 PHP Class - Session 1Fall 2011 PHP Class - Session 1
Fall 2011 PHP Class - Session 1
 
Extjs Howto
Extjs HowtoExtjs Howto
Extjs Howto
 
Vim week
Vim weekVim week
Vim week
 
TagLoops
TagLoopsTagLoops
TagLoops
 

Similar a Your money, your media a DRMtastic (reverse|re) eng. tutorial

Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
ConFoo
 
Scottish Ruby Conference 2014
Scottish Ruby Conference  2014Scottish Ruby Conference  2014
Scottish Ruby Conference 2014
michaelag1971
 
Effective entrepreneurship for developers
Effective entrepreneurship for developersEffective entrepreneurship for developers
Effective entrepreneurship for developers
Carlos Ble
 

Similar a Your money, your media a DRMtastic (reverse|re) eng. tutorial (20)

Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3
 
Headless Android
Headless AndroidHeadless Android
Headless Android
 
Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)
Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)
Pigaios: A Tool for Diffing Source Codes against Binaries (Hacktivity 2018)
 
Super lazy side projects - Hamik Mukelyan
Super lazy side projects - Hamik MukelyanSuper lazy side projects - Hamik Mukelyan
Super lazy side projects - Hamik Mukelyan
 
12 tricks to avoid hackers breaks your CI / CD
12 tricks to avoid hackers breaks your  CI / CD12 tricks to avoid hackers breaks your  CI / CD
12 tricks to avoid hackers breaks your CI / CD
 
Half-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code RecoveryHalf-automatic Compilable Source Code Recovery
Half-automatic Compilable Source Code Recovery
 
Resisting App Pirates
Resisting App PiratesResisting App Pirates
Resisting App Pirates
 
Sonatype DevSecOps Leadership forum 2020
Sonatype DevSecOps Leadership forum 2020Sonatype DevSecOps Leadership forum 2020
Sonatype DevSecOps Leadership forum 2020
 
Design and Evolution of cyber-dojo
Design and Evolution of cyber-dojoDesign and Evolution of cyber-dojo
Design and Evolution of cyber-dojo
 
Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
 
Scottish Ruby Conference 2014
Scottish Ruby Conference  2014Scottish Ruby Conference  2014
Scottish Ruby Conference 2014
 
Beginning Kindle Hackery
Beginning Kindle HackeryBeginning Kindle Hackery
Beginning Kindle Hackery
 
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
NanoSec Conference 2019: Code Execution Analysis in Mobile Apps - Abdullah Jo...
 
Effective entrepreneurship for developers
Effective entrepreneurship for developersEffective entrepreneurship for developers
Effective entrepreneurship for developers
 
My solution to malware.lu HackGyver's challenges.
My solution to malware.lu HackGyver's challenges.My solution to malware.lu HackGyver's challenges.
My solution to malware.lu HackGyver's challenges.
 
Learn to Code and Have Fun Doing It!
Learn to Code and Have Fun Doing It! Learn to Code and Have Fun Doing It!
Learn to Code and Have Fun Doing It!
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLEAN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE
 
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
AN EXERCISE IN CLEANER CODE - FROM LEGACY TO MAINTAINABLE - CFObjective() 2017
 
Introduction to google chromebooks and chromeboxes presentation tech-talk
Introduction to google chromebooks and chromeboxes presentation tech-talkIntroduction to google chromebooks and chromeboxes presentation tech-talk
Introduction to google chromebooks and chromeboxes presentation tech-talk
 
Fuzzing - Part 2
Fuzzing - Part 2Fuzzing - Part 2
Fuzzing - Part 2
 

Más de Security BSides London

Más de Security BSides London (11)

Security YMCA
Security YMCASecurity YMCA
Security YMCA
 
Penetration testing must die
Penetration testing must diePenetration testing must die
Penetration testing must die
 
You built a security castle and forgot the bridge…now users are climbing your...
You built a security castle and forgot the bridge…now users are climbing your...You built a security castle and forgot the bridge…now users are climbing your...
You built a security castle and forgot the bridge…now users are climbing your...
 
Agnitio: its static analysis, but not as we know it
Agnitio: its static analysis, but not as we know itAgnitio: its static analysis, but not as we know it
Agnitio: its static analysis, but not as we know it
 
The Funny Thing About Information Security
The Funny Thing About Information SecurityThe Funny Thing About Information Security
The Funny Thing About Information Security
 
Breaking, Entering and Pentesting
Breaking, Entering and Pentesting Breaking, Entering and Pentesting
Breaking, Entering and Pentesting
 
All your logs are belong to you!
All your logs are belong to you!All your logs are belong to you!
All your logs are belong to you!
 
Practical Crypto Attacks Against Web Applications
Practical Crypto Attacks Against Web Applications Practical Crypto Attacks Against Web Applications
Practical Crypto Attacks Against Web Applications
 
Jedi mind tricks for building application security programs
Jedi mind tricks for building application security programsJedi mind tricks for building application security programs
Jedi mind tricks for building application security programs
 
Dns tunnelling its all in the name
Dns tunnelling its all in the nameDns tunnelling its all in the name
Dns tunnelling its all in the name
 
Cloud computing due diligence WTF?
Cloud computing due diligence WTF?Cloud computing due diligence WTF?
Cloud computing due diligence WTF?
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

Your money, your media a DRMtastic (reverse|re) eng. tutorial

  • 1. Your money, your media A DRMtastic (reverse|re)engineering tutorial
  • 2. Who dat dude with the mic? ● Hi, I'm Manuel. An academic researcher without academic title.
  • 4. Kobo ● Global eBook retailer ● “We believe consumers should be able to read any book, anytime, anywhere, and on the device of their choice” ● “We believe open standards for eBooks are best for consumers, publishers, retailers and hardware manufacturers. Closed systems stifle innovation and growth. Kobo proudly supports EPUB and encourages our users to read a Kobo-purchased eBook on their smartphone, Sony Reader, laptop, or whichever device they choose.”
  • 9. I BUY books. I don't “lend them under certain terms”. ● $10 for a digital copy, and you restrict how I use it?
  • 10. NOTICE ● I ONLY WANTED TO ACHIEVE INTEROPABILITY WITH OTHER PROGRAMS ● THAT ARE NOT COMPETING WITH THE KOBO READER ● KOBOPIER ONLY REPRODUCES THE DECRYPTION INTERFACE ● DON'T PIRATE XOR DON'T GET CAUGHT
  • 11. Whoo, look at my ePenis!
  • 12. Android reversing ● Dalvik ● Smali ● Can haz apktool?
  • 14. Workflow example ● adb pull /data/app/com.MyLittlePony.apk /tmp/ ● java -jar baksmali.jar -o /tmp/pony MyLittlePony.apk ● OR apktool d MyLittlePony.apk /tmp/pony ● vim /tmp/pony/smali/com/mylilpony/Main.smali
  • 15. MOAR DATA ● adb pull /data/data/com.kobobooks.android/ kobothings
  • 20. Your reaction: The Right One
  • 21. Java/smali is hard to obfuscate ● MADE to be readable ● invoke-static {p0, v1, v0}, Lcom/kobobooks/android/f/i;- > a([BLjavax/crypto/Cipher;Ljavax/crypto/SecretKey;)[B
  • 22. The search begins grep -Ri javax.crypto...? ...Algorithm="http://www.w3.org/2001/04/xmlenc#aes128- cbc"/> ...so I'm searching for “AES”.
  • 23. Bingo!...FAIL. ● Found a decryption! ● sqlite3 <kobo datadir>/databases/Kobo ● '.tables' + '.headers on ' ● ParentContentID|...| DecryptKey|...
  • 25. Moar reversing ● Who's calling my decryption? ● What other methods is it calling? ● Learn to read smali. It's a somewhat neat language. ● What data is it using? ● ...remote Dalvik debugging?
  • 26. apktool ● Disassemble ● Modify (theme, patch, break...) ● Build (apktool b...) ● Sign (jarsigner) ● adb install hax.apk ● Uninstall the old version first
  • 28. On the right track! ● Then: “Is it possible?” ● Now: “How to make it practical?” ● More patching: Dumping all parts of the key ● Caller of the decryption method creates the key ● Three strings as input ● Does some weirdass stuff, more on that later
  • 30. Hashing IDs && Base64 decode ● H(DeviceID || UserID).substring(15); ● Algorithms (hardcoded arrays/tables) look intimidating in smali ● Public Domain Base64.java :)
  • 31. Part Three: WTF Crypto?
  • 32. Part Three: WTF Crypto Hardcoded Strings, again!
  • 33. Part Three: WTF Crypto ● Rijndael ● BouncyCastle AND own implementation ● I'm here to break, not question it. ● encrypt() and decrypt() have the same signature...
  • 34. Putting the parts together ● Read chapter (cp /sdcard/Kobo/epubs ...) ● H(DeviceID || UserID) ● base64_decode(DecryptKey) ● D(encoded_decryptkey, hash_part) ● Clever (and common) from a DRM perspective ● D(chapter, decrypted_key)
  • 36. Result: Kobopier http://sporkbomb.eu/kobopier/ * Kobopier - a Kobo Android ePub DRM stripper * * You can reach the author at kobopier@acanthephyra.net. * New versions of Kobopier will be made available at http://sporkbomb.eu/kobopier/. * * Important note: Kobopier is not made for piracy. It does not break any encryption, * it simply replicates a few steps the original Android Kobo reader does. * Please read the license below. Also, consider that it is YOUR responsibility to deal * with any legal issues that arise from YOU using this tool. * If you buy one copy of an ebook, decrypt it with this tool and then give it away, * that's fine with me - but you alone are responsible if Kobo sues you. * * Copyright (C) 2011 sporkbomb
  • 37. Questions? ● Complaints? ● Compliments? ● Suggestions? @__sporkbomb