<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0"><id>tag:blogger.com,1999:blog-8203485581570185491</id><updated>2012-02-16T13:39:14.198-05:00</updated><title type="text">G2's BLOG</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://blog.g2-inc.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://blog.g2-inc.com/" /><author><name>Nathan Benson</name><uri>http://www.blogger.com/profile/13819659429302561666</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="http://3.bp.blogspot.com/_66LP7tQxYbg/TTXu9GHbHzI/AAAAAAAAAAM/rFRpIbL-JVA/S220/Nate%2B-%2BAvatar.png" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/feedsg2blog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="feedsg2blog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry><id>tag:blogger.com,1999:blog-8203485581570185491.post-8117876371544354991</id><published>2011-03-24T13:31:00.006-04:00</published><updated>2011-03-24T15:42:11.968-04:00</updated><title type="text">Malware Distribution Server Hostname Similarities by Michael Rash</title><content type="html">On the Arbor Networks security blog there was an interesting post&lt;br /&gt;(see: &lt;a href="http://asert.arbornetworks.com/2011/03/jkddos-ddos-bot-with-an-interest-in-the-mining-industry/" target="_blank"&gt;asert.arbornetworks.com/2011/03/jkddos-ddos-bot-with-an-interest-in-the-mining-industry/&lt;/a&gt;)&lt;br /&gt;about a Chinese DDoS bot called "JKDDOS" that appears to specifically&lt;br /&gt;target the heavy mining industry.  That by itself is noteworthy&lt;br /&gt;considering that China is reducing rare eath exports (see:&lt;br /&gt;&lt;a href="http://uk.reuters.com/article/2010/12/29/uk-china-rareearth-idUKTRE6BR0UZ20101229" target="_blank"&gt;uk.reuters.com/article/2010/12/29/uk-china-rareearth-idUKTRE6BR0UZ20101229&lt;/a&gt;),&lt;br /&gt;but what I found interesting in the JKDDOS analysis is a link between&lt;br /&gt;the distribution servers for JKDDOS and another malware family called&lt;br /&gt;the Avzhan family.  That is, a disbtribution server for JKDDOS is&lt;br /&gt;(sanitized) nnnavzhan.3322nnn.org and two distribution servers for&lt;br /&gt;the Avzhan family are nnnavzhan1.3322nnn.org and&lt;br /&gt;nnnavzhan2.3322nnn.org.  So, they are the same to within one&lt;br /&gt;character, and this is most likely not just a coincidence.&lt;br /&gt;&lt;br /&gt;Now, if we wanted to take our current malware repository and quickly&lt;br /&gt;determine which distribution hostnames are highly similar, we could&lt;br /&gt;use something like the perl String::Similarity module, or the&lt;br /&gt;Levenshtein Python extension (see: &lt;a href="http://code.google.com/p/pylevenshtein/" target="_blank"&gt;code.google.com/p/pylevenshtein/&lt;/a&gt;).&lt;br /&gt;Given two strings, each of these will return a number between 0 and 1&lt;br /&gt;that is a measure of how similar they are.  Zero implies totally&lt;br /&gt;different, and 1 implies identical.  So, for a quick one liner in perl&lt;br /&gt;(see below), we can see that the two hostnames mentioned above are&lt;br /&gt;extremely similar, and it would be an interesting result to see this&lt;br /&gt;applied across our entire malware repository - we might discover a&lt;br /&gt;previously unknown relationship between two pieces of malware that is&lt;br /&gt;worth exploring.  Of course, just because a malware distribution&lt;br /&gt;server is similar does not (by itself) prove anything - more&lt;br /&gt;investigation would be necessary.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="py"&gt;&lt;br /&gt;$ perl -e 'use String::Similarity; print similarity($ARGV[0],&lt;br /&gt;$ARGV[1]), "\n"' &lt;a href="http://nnnavzhan.3322nnn.org/" target="_blank"&gt;nnnavzhan.3322nnn.org&lt;/a&gt; &lt;a href="http://nnnavzhan1.3322nnn.org/" target="_blank"&gt;nnnavzhan1.3322nnn.org&lt;/a&gt;&lt;br /&gt;0.976744186046512&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;--&lt;br /&gt;Michael Rash&lt;br /&gt;If you would like to discuss DDOS, or anything else in this post, email Michael at:&lt;br /&gt;michael (dot) rash (at) g2-inc (dot) com&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8203485581570185491-8117876371544354991?l=blog.g2-inc.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.g2-inc.com/feeds/8117876371544354991/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.g2-inc.com/2011/03/malware-distribution-server-hostname.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8203485581570185491/posts/default/8117876371544354991" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8203485581570185491/posts/default/8117876371544354991" /><link rel="alternate" type="text/html" href="http://blog.g2-inc.com/2011/03/malware-distribution-server-hostname.html" title="Malware Distribution Server Hostname Similarities by Michael Rash" /><author><name>G2 Admin</name><uri>http://www.blogger.com/profile/11957206992792456779</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8203485581570185491.post-2464912145988615071</id><published>2011-03-15T11:36:00.005-04:00</published><updated>2011-03-15T11:55:17.953-04:00</updated><title type="text">Parsing Malware XML - By Riley Porter</title><content type="html">So AMA's XML parsing was tossing an error as of 2 days ago.  It turns out that
&lt;br /&gt;there were some invalid characters in the url section of the malware stream.  This is nothing
&lt;br /&gt;new, as a few months back I noticed this same sort of thing.  How I got around it last time was, just walking every line
&lt;br /&gt;before we processed the XML and re-wrote the file to disk. Like so:
&lt;br /&gt;
&lt;br /&gt;&lt;pre name="code" class="python"&gt;
&lt;br /&gt;for line in xmlfile.readlines():
&lt;br /&gt;    tmpfile.writelines(filter(&lt;wbr&gt;lambda x: x in string.printable,line))
&lt;br /&gt;tmpfile.close()
&lt;br /&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Why is this breaking again?  Continue down the rabbit hole.  Here is the
&lt;br /&gt;offending XML:
&lt;br /&gt;
&lt;br /&gt;&lt;textarea name="code" class="xml"&gt;&lt;br /&gt;&lt;entry&gt;&lt;br /&gt;&lt;url&gt;&lt;!--[CDATA[hxxp:\\download955.mediafire.com/k52y7xf2fh=fg/b765xt317j5dsc4/&lt;98--&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/&lt;98&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/&lt;98&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/&lt;98&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/&lt;98&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/&lt;98&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/&lt;98&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/&lt;98&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/&lt;98&gt;&lt;92&gt;=E8=F0#.5^@^@=E6h^@.^@^@^@DarkCometRAT3FIX1/DarkCometRAT3.0.1/Client.exe=BC=FD^M@TU=FE?&lt;8e&gt;=DF&lt;99&gt;=B90^C&lt;8c&gt;=CC=A0&lt;98=^oqqqi&gt;^Da=A5=A25&lt;^L&lt;82&gt;&lt;82&gt;&lt;8e&gt;^L]]&gt;&lt;/url&gt;&lt;br /&gt;&lt;/entry&gt;&lt;br /&gt;&lt;/textarea&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;(note that blogger is stripping some of this content but you get the idea)
&lt;br /&gt;So the crazy thing is the URL element actually worked!  If you were to
&lt;br /&gt;paste that into a browser it would have downloaded a file.
&lt;br /&gt;Note I have made http:// into hxxp:\\ in order to not make it an auto
&lt;br /&gt;link.  So what is this link to?  It looks like its a copy of "DarkComet Rat".
&lt;br /&gt;DarkComet RAT is a Remote Administration Tool (or known as a
&lt;br /&gt;RAT in the Malware Community).  It is a zip file too so it's not super
&lt;br /&gt;dangerous inherently.  However, there are executables inside the archive that I have
&lt;br /&gt;NOT examined or tested. Best not mess with them.  However, here is the
&lt;br /&gt;link for the RAT tools webpage:
&lt;br /&gt;http://www.darkcomet-rat.com/
&lt;br /&gt;
&lt;br /&gt;The question still remains why is our xml parser dying on this url?  As it turns out the
&lt;br /&gt;bytes 0x0a and  0x0d are in string.printable.
&lt;br /&gt;We were seeing some sneaky malware authors placing  the 0x0d (form feed!) in the urls. When these bytes are inserted
&lt;br /&gt;into a browser URL bar they are stripped right out.
&lt;br /&gt;However xml parsers and python file.readlines() interpreted it as a
&lt;br /&gt;new line which in turn broke the parsing engine!  So anyhow heres the
&lt;br /&gt;code should anyone want to see it.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;&lt;pre name="code" class="python"&gt;
&lt;br /&gt;"""A bit of a hack... However it works.  Some malware authors
&lt;br /&gt;  were innovating with the use of non-printable characters a few months back.
&lt;br /&gt;  filtering based of string.printable() fixed most of this until today. 1-17-2011
&lt;br /&gt;  It appears the 0x\0a - 0x\0d are "PRINTABLE".  What we were seeing is form feed
&lt;br /&gt;  inserted into our xml url streams.  This caused a new line in the xml and then
&lt;br /&gt;  an invalid xml document as the tag was not closed.  This code fixes that issue.
&lt;br /&gt;  """
&lt;br /&gt;  for y in xmlfile.read():
&lt;br /&gt;      try:
&lt;br /&gt;          if iscntrl(y) and y != "\n":
&lt;br /&gt;              y = ""
&lt;br /&gt;          else:
&lt;br /&gt;              pass
&lt;br /&gt;      except:
&lt;br /&gt;          pass
&lt;br /&gt;      tmpfile.write(filter(lambda x: x in string.printable, y))
&lt;br /&gt;  tmpfile.close()
&lt;br /&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;With that code added to our pre-processor class our xml is now 'clean' enough to be parsed.
&lt;br /&gt;
&lt;br /&gt;To see a picture of the hex in action go &lt;a href="http://www.flickr.com/photos/rileyporter/5365684474"&gt;here&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;-Riley
&lt;br /&gt;
&lt;br /&gt;P.S. If you would like to discuss this post further email Riley at riley (dot) porter (at) g2-inc (dot) com.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8203485581570185491-2464912145988615071?l=blog.g2-inc.com' alt='' /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://blog.g2-inc.com/feeds/2464912145988615071/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://blog.g2-inc.com/2011/03/parsing-malware-xml-by-riley-porter.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8203485581570185491/posts/default/2464912145988615071" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8203485581570185491/posts/default/2464912145988615071" /><link rel="alternate" type="text/html" href="http://blog.g2-inc.com/2011/03/parsing-malware-xml-by-riley-porter.html" title="Parsing Malware XML - By Riley Porter" /><author><name>G2 Admin</name><uri>http://www.blogger.com/profile/11957206992792456779</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total></entry></feed>

