Friday, August 31, 2012

Brute-forcing with Hydra

Hydra is a great tool for brute-forcing. With this tool it is possible to brute-force most websites and protocols.


Protocols supported:
AFP, Cisco AAA, Cisco auth, Cisco enable, CVS, Firebird, FTP, HTTP-FORM-GET, HTTP-FORM-POST, HTTP-GET, HTTP-HEAD, HTTP-PROXY, ICQ, IMAP, IRC, LDAP2, LDAP3, MS-SQL, MYSQL, NCP, NNTP, Oracle, Oracle-Listener, Oracle-SID, PC-Anywhere, PCNFS, POP3, POSTGRES, RDP, REXEC, RLOGIN, RSH, SAP/R3, SIP, SMB, SMTP, SMTP-Enum, SNMP, SOCKS5, SSH(v1 and v2), Subversion, Teamspeak (TS2), Telnet, VMware-Auth, VNC and XMPP.
Can be found here: Hydra (http://www.thc.org/thc-hydra)

I dediced to see if it possible to brute-force my home AccessPoint administation login page.
Below is what i did.
First i started to examine the login page.

Viewing the source of the login-page to see if i could find any clues, find out what authentication it uses.
Basic, form-based etc.. There are a few ways of finding this out.
Using wireshark and intercept a login session gives a LOT of useful information.
Tried to login with a password while sniffing the traffic with wireshark, the password was incorrect (as suspected), but from this information we can see what variables are used for logging in.
Analyzing the sniffer output with "Follow TCP stream" i could see the following:
 

I was looking for what happens after the submit button was pressed and also what is sent in HTTP-POST. Found the variable pws indicating that this is used for password input.

Found an interesting variable: "dw(wrhtpsswd)" What does this do?
As we can see the password is base64 encoded as it is sent to the AP.
We can see that the length is 9 characters, max size is 12 characters.

Next step was further analysis with Mantra to examine web content.
DOM tab is an excellent way of analyzing variables and their associations.



This parameter wrhtpsswd sounds familiar. Incorrect password...
For a successful attack with Hydra we need to know the variable that submits the password and string included with it.
We also need to know the error message sent to us when entering an incorrect password.

From wireshark output we could not clearly see the Incorrect password message, but instead the AP sends a dw(wrhtpsswd) that DOM identified as the "Incorrect Password, Please confirm your password and try again" message.

Awesome, we can now go ahead and start the attack.
hydra parameters:
-l "" # There is no username required
-P PASSWORDS.TXT # Password file (in base64 encoded format)
-t #How many simultanious tasks
-f # Exit after the first found password
-v / -V # Verbose. Show every password combination
IP-address # you know
http-post-form # Method used
/login.cgi # The login page of the AP
"page=&logout=&action=submit # The string sent simulating a click on Submit button &pws=^PASS^%3D&itsbutton1=Submit&h_language=en" #pws from PASS in PASSWORDS.TXT
wrhtpsswd # The string to look for in the response when an incorrect password is entered

Awesome! Mission accomplished!

Hydra can be very time consuming depending on the size of the wordlist. A lot of options you can tweak for best timing and results. Play with it. Anything is possible, if not try harder.

A good source for common password lists can be obtained from SkullSecurity.
http://www.skullsecurity.org/wiki/index.php/Passwords

If you need to create your own custom password list Crunch is the way to go.
Excellent tool also included in Backtrack distributions or download it from Sourceforge.
http://sourceforge.net/projects/crunch-wordlist/

A good how-to can be found here.
http://adaywithtape.blogspot.se/2011/05/creating-wordlists-with-crunch-v30.html


Til next time. Bye for now!

/M

Wednesday, August 29, 2012

Wireless Hacking: Hacking WPS enabled AccessPoints

Just when you think you are safe with WPA2 and a PSK over 20 characters long something like this comes along.
It seems that most vendors have WPS enabled as a default setting, so was my Belkin home AP.
In this tutorial i will go through the steps of how i hacked my WPS enabled AccessPoint.
For more information about WPS (Wifi protected Setup) see:


Prerequisites:
- A wireless card supporting monitor mode
- Backtrack distribution: (I used Backtrack 5 R2) or
  Reaver WPS from http://code.google.com/p/reaver-wps/

First you need to set your wireless card in monitor mode:


To find WPS enabled accesspoints we can use the command "wash" included in Backtrack 5
This command also shows if the WPS is locked, the channel the AP is running on and the BSSID and ESSID of the AP as well as RSSI which is the receive signal strength.



Above we see an AP on Channel 6 with ESSID: SSID-1 that has WPS version 1.0 enabled and RSSI of -30 which means we are close to the AP.


Brute forcing WPS PIN:

open 2 command windows.
In window 1 run:



Explainations to reaver command-line : -c channel, -A no association, -E Send EAP terminate, -N no acks, -vv very verbose (if you want to see all login attempts)



In window 2 run:

You might need to test the appropriate timing values depending on how close you are to the AP.

After a long while you should see this in window 1
For some reason i do not always get the WPA PSK echoed out like above.
What you can do then is to test the PIN with:
reaver -i mon0 -b XX:XX:XX:XX:XX:XX -c 6 -p <PIN>

After the PIN is discovered and verified. Get WPA-PSK with the below method.
Create a wpa_supplicant.conf including the lines below

Run wpa_supplicant

Run wpa_cli

wpa_cli wps_reg <BSSID> <PIN>   # wait for CONNECTED

save_config

Check your saved wpa_supplicant.conf with

cat wpa_supplicant.conf

It should now show you the PSK in clear text.


Hope you find the above useful.

Note:
I wrote this tutorial for reference and in good intentions.
Before you go ahead and hack your neighbours AP ask for permission!
I am not responsible what you do with the above information!
Cheers.

/M