the do-it-yourself security audit

20
an Security eBook The Do-It-Yourself Security Audit

Upload: iamtechnophile

Post on 21-Apr-2015

34 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: The Do-It-Yourself Security Audit

an Security eBook

The Do-It-Yourself

Security Audit

Bobcat
Stamp
Page 2: The Do-It-Yourself Security Audit

contentsPaul Rubens is an IT consultant based in Marlow,England, and has been writing about businesstechnology for leading US and UK publications foralmost 20 years.

The Do-It-Yourself Security Audit, an Internet.com Security eBook.© 2008, Jupitermedia Corp.

2 Introduction

4 Carrying Out Your OwnPenetration Tests

7 Network Discovery:Scanning with Nmap

8 Sniffing Your Networkwith Wireshark

10 Checking Password Securitywith Hydra

12 Spotting Weak PasswordsUsing Offline Attacks

16 Checking Wireless Securitywith aircrack-ng

The Do-It-Yourself Security Audit[ ]

4

2

8

12 14

1

Page 3: The Do-It-Yourself Security Audit

Keeping the servers, laptops and desktop PCs in yourorganization secure is a vital job, as a breach in securitycan lead to valuable data being destroyed or altered;

confidential data being leaked; loss ofcustomer confidence (leading to lostbusiness); and the inability to use com-puting resources (and therefore lost pro-ductivity).

The cost of a serious security breachcan be very high indeed, so mostorganizations devote significantresources to keeping malware andmalicious hackers from getting on tothe corporate network and gettingaccess to data.

Typical defenses against these threatsinclude:

• A firewall to separate the corpo-rate network from the Internet• An intrusion prevention/detection system (IPS/IDS)to detect when typical hacker activities, such as portscans, occur and to take steps to prevent them fromsuccessfully penetrating the network• Malware scanners to prevent malicious software

getting on to the network hidden in e-mail, instantmessaging or Web traffic• The use of passwords to prevent unauthorized

access to networks, computers, ordata stored on them.

Every organization should havethese defenses in place, but thisleaves a very important question tobe answered: How effective arethese measures? It's a deceptivelysimple question, but it's essentialthat you know the answer to it.That's because if you don't it mayturn out that:

• Holes in your firewall leave yournetwork vulnerable• Your IPS/IDS is not configured cor-rectly and will not protect your net-work effectively• The passwords used to protect

your resources are not sufficiently strong to providethe protection you require• Your IT infrastructure has other vulnerabilities youare not aware of, such as an unauthorized and inse-cure wireless access point, set up by an employee.

2 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

The Do-It-Yourself Security Audit[ ]

The Do-It-Yourself Security Audit

By Paul Rubens

Jupiterimages

The cost of a serious security breach can be very high indeed, so most organizationsdevote significant resources to keeping malware and malicious hackers from getting on

to the corporate network and getting access to data.

Page 4: The Do-It-Yourself Security Audit

The Do-It-Yourself Security Audit

Penetration TestingPenetration testing seeks to find out how effective thesecurity measures you have in place to protect yourcorporate IT infrastructure really are by putting them tothe test. It may involve a number of stages including:

• Information gathering: using Google and otherresources to find out as much as possible about a com-pany, its employees, their names, and so on• Port scanning: to establishwhat machines are connected toa network and what services theyhave running that may be vulner-able to attack• Reconnaissance: contactingparticular servers that an organi-zation may be running and get-ting information from them (likethe usernames of employees, orthe applications that are runningon a server)• Network sniffing: to find user-names and passwords as they travel over the network• Password attacks: to decrypt passwords found inencrypted form, or to guess passwords to get access tocomputers or services

Defending a network and attacking a network are twodifferent disciplines that require different mindsets, so itfollows that the people best qualified to carry out apenetration test are not corporate security staff – who

are experts at defending a network – but hackers, whoare experts at attacking them.

The best penetration tests involve using the services of"ethical hackers" who are engaged to attempt to breakin to the network and discover as much informationand get access to as many computers as possible.

A cheaper option is to use penetration-testing soft-ware, which searches for vulnerabilities, and in some

cases even carries out attacksautomatically. A skilled human ismore likely to be successful thanany software tool, but using pene-tration-testing software to carryout your own penetration tests isstill a good idea.

