Archive for January, 2006

h1

Having fun with Windows Metafile Handling Code Execution

January 5, 2006

If you haven’t heard about the Windows Metafile exploit and are using Windows XP or Windows 2003 then you should be a little worried. This exploit allows someone to execute any command they want on your computer as easily as sending you a link and having you browse to it using Internet Explorer. To demonstrate how critical this issue is I am going to show you how to create a .wmf file that will pop up calc.exe on a Windows XP computer by only having them browse to a web page with the .wmf exploit on it.

To easily create the exploit we will be using Metasploit. To do this we will need to download the exploit code and then put it into Metasploit in the correct format. The code for this Metasploit module can be found at www.frsirt.com it is called ie_xp_pfv_metafile.pm.

Open up the link and then copy all of the code (from ## through 1; ) now open up TextEdit and paste the code into TextEdit and save the file as ie_xp_pfv_metafile.pm it is really important you name the file correctly or Metasploit will not be able to use it.

Now that you have a .pm file you need to put it in the correct place in Metasploit. Using Finder Browse to where you have your Metasploit folder named framework-2.5 inside the framework folder is a folder named exploits. You will want to place the ie_xp_pfv_metafile.pm file in the exploits folder. Now you want to set the permissions on the new file to the same permissions as the rest to the files in the exploits folder. The easiest way to do that is using Terminal and cd to the framework-2.5/exploits folder and then

ls -la

To see the permissions and owners of the file. If you need to, use chmod and chown to make the permissions match the other files exactly.

Now that the new exploit module is ready you can now fire up the msfcli or msfweb to create a .wmf file. I will be showing you the easy way to do this using msfweb.

Using Terminal cd to the framework-2.5 directory and then run msfweb with the following command

./msfweb

Now open up a web browser and point it to 127.0.0.1:55555 to get to the Metasploit web based GUI.

Using the Filter select app :: ie and click Filter Modules. Now click on Windows XP/2003 Picture and Fax Viewer Metafile Overflow to get started.

Click the Select Target link. We will be executing a harmless remote command so select win32_exec as the Payload.

Now under HTTPHOST put in 127.0.0.1 and in the CMD field type in calc.exe

Picture 2.png

and now click Exploit. You will now see [*] Waiting for connections to http://127.0.0.1:8080/anything.wmf.

Open up a new tab and browse to http://127.0.0.1:8080/anything.wmf and save that file to disk.

The file is now ready to be uploaded to your web server. Upload the file to your web server and set the correct file permissions. Now browse to the file’s URL using a Windows XP or 2003 computer and Internet Explorer and watch your calculator pop up.

Microsoft knows about this vulnerability and will release the patch on the 6th of January 2006. Until then if you have a vulnerable computer I suggest patching it with the patch available from SANS. Keep in mind though this patch is not authorized by Microsoft and has been found to cause some printing problems when the DLL is registered.

h1

Running Bastille on OS X 10.3

January 5, 2006

Securing your Mac OS X 10.3 with Bastille.

Note: This tutorial assumes you have a basic understanding of the Mac OS X terminal command line and that you have the Apple Developer Tools installed on your computer and are comfortable compiling applications from source code. This tutorial is only good for OS X 10.2 and 10.3.

Bastille is an operating system hardening program. It was originally designed for *nix operating systems. Since Mac OS X is based on a flavor of BSD which is a branch of Unix it only makes sense that Bastille would work on OS X as well. The following is instructions on how to install and run the Bastille program on your Mac to either harden your current installation or to evaluate your current installation to see how secure it really is. Beware you are now going into the world of BSD so you better be comfortable on the command line.

The first thing you need to do is go and download yourself a copy of Bastille at www.bastille-linux.org/source.htm. We will want to get a copy of the source code for this installation. If you are still running OS X 10.2 you should read the OS X 10.2 specific instructions available here http://www.bastille-linux.org/os_x_10_2.htm.

Open up the terminal and browse to the directory you downloaded the tarball to. Now run the command

tar -xjvf Bastille.tar.bz2

This will un-zip and un-tar the sources and create a Directory named Bastille.

Now in order for you to run Bastille in Graphical Mode you will need to have X11 installed on your Mac. If you do not have it installed yet luckily X11 comes free on your Tiger or Panther Install DVD. Just open up the install DVD and Click on Optional Installs then select the X11 package.

Now that X11 is installed and working you can run the install script.

Open the Terminal and go Back into the directory you unpacked Bastille into.
Go into the Bastille directory

cd Bastille

Now run the install script for OS X

sh Install-OSX.sh

The GUI for the Bastille program depends on the Perl module Tk. By default it is not installed on a regular Mac OS X system. The easiest way to install the Tk module is to use the cpan program from the command line. You will need to have a few more programs installed in order for cpan to run correctly. They are wget, ncftp.

To install wget get the source code at ftp://ftp.gnu.org/pub/gnu/wget/wget-1.10.1.tar.gz.

Now go to the directory where you downloaded the sources to and run the following commands.
1. Untar and unzip the archive
tar xzvf wget-1.10.2.tar.gz

2. Go into the un-archived directory
cd wget-1.10.2

3. Run the configure script to get the source code configured for Mac OS X
./configure

4. Build the source code
make

5. Install the source code in its proper place (/usr/local/bin)
make install

You should now be able to run the wget commmand from the terminal command line. If you get command not found, check your PATH and make sure /usr/local/bin is in your shells path.

Ncftp is an easier install. You can get the .dmg from http://www.ncftp.com/download/ make sure you download the Ncftp Client and not the server. Install the .dmg as you would any other application.

Now that you have the required programs installed, run the cpan program from the commmand line

cpan

You will be asked to set up the cpan program if you have never used it before. I was able to configure it by accepting all of the defaults. If you use a proxy for HTTP or FTP then you will be prompted for the proxies during the cpan configuration. Once the configuration is complete you will be dropped into the cpan prompt that will look like this:

cpan>

Here we will need to install the Perl Tk module with the following command.

cpan> install module Tk

Be patient, this will take a few minutes to download, compile, and install.

Now you will be able to run the Bastille program to harden your install of OS X.

As soon as the new version of Bastille that supports OS X 10.4 is available I will revise this tutorial.