Archive for the ‘Defense’ Category

Security I want around my online banking experience…

Online banking and bill pay are two of the conveniences of the information age. I have memories of seeing my mom paying the monthly bills late at night filling out checks, opening and addressing envelopes, putting on stamps etc. She then of course had to manually balance her checkbook with a calculator. I cringe at the thought of having to spend several hours a month in such a manner, with online banking and bill pay it usually takes me 30 mins to send out the money with little or no writing or mailing. As with many conveniences, however it comes with a risk of potential abuse. Individuals certainly aren’t the only ones being victimized, especially vulnerable are small to medium-sized business who have relatively a lot of money compared to the average Joe Schomo like me and unfortunately for them they are not covered by the FDIC or the bank’s policy. Here’s a Bloomberg article from August last year that goes into several examples of theft and how the banks don’t always reimburse those companies like they do you when your CC is stolen. Bloomberg article

So without further ado here is what I humbly ask from my bank, 3 fairly quick wins that should be implemented as soon as possible. I’ll let you know if I hear anything back from them. I plan on hitting some of the bigger ones up on Twitter and LinkedIn to see if any of that social media mumbo jumbo works for me and my little blog.

Read more

Detecting the Bad from the Good…

UPDATE:  I have had this blog entry written for about 3 weeks, but was hoping I could get some real world experience before posting.  Unfortunetly that hasn’t happened yet, so it will have to be theoretical at this point.  I hope to update this post or add another with maybe a SNORT sig and my experiences with HTTP logs.   –January 16, 2012.
_________________________________________________________________________________
In security monitoring it’s your job to use your creativity to design rules and dashboards so you can identify evidence of malicious activity.  In general there are two strategic ways to do this, detect the bad (blacklisting) or detect the good (whitelisting).  It doesn’t take a genius to realize that whitelisting is the more effective strategy overall, although its much harder to implement.  Even so blacklisting is still useful to use for increasing defense in depth.   Speaking about getting creative to detect the bad guys, a recent thought I had is looking for one of the tactics they use to avoid being taken offline.  Namely registering and using a large number of domains so that content filtering and whitehat organizations can’t keep up.  You could see this during the Conficker worm battles, where early versions were programmed to connect to 250 domains a day, and when the Conficker Cabal launched an effort to pre-register those names later worm versions came out in direct response with algorithms for 50,000 domains per day.
The flaw I see in the “I can register more domains, faster then you can” tactic is often the make up of those domains. By their nature they frequently are a collection of puesdo random letters not valid strung together words in your language, like a normal domain.
For Example: (consonants in a row in red)
jxnrxlwmulpefpjt.org
qqwfddgtgfbafgnhnusmz.cx.cc
fhgis7afg7s6d7fgs76 odf.ws
khetttttttt.coom.in
This makes them fairly easy to detect when browsing through your event stream.  However, it is obviously impossible to manually watch HTTP logs looking for these non-conforming domains all day. So it made sense to me to look for what doesn’t conform to the majority of good URLs.  Because if you are looking for the proverbial needle in a haystack, you need to apply a tatic to everything that will find what doesn’t follow the rules of being a needle. So you could start a fire to burn the haystack (needle and all) which would leave the needle relatively unharmed.  Or spread the haystack over a magnetic strip which only the needle would stick too.   An example of this with Infosec defense would be detecting host names in the HTTP header\Web Logs that do not conform to the rules of your language, which is American English in my world.  I’ve been considering recently how to do this and what made sense to me is “number of constants w/o a vowel between them”.
To do this you need the rules of your language which you can get through the study of phonotactics. Which is how to “deal with restrictions in a language on the permissible combinations of phonemes” wiki here.  In particular I’m looking for consonant clusters, which some languages don’t even allow. The rules of American English are very few words have more then 5 consonants in a row.  Now domains often string words and even numbers together like I do in scottfromsecurity.com. So to test and fine tune my theory, I created a .php script that will loop through a file of domains each on a newline and compare them against a Perl Compatible Regex meant to find a string of x number of constants and/or numbers in a row.  To do this, I collected 1.215 million domains from
1.  malwaredomainlist.com (proven malicious domains)
2.  aboutwebmaster.com (recently expired domains could be good or bad)
3.  quantcast.com (top 1 million websites on the web)
As you can see the file is made up mainly of ”good domains” from Quantcast because this filter is meant to be a “if it hits you need to investigate” kinda technique, so false positive rates need to be near zero.  The table below shows an idea on the true positive/false positive ratio.  I recommend you play with the variables as YMMV.   My best experiences were to exclude the Y on 8 or less constants in a row.
Domains.txt contained
1,215,000 total domain names
NOTE:  Y is sometimes a vowel in American English so how you handle it depends on your false positive (FP) tolerance.
Without “Y”as a vowel With “Y” as a vowel
6 or more matches

