Cracking Android Pattern Hash
#4
Hi budabob07,

I don't think that there is something special w/ the pattern hashes... Maybe the only thing that you could argue is that they are (ALSO) special insecure...
I mean, it is correct that they use sha1 and that the security model should prevent someone to dump the content of gesture.key in /data/system/, but otherwise there is no sign of security... no salt.. iterations etc. NOTHING...

Therefore, they are plain sha1 hashes... and I do *not* think that atom should add something specific for those hashes.
Warning: I have a custom rom, therefore it could be different for someones stock rom. I do not know.

Why I think it is dangerous only having sha1... I often tell my friends that I have NOT enough credit on my phone, I just want to make a call (iff I don't have credit of course). I could simply take there *rooted* phone, open Android Terminal Emulator, cat /data/system/gesture.key and have the lock pattern... or? YES!

I want to document something here so others can test themself:
Hint: the enumeration is as follows:
0 1 2
3 4 5
6 7 8
1. This should be the widget in question: https://github.com/android/platform_fram...Utils.java
2. Class to handle the lock settings: https://github.com/android/platform_fram...rvice.java
3. My test:
Code:
$ adb devices
$ adb pull /data/system/gesture.key gesture.key01458
$ wc gesture.key01458
0 1 20 gesture.key01458
$ # several test show, that length is ALWAYS 20 (sha1?)
$ cat gesture.key01458|xxd -g1
0000000: ae 93 f0 d3 b7 7f 4a b4 2a 4c 90 de 52 91 a8 a1  ......J.*L..R...
0000010: 9b b6 54 0f                                      ..T.
$ javac PatternLock.java;java PatternLock 01458
ae93f0d3b77f4ab42a4c90de5291a8a19bb6540f
4. The fast written,*not* beautiful,to improve code that generates (hex version of) a test gesture.key file:
Code:
import java.lang.Integer;
import java.security.NoSuchAlgorithmException;
import java.security.MessageDigest;

public class PatternLock {
    public static void printHash(byte[] hash) {
        // a simple dumper, use other Java build-ins instead if u prefer
        int i;
        if (hash.length!=20) {
            System.out.print("[!] Warning: hash length is different than 20...w t f ?");
        }
        for (i=0;i<hash.length;i++) {
            System.out.printf("%02x",hash[i]);
        }
        System.out.println();
    }
    public static void main(String[] args) {
        if (args.length<1) {
            System.out.println("[-] Please specify the pattern as first command line argument, e.g 01234");
            System.exit(1);
        }
        // size check
        String pattern=args[0];
        if (pattern.length()<4) {
            System.out.println("[!] Warning: Android does *not* allow pattern smaller than 4");
        }
        int i,cur_pattern;
        byte[] res=new byte[pattern.length()];
        for (i=0;i<pattern.length();i++) {
            try {
                cur_pattern=Integer.parseInt(pattern.substring(i,i+1));
                if (cur_pattern>=0 && cur_pattern<9) {
                    res[i]=(byte)cur_pattern;
                } else { // we should never be able to enter here !?
                    System.out.println("[!] Warning: The number is *not* within the allowed range");
                }
            } catch(NumberFormatException e) {
                System.out.println("[!] Warning: C'mmon the pattern should be numerical");
            }
        }
        try {
            MessageDigest md=MessageDigest.getInstance("SHA-1");
            byte[] hash=md.digest(res);
            printHash(hash);
        } catch (NoSuchAlgorithmException nsa) {
            printHash(res);
        }
    }
}


Therefore, nothing special for hashcat (and atom, hehe) to do... Maybe Android should do somehing about it!?

You can dump (cat) the gesture.key file and convert it to hex and feet it to hashcat iff you really want....


Messages In This Thread
Cracking Android Pattern Hash - by budabob07 - 03-24-2013, 03:02 AM
RE: Cracking Android Pattern Hash - by atom - 03-24-2013, 08:09 AM
RE: Cracking Android Pattern Hash - by atom - 03-24-2013, 08:10 AM
RE: Cracking Android Pattern Hash - by philsmd - 03-24-2013, 01:31 PM
RE: Cracking Android Pattern Hash - by atom - 03-24-2013, 04:10 PM
RE: Cracking Android Pattern Hash - by budabob07 - 03-25-2013, 02:15 AM