They Thinked Differently DerbyCon2013
They Thinked Differently DerbyCon2013
Area 35 919 sq mi
Language Hungarian
Worth reading:
http://9gag.com/gag/
6832266
• László
• Co-founders of Hekkcamp
KFC
mark of
red trade
• In case of phones it supports from
a registe
version 4
is
The logo
• The algorithm is known...
boring
KFC
mark of
red trade
• In case of phones it supports from
a registe
version 4
is
The logo
• The algorithm is known...
boring
t h in k s d iff e re n tly
But Samsung
Saturday, September 28, 13 7
Normal way
password
password PBKDF2
password PBKDF2
partition footer
or
/efs/metadata
password PBKDF2
or
/efs/metadata
password PBKDF2
or
/efs/metadata
password PBKDF2
DEK
partition footer AES128 dmcrypt
EDK
or
/efs/metadata
DEK
partition footer AES128 dmcrypt
EDK
or
/efs/metadata
DEK
partition footer AES128 dmcrypt
EDK
or aes-cbc-
essiv:sha256
keylen=128
/efs/metadata
DEK
partition footer AES128 dmcrypt
EDK
or aes-cbc-
essiv:sha256
keylen=128
/efs/metadata
http://xelusprime.wix.com/ettiennev
IV
IV
partition footer
password PBKDF2 or
/efs/metadata
HEX1
partition footer
password PBKDF2 or
/efs/metadata
HEX2
HEX1 AES256
partition footer
password PBKDF2 or
/efs/metadata
HEX2 AES256
HEX1 AES256
partition footer
password PBKDF2 or
/efs/metadata
HEX2 AES256
partition footer
password PBKDF2 or
/efs/metadata
partition footer
password PBKDF2 or
/efs/metadata
partition footer
/efs/metadata
http://hammerheadgraphics.iwarp.com/
IV
IV
Samsung Android
4096 VS 2000*2
Samsung Android
256 VS 128
Samsung Android
no t h a v e to d e c ry p t th e
p h o nes the v o ld d o e s
On Samsung a s s w o rd
key to v e rify th e p
Wrong password
Wrong password
Good password
Wrong password
Good password
Wrong password
Wrong password
Good password
Wrong password
Samsung S4 Android
verify_EDK VS cryptfs_verify_passwd
in cryptfs.c
in libsec_km.so
} else {
decrypt_master_key
decrypt_master_key(passwd, salt, encrypted_master_key,
decrypted_master_key);
if (!memcmp(decrypted_master_key,
decrypted_master_key saved_master_key,
saved_master_key
crypt_ftr.keysize)) {
/* They match, the password is correct */
rc = 0;
} else {
/* If incorrect, sleep for a bit to prevent
dictionary attacks */
sleep(1);
rc = 1;
}
}
return rc;
decrypt_master_key
decrypted_master_key
} else {
decrypt_master_key(passwd, salt, encrypted_master_key,
decrypted_master_key); saved_master_key
if (!memcmp(decrypted_master_key, saved_master_key,
crypt_ftr.keysize)) {
/* They match, the password is correct */
rc = 0;
} else {
/* If incorrect, sleep for a bit to prevent
dictionary attacks */
sleep(1);
rc = 1;
}
}
return rc;
decrypt_master_key
decrypted_master_key
} else {
decrypt_master_key(passwd, salt, encrypted_master_key,
decrypted_master_key); saved_master_key
if (!memcmp(decrypted_master_key, saved_master_key,
crypt_ftr.keysize)) {
/* They match, the password is correct */
rc = 0;
} else {
/* If incorrect, sleep for a bit to prevent
dictionary attacks */
sleep(1);
rc = 1;
}
sleep(1);
}
return rc;
in s th e d e c ry p t e d d is k
rc es s m em o ry co nta
The vold po
encryption key.
pbkdf
SECKM_HMAC_SHA256
memcmp
DEMO
Saturday, September 28, 13 20
Samsung way
• You need adb and root on the phone (vold runs as root)
• You need adb and root on the phone (vold runs as root)
• You need adb and root on the phone (vold runs as root)
• Create a recovery image that runs the adb, have root and dd
• Create a recovery image that runs the adb, have root and dd
• Create a recovery image that runs the adb, have root and dd
• Try to crack it
• Create a recovery image that runs the adb, have root and dd
• Try to crack it
DEMO
Saturday, September 28, 13 22
Samsung way
• Yes we developed a john the ripper module, but just for demonstration
purposes (no optimization)
• Yes we developed a john the ripper module, but just for demonstration
purposes (no optimization)
• Yes we developed a john the ripper module, but just for demonstration
purposes (no optimization)
• Yes we developed a john the ripper module, but just for demonstration
purposes (no optimization)
• Yes we developed a john the ripper module, but just for demonstration
purposes (no optimization)
• We did not test it, but with GPU the 6 character all lower case might be feasible
also
• Yes we developed a john the ripper module, but just for demonstration
purposes (no optimization)
• We did not test it, but with GPU the 6 character all lower case might be feasible
also
• And users tends to use even weaker password on a mobile device than an a
PC
TEE
Saturday, September 28, 13 27
Samsung way
mobicore
kernel
TEE
Saturday, September 28, 13 27
Samsung way
trustlet
trustlet
trustlet
mobicore
kernel
TEE
Saturday, September 28, 13 27
Samsung way
partition footer
/dev/socket/vold
trustlet vold vdc
trustlet
trustlet
mobicore
kernel
TEE
Saturday, September 28, 13 27
Samsung way
partition footer
/dev/socket/vold
trustlet vold vdc
/dev/ashmem/secure_storage_ashmem
trustlet
secure_storage_daemon
trustlet
mobicore
kernel
TEE
Saturday, September 28, 13 27
Samsung way
partition footer
/dev/socket/vold
trustlet vold vdc
/dev/ashmem/secure_storage_ashmem
trustlet
secure_storage_daemon
trustlet /dev/mobicore
/dev/mobicor-user
libMcClient.so
mobicore mckernelapi
kernel mcdrvmodule
/dev/socket/vold
trustlet vold vdc
/dev/ashmem/secure_storage_ashmem
trustlet
secure_storage_daemon
trustlet /dev/mobicore
/dev/mobicor-user
libMcClient.so
mobicore mckernelapi
kernel mcdrvmodule
mcOpenDevice
mcMAllocWsm
mcMap
mcOpenSession
mcNotify
mcWaitNotification
mcOpenSession
mcOpenDevice
mcMAllocWsm
mcMap
mcOpenSession
mcNotify
mcWaitNotification
mcOpenDevice
mcMAllocWsm
mcMap
mcOpenSession
mcNotify
mcWaitNotification
mcOpenDevice
mcMAllocWsm
mcMap
mcOpenSession
mcNotify
mcWaitNotification
• But now we just would like to be able to - at least - offline brute-force the
password
• But now we just would like to be able to - at least - offline brute-force the
password
m u c h s im p le r wa y!!
We have a
DEMO
Saturday, September 28, 13 32
Samsung way
/data/system/edk_p_sd
/data/system/edk_p_sd
• The format of the file is the same as the partition footer or the /efs/metadata
/data/system/edk_p_sd
• The format of the file is the same as the partition footer or the /efs/metadata
...
...
...
DEMO
DEMO
DB LINK
ORACLE1 ORACLE2
• It is a good idea to cleanup the keys and passwords from the memory
• It is a good idea to cleanup the keys and passwords from the memory
• It is a good idea to cleanup the keys and passwords from the memory
• Now - after a proper backup - you can mount your encrypted SD card
• It is a good idea to cleanup the keys and passwords from the memory
• Now - after a proper backup - you can mount your encrypted SD card
• http://www.sensepost.com/blog/9114.html
• https://viaforensics.com/
• http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/
140sp1632.pdf
• https://hashcat.net/forum/thread-2270.html
• https://source.android.com/devices/tech/encryption/
android_crypto_implementation.html