12,827 matches total
some FPs: yourworld2009.com, thanks4thegift.com
6 or more matches

23,653 matches totals
some FPs: simplycheaphotel.com,shortlyclosed.com
7 or more matches

3,979 matches total
some FPs: wintersports2010.com, irelandsdvdstore.com
7 or more matches

7,128 matches total
some FPs: wildernessparksbystate.com, worldgymperu.com
8 or more matches

1,615 matches total
some FPs: superbowlxxxxvtickets.com
8 or more matches

2,461 matches total
some FPs: holytemplechurch15088.com
9 or more matches

846 matches total
some FPs: bestlcdtvprice.info (could be “bad”, but legit english)
9 or more matches

1,127 matches total
some FPs: dancinggypsyproductions.com, mymonthlycycles.com
results9withY
Often in info sec after creating a control to mitigate risk, you immediately have to create exceptions for the real world.    In this case the exception would be around domains that use random letter strings in the host part of the domains because that is part of the HOST header in the HTTP protocol.  FPs I’ve found are mostly cloud providers such as
pwlmxczqq.google.com
slqkqzcjgh.amazonaws.com
So in closing, there will be false positives you can’t account for in an exception list and it will not detect all bad domains, but maybe it’s another tool in the box for the defenders. Could the bad guys re-write their domain registration scripts quickly to register domains with dictionary words strung together to beat the regex?  Yeap.  But a major goal in the defense of anything is forcing your adversary to change their tactics in the eternal game of cat and mouse; while raising the bar required to successfully defeat you specifically. To paraphrase an old joke, it doesn’t matter if you outrun the bear or the other guy; either way you survive.
I have the .php script and domains.txt linked below, if anyone is interested. Suggestions on my script welcome.
PS.  the order of the letters in the regex look random but in fact are arranged by what several sites suggested is the most accepted letter frequency in the average English text. Don’t know if that will help the scripts efficiency but figured it couldn’t hurt.

Detecting emails spoofing your domain using Outlook Rules…

The concern over targeted emails from sophisticated attackers is only increasing after the Aurora attacks, not to mention the latest Google vs. China row, and RSA’s compromise. One technique the attacker’s use to make their targeted email more legitimate is to fake or spoof the email’s from address using the recipient’s own domain, so it is more likely to be opened. The constant message from security about the dangers of email can make opening a spoofed message cause much alarm for the average user, which of course is usually only evident after the message has been opened. Which is quickly followed by the usual questions, why am I getting this email Joe said he didn’t send it? It says I sent it! It’s not in my sent items, am I infected? Spoofing email addresses has a long history of being allowed by the SMTP protocol and many companies currently rely on that “feature” to deliver mail legitimately, think surveys, send this link to a friend, web page forms, mailing lists etc. So it’s not as simple as just blocking everything with an internal domain that comes from the Internet; because it’s not all bad. It’s also made more difficult in how SMTP works, where the MAIL FROM (aka. Smtp from, RFC2821, envelope from) is often is what is evaluated at the mail gateway/server level, but the user will just see the FROM (aka. RFC2822, message from).

