Hack android pattern lock

How to bypass pattern lock on Android if you have made `too many attempts`

Note: This is tested on Aakash(AllWinner A13) but you may find the scripts and reference useful

Situation: The attempt to unlock pattern was exceeded, so with no Internet connection and no adb access how to delete the database entries

Solution:

Downloading and burning an image on SD-card

  • Buy one 8 GB SD-card and download GNU/Linux image for Aakash from here.
  • Extract that image using the command
    tar -xvjf 12.10-lxde-bootLogo-0secUboot-expeyes-scilab-on-cloud-sleep1.img.bz2
    
  • You need to burn that extracted image to SD-card. Insert the SD-card in to the SD-card slot slot of your laptop/PC and run this command.
    sudo dd if=12.10-lxde_with_scilab_on_cloud_cleaned.img of=/dev/sdb bs=1024
    

    assuming your SD-card was detected as /dev/sdb

  • Or you can use a simplified GUI ddMaker tool for burning an image.

Booting with GNU/Linux image

  • Insert the SD-card in to the SD-card slot of the tablet and hold the power button until you see Aakash’s boot-splash screen.

Installing required dependencies

  • You need to edit the settings.db file. This is sqlite’s database file. You may need to install sqlite3 on the tablet(GNU/Linux side). You can install it using apt-get. On the terminal type
    sudo apt-get install sqlite3
    

    give the password as 123

Mounting the NAND partition

  • login as root
    sudo -s
    

    give the password as 123

  • Now you need to mount /dev/nande partition in which settings.db file resides.
  • Make a temporary directory for mounting NAND partition
    mkdir -p /root/nande
    

    and mount the nande partition using the command

    mount /dev/nande /root/nande
    

Update sqlite database

  • Now change the directory in which settings.db file resides
    cd nande/data/com.android.providers.settings/databases
    

    Make copy of ‘settings.db’ in case you mess up with the content of a file

    cp -v settings.db settings.db-original
    

    and use the database file

    sqlite3 settings.db
    

    You will get an sqlite3 prompt saying

    sqlite
    
  • Now update the database
    update secure set value=0 where name='lock_pattern_autolock';
    
    update secure set value=0 where name='lockscreen.lockedoutpermanently';
    

    quit sqlite3 interface

    .quit
    
  • Also remove the gesture key file
    rm /data/system/gesture.key
    
  • Unmount the NAND partition
    cd /root
    umount /dev/nande
    
  • poweroff the tablet
    poweroff
    
  • Remove the SDcard and boot into Android

Using automated scripts

  • If you decide to use the automated scripts from github, you may also need to install python-pysqlite2. This is python interface library for sqlite3. The command to install is
    sudo apt-get install python-pysqlite2
    
  • Copy both the scripts to /root directory of the tablet(GNU/Linux side) and execute the shell script pattern_unlock.sh
    cd unlock_android_pattern
    bash ./pattern_unlock.sh
    
  • Shutdown the tablet, remove the SD-card and restart it again. Your pattern lock mush have disappeared by now.

Additional commands(sqlite3)

  • View description of table
    pragma table_info([table_name])
    

    for example

    pragma table_info([secure])
    
  • list all the tables in the database
    .tables
    

FOR EDUCATIONAL PURPOSE ONLY!. We do not hold any responsibility if you brick your phone/tablet.

  • dhanancheyan

    hi my akash tab bought on 2012 has locked up. it is not even connecting to wifi and is asking to sign in with playstore id and password. i tried to open it but it does’nt even at the right information. can u tell me a easy and fast way to open it. please also tell me how to upgrade it from 2.3.6 gingerbread to ics or jellybean with root

  • @2f1b84223c6f5b729f1b33042dec0801:disqus Have you tried with open wifi network? If not try once.
    If not you can contact datawind for instructions to re-flash your version of Aakash.
    Please tell more about your present version of Aakash. I mean processor, RAM etc

  • This is why I wrote this tutorial. Fastest way to bypass lock-pattern is; boot into linux and try running

    rm /data/system/gesture.key

    Sometimes, this alone solves the problem. Else you need to follow the whole tutorial.

  • Please ask questions related to above post here. For Aakash, contact aakashlab@cse.iitb.ac.in