Tuesday, 21 February 2012

Hashcat's Maskprocessor

Work in progress, post still to be fully completed.


Creating wordlists for piping through to oclHashcat.

Maskprocessor is a highly configurable, high performance wordlist generator which can be run under
either Linux or Windows (yay, I can continue to be lazy ;) )
It is blisteringly fast.

Output from maskprocessor can be piped to for instance oclHashcat+ for hash cracking.

Installing maskprocessor on BackTrack 5 ;
apt-get update
apt-get install maskprocessor
However at time of writing (21-02-2012) the version in the backtrack repositories is out of date and missing increment options.
(backtrack's version is v0.65 whereas latest version is v0.67)
With the recently released (01-03-2012) BT5R2 repositories however the latest version 
is included. 

cd /pentest/passwords/maskprocessor/
./mp32.bin --help
./mp32.bin -V






















Info and download latest version ;
http://hashcat.net/wiki/maskprocessor

So download and replace the .bin file in /pentest/passwords/maskprocessor/ directory with the downloaded version your system requires (either 32bit or 64bit).
With the latest version increment options are now available.
./mp32.bin --help
./mp32.bin -V































CREATING WORDLISTS WITH MASKPROCESSOR
As seen in the above help information, maskprocessor comes with several pre-defined charsets as in oclHashcat+, among which;

?l   -- lower case alpha values
?u  -- upper case alpha values
?d  -- numeric values
?s   -- special characters including space

Upto 4 custom charsets can be defined using the switches -1, -2, -3, -4,  for example ;
-1 ?dABCDEF   (0123456789ABCDEF)
-2 QWERTY     (just the letters QWERTY)
-3 ?u123          (uppercase alpha values & 123)
-4 ?l?u?d?s       (lower & upper alpha-numeric-special)

In the below examples I will not be writing to file and just showing the stdout of the command given. 
To actually write the output to file you would simply include the -o switch ; 
./mp32.bin ?d?d?d?d?d?d?d?d?d?d -o wordlist.txt 
Remember that wordlist sizes can quickly become large and impractical.

Creating an 8 character lower alpha wordlist
from aaaaaaaa to zzzzzzzz ;
./mp32.bin ?l?l?l?l?l?l?l?l 























Creating an 8 character upper alpha wordlist
from AAAAAAAA to ZZZZZZZZ ;
./mp32.bin ?u?u?u?u?u?u?u?u 























Creating an 8 character numeric wordlist
from 00000000 to 99999999 ;
./mp32.bin ?d?d?d?d?d?d?d?d 























The masks can be changed to what you may require to either fix certain character values at certain positions
or to have multiple charsets at given positions using custom charset masks.

To create a wordlist with the first 4 characters being numeric values and the last 4 characters being upper case alpha values
from 0000AAAA to 9999ZZZZ ;

./mp32.bin ?d?d?d?d?u?u?u?u























To create a wordlist with lower alpha and numeric values.
(note that the order in which you define the custom charset will define how the sequence of characters is printed to the wordlist, but will not change the final content of the total wordlist)
from aaaaaaaa to 99999999 ;

./mp32.bin -1 ?l?d ?1?1?1?1?1?1?1?1 























To create a wordlist with the first 4 characters being lower and upper case alpha values and the last 4 characters being numeric values
from aaaa0000 to ZZZZ9999 ;

./mp32.bin -1 ?l?u ?1?1?1?1?d?d?d?d























To create an 8 character wordlist with the 1st and 2nd characters being lower and upper case alpha values, the 3rd to 6th characters being (upper case) hexadecimal values and the last 2 characters being special characters (including space);

./mp32.bin -1 ?l?u -2 ?dABCDEF ?1?1?2?2?2?2?s?s 






















So wordlist output can be masked in numerous ways to best suit what you are trying to achieve.



CREATING WORDLISTS IN INCREMENTS
=====================================

All of the above can also be done directly in oclHashcat+ when specifying masks to use for
hash cracking, however maskprocessor comes into play when requiring to create wordlists
in increments.

Using the -i switch we tell maskprocessor to create the wordlist in increments, either from the first to the last masked character or  from -- to user-defined positions.


To create a wordlist from 1 character to 10 characters.
Starting from 0 and ending at 9999999999

./mp32.bin -i ?d?d?d?d?d?d?d?d?d?d 























If we want to create a wordlist for WPA/WPA2 then of course there is no point in creating wordlists shorter than 8 characters (minimum passphrase length for WPA/WPA2), so in such a case we would specify to have the increments start at the 8th character.

To create a wordlist with at least 8 numeric values and increment by 1 until it reaches 10 characters;
Starting at 00000000 (8 characters) and stopping at 9999999999 (10 characters)

./mp32.bin -i --increment-min=8 ?d?d?d?d?d?d?d?d?d?d 























As maskprocessor requires masks to be entered, there is no real need to specify the max wordlength as that is also done by the number of mask placeholders.
You could however for instance have 10 mask placeholders and specify to stop at the 9th position ;

./mp32.bin -i --increment-min=8 --increment-max=9 ?d?d?d?d?d?d?d?d?d?d 

Will start at 00000000 (8 characters) and stop at 999999999 (9 characters).



EMULATING INCREMENTAL BRUTEFORCE ATTACK
=============================================

So to put all this to practice together with cracking a hash with oclHashcat+, we could pipe output
from maskprocessor through to oclHashcat+
Note that although maskprocessor can create words of over 15 characters, oclHashcat+ will not process any passphrases with more than 15 characters.
So your hash cracking fun with oclHashcat+ is limited to max 15 characters.

Again I will switch to my Windows system for this.. ;)
I extracted the maskprocessor executable to the same directory as oclHashcat for sake of ease;
c:\oclHashcat\
As I am running a 64bit OS, I am using the mp64.exe