What would help is a way for the average user to see the difference between an externally sent email from your internal domain(s) and an internally sent email from your internal domain(s) BEFORE opening it. I’ve thought of a way to do this with Outlook Client rules and would like to share that here. So if your organization, especially small businesses and SOHOs are struggling with this, give it a shot and let me know how it goes. (The screenshot’s below are from Outlook 2007)

The rule will essentially look for messages with your internal domain(s) in the message from, then look for a special line that your SMTP gateways put in the Received Headers, then if found the rule performs some action. Because if your internet facing mail servers relayed the message it had to come from outside your organization, and hence somebody musta spoofed ya’. I will explain below.

A barebones rule, just to get the idea, will look like this… (just replace @example.com with your own work’s email domain)

Here’s what it does if not obvious…

  1. Search for @example.com in the sender’s FROM address (not MAIL FROM:)
  2. And then look for Received: from mail1.example.com in the message headers
    (you can add other servers separated by an OR, yes the colon and spacing are important!)
  3. Assign the message to the “Spoofed” category.  (I made this up, you could also delete, or move the message to a separate folder, marking the subject unfortunately does not appear to be an option with client rules)

If you don’t know what “mailserver1.example.com” is at your workplace, the best thing is to ask your IT mail admin, if that’s you and you are still clueless (we’ve all been there) you can USUALLY get that information from the DNS MX records your company publishes on the internet.   The site http://mxtoolbox.com will allow you resolve those records.  Just enter your email domain where I have scottfromsecurity.com in screenshot below.  The info under the column “hostname” will be what you want to put in your rule, there will most likely be more than one.

If you want to categorize the suspiciously spoofed message like I did (because deleting or moving it can cause its own problems with lost mail and helpdesk calls) you’ll just need to create an Outlook Category, and choose a color (Red for example).  In Outlook main window click Actions…Categorize…All Categories…New…Add text that you want the user to see when they open the email.

This will allow the message to be categorized and will show a colored bar when opened.  To make it obvious to the user BEFORE the message is opened you’ll have to have them modify their current view.  The view will then color messages that are categorized with your new “Spoofed” category.  In Main Outlook and with your Inbox selected window go to View…Current View…Customize Current View…then click Automatic Formatting… Add,  name the auto formatting rule and set font to desired color, by clicking Font button, as shown.  Then click Condition button…More Choices Tab..Categories…and check off the “Spoofed. Please be CAUTIOUS of Web LINKS contained in this email.” category.

 

Death by Screenshot continues with some pics on the end result of the above configuration.

And here is the opened message showing the red bar with your category message at the top, in case the user does open it. Hopefully discouraging them from clicking any links the email may contain before checking with IT.

For the IT professionals here’s more along the lines of what the a fully functional rule would look like with more than one internet facing MTA, gives it low importance, and has some notable email address exceptions (ie. the good spoofing).

Caveats:

  1. This probably won’t work if your external mail relays are also your internal mail relays, ie you don’t have MS Exchange or something to handle internally sent mail separately.  All mail will be shown as spoofed, unless you use separate interfaces and DNS names.
  2. Far as I know GPO’s can not be used to push out Outlook client rules/configuration; you could potentially export the rule to a .rwz file and have users import it themselves. Tools…Rules and Alerts…Options(upper right)…Export or Import Rules button…navigate to .rwz file.   So deploying the config probably won’t be possible to do automatically, screen shots and a company wide email will most likely be required for the .rwz file import, category and view creation as well.
  3. Also this is a Client only rule. As Outlook warns about when you go to save it.   That simply means if your Outlook client isn’t running the rule won’t take effect.  So on Monday you will need to launch Outlook and let it process your new email to see if it matches the rule.
  4. It will be a window’s user profile specific setup, so might be something to add to the workstation build process or when desktop support delivers the box to the new user, after they log in for the first time.

I’m still in the planning stages of rolling this out at my current contracting position, so as I learn the positive and negatives around this approach I’ll be sure to update this post.