The software allows you to carryout these tests yourself on amonthly or even weekly basis, orwhenever you make significantinfrastructure changes, without

incurring the costs associated with repeated tests car-ried out by a consultant. If you use many of the freepenetration testing tools that are available you willalmost certainly be using the same ones that manyhackers use as hacking tools. If you can successfullycompromise your organization's security with thesetools then so can hackers – even relatively unskilledhackers who know how to use the software. �

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.3

A skilled human is morelikely to be successful thanany software tool, butusing penetration-testingsoftware to carry out yourown penetration tests isstill a good idea.

Page 5: The Do-It-Yourself Security Audit

Themore skills and knowledge you have, the moreeffective your penetration tests will be. A completeguide to penetration testing is beyond the scope of

this eBook, but with some very basic hardware and free orlow-cost software it's still possible to carry out some impor-tant checks to see how effective your security systems are.Any vulnerability you spot and cor-rect raises the bar for anyone want-ing to break in to your network andharm your organization.

What You Will NeedHardwareTo carry out your penetration testsyou'll need a light, portable com-puter with wireless and Ethernetnetworking capability.

Although just about any reason-ably new laptop will suffice, "net-books" such as Acer's Aspire Oneor Asus' Eee PC make ideal pene-tration testing machines becausethey are extremely lightweightand portable, making it easy tocarry around office buildings.Costing about $350 they are inex-pensive, yet powerful enough for the job, and they canrun operating systems booted from a USB stick.

Note: The instructions in this eBook have been testedwith Acer's Aspire One but should work with the EeePC or any other laptop with little or no modification.

SoftwareMost of the software needed is open-source and avail-able free to download, compile, install, and run on

Linux. But by far the easiest wayto get hold of all the softwarecovered in this eBook (plus plen-ty more to experiment with) isby downloading a "live" Linuxsecurity distribution CD imageand burning it on to a CD, orcopying the contents on to aUSB drive (since most netbookslack an optical drive.) The bene-fit of a "live" distribution is thatthe entire operating system andall the software can be run fromthe removable media withoutthe need for hard disk installa-tion.

Note: The instructions in thiseBook assume that the reader isusing a security Linux distribu-

tion called BackTrack 3, which can be downloadedfrom www.remote-exploit.org/backtrack_download.html and run from an CD or USB stick.

The Do-It-Yourself Security Audit

Although just about any reasonably new laptop will suffice, "netbooks" such as Acer'sAspire One or Asus' Eee PC make ideal penetration testing machines because they areextremely lightweight and portable, making it easy to carry around office buildings.

Carrying Out Your Own Penetration Tests

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.4

Jupiterimages

Page 6: The Do-It-Yourself Security Audit

The Do-It-Yourself Security Audit

To start BackTrack3, simply insert the CD or USB intoyour penetration-testing machine, start it up, and bootfrom the removable media. Once the boot sequence iscomplete you will be greeted with the standardBackTrack 3 desktop:

The BackTrack 3 desktop.

Automated Penetration Testing with db_autopwndb_autopwn is an automated penetration testing toolthat can test large numbers of Windows, Linux, andUnix computers on a network for vulnerabilities at thepush of a few buttons. It is part of a suite of softwarepopular with both penetration testers and hackersknown as the Metaspoit Framework.

To use db_autopwn you first need to scan your net-work using a tool called Nmap to discover computerson the network and to establish which ports each ofthese has open.

Using this information, db-autopwn matches any knownvulnerabilities in services that usually run on those portswith exploits in the Metasploit exploit library which usethose vulnerabilities, and attacks the machines by run-ning those exploits. If any of the servers on your net-work are successfully compromised (or "pwn"ed), youwill be presented with a command shell giving youcontrol over the compromised machine.

db_autopwn has a number of benefits. First of all, it'sfree. It's also a popular tool with hackers. Using it willreveal if a hacker could easily compromise your net-work by using it. And if you do find that any of yourcomputers can be compromised, it is easy to identify

the weakness, patch or update the relevant software,and then re-run the test to ensure the problem hasbeen corrected.

