The hacker's guide to website security

2. Active reconnaissance

Step 1: Scanning

IIS technet

HELP IS AT HAND: For info on how to secure your IIS server, including the latest updates, visit msdn.microsoft.com

The sys admin is trying to be sneaky. On the Windows server there's IIS running, MS Terminal Server and MySQL. IIS is version 6.0. Via the terminal server client I can see that it's Windows Server 2003 – unpatched, I bet. I know that Port 3306 is MySQL, but it's filtered rather than closed. This tells me that there's a firewall configured in front of the servers and it's filtering MySQL connections from another server."

Countermeasures: Most applications allow you to change the advertised banner, somewhere. You may have to dig deep but you should be successful. For example, Apache has a directive "ServerSignature", which can be set to OFF. With SENDMAIL you need to change the sendmail.cf file. For IIS you can use the IIS Lockdown tool.

Something else you can do is conceal the file extensions, since the file extensions can give clues to the operating system you're running.

Step 4: Web server application scan

The reconnaissance process has its uses but unless there's a fundamental weakness there's no way to exploit the server. However, it's useful to map out the network and potentially discover hidden gems.

During the name server search, a number of additional host names and subdomains could be discovered. System administrators and developers often forget about these and leave old test scripts, data and vulnerable applications that have been downloaded for tests but never updated.

A paramount step in testing for web application vulnerabilities is to find out which particular applications are hosted on a web server. Many applications have known vulnerabilities and known attack strategies that can be exploited in order to gain remote control or to exploit data. In addition, many applications are often misconfigured or not updated, due to the perception that they're only used 'internally' and therefore no threat exists.

Ethical hacker: "Let's look to see if I can find any juicy pieces of information on these websites. I'll use an Amazon Virtual server to hide my real IP from the sys admin (not that they'll look in the logs anyway). From my passive reconnaissance, I can see that on the Linux server there are five websites hosted and two with subdomains. On the Windows servers I can't see any websites, even though IIS is running.

Starting with the Linux server I'll run the web file scanner, Nikto. I can see a robots. txt, /administration, phpinfo.php, /test, /manual, phpmyadmin, /downloads, /forum and /bakups. The robots.txt file lists the directories that the search engine shouldn't spider but that doesn't stop me looking at them. I can see /includes, /administrator, /cache/, /components/, /images/, /includes/, /installation/, /language/, /libraries/, /media/, /modules/, /plugins/, /templates/, /tmp/, /xmlrpc/. Let's look at phpinfo.php.

As I suspected, it's the PHP information. This will give me some information regarding the installation of PHP. I note the version, paths and installed extensions.

● /administration next. Joomla installation. No version number. I look at the source. The meta tag tells me it's 1.5. There are plenty of security updates for 1.5.
● /Forum. This leads me to a forum for the website. Looking at the footer I can see it's Vbulletin, but no version number. A quick Google search shows me the administration link – /admincp, the admin control panel screen – but still no version. I look at the page source and there it is: version 3.6.8 on the alt tag for the Vbulletin logo – how stupid. I'll search for a hack later.
● /test. There's a copy of a website here.
● /manual. A copy of the Apache manual.
● /bakups. Some old tar files. Worth a look.
● /phpmyadmin. Installation of phpMyAdmin version 3.2.5. The latest version but still an opportunity to test the username and password. Username is generally root.
● /downloads. I can see a Joomla tar file. This may mean Joomla is installed somewhere.

"I move on to the Windows server. The default IP address page confirms it's II6, but there don't seem to be any websites on this server, which must mean it's used for some other purpose. With MySQL and terminal services I'm guessing it's used for some database work."

Countermeasures: Don't leave old or unwanted files on the server. Make sure all installed third-party software is up to date. If you have a login page, can you restrict the IPs that can access it? You can't restrict access to the robots.txt file, so ensure there isn't any valuable information in there.