To start at aaaaaaaa (8 characters) and finish at zzzzzzzzzz (10 characters as there are only 10 mask placeholders) piping through to oclHashcat ;

mp64.exe -i --increment-min=8 ?l?l?l?l?l?l?l?l?l?l | cudaHashcat-plus64.exe -m 2500 fubar.hccap


































Using mixed case starting at aaaaaaaa (8 characters) and stopping at ZZZZZZZZZZ (10 characters)
(Using the ^ symbol to break the line for clarity's sake, in linux you would use the backslash \
to break the line)

mp64.exe -1 ?l?u -i --increment-min=8 --increment-max=10 ?1?1?1?1?1?1?1?1?1?1 | ^
cudaHashcat-plus64.exe -m 2500 -n 40 fubar.hccap


































If you were to expect that the first 4 characters were for instance '1234' then you can fix these characters
in the mask as follows ;

mp64.exe -i --increment-min=8 1234?d?d?d?d?d?d | ^
cudaHashcat-plus64.exe -m 2500 -n 80 fubar.hccap
so Maskprocessor would go through 12340000 -- 1234999999
































This however does not work the other way around, so if for instance knowing that the last 4 characters
are 6789 and using syntax ;
mp64.exe -i --increment-min=8 ?d?d?d?d?d??d6789 | oclHashcat-plus64.exe -m 2500 fubar.hccap
will not work as the syntax is of course passing on the first 8 characters as defined from left to right which
is cutting off the 2 last characters which we would want fixed.

So in such a case as above we would have to use a so-called rule to have the numeric values 6789 appended to each created passphrase.

To create such a rule we would need to create a file called append.rule for instance with the following entry;
$6$7$8$9
This rule would specify that each line fed into oclHashcat will have the numbers 6789 appended to it.

echo $6$7$8$9 > append.rule
In this case you could also specify the --increment-min=4 so that hashcat would always check a minimum
of 8 characters (as 4 characters appended to each generated line)  or just leave out the --increment-min
and let hashcat reject words with less than 8 characters.

mp64.exe -i ?d?d?d?d?d?d?d?d?d?d?d?d | cudaHashcat-plus64.exe -r append.rule -m 2500 fubar.hccap


































RULES

Will have to be my next area of focus..


BENEFITS OF MASKPROCESSOR OVER CRUNCH ;
==========================================
Not much to be honest if you are on a linux system, but what it
does allow is the specification of custom charsets for use in masks.

I have to say though, the more I play with it, the more I like it ;
Having an option which is nearly as versatile as crunch, yet able to
run easily on Windows, makes this a great tool for me.
In combination with Hashcat running on windows this really is a
must have in your toolkit.

I am sure there are other wordlist generators for windows,
but this to me definately seems like the one to have and a truly
inpressive tool.

Speedwise, Maskprocessor is (quite a bit) faster than Crunch, crunch is
of course fast as it is, and possibly better documented (by me ;) ) at time of writing,
but that does not take away from the fact that Maskprocessor is an awesome bit of kit.


There are other uses for Maskprocessor such as creating rules for use with
oclHashcat which I still need to dig into.
(promises.. promises.. ;) )


Linkage ;
http://hashcat.net/wiki/maskprocessor
http://hashcat.net/wiki/mask_attack
http://www.irongeek.com/i.php?page=videos/hack3rcon2/martin-bos-your-password-policy-sucks



Monday, 6 February 2012

WPA Cracking with oclHashcat-plus

oclHashcat-plus is a CPU / GPU password cracker with a huge number of options able to
handle a myriad of hash types.

