Nexus 7: A hackers toolkit. Part 3 – WEP cracking and MAC Spoofing

In the previous posts we looked at how to use a modified Nexus 7 to gain access to a WPA secured network by cracking the WPA handshake or by exploiting WPS. Now it is somewhat of a rarity to see WEP networks in existence these days, however for the sake of completeness this guide will look at how we can attack these networks. We will also look at how we can bypass MAC filtering.

TL:DR – Never use WEP

Disclaimer: the author and contributors to this document will accept no responsibility for the consequences of the actions of individuals concerning wireless networks. Penetration testing networks other than your own may be illegal in your country. It is your sole responsibility to act in compliance with all relevant legislation and regulations.

Wired Equivalent Privacy (WEP) is a RC4 stream cipher, which means a key is used to seed a pseudo-random keystream which is used for encoding (similar to a one-time pad). Because the keystream is not truly random it means the same key cannot be used twice to seed. Otherwise the key can be calculated by gathering enough data.

To combat this shortfall an Initialisation Vector (IV) is transmitted from the router to the client to add to the key so that it is not a constant value. The IV makes up 24 bits of the seed with the key making up the rest (either 36 bits or 100 bits depending on if we are using 64 bit or 128 bit WEP). Unfortunately 24 bits is not enough randomness for a busy network and there is still a 50% probability of a duplicate key after 5000 packets.

