Using OSSEC to Detect MacDefender in Squid Logs

While doing forensics this week to determine where the MacDefender malware was coming from I noticed one thing that was distinct to all the requests for this malicious package. When it was downloaded the mime type for the file request was “application/download” when searching through the logs I noticed that this was a mime type that I would want to know about anyways and that generally there are not a lot of requests associated with this mime type. So I would not be overwhelmed with notifications.

So how do I monitor this? I’ve been using the OSSEC IDS system ( for a few years now. It is an excellent tool and completely customizable. To get OSSEC to monitor my squid log first I added the /var/log/squid/access.log to the list of monitored files in the  /var/ossec/etc/ossec.conf file and restarted the service.


Now, the problem I found with adding this is if you have a pretty busy network with a lot of different clients (Macs, Linux, PCs) then you are going to get some odd traffic that will trigger alerts based on multiple errors found in the squid access log. To monitor this it would be a good idea to shut off active response for a while and then gather some exceptions that you can put into the local_rules.xml file on the OSSEC server. Below is the rule I used to detect application/download.

<group name="squid-custom,">
  <rule id="100400" level="6">
   <description>Application downloaded via squid proxy. Check URL to determine malware.</description>

I have I have email notifications set for level 6 and up and active response to 7 or greater. This way internal hosts will not lose there internet connection abilities when downloading a legitimate program. Below are some of the exceptions that I had to add to the local_rules.xml to make sure that certain requests did not add internal hosts to the hosts.deny file.

  <rule id="35057" level="0">
   <description>False Positive. Symantec Endpoint client going through proxy.</description>
  <rule id="35009" level="0">
   <description>False Positive. Symantec Endpoint client going through proxy.</description>
  <rule id="35008" level="0">
   <description>False Positive. Symantec Endpoint client going through proxy.</description>

There will probably be a few more things to add. Just monitor your alerts carefully and you will have it smoothed out in short order.

As I was about to leave work today I received an alert from OSSEC that looked like what you see below. I’ve edited out the internal information and the bad URL’s host.

OSSEC HIDS Notification.
2011 May 27 14:49:17

Received From: (MyProxy) IPaddress ->/var/log/squid/access.log
Rule: 100400 fired (level 8 ) -> "Application downloaded via squid proxy. Check URL to determine malware."
Portion of the log(s):

1306522093.290    620 <InternalHost> TCP_MISS/200 47939 GET DIRECT/<BadIPAddress> application/download


I blocked the IP on my network, checked the host that downloaded the package and then submitted the bad ip address to the Google Safe Browsing Report here: and as I checked it tonight I receive the warning when going to the site in Firefox and Chrome.


About Craig Szymanski

Systems Administrator Photography Enthusiast
This entry was posted in Computer Security, Macintosh, Phishing and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s