I will go through steps I took to test the cracking of a WPA2 .cap file from my test setup.

I will be using BackTrack5 R1 to capture the .cap file with 4-way handshake and to create the required
.hccap file but will carry out the actual cracking of the .hccap file on a Win7 PC.
This as I am still worried that my knack of fubarring things up could prove life-threatening  if I screw up a BTR1 HDD install on my main machine  ;) so I'll stick with using a VM image for the time being..
lols..


PREPARATION
===============
First things first, I want to use aircrack to create the .hccap file from a standard .cap file using the new
-J option in aircrack as oclHashcat does not work with the standard .cap files.
The aircrack version included on the stock install of BT5R1 does not yet have this option -J included, so we need to get the latest and greatest from the aircrack site and do the necessary to install.

Grab the latest build of aircrack here (last one in the list at time of writing 06-02-2012 was r2061);
http://nightly.aircrack-ng.org/aircrack-ng/trunk/
extract and cd to directory;
tar -xzf aircrack-ng-trunk-2012-02-05-r2061.tar.gz
cd aircrack-ng-trunk-2012-02-05-r2061

To be able to correctly install the latest aircrack some additional installs required before trying to install aircrack;
(reference; http://hashcat.net/forum/thread-816.html)
apt-get install libssl-dev
(I had previously installed this hence the mention already the newest version)
Then from within the aircrack directory install with ;
make
make install






















To update aircrack manually with previously downloaded files, there is a good detailed blogpost
brought to my attention by a reader here http://www.kknd.com.br/security/01/ on how to do that.

Using either of the above methods, you should be ready to rock and roll with the latest aircrack-ng.

Edit 10-02-2012
Backtrack repositories have been updated, the aircrack now included is
v1.1 r2076, so;
apt-get update 
apt-get upgrade
will also get you a current version of aircrack which includes the -J switch.


CAPTURING THE WPA HANDSHAKE
===============
To start the process of capturing the handshake first place the wireless interface in monitor mode using airmon-ng;

airmon-ng
airmon-ng start wlan0





















and then fire up airodump with options to focus only on your target AP, in my case ;

airodump-ng mon0  -c 11 -t wpa -d 98:FC:11:8E:0E:9C -w capture

When the handshake is captured, either by patiently waiting for a client to connect, or by forcing a
connected client to disconnect/reconnect with for instance aireplay-ng, this will be noted at the top right hand side of the airodump window.
We can then stop airodump and verify that the handshake is captured with aircrack ;

aircrack-ng capture-01.cap






















Now we have our .cap file with 4-way handshake, we need to convert it to .hccap format so that we
can use oclHashcat on it.
To do this we use the -J option in aircrack ;
(again, this option only available in the later aircrack builds, not in the stock install on BT5R1)

aircrack-ng capture-01.cap -J capture



























Now we have our .hccap file, I will be switching to my Win7 PC for the actual oclHashcat cracking.
(yeah yeah..I know.. a bit of a fail... ;) )


OCLHASHCAT-PLUS
===============
First of course to download the latest oclHashcat-plus (at time of writing 06-02-2012 v0.07)  if you haven't already done so and extract it to where you want, I extracted all files to ;
c:\oclHashcat\

Open up the command prompt ;
Start --> Run --> cmd
And move to the directory where you extracted the oclHashcat files to, in my case ;

cd c:\oclHashcat

I am running a 64bit Windows 7 system with an nVidia card (CUDA) so I need to run the cudaHashcat-plus64.exe file, with --help for further info ;

cudaHashcat-plus64.exe --help











































All the info may seem somewhat overwhelming, it certainly did to me, so herewith just a couple of
examples on how it can be used.

I copied the capture.hccap previously created to the oclHashcat directory on the Windows system as
'capture_fubar.hccap'


DICTIONARY ATTACK
===============
I will be using the rockyou dictionary as an example as it is a fairly large one, and copied the rockyou.txt file to the oclHashcat directory for easy access.

To start the crack, we need to specify ;
> The version of oclHashcat we need to use
    in my case the 64bit version for cuda enabled cards, for ATI cards, you would use the ocl version.
