Unit 5 Notes
Unit 5 Notes
• Open source intelligence (or OSINT) is gathered from legal sources like
public records and social media.
• The success of a pentest often depends on the results of the
information-gathering phase.
Netcraft:the information that web servers and web-hosting companies
gather and make publicly available can tell you a lot about a website.
Netcraft also provides other services, and their antiphishing offerings
are of particular interest to information security
Whois Lookups
• DNS zone transfers allow name servers to replicate all the entries about a domain.
When setting up DNS servers, you typically have a primary name server and a backup
server.
• many system administrators set up DNS zone transfers insecurely, so that anyone can
transfer the DNS records for a domain.
zoneedit.com is an example of such a domain, and we can use the host command to
download all of its DNS records. Use the -l option to specify the domain to transfer, and
choose one of the name servers from the previous command.
• Searching for Email Addresses
• use a Python tool called theHarvester to quickly scour thousands of search engine
results for possible email addresses. theHarvester can automate searching Google,
Bing, PGP, LinkedIn, and others for email addresses.
• ./theharvester.py –d syngress.com -l 10 -b google.
• This command will search for e-mails, sub domains, and hosts that
belong to syngress.com shows our results.
• “./theHarvester.py” is used to invoke the tool.
• A lowercase “d” is used to specify the target domain.
• A lowercase “l” (that is an L not an 1) is used to limit the number of
results returned to us.
• The tool was instructed to return only 10 results.
• The “b” is used to specify what public repository we want to search.
• Harvester output
• Nmap scans only the 1,000 ports it considers the most “interesting,” not the 65,535
possible TCP or UDP ports. The default Nmap scan will catch common running services,
but in some cases it will miss a listening port or two.
• To scan specific ports, use the -p flag with Nmap. For example, to scan port 3232 on
the Windows XP target.
Syntyax:
root@Kali:~# nmap -sS -p 3232 192.168.20.10
• Starting Nmap 6.40 ( http://nmap.org ) at 2015-12-18 09:03 EST
• Nmap scan report for 192.168.20.10
• Host is up (0.00031s latency).
• PORT STATE SERVICE
• 3232/tcp open unknown
• MAC Address: 00:0C:29:A5:C1:24 (VMware)
Password attacks
• Password attacks aim to gain unauthorized access by compromising
user credentials.
• Widely used in cyberattacks, leading to data breaches and system
intrusions.
• Can be categorized into online and offline attacks.
Password Management
• User Lists
• When creating a user list, first try to determine the client’s username scheme.
• If a company uses a first initial followed by a last name for the username scheme, and
they have
• an employee named John Smith, jsmith is likely a valid username
Use command:
root@kali:~# cat userlist.txt
Output:
• georgia
• john
• mom
• james
Password Lists
• Use command:
root@kali:~# cat passwordfile.txt
Output:
• password
• Password
• password1
• Password1
• Password123
• Password123
tool like the ceWL custom wordlist
• educated guesses based on information you gather about employees online.
Information about spouses, children, pets, and hobbies may put you on the
right track.
• In addition to making educated guesses based on information you gather
while performing reconnaissance, a tool like the ceWL custom wordlist
generator will search a company website for words to add to your wordlist.
• Use command:
• root@kali:~# cewl –help
• The command ceWL --help lists ceWL’s usage instructions. Use the –d (depth)
option u to specify how many links ceWL should follow on the
• target website. If you think that your target has a minimum password-size
requirement, you might specify a minimum word length to match with the -m
option . output ceWL’s results to a file with the -w option .
•
Tool Crunch
• Another method for creating wordlists is producing a list of every possible combination of a given
set of characters, or a list of every combination of characters for a specified number of characters.
• The tool Crunch in Kali will generate these character sets for you.
Use command
root@kali:~# crunch 7 7 AB
Output:
• Crunch will now generate the following amount of data: 1024 bytes
• Crunch will now generate the following number of lines: 128
• AAAAAAA
• AAAAAAB
• --snip—
• the default Crunch character set of lowercase letters. This technique is known as keyspace brute-
forcing. While it is not feasible to try every possible combination of characters for a password in
the span of your natural life, it is possible to try specific subsets.
Guessing Usernames and Passwords with Hydra
• Hydra is an online password-guessing tool that can be used to test usernames and
passwords for running services.
• Use command
root@kali:~# hydra -L userlist.txt -P passwordfile.txt 192.168.20.10 pop3
output
• Hydra v7.6 (c)2013 by van Hauser/THC & David Maciejak - for legal purposes only
• Hydra (http://www.thc.org/thc-hydra) starting at 2015-01-12 15:29:26
• [DATA] 16 tasks, 1 server, 24 login tries (l:4/p:6), ~1 try per task
• [DATA] attacking service pop3 on port 110
• [110][pop3] host: 192.168.20.10 login: georgia password: passwordu
• [STATUS] attack finished for 192.168.20.10 (waiting for children to finish)
• 1 of 1 target successfuly completed, 1 valid password found
• Hydra (http://www.thc.org/thc-hydra) finished at 2015-01-12 15:29:48
Hydra tool
• use Hydra to guess usernames and passwords by running through our username and password
files to search for valid POP3 credentials on our Windows XP target.
• This command uses the –L flag to specify the username file, the -P for the password list file, and
specifies the protocol pop3.
Specific user password track command:
• we can use the -l flag instead of -L to specify one particular username.
Use command:
root@kali:~# hydra -l georgia -P passwordfile.txt 192.168.20.10 pop3
Output:
• Hydra v7.6 (c)2013 by van Hauser/THC & David Maciejak - for legal purposes only
• [DATA] 16 tasks, 1 server, 24 login tries (l:4/p:6), ~1 try per task
• [DATA] attacking service pop3 on port 110
• [110][pop3] host: 192.168.20.10 login: georgia password: passwordu
• [STATUS] attack finished for 192.168.20.10 (waiting for children to finish)
• 1 of 1 target successfuly completed, 1 valid password found
•
Using Netcat to log in with guessed credentials
• Use command
root@kali:~# nc 192.168.20.10 pop3
Output:
• +OK POP3 server xpvictim.com ready <[email protected]>
• Password Attacks 203
• USER georgia
• +OK georgia welcome here
• PASS password
• +OK mailbox for georgia has 0 messages (0 octets)
On line password attack types
• Brute Force Attack: Tries all possible password combinations.
• use tools designed for automating online password attacks or guessing passwords until the server
responds with a successful login. These tools use a technique called brute forcing.
• Tools that use brute forcing try every possible username and password combination, and given
enough time, they will find valid credentials.
• Dictionary Attack: Uses a predefined list of common passwords.
• Credential Stuffing: Leverages leaked credentials from other breaches.
• Phishing: Tricks users into revealing their passwords
Offline password attack
• Performed after obtaining a stolen copy of the password database.
• Conducted without interacting with the live system.
• Faster and more efficient due to lack of real-time restrictions.
• Another way to crack passwords (without being discovered) is to get a copy of the password
hashes and attempt to reverse them back to plaintext passwords.
• guess a password, hash it with the one-way hash function, and compare the result to the known
hash. If the two hashes are the same, we’ve found the correct password.
• Windows XP system via the windows/smb/ms08_067_netapi
• Metasploit module, we can use the hashdump Meterpreter command to print the hashed Windows
passwords.
• Save the output of the hashdump to a file called xphashes.txt, which we will use in “John the
Ripper”
• Not e
1.Recovering Password Hashes from a Windows
SAM File
• The first field in the hashes is the username ; the second is the user ID ; the third is the
password hash in LAN Manager (LM) format ; and the fourth is the NT LAN Manager (NTLM)
hash x.
• both passwords are the string password, the NTLM hash entries for each account are identical,
but the LM hash fields are different.
• LM-hashed password can be brute-forced in minutes to hours. crack the NTLM hashes will
depend on both our ability to guess and the length and complexity of the password.
4.The Trouble with LM Password Hashes
• Run a plaintext password guess through the cryptographic hashing function and compare the results to the
hash we’re trying to crack; if they’re the same, we’ve found the correct password.
The following issues contribute to the insecurity of LM hashes:
• Passwords are truncated at 14 characters.
• Passwords are converted to all uppercase.
• Passwords of fewer than 14 characters are null-padded to 14 characters.
• The 14-character password is broken into two seven-character passwords that are hashed separately.
Different format of passwords
Consider the following password as different format
1. T3LF23!+?sRty$J
• This password has 15 characters from four classes, including lowercase letters,
uppercase letters, numbers, and symbols, and it’s not based on a dictionary word.
• the LM hash algorithm, the password is truncated to 14 characters like this:
T3LF23!+?sRty$
2. Then the lowercase letters are changed to uppercase:
T3LF23!+?SRTY$
3.Next, the password is spl Next, the password is split into two seven-character
parts.
The two parts are then used as keys to encrypt the static string KGS!@#$% using
the Data Encryption Standard (DES) encryption algorithm:
• T3LF23! +?SRTY$
The resulting eight-character ciphertexts from the encryption are thenconcatenated
to make the LM hash.
5.John the Ripper tool
• One of the more popular tools for cracking passwords is John the Ripper.
• John the Ripper cracks the seven-character password hashes.
• The default mode for John the Ripper is brute forcing. Because the set of possible plaintext passwords in LM hash is
so limited, brute forcing is a viable method for cracking any LM hash in a reasonable amount of time, even with our
Kali virtual machine, which has limited CPU power and memory.
• Use command
root@kali: john xphashes.txt
Output:
• root@kali: john xphashes.txt
• Warning: detected hash type "lm", but the string is also recognized as "nt"
• Use the "--format=nt" option to force loading these as that type instead
• Loaded 10 password hashes with no different salts (LM DES [128/128 BS SSE2])
• (SUPPORT_388945a0)
• PASSWOR (secret:1)
• (Guest)
• PASSWOR (georgia:1)
• PASSWOR (Administrator:1)
• D (georgia:2)
• D (Administrator:2)
• D123 (secret:2)
Cracking Linux Passwords
• the MD5 hashed passwords we found in the FileZilla FTP server configuration file we
downloaded with the Zervit 0.4 file inclusion vulnerability.
• The administrator of this system forgot to change the default password for the built-in
FTP account.
Rainbow Tables
• Rainbow tables typically hold every possible hash entry for a given algorithm up to a
certain length with a limited character set.
• For example, you may have a rainbow table for MD5 hashes that contains all entries
that are all lowercase letters and numbers with lengths between one and nine.
• This table is about 80 GB— A full set of LM hash rainbow tables is about 32 GB.
• The tool Rcrack in Kali can be used to sift through the rainbow tables for the
correct plaintext.
Online Password-Cracking Services
• Set up up your own high-powered machines in the cloud, create your own wordlists,
and so on, but there are also online services that will take care of this for you for a fee.
• For example, https://www.cloudcracker.com/ can crack NTLM Windows hashes, SHA-
512 for Linux, WPA2 handshakes for wireless, and more. You simply upload your
password hash file, and the cracker does the rest.
C:\>wce.exe –w
output
• wce.exe -w
• WCE v1.42beta (Windows Credentials Editor) - (c) 2010-2013 Amplia Security - by Hernan
Ochoa
• ([email protected])
• Use -h for help.
• georgia\BOOKXP:password
• Many routers that come with encryption enabled use older encryption called wired equivalent
privacy (WEP) by default.
• The fundamental problem with WEP is that flaws in its algorithm make it possible for an
attacker to
• recover any WEP key. WEP uses the Rivest Cipher 4 (RC4) stream cipher and a pre-shared
key.
• Anyone who wants to connect to the network can use the same key, made up of a string of
hexadecimal digits, for both encryption and decryption.
• The plaintext (unencrypted) data undergoes an exclusive or (XOR) bitwise operation with the
keystream to create encrypted cipher text.
• The bitwise XOR operation has four possibilities:
• 0 XOR 0 = 0
• 1 XOR 0 = 1
• 0 XOR 1 = 1
• 1 XOR 1 = 0
WEP decryption
• The zeros and ones in the bitstream in Figures 15-2 and 15-3 can represent any data
being sent over the network. Figure 15-2 shows how the plaintext I XORed with the
keystream to create the ciphertext.
Plaintext: 101101100000111100101010001000...
Keystream: 110001101011100100011100110100...
Ciphertext: 011100001011011100100110001100...
• Figure 15-2: WEP encryption
When decrypted, the same keystream is XORed against the ciphertext to restore the
original plaintext, as shown in Figure 15-3.
Ciphertext: 011100001011011100100110001100...
Keystream: 110001101011100100011100110100...
Plaintext: 101101100000111100101010001000...
• Figure 15-3: The shared WEP key can be either 64 or 148 bits
• The shared WEP key can be either 64 or 148 bits.
• In either case, an initialization vector (IV) makes up the first 24 bits of the key to add
randomness,making the effective key length really only 40 or 104 bits.
• Adding randomness with an IV is common in cryptographic systems because if the same
key is used repeatedly, attackers can examine the resulting ciphertext for patterns and
potentially break the encryption.
• The IV and key are concatenated, then run through a key-scheduling algorithm (KSA) and a
pseudorandom number generator (PRNG) to createthe keystream.
• Next, an integrity check value (ICV) is computed and concatenated with the plaintext before
encryption
• in order to prevent attackers from intercepting the ciphertexts, flipping some bits, and
changing the resulting decrypted plaintext to something malicious or, at least, misleading.
• The plaintext is then XORed with the keystream (as shown in Figure 15-2). The resulting
packet is made up of the IV, the ICV, the ciphertext, and a two-bit key ID, as shown in Figure
15-4.
• Decryption is similar, The IV and key (denoted by the key ID), stored in
plaintext as part of the packet, are concatenated and run through the same
key-scheduling algorithm and pseudorandom number generators to create a
keystream identical to the one used for encryption.
• The ciphertext is then XORed with the keystream to reveal the plaintext and
the ICV.
• Finally, the decrypted ICV is compared with the plaintext ICV value appended
to the packet. If the values don’t match, the packet is thrown out.
WEP Weaknesses
•Static Shared Key:
WEP uses a single key for all devices on the network, making it vulnerable to attackers w
the key.
•RC4 Algorithm Weakness:
The RC4 algorithm used in WEP has known vulnerabilities, making it susceptible to variou
•IV Collisions:
WEP's relatively short IVs (24 bits) can lead to collisions, allowing attackers to recover the
•Lack of Mutual Authentication:
WEP lacks mutual authentication, meaning devices can't verify the identity of the access
to man-in-the-middle attacks.
•Optional Use:
The use of WEP was optional, leading to many devices not having it enabled, further incre
•Poor Key Management:
WEP's key management mechanisms were weak, and some implementations reused the
security.
•Tools for Cracking:
Numerous tools, like AirSnort, are available to crack WEP keys, making it easy for attacke
•Susceptibility to ARP Spoofing:
WEP's vulnerabilities enable Address Resolution Protocol (ARP) spoofing attacks, allowing
Cracking WEP Keys with
Aircrack-ng
• There are multiple ways to crack WEP keys, including the fake authentication attack, fragmentation
attack, chopchop attack, caffé latte attack, and PTW attack.
• authentication attack, which requires at least one legitimate client connected to the access point.
• Command:
• Airodump-ng to use the wireless interface in monitor mode mon0, and use the -w flag to save all
packets to a file.
root@kali:~# airodump-ng -w book mon0 --channel 6
• CH 6 ][ Elapsed: 20 s ][ 2015-03-06 19:08
• BSSID PWR Beacons #Data, #/s CH MB ENC CIPHER AUTH ESSID
• 00:23:69:F5:B4:2Bu -53 22 6 0 6v 54 . WEPw WEP linksysx
• BSSID STATION PWR Rate Lost Frames Pro
Use command:
root@kali:~# aireplay-ng -1 0 -e linksys -a 00:23:69:F5:B4:2B -h 00:C0:CA:1B:69:AA mon0
We fake authentication using the following flags with their associated data:
• -1 tells Aireplay-ng to fake authentication.
• 0 is the retransmission time.
• -e is the SSID; in my case linksys.
• -a is the MAC address of the access point we want to authenticate with. -h is the MAC address of
our card (which should be on a sticker on the
• device).mon0 is the interface to use for the fake authentication. After sending the Aireplay-ng
request, you should receive a smiley face and indication that authentication was successful u.
Output:
• 20:02:56 Waiting for beacon frame (BSSID: 00:23:69:F5:B4:2B) on channel 6
• 20:02:56 Sending Authentication Request (Open System) [ACK]
• 20:02:56 Authentication successful
• 20:02:56 Sending Association Request [ACK]
Generating an ARP Request
• To generate an ARP request, we’ll use the host system as a simulated client by pinging
an IP address on the network from the connected host system.
• Aireplay-ng will see the ARP request and retransmit it to the access point over and
over.
• the Airodump-ng screen the #Data number, indicating captured IVs, increases
rapidly as Aireplay-ng
• continues to retransmit the ARP packet, causing the access point to generatemore IVs.
• output
• CH 6 ][ Elapsed: 14 mins ][ 2015-11-22 20:31
• BSSID PWR RXQ Beacons #Data, #/s CH MB ENC CIPHER AUTH ESSID
• 00:23:69:F5:B4:2B -63 92 5740 85143u 389 6 54 . WEP WEP OPN linksys
Generating IVs with the ARP Request Relay Attack
• Use command:
• root@kali:~# aircrack-ng -b 00:23:69:F5:B4:2B book*.capu
• Opening book-01.cap
• Attack will be restarted every 5000 captured ivs.
• Starting PTW attack with 239400 ivs.
• KEY FOUND! [ 2C:85:8B:B6:31 ] v
• Decrypted correctly: 100%
Challenges with WEP Cracking
• Access points could use MAC filtering to allow only wireless cards with certain MAC
addresses to
• connect, and if your Alfa card isn’t on the list, your fake authentication attempt will fail.
• To bypass MAC filtering, you could use a tool like MAC Changer in Kali to spoof a MAC
address and create an accepted value.
• Keep in mind that WEP keys are always crackable if we can gather enough packets, and
for security reasons, WEP encryption should not be used in production.
• It’s worth noting that the Wifite tool, installed by default in Kali Linux, behaves as a
wrapper around
Wi-Fi Protected Access
• Wi-Fi Protected Access (WPA), also known as Temporal Key Integrity Protocol (TKIP)
• WPA uses the same underlying algorithm as WEP (RC4) but seeks to address WEP’s
weaknesses by adding keystream randomness to IVs and integrity to ICV.
• WEP, which uses a 40- or 104-bit key combined with weak IVs for each packet, WPA
generates a 148-bit key for each packet to ensure that each packet is encrypted with a
unique keystream.
• Additionally, WPA replaces WEP’s weak CRC-32 message integrity check with a
message authentication code (MAC) algorithm called Michael, to prevent attackers from
easily calculating the resulting changes to the ICV when a bit is flipped.
• Though both WPA and even WPA2 have their weaknesses, the most common
vulnerability is the use of weak passphrases.
WPA2
• WPA2 was built from the ground up to provide a secure encryption system for wireless networks. It
implements an encryption protocol built specifically for wireless security called Counter Mode
with Cipher Block Chaining Message Authentication Code Protocol (CCMP).
• CCMP is built on the Advanced Encryption Standard (AES).
• WPA and WPA2 support both personal and enterprise setups.
• WPA/WPA2 personal uses a pre-shared key, similar to WEP. WPA/WPA2 enterprise adds an
additional element called a Remote Authentication Dial-In User Service (RADIUS) server to
manage client authentication.
The Enterprise Connection Process
• In WPA/WPA2 enterprise networks, the client connection process comprisesfour steps
• First the client and the access point agree on mutually supported security protocols. Then, based
on the
• authentication protocol chosen, the access point and the RADIUS server exchange messages to
generate a master key.
• Once a master key is generated, a message that authentication was successful is sent to the
access point and passed on to the client, and the master key is sent to the access point.
• The access point and the client exchange and verify keys for mutual authentication, message
encryption, and message integrity via a four-way handshake.
• Following key exchange, traffic between the client and the access point is secured with WPA or
WPA/WPA2 enterprise connection
The Personal Connection
Process
• The WPA/WPA2 personal connection process is slightly simpler than the enterprise one: No
RADIUS server is required, and the entire process is between the access point and the client.
• No authentication or master key step occurs, and instead of a RADIUS server and master key,
WPA/WPA2 personal use pre-shared keys, which are generated using pre-shared passphrases.
• The WPA/WPA2 personal passphrase that you enter when you connect to a secured network is
static, whereas enterprise setups use dynamic keys generated by the RADIUS server.
The cryptographic algorithms used in WPA and WPA2 are robust enough to stop attackers
from recovering the key simply by capturing enough traffic and performing cryptanalysis.
• To try to guess a weak password, we first need to capture the four-way handshake for
analysis.
• Recall that given the correct passphrase and the SSID of the access point, the PBKDF2
hashing algorithm can be used to generate the shared key (PMK).
• Given the PMK, we still need the ANonce, SNonce, and the MAC addresses of the
access point and client to calculate the PTK.
• the PTK will differ for each client, because the nonces will differ in each four-way
handshake, but if we can capture a four-way
• handshake from any legitimate client, we can use its MAC addresses and nonces to
calculate the PTK for a given passphrase.
Using Aircrack-ng to Crack WPA/WPA2 Keys
• To use Aircrack-ng to crack WPA/WPA2, first set up your wireless access point for WPA2 personal.
• Choose a pre-shared key (passphrase) and then connect your host system to your access point to simulate a real
client.
• To use a wordlist to try to guess the WPA2 pre-shared key (passphrase), we need to capture the four-way handshake
Use command( authenticate)
root@kali:~# airodump-ng -c 6 --bssid 00:23:69:F5:B4:2B -w pentestbook2 mon0
• Enter airodump-ng -c 6 for the channel, --bssid with the base station MAC address, -w to specify the filename for
output (use a different filename than you used in the WEP crackin example), and mon0 for the monitor interface.
• To force a client to reconnect, use Aireplay-ng to send a message to a connected client telling it that it is no longer
connected to the access point.
• When the client reauthenticates, we’ll capture the four-way handshake between the client and access point.
Use command(deauthenticate)
• root@kali:~# aireplay-ng -0 1 -a 00:23:69:F5:B4:2B -c 70:56:81:B2:F0:53 mon0
• The Aireplay-ng options we’ll need are:
• -0 means deauthentication.
• 1 is the number of deauthentication requests to send.
• -a 00:14:6C:7E:40:80 is the MAC address of the base station.
• -c 00:0F:B5:FD:FB:C2 is the MAC address of the client to deauthenticate.
Use command(deauthenticate)
• root@kali:~# aireplay-ng -0 1 -a 00:23:69:F5:B4:2B -c 70:56:81:B2:F0:53 mon0
• The Aireplay-ng options we’ll need are:
• -0 means deauthentication.
• 1 is the number of deauthentication requests to send.
• -a 00:14:6C:7E:40:80 is the MAC address of the base station.
• -c 00:0F:B5:FD:FB:C2 is the MAC address of the client to deauthenticate.
• captured the WPA2 handshake, close Airodump-ng, and open the .cap file in Wireshark
with FileOpenfilename.cap. Once in Wireshark, filter for the eapol protocol to see the
four packets that make up the handshake.
• Next we use Aircrack-ng to test the keys in the wordlist, specifying a list with the -w
option.
• Otherwise, the command is identical to cracking the WEP key. If the correct key is in the
wordlist, it will be recovered with Aircrack-ng.
• This sort of dictionary attack against WPA/WPA2 can be prevented by using a strong
passphrase.
• Aircrack-ng is just one suite of tools for cracking wireless.
Wi-Fi Protected Setup
• Wi-Fi Protected Setup (WPS) was designed to allow users to attach their devices to secure
networks with an eight-digit pin instead of a potentially long and complicated
passphrase.
• When the correct pin is supplied, the access point sends over the passphrase.
• WPS can be vulnerable to brute force attacks if the PIN is not disabled or if the network is configured with push-button WPS and an easily
guessed PIN.
• Kali provides tools that you can use to implement a brute-force attack against WPS.
• One such tool is Bully.
• We can use Bully to brute-force the WPS pin as well as test a specific pin.
• To use Bully we need the SSID, MAC address, and channel of the access point, which
we found with iwlist.
• Use the -b flag to specify the MAC address, the -e flag for the SSID, and the -c
flag for the channel,
• Use command:
• root@kali:~# bully mon0 -b 00:23:69:F5:B4:2B -e linksys -c 6
• Bully should be able to brute-force the pin in around four hours and recover the
correct pre-shared PIN.
• WPS is enabled by default on many wireless access points and may be an easier way
in than guessing a strong WPA/WPA2 passphrase.
Wireless attack tools
Tools:
• Aircrack-ng
• Wireshark
• Kismet
• Reaver
• Metasploit