I was also toying with the idea, of using different actions such as “run a script” and “custom action” but they would further complicate what’s now is pretty simple. Also my current security monitoring analyst job does not get heavily into administration so can I  leave that up to the Exchange admins out there?  If anyone thinks up a better way to do this or anything cool (like marking the subject, so the category and view setup wouldn’t be needed) using a VB script or custom action with a .dll, feel free to leave a comment and share it with the 5 other people who read this blog.

___________________________________________________________________________
PS:  Lastly if all of the above is not appealing another blogger had a simpler approach involving tagging everyone’s email signature with some consistent text string and then writing a rule to filter on that.  This technique would identify the good (whitelist), where as mine identifies the bad(blacklist), why not try both and see which one works best for you? It also just occurred to me, with his approach, you might even want to make that text string white so it’s not overly obvious when the recipient sees it.  Read about it here… http://www.countryipblocks.net/training/the-cheap-way-to-keep-spoofed-email-out-of-your-inbox/

Good luck in your SPAM fight.

 

Cheap Website Monitoring…

A big part of being a security analyst is figuring out why something you admin is blocking what a customer is trying to get to.  I actually like those problems because I look at them like a mini-puzzle. The key to these issues, and many others for that matter, is being able to recreate the trouble with your own equipment.  I usually tell people, if it’s blocked for me too then I will be able to fix it.  The hard problems come when it’s an occasional issue, or only from one part of the network, etc.

Anyway, the latest scenario involved a city employee trying to get to a local high school’s website to get their layout.  The site was blocked with the category pornography, which seemed like a miscategorization.  After recreating the problem on my desktop I got a hunch, which leads me to the reason for this post.  I headed to google and searched “site:xxxxxx.edu nude”  and it came back with the results that would make any webmaster wince.  Pictured below (anonimized to protect the innocent)…

Screen shot of SEO injected keywords

So that was quickly solved by making the school’s webmaster aware of the injected HTML SEO poisoning keywords and asking our vendor to re-evaluate the site once cleaned.  But more to the point such Google searches are a really cheap way to do some manual monitoring for websites under your protection. I personally do searches like these every few weeks, on the off chance one day I will get something other then no webpages found.  Don’t forget to submit requests to clear the major search engine’s cache if you’re hit or these results will stick around for a while.

PS I’ll leave it up to the reader’s imagination on which keywords to use.

Deleting Files Already in Use Remotely…

I had a bit of a frustrating day the other week, a machine was infected with an IRC bot that AV couldn’t detect or remove, beyond the relatively minor host file modifications. The machine was re-imaged and then even replaced, but kept getting reinfected a few hours later.  Of course 99% of the time that means a PEBCAK (google it).  It turned out to be a user’s personal infected thumb drive that was spreading the bad stuff.  Anyway since we were getting a large amount of email alerts from the IPS on outgoing IRC NICK registration to IPs in Asia, I RPDed to the machine and copied TCPview from a share to see what exe was creating the process sending the IRC traffic.  The malware was able to hide the process from taskmgr but not the sysinternals tool. It turned out to be the file run64dll.exe so I tried to stop the process and it immediately started back up, not surprising.  I tried the delete the exe but Windows complained about it being in use.  This is usually where safe mode comes into play but I was sitting miles away, so I employed a trick that is the reason I’m writing this blog entry.  Of course you will most likely have to be local Admin or have those rights on the target folder/file, but when you need to kill a file in use try changing the permissions on the file to DENY ALL (Right click file and go to permissions tab in WinExplorer).  This will then quickly stop the process you couldn’t from accessing the file and probably will allow you to delete the file.  Worked for me and hopefully it will for you.  After that I highly recommend a full re-image, you have proof that malicious software successfully ran on that machine and there is no way to know for sure how deep the infection went, don’t risk it just wipe it.

Return top

Bad Behavior has blocked 18 access attempts in the last 7 days.