Because the first few bytes of a header of a packet are known or predictable (similar to how enigma was cracked) then it is possible to work out the key once we capture enough packets. Using the IV’s we can guess each letter of the key sequentially rather than having to bruteforce the complete key (see here.

This assumes we’ve got a device setup as discussed in the previous article. Now let’s have a go at this on our demo network:

  1. Enable monitor mode on the wifi interface
  2. Identify the network we are looking to attack
  3. Start listening and capturing ivs
  4. Deauthenticate connected clients to increase capture rate

For a complete guide to running these attacks please refer to the aircrack-ng simple wep cracking guide. For simplicity I will be using the wifite python script. This script handles all of the steps described above without us needing to remember all of the commands, and if you are interested in what is doing in each step you can view the source.

Enable monitor mode on the interface


Find the network to target.


Attack the target using wifite (automatically & recommended) or via aircrack-ng


Now we have the WEP key in plaintext and can use it to connect to the network or decrypt network traffic.

For added security a router can add MAC filtering which only allows devices with set MAC addresses access even once the password is known.

However it is pretty trivial to change the MAC address of our wireless interface and access the network as an imposter. This involves listening to a network to find the MAC address of a connected client and then setting their MAC address as our own.

  1. Find client to impersonate
  2. Disable monitor mode on the wireless interface
  3. Change MAC address of the interface
  4. Profit…

First we need to find a client to impersonate. We do this by using airodump-ng to monitor (assuming monitor mode is already enabled, see above for this step).

airodump-ng -i mon0 -c 5 -b 3C:81:D8:95:6B:EC

Where mon0 is our monitoring interface, 5 is the channel to lock to (optional), 3C:81:D8:95:6B:EC is the MAC address of our target router (optional).


Here we see that a client (AC:7B:A1:5B:CF:11) is connected to our target network (3C:81:D8:95:6B:EC).

airmon-ng stop wlan1

where wlan1 is the wireless interface to stop monitoring on

We can use ifconfig to list information about all the interfaces we have available. This will show us what our current mac address is.

ifconfig -a


macchanger -m AC:7B:A1:5B:CF:11 wlan1

Where AC:7B:A1:5B:CF:11 is the MAC address we want to change to, and wlan1 is the wireless interface we wish to change the MAC address of.


Now when we run ifconfig again we will see that the MAC address has changed

ifconfig -a


And voila! Your interface is now an imposter. Trying to connect to a MAC filtered network is not an issue as you have an approved MAC address.


This handy trick can be used to bypass time restrictions that some routers use to restrict internet usage to 30 mins or so before trying to make you pay. Change the MAC address, you appear as a new user.

We have shown how trivial it is to crack WEP keys and gain unauthorised access to a wireless network and how to bypass a MAC address filter if one is in place.

Read More

Nexus 7: A hackers toolkit. Part 2 – WPS hacking

In the last post we looked at how to obtain WPA handshakes and how to crack them in order to obtain the password using a modified Nexus 7. Now we will look at a simpler way to get the password by exploiting a vulnerability found in many routers.

TL:DR – disable WPS on your home router!


Disclaimer: the author and contributors to this document will accept no responsibility for the consequences of the actions of individuals concerning wireless networks. Penetration testing networks other than your own may be illegal in your country, it is your sole responsibility to act in compliance with all relevant legislation and regulations.

Wifi Protected Setup (WPS) is used to simplify setting up wifi networks by bypassing the need to know a complicated password. There are two main types of WPS; 1. Push button – Where a button is pressed on the router and the client device 2. Pin – Using an 8 digit number to bypass needing a complex password. Both WPS types can be seen in the images below:



We will be exploiting the pin method of WPS. Once you know the correct 8 digit pin the router will spit out the password in plain text.

So you’d think that with an 8 digit pin there would be 10^8 combinations, which would take a while to brute force as most routers can typically handle 1 guess every 10 seconds. However there are a few pitfalls with the implementation.

Our first win is that the last digit of the 8 digit number is a checksum of the previous 7 numbers. So that’s only 10^7 combinations… still a lot.

The second pitfall of the implementation is that the 8 digit pin is checked in two halfs, so you will be told when the first half is correct and then if it is, it will go on to check the second half.

So this means that you have 10,000 combinations for the first half, and then just 1000 combinations for the last half. This means you can brute force the combination in less than 11,000 attempts.


This assumes we’ve got a device setup as discussed in the previous article. Now let’s have a go at this on our demo network:

  1. Enable monitor mode on the wifi interface
  2. Identify the network we are looking to attack
  3. Run a wps attack against this network (Reaver or Bully)

Monitor mode allows us to listen to the raw packets coming into the wireless interface. We can start or stop monitor mode using airmon-ng.

airmon-ng start wlan1

where wlan1 is the interface we want to start monitor mode on.


Using aerodump-ng we can see the wireless network in range and some information about them.

airodump-ng -i mon0

Where mon0 is our newly created monitoring interface. There are lots of switches for airodump -c 1 for instance would lock the channel to 1 (see help for more airodump-ng –help).


Here we can see the ‘Intohand_Demo’ network we are looking for. Now we can use this information to start guessing WPS pins.

reaver -i mon0 -b 3c:81:d8:95:6b:ec -vv

where mon0 is the monitor mode interface to our wireless device, 3c:81:d8:95:6b:ec is
the MAC address of the router we are attacking, and -vv instructs reaver to be very verbose.


This will churn through all the possibilities (starting with a few common ones then sequentially). When we get the first 4 digits of the pin incorrect we only see messages 1 to 4, when this changes to get 5 and above the first 4 digits are correct.


When the pin is guessed correctly, the router will spit out the password in plaintext. Too easy right?!

Once the pin is known, if the user changes the password we can simply run reaver again, this time already knowing the correct pin and the new password will be revealed to us.

reaver -i mon0 -b 3c:81:d8:95:6b:ec -vv -p 27319734

Where 27319734 is the WPS pin to try.

Newer routers have a WPS lock out mode when they detect brute forcing attempt, which block WPS attempts for 5 mins to 1 day (Depending on model). This makes the bruteforcing take days to weeks rather than hours. Sometimes this lockout is MAC specific so it is possible to bypass this by changing mac address of our wireless interface. It can also be possible to force the router to restart by using a DOS style attack using MDK, however I’ve not had much success using this tool.

Some routers have attempted to bypass this method of brute forcing by using invalid pins. I.E Where the checksum is invalid. This increases the keyspace from 11,000 to 100,000. This dramatically increases the time it will take to crack a WPS pin, but does not prevent it entirely.

The best defence against WPS attacks is simply to disable WPS on your router.

It can still take a long time to crack a WPS pin, but thankfully some router manufacturers have made it easier for us. TalkTalk, a UK ISP, are a super cheap broadband provider and also it seems they have a flaw in the way the WPS pins are created.

On many routers the default ESSID (network name) has a string of randomly generated characters at the end, to avoid multiple networks with the same name. But this seemingly random string is actually the last 6 characters of the MAC address of the router. And now the security flaw: The WPS pin is calculated from the last part of this MAC address.

Extract partial MAC address from ESSID
Convert to decimal & limit to 7 digits
Calculate checksum (for last digit) & append to end
And here is a python script that can do that for you!

$ python talktalk_wps_pin_calc.py
Essid: TALKTALK-33A3C0
WPS Pin: 33842561

We have demonstrated a devastating attack on WPS enabled networks which reveals the plaintext password in a relatively short amount of time, all using the Nexus 7. Hopefully this has convinced you to disable WPS on your home and work WiFi routers.

Read More

Nexus 7: A hackers toolkit. Part 1 – Setup and hacking WPA networks


This is the first of a series of posts where we will take an old Nexus 7 (2012 wifi) and convert it into a compact penetration testing toolkit. In this first article we’ll setup and install the Nexus 7 tablet and complete our first penetration test on a secure WPA network. It should make a good showcase for the flexibility and extensibility of the Android operating system.

This will be done by installing custom linux chroot onto our device and taking advantage of the freely available penetration testing tools that are available. We will then perform some basic penetration testing against our demo wireless networks in order to demonstrate the importance of understanding network security.

Disclaimer: the author and contributors to this document will accept no responsibility for the consequences of the actions of individuals concerning wireless networks. Penetration testing networks other than your own may be illegal in your country, it is your sole responsibility to act in compliance with all relevant legislation and regulations.

There is a choice of two popular distributions, both are built on the Kali Linux distribution – each with their own advantages and disadvantages, but with identical core functionality.

Kali Linux NetHunter https://www.offensive-security.com/kali-linux-nethunter-download/

  • Supports newer version of android (4.4.4)
  • Offers an additional toolkit with a simple graphical interface that can carry out sophisticated attacks (HID Attack, BadUSB)


Pwnie Express Community Edition https://www.pwnieexpress.com/community/

  • Easier shortcuts to commonly used command line tools



  • Unlocking the bootloader will wipe all your data. So ensure your data is backed up before you start!
  • Although this process is reversible it can void your warranty

First you will need a compatible device. This will depend on which distro you decide to go with.

For Pwnie Express (https://www.pwnieexpress.com/community/ )

  • Nexus 7
  • Nexus 5

For Kali Linux NetHunter (https://www.offensive-security.com/kali-linux-nethunter-download/ https://www.kali.org/kali-linux-nethunter/)

  • Nexus 10
  • Nexus 7
  • Nexus 5
  • OnePlus One


USB OTG Y-cable – You can use just a standard OTG cable however using a Y-cable allows us to charge the device at the same time as using a usb peripheral. Note that while the device will charge and the battery percent will increase the charging indicator may not show.

USB ethernet adapter – This allows us to connect the android device to a network via ethernet. I have had mixed success in using this as sometimes the device doesn’t seem to want to register on the network.

USB wifi adapter – It is important to select a wifi adapter that supports monitor mode. The TP­Link TL­WN722N is recommended.

Using a small amount of velcro tape we can attach the wifi and ethernet adapter to the back of the device which makes it easier to move around without accidentally unplugging them.


To install NetHunter or Pwnie Express you must first unlock the bootloader and root the device. This is explained in the respective guides, but is very similar to flashing custom roms (such as cyanogen) onto a device.


  1. Download the correct image for your device https://www.offensive-security.com/kali-linux-nethunter-download/
  2. Follow this guide to install https://www.nethunter.com/prepare/

Pwnie Express

  1. Ensure your device is running android 4.2.2, otherwise this will not work! Please downgrade to this version before continuing. You can find the factory images for Nexus devices here https://developers.google.com/android/nexus/images
  2. Download the correct image for your device and follow the installation guide here https://www.pwnieexpress.com/community/

Now we have our device set up it’s time to get to the good stuff! Below is a condensed list of some of the tools available to us:

  1. Aircrack-ng – a collection of wifi hacking tools
  2. airodump-ng – Sniffing tool
  3. aircrack-ng – Cracking tool (WEP/WPA2)
  4. airmon-ng – enabled/disables monitor mode of wireless devices connected
  5. besside-ng – useful script for capturing WPA handshakes however I’ve not had success getting it working on my Nexus 7.
    many more tools in this package, see https://www.aircrack-ng.org/ for details.
  6. Dsniff – Script that watches an interface and scans for passwords and other sensitive strings
  7. EvilAP – Script that creates an access point and allows clients to connect to it in order to perform man-in-the-middle attacks between the client.
  8. Kismet – Sniffing tool similar to airodump
  9. MAC Changer – changes the mac address of interfaces
  10. Nmap – Powerful port scanner and OS-fingerprinting tool
  11. Tshark – command line version of wireshark for packet capture and analysis
  12. Strings Watch – Script that watches an interface and scans for strings
  13. Wifite – Python script that automates wireless attacks
  14. Ubertooth – bluetooth sniffing tool

Note that as we are running kali linux distro we can download more packages via the package manager (apt), but I have had mixed success with this.

Often we assume that our private wifi networks are secure just because they use a password and as a result sensitive information may be readily available to anyone able to connect/listen to the network. Let’s have a quick look at the wifi tools we can use to defeat basic wireless security.

There are two common types of security employed on wireless networks: Wired Equivalent Privacy (WEP) and Wi-Fi Protected Access (WPA). WEP has several flaws in it’s implementation and was not intended to be robust to attack, fortunately this has meant that it’s popularity has decreased significantly in recent years and now it is somewhat of a rarity to see WEP networks.

WPA is much more secure and only really vulnerable to dictionary attacks. These dictionary attacks can be performed offline by capturing the 4 way handshake as a client connects to the router.

To capture a handshake we need to do the following

  1. Put the wireless interface into monitor mode (so it can sniff networks)
  2. Select a network to attack
  3. Sniff the network until a handshake is sent (sent each time a client connects)
  4. Optional: Deauthenticate clients so they must reconnect (and thus send another handshake). This massively speeds up the capture.

Thankfully the wifite script will perform all of these steps for us, which is great considering typing on the Nexus 7 can be time consuming.




Now we have the handshake but brute forcing a password is somewhat beyond the power of our little Nexus 7’s hardware (although we could use a small dictionary). However there exist dedicated and distributed hardware / services that can do this for you we just need to upload the handshake to a website. We look at a couple below:

https://wpa-sec.stanev.org/(Free) This is a distributed network of volunteers running a cracking service for free in the interest of promoting better security. You upload the handshake files and it will be tested against several dictionaries. The statistics page shows that about 15.5% of submitted networks are successfully cracked.

https://gpuhash.me(Paid) – This is a cracking service that charges bitcoins for attempting to crack a handshake. If you know the keyspace used by the key (say a default router password) then this can be very cost effective. For example Sky Routers use an 8 uppercase letters (A-Z), this costs 0.25BTC (current valued at about £40). However if the password has changed from the default then the cracking will be unsuccessful, however many users don’t change their password from the default. Helpfully they show the success rate of each dictionary in the FAQ section on the site.

https://www.cloudcracker.com(Paid) – Another cracking site that accepts credit card payments and offers numerous dictionaries.

By uploading this handshake file to wpa-sec.stanev.org the password to our network is cracked in minutes. Turns out the password to our wifi network was ‘password1’…


We’ve dusted off a rather old device going unused and turned it into a very powerful security auditing tool and demonstrated how to capture a WPA handshake in order to brute force the password. Pretty neat.
In the next post we’ll look at exploiting Wifi Protected Setup (WPS) as a quicker and potentially cheaper method of gaining access to WPA protected networks.

Read More

Review of day 1 of droidcon uk 2010 (barcamp sessions)

Below is a short overview of some of the stuff that I saw a droidcon today (Day 1: Barcamp), I was hoping to write more but it’s late and I can always update this post. Apoloigies to those who I did not manage to get the names of, I can update this post when I find out who you are 😛

As this is quite a long post here is a mini table of contents to speed it up:


Barcamp schedule (sorry for crap pic)

Barcamp schedule (sorry for crap pic)

Git on android

This was a really surprising talk, just by the name it’s a little confusing as to why this would be useful but it was a really good talk. A guy from who works at the guardian (need to find name) walked through all the problems he came across when trying to use git on android and how using open source goodness he could simplify a lot of trouble by simply extending pre-written code and even create work arounds for troublesome bugs.

It was a very interesting talk just to see how everything had fitted together and to see a demo of some sexy git-based syncing, including using some ssh agents securely.

Swing me

Draft still…too tired to write.
A single UI widget toolset that can easily be ported to other operating systems. Uses guestures pinch zoom all the things you would be used to. Non-android specific code and can specify protocols nicely to cooperate with different devices. Removes hassle on behalf of developer, debug using xml, then switch to binary mode for performance
Difference between keys on certain phones… assign buttons, like “back” as a button on phones with dedicated back buttons ie nokia soft key hidden and at bottom, android will hide it and use android hardware back button. IE. unhidden back button not hidden (good solving of problem)

Problems with accessing core bits of anroid but private/protected stuff. Radio easy but problem with tick box.
Missing clipboard (almost finished, work on android, symbian, desktop… lol @ apple)
Still use native android based stuff

Google Bootcamp 1

So there were four google guys present to answer the questions and complaints of the developers and one to pass the microphone around.

Google Barcamp 1

Google Barcamp 1

Someone asked when Gingerbread was going to be released and Reto Meier answered by not confirming anything regarding the release date, be it this year or next. He even went as far as to say that he couldn’t confirm gingerbread’s existence, despite the rather large statue outside building 44

Roman was asked a question about the Action bar and if it was going to become a standard widget in the android apk, he said that it wasn’t currently part of the widget set and couldn’t confirm when it would be added.

Reto mentioned about in app purchasing and said google was looking into other method to monetise can’t comment on specifics. However in app purchasing currently is against the google TOS, so you might want to be careful if your app has this and is distributed via the google market. Of course this is fine to do if released on to another app store such as and app, doubtful that orange and vodaphone app stores would be so generous.

Google tv was mentioned and how to write android on it. Currently only html 5 / web stuff but as it is based on android the plan is to be compatible. So we are waiting for compatability hopefully sometime next year. The google tv’s should receive market via OTA updates so there will probably be no need for OEM manufactures to get in the way. Media server such as a upnp server, status is currently unknown.

In app google analytics was mentioned and another barcamp talk was refered to which unfortunatly I missed, if anyone went to this and has written it up I am happy to add the link in here.

In app logic – services/content providers global = bad, shared prefs, instance state mainly for UI shiz. setters/getters saved pref/database on logic. check if its been set etc. roman/reto

Someone briefly asked about adverts without using the internet permission and instead using an addon/plugin which did access the internet. Currently it seems this is not possible at the moment but is something they may look into in the future.

Have I missed off any of the other topics discussed during this bootcamp, if so let me know!

Alternative Markets

Draft still…too tired to write.
Vodaphone – incentive – random draw to win a htc legend. 30 70 split
Orange – 30 70 again (yawn) want good apps, as many as possible pay via phone bill, no registeration, france/uk last year. need several countries/languages arabic/african etc.
Nokia – no alternative operators, content agregator, locilzation/adaptation/uploads etc… Sensing, in app billing

Individual / OS devs fetching market data/pulling to diff apps sotres as we dont have the time to move to diff places

App stores share with other stores, very nice
Orange apps tied to network you lose them if you move 🙁

Meta-Market Model

This talk tied in very nicely with problems regarding using alternative markets discussed in the previous talk. Mark Murphey (Commonsware) discussed an alternative to writing open letter to google (as was discussed via email) about the android market. He created a brain stroming session on the market problems and what can we can do as a community to help improve this for ourselves (devs) and for users.

Mark Murphey Meta Markets

Mark Murphey Meta Markets

Some of the good problems highlighted by people were:

  • Comment spam, and no way to “Reacting to punters” or dealing with users who are “dissing” all apps
  • Not enough screenshots / descriptions / add videos etc…
  • Searching the market is terrible (My contribution)
  • Analytics
  • Email messages about cancelled users every time
  • Refund policy too leaniant
  • Option to explain the reason behind each permission as users don’t know what’s going on when you can’t fit an explanation in the description
  • Better rating levels, UI/UX etc.
  • Downloads don’t work

The market on android is improving at a “Glacial pace” and even though there was some sexy stuff demonstrated at Google IO 5 months ago we are still waiting to see the improvements, such as a web based market that can push applications to devices.

There was also a good discussion about the websites that scrape data from the android market (appbrain, cryket, androidzoom)which is kinda sketchy territory as it is probably against TOS of android, kinda counting as pirated data. There is even a google code project to fetch the data from the android market.

Data goes in data doesn’t come out
Pirated data not supported by data cant rape data from market.

So what makes this presentation more than just a compaint about the android market?
Market is a closed club, OEM’s who don’t agree to the rule book don’t have access. And simply creating a app store for each carrier/OEM etc. isn’t a viable solution which Mark summarised with a brilliant quote: “those who complain about fragmentation you ain’t seen nothing yet”.

So Mark has come up with an idea about having a single open feed of android applications that all the market applications can hook into. So this would work as some sort of extended atom/rss feed (just add namespace) with open access which could benefit from the standards introduced and the maturity of the software already written. This sounds like a great idea but will obviously need a large amount of momentum to succeed, Mark is obviously a major player in the android field and this proposal was backed up by the developer of AndAppStore.

Mark also mentioned that even market owners who were unwilling could be worked-around using a firefox plugin to remove most of the leg work. So this would mean that developers can have a single place where they have the app description, screen shots, all the minimums required for android market but more for those who support more.

To wrap up mark said that instead of us complaining at google to fix the market we should fix the market problems ourselves. At the end of the session Mark was collecting email addresses to create a mailing list with regards to the start of this process.

How I do it

Kevin McDonagh of Novoda gave some brilliant tips and tricks for writing android applications. I’ve written some of them up, but hopefully he will publish his whole list online (hint hint…)

public void onLowMemory(){
// Code to execute on low memory
// Free up unused drawables etc.
  • Use weak references
  • Avoid Generics, use primitives where possible
  • Clean up drawables onPause()
  • Use the heirachy viewer

Kevin also mentioned some stuff which I’m sure I should have come across before but for some reason I was still oblivious to.

Extending styles to avoid having to retype android:height=”wrap_content” etc. on every item.

There was some good discussion on the conventions for android:versionCode and android:versionName and someone mentioned very helpfully that versionName appears in the market description and is limited only to 255 chars, which means you can add additional versioning changes into this (shown below a screen shot of nexus revamped in the market with the versionName highlighted).

android:versionName displayed in android market

android:versionName displayed in android market

Apps for good
Apps for good is a charity that gets a group of people between the ages of 18 and 25 and gives them the resources and skills required to create an application that can benefit society. Once students have finished the course they often go on to mentor the next batch of students.

The apps they have already produced on this scheme are Stop and Search StudentVoice StudioPhly and they discussed a up and coming app they are working on currently so that the balance of an oyster card can be checked via a android device so that you are never caught out.

They are looking for help so if you are feeling charitable I am sure they would appreciate your input or if you know of anyone 18-25 who would like to go on the course, please inform them of the opportunity.

Google Barcamp 2

Ok, so this barcamp was delayed and I think alot of the better questions were already asked, that in combination with my laptop battery dying mean I have less notes and worse memory about this one.

Google Barcamp day 2

Google Barcamp day 2

Bundling several apps into one installer apk, currently not possible. Could be achieved by having a program that sends intents to install other apps, or by having one large app with serveal launcher items in the app menu.

Tips from tech hub:

  • Devs arn’t always design focussed, should assume users are complete idiots and don’t understand anything.
  • Ported apps don’t act in an android style – back button doesn’t close etc, as devs don’t understand application lifecycle

App Circus
So app circus had a bit of a disappointing number of contestants, about 6 I think it was in total hopefully next time there will be more. The winners were

  • 1st: Swiftkey
  • 2nd: — Blind something? Sorry forgot the proper name
  • 3rd: ProductPay


Coding in a hammock and drinking beer

Coding in a hammock and drinking beer

I also met a lot of very interesting people and plan on meeting a whole load more tomorrow!

Read More

Cracking real world salted MD5 passwords in python with several dictionaries

Recently a friend (who will remain unnamed for obvious reasons) asked me to penetration test a website he created. I found a very simple exploit where I could upload an avatar but the file was not checked to ensure it was an image, so I uploaded a php script I wrote an began exploring the server. I printed out all of the usernames, passwords and salts from the database to see how many of the 1,109 passwords could be easily cracked.

The passwords were stored as MD5 hashes with a random 6 character alphanumeric salt. To create the MD5 hash of the password the salt was prefixed to the password and then the combination was hashed. Thanks to this method we can employ a simple bruteforce/dictionary attack on the passwords. I will start with the wordlists creation, then results I obtained to keep your interest, and finally show my python code.

Creating wordlists
I already has two reasnoble sized dictionaries that I use for different things like wordcube. I used john the ripper on my double sized dictionary to create lots of common permutations on words, such as captial first letter, and a number affixed to the end. To do this you run john with the following parameters, where dic.txt is the input dictionary and dic_plus_rules.txt is the output from john with all of the additions it has made.

john –wordlist=dic.txt –rules –stdout > dic_plus_rules.txt

I also download two wordlists from openwall, one which is a list of ~3100 common passwords, and one labelled ALL that has a large amount of words (~4 million) in various languages. Because of the highly compressible nature of text the files are available in small gzip files. ALL is 11.5Mb which unzips to 41.4Mb and password 12kb which unzips to 21.8kb. There are also more wordlists avaliable for different languages, but the ALL file includes these.

The size of all of the wordlists I used is shown below:

Dictionary Combinations
English 42,987
Double-English 80,368
Double+john-rules 3,986,706
Openwall Common Passwords 3,158
Openwall ALL 3,917,116


Dictionary Cracked Percentage Time
English 60 5.41% 80s
Double-English 65 5.86% 170s
Double+john-rules 116 10.46% 2.5hrs (8393s)
Openwall Common Passwords 112 10.10% 7s
Openwall All 210 18.94% 2.45hrs (8829s)
Total Passwords Obtained 254 22.90% ~5hrs

Comical passwords

Here are some of the more amusingly bad passwords, the number in brackets shows the frequency of the password.

Crap passwords: 123456 (18), password (4), 1234567 (4), 123456789 (3) 12345678 (2), 12345 (2), abc123 (2), asdfgh (2), nintendo (2), 123123, abcd1234, abcdefg, qwerty
Self-describing passwords: catholic, cowboy, creator, doger, ginger, killer, maggot, player, princess, skater, smallcock, smooth, super, superman, superstar, tester, veggie, winner, wolverine
Some other passwords:bananas, cheese, cinnamon, hampster ,DRAGON, dribble1, poopie, poopoo

Python Program

# -*- coding: utf-8 -*-
import hashlib, sys
from time import time

# Change to commandline swtiches when you have the time!
hash = ""
hash_file = "hash2.csv"
wordlist = "mass_rules.txt"; 

# Read the hash file entered
	hashdocument = open(hash_file,"r")
except IOError:
	print "Invalid file."
	# Read the csv values seperated by colons into an array
	for line in hashdocument:
		inp = line.split(":")
		if (line.count(":")<2):

# Read wordlist in
	wordlistfile = open(wordlist,"r")
except IOError:
	print "Invalid file."

tic = time()
for line in wordlistfile:
	line = line.replace("\n","")
	for i in range(0,len(hashes)):
		m = hashlib.md5()
		word_hash = m.hexdigest()
		if word_hash==hashes[i][1]:
			toc = time()
			print hashes[i][0]," : ", line, "\t(",time()-tic,"s)"

	# Show progress evey 1000 passwords tested
	if tested%1000==0:
		print "Cracked: ",cracked," (",tested,") ", line

# Save the output of this program so we can use again 
# with another program/dictionary adding the password 
# to each line we have solved.
crackout = open("pycrackout.txt","w")
for i in hashes:
	for j in i:
		if s!="":

print "Passwords found: ",cracked,"/",len(hashes)
print "Wordlist Words :", test
print "Hashes computed: ",len(hashes)*tested
print "Total time taken: ",time()-tic,'s' 


  • Play with more dictionaries
  • Speed up code:
    • Add multi-threading: My experience with multi-threading in python is that it doesn't work well for cpu intensive tasks, if you know otherwise please let me know.
    • Have a look at PyCUDA to see if I can use my graphics card to speed up the code significantly (another type of mutli-threading really...) without having to change language like in my previous post of CUDA MD5 cracking
  • Remove hash once found to stop pointless checking
  • Add command line switches to all it to be used like a real program
Read More

Cracking MD5 hashes (or passwords) ultra-fast with GPU acceleration

Do you want to crack MD5 hashes in at a rate of ~300MHash/s without a massive rainbow table? Do you have a CUDA enabled GFX card? If you said yes or maybe to these questions then read on for a brief introduction on how to compile and run a CUDA accelerated MD5 cracker (coded by Benjamin “Titan” Vernoux ).

Pre-Requisites and Downloading

Building in Ubuntu 10.04

Extract the archive and do a make on the source code. When doing this I came across two problems that can be fixed by modifying the common.mk file.

Problem 1: (cannot be declared weak)

$ make
/usr/include/string.h:43: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak
/usr/include/string.h:64: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak
/usr/include/bits/string3.h:49: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak
/usr/include/bits/string3.h:78: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak
/opt/cuda/bin/../include/common_functions.h:59: error: inline function ‘void* memset(void*, int, size_t)’ cannot be declared weak
/opt/cuda/bin/../include/common_functions.h:62: error: inline function ‘void* memcpy(void*, const void*, size_t)’ cannot be declared weak
/opt/cuda/bin/../include/math_functions.h:422: error: inline function ‘int __signbit(double)’ cannot be declared weak
/opt/cuda/bin/../include/math_functions.h:427: error: inline function ‘int __signbitf(float)’ cannot be declared weak
/opt/cuda/bin/../include/math_functions.h:440: error: inline function ‘int __signbitl(long double)’ cannot be declared weak
/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbit(double)’ cannot be declared weak
/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitf(float)’ cannot be declared weak
/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitl(long double)’ cannot be declared weak
/usr/include/bits/mathinline.h:36: error: inline function ‘int __signbitf(float)’ cannot be declared weak
/usr/include/bits/mathinline.h:42: error: inline function ‘int __signbit(double)’ cannot be declared weak
/usr/include/bits/mathinline.h:48: error: inline function ‘int __signbitl(long double)’ cannot be declared weak

Solution 1

# Debug/release configuration
ifeq ($(dbg),1)
BINSUBDIR := debug
##############Change the following line to have -O0 instead of -O2
BINSUBDIR := release
NVCCFLAGS += –compiler-options -fno-strict-aliasing
CXXFLAGS += -fno-strict-aliasing
CFLAGS += -fno-strict-aliasing

Problem 2: (lcudart)

$ make
/usr/bin/ld: skipping incompatible /opt/cuda/lib/libcudart.so when searching for -lcudart
/usr/bin/ld: skipping incompatible /opt/cuda/lib/libcudart.so when searching for -lcudart
/usr/bin/ld: cannot find -lcudart
collect2: ld returned 1 exit status
make: *** [bin/linux/release/gpu_md5_crack_0.2.3] Error 1

Solution 2

############## Change lib to lib64 if using a 64 bit operating system

Remember that you should “make clean” in-between each attempt to compile.


Once it has compiled nicely you can give it a testdrive with its build in benchmark (with an NVIDIA 260 GFX card). Just run with the -b option:

./gpu_md5_crack_0.2.3 -b
GPU_MD5_Crack v0.2.3 09 July 2009 LGPL for BackTrack 4.
Copyright (C) 2009 TitanMKD ([email protected]).

Benchmark Start
Using default CUDA GPU device:0
Cuda device ID:0, Device name:GeForce GTX 260, supporting CUDA:1.3,
multiProcessorCount:27, clockRate:1466.00 MHz, TotalMem:895.31 MB
******* Test 0 Start *******
Expected Password: 1234567890
MD5 Hash:e807f1fcf82d132f9bb018ca6738a19f, Start Password:1200000000, Total pwd to check:1000000000
Charset used 0:0123456789
MD5 brute force started

MD5 Cracked pwd=1234567890 hash=e807f1fcf82d132f9bb018ca6738a19f
Instant 200.02 Mhash/s(40.00 ms)
Average 190.49 Mhash/s, Total Time:0.21s(210.00 ms)
MD5 brute force finished
******* Test 0 End *******

******* Test 1 Start *******
Expected Password: azerty
MD5 Hash:ab4f63f9ac65152575886860dde480a1, Start Password:, Total pwd to check:1000000000
Charset used 1:abcdefghijklmnopqrstuvwxyz
MD5 brute force started

MD5 Cracked pwd=azerty hash=ab4f63f9ac65152575886860dde480a1
Instant 200.02 Mhash/s(40.00 ms)
Average 240.02 Mhash/s, Total Time:0.10s(100.00 ms)
MD5 brute force finished
******* Test 1 End *******

******* Test 2 Start *******
Expected Password: azer09
MD5 Hash:41b9cabe6033932eb3037fc933060adc, Start Password:, Total pwd to check:1000000000
Charset used 2:abcdefghijklmnopqrstuvwxyz0123456789
MD5 brute force started
Progress 5%, Pwd:6lmea, Instant 280.02 Mhash/s(28.57 ms)
MD5 Cracked pwd=azer09 hash=41b9cabe6033932eb3037fc933060adc
Instant 266.69 Mhash/s(30.00 ms)
Average 287.20 Mhash/s, Total Time:0.39s(390.00 ms)
MD5 brute force finished
******* Test 2 End *******

******* Test 3 Start *******
Expected Password: AZBVSD
MD5 Hash:fd049008572788d60140aaead79336cc, Start Password:, Total pwd to check:1000000000
MD5 brute force started

MD5 Cracked pwd=AZBVSD hash=fd049008572788d60140aaead79336cc
Instant 266.69 Mhash/s(30.00 ms)
Average 240.02 Mhash/s, Total Time:0.10s(100.00 ms)
MD5 brute force finished
******* Test 3 End *******

******* Test 4 Start *******
Expected Password: AZ09AA
MD5 Hash:7a552dd9cdd49acc5320bad9c29c9722, Start Password:, Total pwd to check:1000000000
MD5 brute force started
Progress 5%, Pwd:6LMEA, Instant 266.69 Mhash/s(30.00 ms)
MD5 Cracked pwd=AZ09AA hash=7a552dd9cdd49acc5320bad9c29c9722
Instant 266.69 Mhash/s(30.00 ms)
Average 280.02 Mhash/s, Total Time:0.40s(400.00 ms)
MD5 brute force finished
******* Test 4 End *******

******* Test 5 Start *******
Expected Password: zaZAab
MD5 Hash:aef49f70bb7b923b8bc0a018f916ef64, Start Password:zCAAAA, Total pwd to check:1000000000
Charset used 5:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
MD5 brute force started
Progress 17%, Pwd:zaDpoA, Instant 280.02 Mhash/s(28.57 ms)
MD5 Cracked pwd=zaZAab hash=aef49f70bb7b923b8bc0a018f916ef64
Instant 266.69 Mhash/s(30.00 ms)
Average 283.10 Mhash/s, Total Time:0.65s(650.00 ms)
MD5 brute force finished
******* Test 5 End *******

******* Test 6 Start *******
Expected Password: za0ZA9
MD5 Hash:062cc3b1302759722f48ac0b95b75803, Start Password:zaAAAA, Total pwd to check:1000000000
Charset used 6:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
MD5 brute force started

MD5 Cracked pwd=za0ZA9 hash=062cc3b1302759722f48ac0b95b75803
Instant 266.69 Mhash/s(30.00 ms)
Average 266.69 Mhash/s, Total Time:0.06s(60.00 ms)
MD5 brute force finished
******* Test 6 End *******

******* Test 7 Start *******
Expected Password: a^-*|
MD5 Hash:cf7dcf4c3eeb6255668393242fcce273, Start Password:a0000, Total pwd to check:1000000000
Charset used 7: !”#$%&'()*+,-./0123456789:;<=>[email protected][\]^_`abcdefghijklmnopqrstuvwxyz{|}~
MD5 brute force started

MD5 Cracked pwd=a^-*| hash=cf7dcf4c3eeb6255668393242fcce273
Instant 266.69 Mhash/s(30.00 ms)
Average 266.69 Mhash/s, Total Time:0.15s(150.00 ms)
MD5 brute force finished
******* Test 7 End *******

Benchmark End

So from the benchmark you can see that we are getting between 200 and 300 Mhash/s, that is about 250,000,000 hash attempts per second! AMAZING!!!

Number of combinations for different alphabets

Length 0-9 a-z a-z0-9 a-zA-Z a-zA-Z0-9
1 10 26 36 52 62
2 100 676 1,296 2,704 3,844
3 1,000 17,576 46,656 140,608 238,328
4 10,000 456,976 1,679,616 7,311,616 14,776,336
5 100,000 11,881,376 60,466,176 380,204,032 916,132,832
6 1,000,000 308,915,776 2,176,782,336 19,770,609,664 56,800,235,584
7 10,000,000 8,031,810,176 78,364,164,096 1,028,071,702,528 3,521,614,606,208
8 100,000,000 208,827,064,576 2,821,109,907,456 53,459,728,531,456 218,340,105,584,896
9 1,000,000,000 5,429,503,678,976 101,559,956,668,416 2,779,905,883,635,710 13,537,086,546,263,600
10 10,000,000,000 141,167,095,653,376 3,656,158,440,062,980 144,555,105,949,057,000 839,299,365,868,340,000

Estimated time (in seconds) to crack (at 250MHash/s)

Length 0-9 a-z a-z0-9 a-zA-Z a-zA-Z0-9
1 0.00 0.00 0.00 0.00 0.00
2 0.00 0.00 0.00 0.00 0.00
3 0.00 0.00 0.00 0.00 0.00
4 0.00 0.00 0.00 0.01 0.03
5 0.00 0.02 0.12 0.76 1.83
6 0.00 0.62 4.35 39.54 113.60
7 0.02 16.06 156.73 2,056.14 7,043.23
8 0.20 417.65 5,642.22 106,919.46 436,680.21
9 2.00 10,859.01 203,119.91 5,559,811.77 27,074,173.09
10 20.00 282,334.19 7,312,316.88 289,110,211.90 1,678,598,731.74

Full calculations avaliable here: MD5 hash cracking time using GPU accelerated brute forcing

What now?
Well you can crack MD5’s at an extremely accelerated rate, so enjoy doing so responsibly (let your morals guide you :P). You could also explore the source code and make additions as you see fit, I am planning on modifying it to allow an extra parameter so that prefixes can be added if you already know how the password starts. This can be the case when someone has prefixed the password with a known salt.

Read More