On the other hand, db_autpwn generally does not findvulnerabilities in services running on non-default ports(although hackers using the tool generally won't either).There is also the possibility that running the tool could

Creating a Backtrack 3"Live" CD or USB Stick

To create a bootable BackTrack CD, downloadthe BackTrack 3 CD image from www.remote-exploit.org/backtrack_download.html and burnit to a CD.

To create a bootable BackTrack 3 USB stick,follow these steps:

1. Download the extended USB version ofBacktrack 3 fromhttp://www.remote-exploit.org/backtrack_download.html

2. Open the downloaded .iso file using anapplication such as MagicIso or WinRAR (onWindows) or unrar (Linux).

3. Copy the "boot" and "bt3" folders on to amemory stick (minimum 1Gb)

4. Make the USB stick bootable.• In Windows, open a command prompt andnavigate to the "boot" folder on your memorystick. If your memory stick is drive F:\ thentype:

cd f:\bootbootinst.bat

• In Linux, open a terminal window, andchange directory to your memory stick, proba-bly:

cd /media/disk

and execute the script bootinst.sh by typing:

bootinst.sh

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.5

Page 7: The Do-It-Yourself Security Audit

The Do-It-Yourself Security Audit

Automated PenetrationTest Using db_autopwn

1.Open a terminal window and move to theMetasploit Framework folder:cd /pentest/exploits/framework3

2. Start Metasploit:./msfconsole

3. Create a database to store the results of yourNmap scan:load db_sqlite3db_create Nmapresults

4. Scan your network and place the results in thedatabase:db_Nmap [target] (Replace the [target] stringwith the network block of your local subnet or theIP address of a target system that you want totest, e.g. 192.168.1.*)

5. Try to exploit the known vulnerabilities in anyservices running on the default ports on any ofthe machines:db_autopwn -t -p -e

6. Once the auto_pwn process is over, check to seeif you managed to compromised any machineswith the command:sessions –l

7. A numbered list of compromised computers willbe displayed. To take control of one of these com-puters, type:

sessions –i 1 (replacing 1 with the number ofthe computer you want to control)This will result in the command shell of the com-promised computer, looking something like this:[*] Starting interaction with 1...

Microsoft Windows XP [Version 5.1.2600](C) Copyright 1985-2001 Microsoft Corp.C:\WINDOWS\system32>

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.6

cause "collateral damage," i.e., you might crash serverson your network. A hacker running the tool would alsodo this, so arguably it is better to crash the machines

yourself when you are prepared for it than for a hackerto do so unannounced �

Preparing to run db_autopwn in BackTrack3

Page 8: The Do-It-Yourself Security Audit

The Do-It-Yourself Security Audit

db_autopwn is often used by relatively unskilled"script kiddies," and if it fails to find any vulnera-ble machines this doesn't mean that all the sys-

tems on the network are secure. That's because askilled hacker may use other, more labor-intensivemethods, plus knowledge and creativity, to try to finda way into machines on the targeted network.

One of the first thingsan intruder is likely todo is scan the networkto find out whatmachines are connect-ed, and what ports theyhave open, possiblyusing Nmap, (the samescanner used to findmachines to exploitusing db_autopwn.)Scanning your own net-work with this scanningtool can reveal what ahacker could discover,the devices connectedto your network, andthe ports they haveopen and the servicesthey are (probably) run-ning

This should alert you if unauthorized machines areattached to your network, or if any users are runningunauthorized services. Nmap is a command line tool,but it can be operated more easily using a graphicalfront end such as Zenmap, which is included inBackTrack3.

Scanning Your Network with ZeNmap1. Start Zenmap by typing "zenmap" into the text boxon the bottom panel on the BackTrack3 desktop.

2. Type in the network block of your local subnet or theIP address of a target system that you want to test inthe Target box, e.g. 192.168.1.*, choose a scan profile(or leave the default "intense scan") and click on scan.

After some minutesyou'll be presented withthe results:

On the left you can seea list of the hostsattached to the networkand an icon representingthe operating systemsthey are running. On theright is displayed a list ofopen ports and corre-sponding services on thehost 192.168.1.10, aWindows Server 2003machine.

In this example you cansee that the server is

running Windows IIS Webserver, and also has port

3389 open for remote desktop sessions. Both of thesehave potential vulnerabilities, and present you with theopportunity to close these ports if these services arenot required.

Zenmap is an extremely powerful scanning tool, and forcomplete instructions and usage exampled visit:http://nmap.org/book/zenmap.html. �

Zenmap displaying the results of a scan.

Network Discovery: Scanning with Nmap

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.7

Page 9: The Do-It-Yourself Security Audit

Nmapcan give you a clear picture of the hosts con-nected to your network and which ports they areexposing, but it gives you no insight into the packets

running over your network and the sensitive informationthese packets could reveal to an intruder. To discover thisyou need tomake use ofWireshark (formerly known asEthereal) an open source network protocol analyzer or pack-et sniffer. Many people describe usingWireshark as a reve-lation – the difference between getting a feel for the net-work they have responsibility forand turning on the lights and look-ing at what's going over it.

Choosing a Point toPlug in to YourNetworkBefore using Wireshark it is vitalto consider where you are goingto plug your penetration-testingmachine in to the network. That'sbecause switches only sendpackets to ports leading to thedestination machine, so if youplug your machine in to certainports in your network infrastruc-ture some packets won't reachyour network interface card at all.

And some hubs (which should send traffic to all ports)are actually switched, so again you will miss out onsome traffic.

But if you take time to understand your network topol-ogy and your hardware, you should be able to work outthe best place (or places) to connect Wireshark to the

network to capture all the packets you are interested in.

To make things easier, some switches have a specialmonitoring port that replicates traffic to all other ports:plugging your penetration-testing machine into thisport will enable you to see all traffic passing throughthat switch.

Why is Wireshark useful for a hacker?• Sniffing a username and pass-word pair provides the hackerwith access to the user's e-mailbox, which could contain sensi-tive or confidential corporateinformation• Many organizations give usersthe same username for manydifferent purposes, and manypeople use the same passwordfor many different purposes. Sogaining a username and pass-word can help a hacker accessother systems on your network,potentially causing far moredamage than would be possiblewith access only to an e-mailaccount.

Wireshark can be put to a widerange of uses, including sniffing your network for trafficusing protocols that have been banned for security rea-sons (such as MSN traffic.)

You can find a complete user guide at:www.wireshark.org/download/docs/user-guide-a4.pdf

The Do-It-Yourself Security Audit

Jupiterimages

Sniffing Your Network with Wireshark

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.8

Page 10: The Do-It-Yourself Security Audit

The Do-It-Yourself Security Audit

Sniffing Your Networkwith Wireshark

1. Start Wireshark by typing "wireshark" into thetext box on the bottom panel on the BackTrack3desktop.

2. Click on "Capture – Interfaces …" to select thenetwork interface you want to use to monitor traf-fic, and then "Options" to set up the interface fortraffic monitoring.

3. Check the "Capture packets in promiscuousmode" box to ensure your network interface cap-tures and sniffs all packets on the network seg-ment, not just those relating to your own networkinterface.

4. Click start to begin sniffing. The picture belowshows Wireshark sniffing TCP traffic as segmentsof a page from the website at metasploit.comdownloads.

One way that hackers can steal information is bysniffing passwords as they travel across the net-work. For example, they may sniff pop traffic todiscover e-mail usernames and passwords, whichare often unencrypted.

5. Type "pop" into Wireshark's filter text box (insome versions type "prot=pop"). Next time a userchecks their e-mail on a pop server using an unen-crypted connection, their username and passwordwill be sniffed by Wireshark.

In this example a user has attempted to log in to apop server with the username "ethereal" and pass-word "wireshark".Wireshark capture options.

Wireshark sniffing TCP packets containing awebpage from milw0rm.com.

Wireshark sniffing poppackets, revealingusername ethereal andpassword wireshark.

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.9

Page 11: The Do-It-Yourself Security Audit

There are many ways a hacker might get the e-mailusernames of people working at your organization.These range from simple techniques, such as looking

at your company's Web page and searching for e-mailaddresses to relatively difficult techniques such as sniffingyour network traffic or interrogating your mail server (whichcould have been discovered during an Nmap scan.)

If your organization has an obvious e-mail usernamepolicy, such as firstname.lastname (john.smith) or intital-lastname (jsmith) then by searching your company Web

site or other material for the names of employees itwould be very easy to compile a list of e-mail user-names.

Many people use the same username for many differ-ent uses, so if a hacker gets a hold of a few e-mail user-names they could well be valid on other servers such asftp or smtp.

To discover the passwords that match these usernameson other servers, the hacker would probably carry out

The Do-It-Yourself Security Audit

Jupiterimages

Checking Password Security with Hydra

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.10

Carrying Out an OnlinePassword Attack1. Launch Hydra by typing xhydra in the text boxon the BackTrack 3 desktop

2. Choose a protocol to test from the Protocoldropdown box: Hydra can handle about 40 com-mon protocols, including Pop3, telnet, ftp, VNC,SMTP, Cisco auth.

3. Choose a target – either the name or IP addressof a single server, or a text file with a list of them.

4. Click on the Passwords tab, then either enter asingle username to test – in this case testorg123,and specify a Password list that you want to test.This is a simple text file containing a list of possi-ble passwords. You can either compile your own,or use Google to find and download lists of hun-dreds or even thousands of commonly used pass-words. You can also add words that are relevant toyour organization – the office name or currentproduct or project names, for example.

5. Click on the Tuning tab and selecting the num-ber of login attempts that are submitted simulta-neously. This number is important to a hackerbecause the higher this number is set the higherthe chance of being detected or locked out of thesystem are greater, but the faster the attack willproceed.

continuedHydra

Page 12: The Do-It-Yourself Security Audit

The Do-It-Yourself Security Audit

an online password attack. Essentially this involvesattempting to log on to the relevant server using a like-ly username and a guessed password, and repeatingthis process with different passwords until a successfullogin occurs.

If the correct password is an "obvious" one like qwertyor 123456 then the hacker is likely to find it quickly –before the server spots that anything is amiss and pre-vents the hacker from submitting more login requests.(A well-configured server will limit the number of failedpassword attempts that are allowed before the accountis suspended, the hacker's IP address is blocked or theperiod before a new login attempt can be made isextended. It should also log where failed attempts arecoming from and alert administrators.)

The best way to check that your users have selectedstrong, difficult-to-guess passwords, and that your

servers are configured to spot a hacker submitting mul-tiple guesses, is to carry out an online attack yourself,using the popular open-source password guessing toolcalled Hydra.

If a server is configured well, it should spot excessivefailed login attempts and block Hydra before it man-ages to find any passwords (unless the hacker getslucky in his first few guesses.) If you find you can workthrough a long list of passwords fairly quickly then it iswell worth reconfiguring the security settings on yourserver to block access after fewer failed login attempts:legitimate users may misspell their passwords a coupleof times, but there is no reason why anyone should beentering their password incorrectly more than a handfulof times consecutively. �

][

The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.11

6. Click the Start tab and click Start to launch theattack. In the example below, the correct passwordwas found in a few moments -- the user had pickedthe very simple password "qwerty." Workingthrough a list of all your users and a long pass-

word list will reveal all of the users in your organi-zation that have passwords which can be guessedby a hacker in a reasonable amount of time usingHydra – if the server hasn't been configured toprevent online password attacks.

Hydra's Tuning tab.

Hydra successfully guesses the password "qwerty"for the username "testorg123."

Carrying Out an Online Password Attack continued

Page 13: The Do-It-Yourself Security Audit

Whena user logs on to a server, he or she first hasto submit their password. This password is passedthrough a hashing function, a mathematical

process that converts it into a completely different string ofcharacters, known as the password hash. The server consultsa list that contains passwords hashes of all its users, andchecks that the one it has receivedfrom the user matches the one in itspassword list.

The beauty of this system is thatsince hash functions are one-way(meaning that it is not possible toconvert a password hash back tothe original password) a hackerthat gets access to the list of pass-word hashes by breaking in to aserver has no direct way to get atthe passwords themselves: all theyhave is a list of password hashes,which have no instant value inthemselves.

The only way to use the passwordhashes to get at the original pass-words is by feeding differentguesses into the hashing function and waiting until apassword hash comes out that matches one of thehashes in the password list.

Since the hacker has the password hash list in their pos-session, there is no need to submit guesses to the serv-er (using a tool like Hydra) to see if they are correct.Instead, they can run the whole process of passingguesses through a hashing function and comparing theresults with the password hashes on the stolen pass-

word list on their own computer– a so-called "offline attack."

An offline attack is many timesfaster than an online attack, limit-ed by the power of the computercarrying out the attack, not theserver under attack. The servercan't detect an offline attackitself, as it is being carried out ona completely unconnected sys-tem.

As well as using a list of guessesto try, it is also possible toattempt to "brute-force" thepassword hashes. This involvestrying every combination of one,two, three, four (and so on) char-acter passwords. Given enough

time brute-force attacks are bound to be successful. Abrute-force attack will find short passwords very quicklyindeed, but a password made up of eight random char-acters could take hundreds of years to brute-force, and

The Do-It-Yourself Security Audit

12 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

[ ]

Spotting Weak PasswordsUsing Offline Attacks

Jupiterimages

An offline attack is many times faster than an online attack, limited by the powerof the computer carrying out the attack, not the server under attack.

Page 14: The Do-It-Yourself Security Audit

a nine character password could take thousands ofyears.

To test whether any of your users are using easilyguessable or short passwords, you need an offlinepassword-cracking tool like John the Ripper – knownsimply as John - which is included in BackTrack 3.Unlike many of the open source tools in BackTrack3,John has no built-in GUI, but fortunately it is very sim-ple to use.

Getting a Password Hash List from aLinux or Windows ServerFrom a Linux server:1. Copy /etc/passwd and /etc/shadow from a serveronto a memory stick, and transfer these files onto yourpenetration testing machine to the folder/usr/local/john-1.7.2/

2. Combine these two files into a file called pass-wordlist.txt using John's unshadow command:

cd /usr/local/john-1.7.2/unshadow /etc/passwd /etc/shadow > Password.txt

From a Windows server:

Since Windows protects the file in question, it is neces-sary to overcome this by booting your server intoBackTrack3 using either a CD or USB. (Note: if this isnot possible because they have been disabled then thismeans that a hacker trying to do this will also bethwarted.)

1. Once BackTrack 3 has booted, run bkhive on SYS-TEM to get the system key:

bkhive (path to)/SYSTEM systemkey.txtAn example of the path is:mnt/sda1/Windows/System32/config

2. Use samdump2 to get at the account names andpassword hashes from the SAM:samdump2 (path to)/SAM systemkey.txt>Password.txt

The result in either case is a file that might look like thisone, which has two users, user11 and user22, and twocorresponding password hashes.

LM and NT hashesMost Windows systems store a type of password hashcalled an LM hash, and unfortunately, LM hashes areflawed. Passwords longer than seven characters aresplit into two chunks of seven characters (with zerosadded if necessary to make exactly 14 characters.) Bothsections of seven characters can usually be guessed orbrute-forced in a matter of hours.

All modern versions of Windows software also use amore secure hashing function called the NT hash, so itis wise to ensure that none of the computers in yourorganization use the LM hash. The only time you mightneed LM hashes is if you have Windows 95 or 98clients or Apple Macintosh clients on your network.You can find out how to disable LM hash usage on yourcomputers at:http://support.microsoft.com/kb/299656

The Do-It-Yourself Security Audit

13 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

[ ]

A password hash file with two usernames and their corresponding password hashes.

Page 15: The Do-It-Yourself Security Audit

Note: Any passwords longer than 14 characters willalways be stored using an NT hash only – an LM hashwill not be used even if LM hashing has not been dis-abled.

Just about any LM hash and some NT hashes can actu-ally be cracked to reveal the original password in amatter of minutes using rainbow tables. These are pre-computed lists of (almost) all possible passwords andtheir resulting LM hashes. Cracking a given hash is thusa simple matter of using a program like Ophcrack tolook it up in the table to find the corresponding pass-word.

Carrying Out an Offline AttackUsing John1. To run a test on the list of hashes, simply type

john Password.txt

When run with no options, John gets to work on thepasswordlist.txt file, first attempting a single attack,using login information from the password file. It thencarries out a wordlist attack using the default wordlistsupplied with John, followed by a brute force attack.

In the example above, John finds the simple passwordsdd (user1) and ddd (for user2) in a fraction of a second.This illustrates the point that short passwords can befound easily, and also shows the power of hashing func-tions. The two passwords dd and ddd differ only byone "d," yet the DES hashes they produce are identicalin length and completely different. Very similar inputleads to completely different output, and input of dif-

The Do-It-Yourself Security Audit

14 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

[ ]

Ophcrack successfully cracks user Jacco'spassword "DUCKBOY.

John brute-forces passwords for user11 (dd) and user22 (ddd).

Cracking LMHashes UsingRainbow Tables with Ophcrack1. Download and install Ophcrack for Windows ofLinux from:http://ophcrack.sourceforge.net/download.php

and a set of rainbow tables from:http://ophcrack.sourceforge.net/tables.php

2. Click Load and select the password hashes thatyou got using one of the techniques outlines above

3. Click Crack to find the passwords

In this case, the user Jacco's password DUCKBOYwas looked up and found in 58 seconds. The userMargin's password (which in fact was longer than 14characters and therefore only stored as an NT hash)could not be found, after searching all hashes heldin the "XP free fast" and "Vista free" rainbow tables.

Page 16: The Do-It-Yourself Security Audit

ferent lengths produces output that is always the samelength – in this case 13 characters.

John stores any passwords it cracks in a results filescalled john.pot, and you can view these passwords andtheir associated usernames by typing

john --show Password.txt

You can try to crack passwords in more than one list atonce simply by adding the names of the extra lists:

john passwordlist.txt passwordlist1.txt passwordlist3.txtThere are many, many other options you can use torefine how john runs. Once of the most useful is

john --users=0

which only attempts to crack root user (UID=0) pass-words.

For a complete list of options and examples go to:http://www.openwall.com/john/doc

Running John regularly on all the password hashes onyour system will give you an idea of the proportion ofyour users' passwords that are insecure. You couldthen:• Consider changing your password policies toreduce that proportion (perhaps by increasing theminimum length.)

• Contact users with weak passwords and ask themto change them.

• Consider a user education program to help themselect more secure passwords. �

The Do-It-Yourself Security Audit

15 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

[ ]

Page 17: The Do-It-Yourself Security Audit

Wireless networking can be a very big security risk foryour organization for at least two reasons:

• A hacker could get access to your network if they canget within range of a wireless access point that is notprotected by encryption (an "open" network) or if theencryption key can easily beguessed• A hacker could set up a so-called "rogue" open access point,and then trick users into connect-ing to that rather than the compa-ny's real wireless access point.Once connected the hacker canusually gain access to the user'scomputer and any data sent to therogue access point.

Wireless EncryptionTo connect to your wireless net-work, a hacker first needs toauthenticate himself by providingan encryption key (unless it is an"open" access, which is an openinvitation to hackers). Most organi-zations use a system called WPA Enterprise, which isgenerally very secure, but smaller organizations mayuse alternative systems called WPA, WPA2, or WEP.

WEP is a very insecure system, and a hacker can often

get access to a network that uses WEP encryption inless than two minutes. (For more information aboutthis, seehttp://www.enterprisenetworkingplanet.com/netsecur/article.php/3670961).

WPA and WPA2, on the otherhand, are both very secure --unless the WPA key needed toaccess the wireless network isshort enough to be brute-forced(in a similar way to that illustratedearlier using John).

To maintain security it is impor-tant to ensure some form of WPAwith long, random passwordsprotects your wireless networks.There is also a danger that userswithin your organization decideto connect their own accesspoints to the network for theirown purposes – perhaps so thatthey can use a Wi-Fi equippedmobile device – or that a hackersets up an open access point.

These unauthorized or rogue access points are securityrisks, so it is important to scan your workplace regularlyto detect them as quickly as possible.

The Do-It-Yourself Security Audit

16 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

[ ]

Checking Wireless Security with aircrack-ng

Jupiterimages

To maintain security it is important to ensure some form of WPA with long,random passwords protects your wireless networks.

Page 18: The Do-It-Yourself Security Audit

Looking for Rogue Access PointsThe easiest way to scan for rogue access points, includ-ing hidden access points that do not broadcast theirnetwork name and that many people believe are there-fore invisible to scanners, is to use a BackTrack 3 toolcalled airodump-ng, part of a suite of wireless toolscalled aircrack-ng.

Before using these tools, the wireless card on your pen-etration testing machine must be put in to monitormode, allowing it to access packets without being asso-ciated (connected) to any particular access point.

1. Put the wireless card in monitor mode:airmon-ng stop ath0airmon-ng start wifi0

2. Start airodump-ng:airodump-ng ath0

Airodump-ng will display a list of every access point itcan detect in the vicinity, and information including:

BSSID – the MAC address of a detected access pointCH – the wireless channel it is operating onENC – the encryption system it is using (WPA, WEP orOPN [for open networks])ESSID – the network name. This may remain blank untila device connects to it if the network is set to "hidden." Note: airodump-ng will still detect the network, evenif it is "hidden"STATION – the MAC address of a connect device

By looking at the results of airodump-ng it is possibleto spot rogue access points (which will then need to be

tracked down, and to ensure that all authorized accesspoints are using WPA encryption.

If your organization is large it is wise to walk aroundand run airodump-ng from many different places toensure that you cover the whole area. You should alsowalk around outside the buildings to see if any author-ized access points can be detected in public places. Ifthis is the case you should consider moving your accesspoints or reducing the power of the internal radio tominimize this, even if WPA protects access.

Mac Address FilteringSome organizations set up Mac address filtering on theiraccess point as an alternative to using WPA encryptionunder the mistaken belief that it is only possible for adevice to connect to the network if its MAC address ison a list of devices recognized by the access point.

But as can be seen in the illustration above, airodump-ng records the MAC address of any clients connectedany access points (under "STATION".) A hacker can eas-ily overcome MAC filtering by making a note of a per-mitted MAC address (in this case 00:0B:6C:4E:D9:E8),waiting until that client disconnects, and then connect-ing to the network using that MAC address. This is easyto do this in Linux using a utility called macchanger,which changes the true MAC address of a network inter-face card to any arbitrary false MAC address. To spoofthe MAC address 00:0B:6C:4E:D9:E8 a hacker needonly open a terminal window and type:airmong-ng stop ath0ifconfig wifi0 downmacchanger –m 00:0B:6C:4E:D9:E8ifconfig wifi0 up

The Do-It-Yourself Security Audit

17 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

[ ]

Airodump-ng detects one open and two WPA protected access points.

Page 19: The Do-It-Yourself Security Audit

MAC address filtering therefore offers no securityagainst a hacker, and should not be used as an alterna-tive to WPA encryption.

Cracking WPAHackers can get access to WPA or WPA2 (but not WPA-Enterprise) protected networks if the password is notlong or uses a guessable password (or passphrase). Todo this they need to capture the packets that are trans-mitted when a user authenticates and joins the wirelessnetwork, known as the WPA handshake. Once thehacker has captured the WPA handshake they can sub-ject it to a dictionary attack.

Testing WPA Passwords1. In a terminal window, place the wireless card in mon-itor mode as run airodump-ng as before:airmon-ng stop ath0

airmon-ng start wifi0airodump-ng ath0

2. Start airodump-ng to capture a WPA handshake onthe network "GOAT":

airodump-ng -c 2 --bssid00:14:6C:61:71:8A -w wpacapture ath0

In this example we are testing the network on channel2 (-c 2) which has the BSSID 00:14:6C:61:71:8A, andattempting to capture a WPA handshake and write it toa file called wpacapture (-w wpacapture)

3. Connect another device to the WPA network, so thatairodump-ng can capture the WPA handshake. Whenthis is successful the message "WPA handshake:00:14:6C:61:71:8A" will appear in the top right of thescreen as illustrated below:

The Do-It-Yourself Security Audit

18 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

[ ]

airodump-ng detects three WPA protected networks.

airodump-ng displaying a successful WPA handshake capture

Page 20: The Do-It-Yourself Security Audit

4. Run aircrack-ng on the wpacapture file containingthe handshake, to see if the password is easily crack-able using guesses from a word list wordlist.txt:

aircrack-ng -w wordlist.txt -b00:14:6C:61:71:8A wpacapture*.cap

5. If successful, aircrack-ng will display the WPA pass-word: see image above

6. Important note: Due to an apparent bug, on somecomputers aircrack-ng running from BackTrack3 will failto find the password even if it is in the password list. Tocheck whether this is the case with your setup, set thepassphrase for an authorized access point to a simplepassword like "test", and run the process above with awordlist.txt file containing only this password. If it fails

to find the password, try running the aircrack-ng suiteon another machine.

If you can crack your own WPA password then it isessential that you change it to something more secure.The ideal WPA password is a random string of 63 char-acters, and you can generate a suitable one online at:https://www.grc.com/passwords.htm. �

Paul Rubens is an IT consultant based in Marlow,England, and has been writing about business technol-ogy for leading US and UK publications for almost 20years.

The Do-It-Yourself Security Audit

19 The Do-It-Yourself Security Audit, an Internet.com Security eBook. © 2008, Jupitermedia Corp.

[ ]

aircrack-ng find the password “backtrack”