> -m [hash type #] (see number references for hash types at bottom of  help section)
    in this case '2500' which is used for WPA/WPA2.
> The path to the hash file / hccap file
    in this case 'capture_fubar.hccap' in the same directory.
> The path to the dictionary we are using for the attack
    in this case 'rockyou.txt' in the same directory.

cudaHashcat-plus64.exe -m 2500 capture_fubar.hccap rockyou.txt
Press 's' to get an updated status report (I hit enter first to create as space between status reports)











































oclHashcat went through over 11,5million passphrases in 2min15sec at around 54k passphrases a second..

Increasing the load on the GPU with the -n option can increase performance and the number of passphrases checked per second ;

cudaHashcat-plus64.exe -m 2500 -n 80 capture_fubar.hccap rockyou.txt











































So with the increased load on the GPU it went from around 54k passphrases/sec to around 64k passphrases/sec.



MASK (BRUTEFORCE) ATTACK
===============


From what I read oclHashcat-plus is not yet able to mask bruteforce in increments (so first testing 8 characters then 9, then 10 etc) so you need to test that manually.
However not completely sure on the bruteforce options to be honest as I see in the WIKI there are specific
bruteforce options mentioned, but I can't seem to get that working as of yet.
Reading up ;)

The masked bruteforce attack works by defining character sets to use (if custom character sets are required),
and then uses the masks to define in which position in the passphrase the charsets should be used.

There are various predefined charsets, among which ;
?l   -- lower case alpha
?u  -- upper case alpha
?d  -- numeric values
?s  -- special characters including space

To start a mask / bruteforce attack, you need to specify ;

> The version of oclHashcat you need to use
> -m [hash type #]  (-m 2500 for WPA/WPA2)
> -a [attack mode #] (-a 3 for bruteforce).
> The custom character sets (if any).
> The path to the hash file / hccap file.
> The mask to use.


The mask used has to match the length of the password, so if testing for a 8 digit password
you have to enter 8 mask entries.

If for instance testing all uppercase values for an 8 character password ;

cudaHashcat-plus64.exe -m 2500 -a 3 capture.hccap ?u?u?u?u?u?u?u?u



























If testing for numeric values only for an 8 character password ;

cudaHashcat-plus64.exe -m 2500 -a 3 capture.hccap ?d?d?d?d?d?d?d?d



























If we know that for an 8 digit password the 1st 4 digits of the password are numeric values and the last 4 digits are upper case values, then you would specify that as follows ;

cudaHashcat-plus64.exe -m 2500 -a 3 capture.hccap ?d?d?d?d?u?u?u?u




























CUSTOM CHARSETS

You can define upto 4 custom charsets to be used, this is done by using the switches ;
-1, -2, -3, -4

So thinking of our above dictionary crack, for the sake of argument, lets say we know the passphrase
used is a 4 digit number only containing the numbers 1 2 3 4  followed by 6 upper case values only containing the letters Y T R E W Q.

We could create a custom charset containing the numbers 1234 and specify these to be used for the
first 4 digits of the passphrase.
and also create a second custom charset containing YTREWQ and specify these to be used for the last 6 digits of the passphrase.
In the mask you would then specify where to use the 1st custom charset and where to use the 2nd custom charset with ?1 for the 1st custom charset and ?2 for the 2nd custom charset as follows ;
Of course this is not a terribly realistic scenario .. but hey, you get the idea.. 

cudaHashcat-plus64.exe -m 2500 -a 3 -1 1234 -2 YTREWQ capture_fubar.hccap ?1?1?1?1?2?2?2?2?2?2




























If you were to actually know that the first 4 digits of the passphrase are '1234' followed by 6 uppercase alpha values then you can define the 1st 4 values of '1234' directly in the mask ;

cudaHashcat-plus64.exe -m 2500 -a 3 -n 80 capture_fubar.hccap 1234?u?u?u?u?u?u




































Of course the above examples are for the purpose of explanation only and probably not realistic for real-world scenarios, but I hope it shows at least a small part of how oclHashcat-plus can work.


oclHashcat-plus is truly an awesome bit of kit, the speeds are certainly astonishing to me since I was used
to non-GPU speeds before ;) 30 minutes to get through an 8 digit numeric wordlist ?!! awesome..
And thats just on my nVidia GTX590 which sux big time compared with the benchmarks I see on hashcat's site for the ATI cards..

There are many, many other options I need to get my head around; rules, dictionary mangling, bruteforce, the list goes on and on ..  !
A lot more reading and testing required...

A good hint is to to also checkout the GUI for oclHashcat, it gives you a quick visual view of the commands
that you are using so that you can trouble shoot what you are doing wrong when trying just on the command line.



If I messed up anywhere on the above, please comment on it, have just started out trying hashcat so learning as I go !



Linkage/Credits; 

http://hashcat.net/oclhashcat-plus/

http://danielweis.wordpress.com/2011/10/13/gpu-password-cracking-of-wpa-using-airodump-oclhachcat-gui-a-basic-how-to/

d3ad0ne's awesomeness ;
http://ob-security.info/?p=31
http://pauldotcom.com/2010/10/your-password-cracking-system.html
http://ob-security.info/?p=274
 
Google Analytics Alternative