<?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/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;AkMERXw7fSp7ImA9WxNVF0g.&quot;"><id>tag:blogger.com,1999:blog-34826778</id><updated>2009-10-28T12:33:24.205-07:00</updated><title>EM_386</title><subtitle type="html">A blog about computer { science, security, programming, operating systems }</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://em386.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://em386.blogspot.com/" /><link rel="hub" href="http://pubsubhubbub.appspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/06213034368649454197</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>43</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><link rel="self" href="http://feeds.feedburner.com/EM_386" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry gd:etag="W/&quot;CkUESXo9fSp7ImA9WxJVFk4.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-752894638547969799</id><published>2009-07-03T07:09:00.000-07:00</published><updated>2009-07-03T07:10:08.465-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-07-03T07:10:08.465-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="debugging" /><category scheme="http://www.blogger.com/atom/ns#" term="leaf" /><category scheme="http://www.blogger.com/atom/ns#" term="ELF" /><title>Leaf - Hit Tracing</title><content type="html">&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;I just posted a new version of the &lt;a href="http://leafre.googlecode.com/"&gt;Leaf framework&lt;/a&gt;. So I thought this might be a good time to blog on how to write and use a hit tracer using Leaf. Even though it is mostly a static analysis tool, the data it collects during this process is really useful to a debugger. I wanted a debug API and I wanted it fast, so a few versions ago I wrote a quick wrapper to Ptrace and put it into Leaf. It currently has only been tested for x86 Linux so there's work to be done in making it support BSD. I am always looking into other ways to make the debugging API cleaner, more useful and easier to code with, so please send any suggestions. So lets look at the steps needed to write a plugin that implements a hit tracer.&lt;br /&gt;&lt;br /&gt;Here is what my basic hit tracer, 'lhit' (included with Leaf) implements:&lt;br /&gt;&lt;br /&gt;1. LEAF_init() - a mandatory function that must be present in all plugins. You can use it to initialize any private data structures your plugin may need, or you can leave its function body blank.&lt;br /&gt;&lt;br /&gt;2. LEAF_interactive() - this is the plugin hook a debugger would want to call. Ideally you only want *one* plugin calling this, it doesnt make sense to have more then one. If your plugin implements this hook it will be called after all other static analysis if finished, consider it your debugger plugins main()&lt;br /&gt;&lt;br /&gt;3. LEAF_attach(pid_t) - takes a pid_t as its only argument and will attach the debugger to your target process.&lt;br /&gt;&lt;br /&gt;4. LEAF_set_hittracer(pid_t, breakpoints_t, int)  - this is where it gets slightly tricky. Your plugin must declare a structure somewhere of type breakpoints_t. Pass the targets pid, the breakpoints structure and flag (ON/OFF) to this function and Leaf will automatically use the vector of function addresses it collected during static analysis and set breakpoints on each of them. There is no need for your plugin to manage any of this. There is also another function called LEAF_set_breakpoint, which takes a pid_t, a breakpoints_t structure, and the address you want to break on, you can use this for any other manual breakpoints you want to set.&lt;br /&gt;&lt;br /&gt;5. LEAF_cont(pid_t) - this one is pretty self explanitory, it takes a pid_t as its only argument, and instructs the traced program to continue. At this point Leaf will handle calling wait() for you. All you have to do is inspect and handle the signal it returns. If you had used LEAF_set_hittracer and you hit one of the breakpoints it set then you will want to call LEAF_reinstall_breakpoint and Leaf will take care of putting the old instruction back, single stepping and reinstalling the breakpoint for you.&lt;br /&gt;&lt;br /&gt;6. LEAF_get_regs(pid_t, user_regs_struct) - this will retrieve the processes registers for you.&lt;br /&gt;&lt;br /&gt;7. LEAF_detach(pid_t) - will detach Leaf from your process.&lt;br /&gt;&lt;br /&gt;8. LEAF_cleanup() - another mandatory plugin hook which you can use to free memory or close file descriptors, or you can leave it blank.&lt;br /&gt;&lt;br /&gt;You will find an example hit tracer (lhit) which implements all of this in version 0.0.15 of Leaf &lt;a href="http://leafre.googlecode.com/"&gt;here&lt;/a&gt;. Its not the best hit tracer in the world but it does the job. The debugger internals will be getting an overhaul soon, but the API should stay the same.&lt;br /&gt;&lt;br /&gt;This new version of Leaf also contains my experimental LeafRub plugin which embeds a Ruby interpreter for scripting capabilities. An example LeafRub.rb script is also included, but I'll blog more about that later.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display: block;" id="formatbar_Buttons"&gt;&lt;span class="on down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-752894638547969799?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/JCBjDQX-oXU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/752894638547969799/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=752894638547969799&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/752894638547969799?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/752894638547969799?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/JCBjDQX-oXU/leaf-hit-tracing.html" title="Leaf - Hit Tracing" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://em386.blogspot.com/2009/07/leaf-hit-tracing.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0ENRXk6eCp7ImA9WxJWGEQ.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-4921107265056238640</id><published>2009-06-20T21:52:00.000-07:00</published><updated>2009-06-24T20:14:54.710-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-24T20:14:54.710-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="c++" /><category scheme="http://www.blogger.com/atom/ns#" term="vulnerabilities" /><category scheme="http://www.blogger.com/atom/ns#" term="stl" /><title>Fun with erase()</title><content type="html">&lt;p&gt;Over the last few months I've been knee deep in C++, you can view this as good thing or a bad thing, I for one enjoy it. I personally like finding bugs in C++ applications, as they are usually more complex then plain old C and require a bit more thought:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Keeping track of what variables  your destructor will take care of, and which it wont&lt;/li&gt;&lt;li&gt;Iterators, and what methods invalidate them&lt;/li&gt;&lt;li&gt;(insert your favorite C++ gotcha here)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;While debugging a crash one day it occured to me that the security research community has paid very little attention to the STL and CPPism's in general. There are a few things out there like TAOSSA's &lt;a href="http://taossa.com/index.php/2007/01/03/attacking-delete-and-delete-in-c/"&gt;delete vs delete[]&lt;/a&gt; and of course there is also &lt;a href="https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=637"&gt;Cert's secure coding standards&lt;/a&gt;. But there is very little written on exploring STL specific bugs. Maybe its all private and im just not cool enough to see it :/&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I decided to document some ways  STL specific bugs may be exploited. The first place I looked was containers, you know vectors/queues/lists etc... Any use of these containers probably means lots of interesting data is being stored, and considering they all have very easy-to-use methods even novice C++ developers were (ab)using them somewhere.&lt;/p&gt;&lt;p&gt;Most of these methods take in iterators (don't let the name fool you, they're just pointers), and tainted iterators have been a known bad thing for a long time (read certs secure coding standards). But where were the exploits? Where were the how-to's on owning an attacker influenced iterator? I decided to look into it myself.&lt;/p&gt;&lt;p&gt;I settled on using vectors as my first topic of interest, as they are widely used for their efficiency and ease of use. I further focused my efforts by looking at any method that added/moved/deleted multiple elements of data at a time from a container. The erase method seemed like a good candidate considering the amount of memory copies that take place under the hood.&lt;/p&gt;&lt;p&gt;The erase method either takes a single position within the container and removes it, or it takes a range supplied by two iterators and deletes the elements within that range. But I needed to see what it looked like under the hood. After navigating the tangled mess that is the GNU C++ templates (this is probably the real reason no one has done a lot of STL security research) I was able to isolate the relevant erase() code and find what I was looking for.&lt;/p&gt;&lt;p&gt;&lt;b&gt;This is where you are probably getting bored, so I'll skip ahead and just tell you why you care about any of this.&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Tainted iterators are a known C++ gotcha that every code auditor should know about, but in certain situations they can lead to very interesting conditions for an exploit writer. The Cert secure coding standard begins to touch on the subject of invalid iterator ranges, but labels their 'undefined behavior' as equivalent to a buffer overflow. This is true, however it can be more then that depending onthe STL implementation. When an attacker can control the range iterators passed to erase() he may be able to leak or directly overwrite memory contents or even better he can trick the STL into resizing the container to encapsulate adjacent heap memory (think 'other containers'). This opens up all kinds of doors for creative exploitation.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I would love to post those details here, but blogger mangled my write up pretty bad. &lt;a href="http://sites.google.com/site/em386cr/Home/Exploring_the_STL_Owning_erase.pdf?attredirects=0"&gt;So I've uploaded it here&lt;/a&gt;. If you spot any inaccurate technical information please &lt;a href="mailto:chris.rohlf@gmail.com"&gt;let me know&lt;/a&gt;.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-4921107265056238640?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/LlivVY22M2I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/4921107265056238640/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=4921107265056238640&amp;isPopup=true" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/4921107265056238640?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/4921107265056238640?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/LlivVY22M2I/fun-with-erase.html" title="Fun with erase()" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://em386.blogspot.com/2009/06/fun-with-erase.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8NRHw4eyp7ImA9WxVUEU0.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-1288179109246828090</id><published>2009-01-08T00:09:00.000-08:00</published><updated>2009-03-15T00:58:15.233-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-03-15T00:58:15.233-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="reversing" /><category scheme="http://www.blogger.com/atom/ns#" term="leaf" /><title>Leaf</title><content type="html">&lt;span style=";font-family:verdana;font-size:85%;"  &gt;It's been awhile since I have posted. This blog is up to almost 500 subscribers somehow.&lt;br /&gt;&lt;br /&gt;I posted a &lt;a href="http://code.google.com/p/leaf-re/"&gt;new project&lt;/a&gt; on googlecode. Leaf is an ELF reversing framework written in C. It has a built in API for developing your own analysis and output plugins. The current version (0.0.7) supports plugins written in C. The whole point of the project is flexibility in the analysis and output of the stuff your interested in. It's not just another text based disassembler, although a plugin that implements one can be easily written. In fact I released one with it and its available for download at the website. I am slowly releasing other plugins of varying quality. There are plenty of great tools for reversing on the Win32 platform, so there is no plan to support the PE format. If you want more information on it check out the googlecode link and look at the wiki. &lt;/span&gt;&lt;span style=";font-family:verdana;font-size:85%;"  &gt;It's still beta quality and there are definitely a few bugs. I hope you find it useful.&lt;br /&gt;&lt;br /&gt;Update: Posted Leaf-0.0.10.tar.gz at http://leaf-re.googlecode.com It now uses udis86. Lots of work still to do, but its a start.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-1288179109246828090?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/Doa3SSkBSqA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/1288179109246828090/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=1288179109246828090&amp;isPopup=true" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/1288179109246828090?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/1288179109246828090?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/Doa3SSkBSqA/leaf.html" title="Leaf" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">8</thr:total><feedburner:origLink>http://em386.blogspot.com/2008/09/leaf.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYDQH0zfyp7ImA9WxdXF0Q.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-1547254424023396375</id><published>2008-06-25T14:15:00.000-07:00</published><updated>2008-06-29T20:22:51.387-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-29T20:22:51.387-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="bitstruct" /><category scheme="http://www.blogger.com/atom/ns#" term="binary" /><title>BitStruct is great</title><content type="html">If you code in Ruby and do any binary parsing then you need to be using &lt;a href="http://redshift.sourceforge.net/bit-struct/"&gt;BitStruct&lt;/a&gt;. It makes C style structs in Ruby very easy. Sometimes you have to sniff a custom binary protocol the quick and dirty way, these are times I turn to Ruby instead of C. The Bitstruct release has some good examples of parsing network protocols but using raw sockets in Ruby is ugly. I prefer to use the LibPcap wrappers instead for the awesomeness of pcap filters.&lt;br /&gt;&lt;pre&gt;require 'pcaplet'&lt;br /&gt;require 'bit-struct'&lt;br /&gt;&lt;br /&gt;   # Fake protocol I made up for this example&lt;br /&gt;   class CustomProtocol &lt; BitStruct        &lt;br /&gt;       char        :header,    64,     :endian =&gt; :native&lt;br /&gt;       unsigned    :length,    8,      :endian =&gt; :native&lt;br /&gt;       unsigned    :next_hdr,  16,     :endian =&gt; :little&lt;br /&gt;       unsigned    :next_tag,  16,     :endian =&gt; :network&lt;br /&gt;       unsigned    :type,      32,     :endian =&gt; :native&lt;br /&gt;       rest        :data&lt;br /&gt;   end&lt;br /&gt;&lt;br /&gt;# Capture up to 1533 bytes&lt;br /&gt;sniff = Pcaplet.new('-s 1533')&lt;br /&gt;&lt;br /&gt;# Specific pcap filter so we only grab the protocol we are dissecting&lt;br /&gt;pcap_filter = Pcap::Filter.new('tcp &amp;amp;&amp;amp; port 34504 &amp;amp;&amp;amp; src 192.168.1.10', sniff.capture)&lt;br /&gt;&lt;br /&gt;sniff.add_filter(pcap_filter)&lt;br /&gt;&lt;br /&gt;for pkt in sniff&lt;br /&gt;   if pcap_filter =~ pkt&lt;br /&gt;       puts pkt&lt;br /&gt;       struct = CustomProtocol.new(pkt.tcp_data)&lt;br /&gt;       puts sprintf("ASCII Header: %s\tLength: %x\tNext Hdr: %x\tNext Tag: %x\tType: %x\tData: %s",&lt;br /&gt;           struct.header, struct.length, struct.next_hdr, struct.next_tag, struct.type, struct.data)&lt;br /&gt;   end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-1547254424023396375?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/wXRz28lvnSQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/1547254424023396375/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=1547254424023396375&amp;isPopup=true" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/1547254424023396375?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/1547254424023396375?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/wXRz28lvnSQ/bitstruct-is-great.html" title="BitStruct is great" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://em386.blogspot.com/2008/06/bitstruct-is-great.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkYCRH05fCp7ImA9WxdRFU4.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-7820700493630541812</id><published>2008-06-03T13:39:00.000-07:00</published><updated>2008-06-03T14:56:05.324-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-06-03T14:56:05.324-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="reverse engineering" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="ELF" /><title>Known API's and automated static code analysis</title><content type="html">&lt;div&gt;I did some quick work a few weeks ago on automating static code analysis by using known API's to generate information about data structures and logic flow. The work is not ground breaking but I felt the techniques are quite useful and I wanted to document them clearly for myself and others. You can grab the short paper &lt;a href="http://chris.rohlf.googlepages.com/Static_DS_REC.pdf"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;It's interesting that slides Halvar &lt;a href="http://www.blackhat.com/presentations/win-usa-04/bh-win-04-flake.pdf"&gt;presented&lt;/a&gt; in 2004 on automating reverse engineering are entirely still relevant. He made a good point ... "no matter how stupid an analysis tool is, some programmers will make mistakes which are stupider". How true... &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-7820700493630541812?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/Wa-9hqbD6Xc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/7820700493630541812/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=7820700493630541812&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/7820700493630541812?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/7820700493630541812?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/Wa-9hqbD6Xc/known-apis-and-automated-static-code.html" title="Known API's and automated static code analysis" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://em386.blogspot.com/2008/06/known-apis-and-automated-static-code.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMER34zeyp7ImA9WxZaGUQ.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-1494508837295707111</id><published>2008-05-02T22:20:00.001-07:00</published><updated>2008-05-05T06:16:46.083-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-05-05T06:16:46.083-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="ELF" /><title>Self Protecting GOT</title><content type="html">&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;I had some time to kill over the past few days and I wanted to explore an idea I had a few months ago. The idea is to protect the ELF GOT (Global Offset Table) (and other segments of memory) from userland without the support of 'relro' functionality now found in the GNU dynamic linker. I accomplished it through techniques such as linker script modification and constructor functions. No kernel modifications are needed and I have tested it on a semi large project (Snort IDS).&lt;br /&gt;&lt;br /&gt;You can find the draft version 1.1 of my writeup &lt;a href="http://chris.rohlf.googlepages.com/Self-Protecting-GOT.html"&gt;here&lt;/a&gt;. If you find any mistakes let me know and I will fix them.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-1494508837295707111?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/pA5h4Hy6uGc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/1494508837295707111/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=1494508837295707111&amp;isPopup=true" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/1494508837295707111?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/1494508837295707111?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/pA5h4Hy6uGc/self-protecting-got.html" title="Self Protecting GOT" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://em386.blogspot.com/2008/05/self-protecting-got.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUINRH04eip7ImA9WxZbFk0.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-868574965567102725</id><published>2008-04-18T21:12:00.000-07:00</published><updated>2008-04-19T05:19:55.332-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-04-19T05:19:55.332-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="kernel" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="ELF" /><title>kmemcheck and an old bug</title><content type="html">&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;I wanted to do a quick post about '&lt;a href="http://kerneltrap.org/node/15912"&gt;kmemcheck&lt;/a&gt;' because I think the concept is pretty cool. It's a debugging patch in its 7th rev that is now proposed for the mainline Linux kernel in 2.6.26 and the idea&lt;/span&gt;&lt;span style="font-family:arial;"&gt;&lt;span style="font-family:arial;"&gt; is pretty simple but has lots of security uses...&lt;/span&gt;&lt;br /&gt;&lt;blockquote style="font-family: arial;"&gt;"kmemcheck is a patch to the linux kernel that detects use of uninitialized memory. It does this by trapping every read and write to memory that was allocated dynamically (e.g. using kmalloc()). If a memory address is read that has not previously been written to, a message is printed to the kernel log."&lt;/blockquote&gt;&lt;span style="font-family:arial;"&gt;The author provided a sample log file from the patch which is &lt;/span&gt;&lt;a style="font-family: arial;" href="http://folk.uio.no/vegardno/linux/kmemcheck-20071127.txt"&gt;here&lt;/a&gt;&lt;span style="font-family:arial;"&gt;. I spent a few minutes browsing it and I think it definitely shows promise for more than debugging. **Consider the case of these &lt;/span&gt;&lt;a style="font-family: arial;" href="http://marc.info/?l=bugtraq&amp;amp;m=110010551907076&amp;amp;w=2"&gt;ELF loader vulnerabilities&lt;/a&gt;&lt;span style="font-family:arial;"&gt; found by Paul Starzetz in 2004. Bug [1] is basically incorrect checking of the kernel_read() return value. Here's the bug:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;...&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;       size = elf_ex.e_phnum * sizeof(struct elf_phdr);&lt;br /&gt;       elf_phdata = (struct elf_phdr *) kmalloc(size, GFP_KERNEL);&lt;br /&gt;       if (!elf_phdata)&lt;br /&gt;              goto out;&lt;br /&gt;&lt;br /&gt;       retval = kernel_read(bprm-&gt;file, elf_ex.e_phoff, (char *) elf_phdata, size);&lt;br /&gt;       if (retval &lt; 0)&lt;br /&gt;              goto out_free_ph;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;...  &lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;The code above makes the incorrect assumption that kernel_read() will return less than zero if an error occurs. This is true however kernel_read() can also return greater than zero but less than 'size'. Which in this case leaves a portion of elf_phdata uninitialized. Whats my point? I'm getting to that. An attacker can potentially control this uninitialized data and take control of a process image. Now this particular bug is pretty hard to trigger and even harder to exploit. But the important thing is kmemcheck may have caught this particular issue, and others like it. kmemcheck would fire off a log entry when the ELF loader goes to read the uninitialized data in elf_phdata because technically the attacker controlled data was never written to it in this context, its old 'left over' data. Very neat stuff.&lt;br /&gt;&lt;br /&gt;The kernel allocators are a bit more complex than malloc in userland though. The slab code has many small details about it that can make or break a kmalloc based vulnerability, but the concept here is very intriguing regardless. You can grab the kmemcheck patches &lt;a href="http://folk.uio.no/vegardno/linux/kmemcheck/"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;**As a side note, I took a quick look at linux/fs/binfmt_elf_fdpic.c and &lt;a href="http://chris.rohlf.googlepages.com/elf_fdpic_vuln.txt"&gt;found&lt;/a&gt; this bug in virtually the same place as Paul found it and in an additional spot as well, where the program interpreter is loaded. They affect a small population and have already been &lt;a href="http://www.uwsg.indiana.edu/hypermail/linux/kernel/0804.2/1480.html"&gt;fixed&lt;/a&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-868574965567102725?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/0t-bhyOwK-g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/868574965567102725/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=868574965567102725&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/868574965567102725?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/868574965567102725?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/0t-bhyOwK-g/kmemcheck-and-old-bug.html" title="kmemcheck and an old bug" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://em386.blogspot.com/2008/04/kmemcheck-and-old-bug.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0AAQXcycCp7ImA9WxZWGUs.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-3640494029225161250</id><published>2008-03-19T11:32:00.000-07:00</published><updated>2008-03-19T16:35:40.998-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-03-19T16:35:40.998-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="gcc" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>CLD/STD and GCC 4.3.0</title><content type="html">&lt;span style=";font-family:arial;font-size:85%;"  &gt;Some of you may have seen &lt;a href="http://lwn.net/SubscriberLink/272048/ecf14f359bcdcd15/"&gt;this&lt;/a&gt; already. Its a very subtle bug that was exposed by GCC &lt;a href="http://gcc-uk.internet.bs/snapshots/4.3-20080313/"&gt;4.3.0&lt;/a&gt; that manifests itself in an interesting way. Heres a quick overview. In its latest version, GCC has changed a very small detail. Before version 4.3.0 GCC would insert a CLD (Clear Direction Flag) instruction before any inline string copy functions as shown below:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;804de86:       fc                  cld &lt;br /&gt;804de87:       f3 a4               rep movsb %ds:(%esi),%es:(%edi)&lt;br /&gt;804de89:       89 c1               mov    %eax,%ecx&lt;br /&gt;804de8b:       c1 e9 02            shr    $0x2,%ecx&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This instruction (CLD) clears a flag that determines which direction data should be written in (forward or backward). The flag itself is stored in the EFLAGS register. Clearing the flag with CLD sets the flag to 0 (forward). The STD instruction can then change this by setting the flag to 1 (backward). GCC no longer emits this instruction before inline string copies. This change is documented &lt;a href="http://gcc.gnu.org/gcc-4.3/changes.html"&gt;here&lt;/a&gt;. Technically this is right because the &lt;a href="http://www.sco.com/developers/devspecs/abi386-4.pdf"&gt;ABI&lt;/a&gt; states the direction flag should be cleared before entering any function (see page 38 under &lt;span style="font-style: italic;"&gt;EFLAGS&lt;/span&gt;). The problem in this case is that the Linux kernel does not clear the flag when entering a signal handler. So in theory the flag is set to 1 for whatever reason and then a signal gets tripped and calls something like memcpy or memmove. Since the CLD instruction is no longer used inline the copy can &lt;/span&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;write data in the wrong direction&lt;/span&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;. This can obviously lead to security issues. I put together some x86 example code for this based on the x86_64 version posted to LKML, you can find it &lt;a href="http://chris.rohlf.googlepages.com/cld.c"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;pre&gt;./cld&lt;br /&gt;Hit Ctrl+C&lt;br /&gt;In signal handler...&lt;br /&gt;DF = 1 (backward)&lt;br /&gt;In signal handler...&lt;br /&gt;DF = 1 (backward)&lt;br /&gt;In signal handler...&lt;br /&gt;DF = 0 (forward)&lt;br /&gt;In signal handler...&lt;br /&gt;DF = 0 (forward)&lt;br /&gt;In signal handler...&lt;br /&gt;DF = 1 (backward)&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-3640494029225161250?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/D4_QB41R2Ds" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/3640494029225161250/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=3640494029225161250&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/3640494029225161250?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/3640494029225161250?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/D4_QB41R2Ds/cldstd-and-gcc-430.html" title="CLD/STD and GCC 4.3.0" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://em386.blogspot.com/2008/03/cldstd-and-gcc-430.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUDSH06eCp7ImA9WxZXGUg.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-4057209393891029273</id><published>2008-03-03T09:30:00.000-08:00</published><updated>2008-03-07T20:24:39.310-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-03-07T20:24:39.310-08:00</app:edited><title>Updated: Spamhaus-Snort Correlation Script</title><content type="html">If you have ever worked in security operations before you should be pretty familiar with the daily pains of trying to detect and stop malware before it gets into your network environment. Theres &lt;a href="http://www.malwaredomains.com/"&gt;plenty&lt;/a&gt; of &lt;a href="http://www.emergingthreats.net/"&gt;sources&lt;/a&gt; out &lt;a href="http://ddanchev.blogspot.com/"&gt;there&lt;/a&gt; to help you out. Last year I toyed with the concept of &lt;a href="http://chris.rohlf.googlepages.com/spamhaus-snort.sh"&gt;correlating my Snort alert sources&lt;/a&gt; with the &lt;a href="http://www.spamhaus.org/"&gt;spamhaus&lt;/a&gt; DNS blacklist. The results were pretty much what I expected. A lot of the unsolicited attacks and probes picked up by my IDS were coming from hosts that were on the &lt;a href="http://www.spamhaus.org/"&gt;spamhaus&lt;/a&gt; black list. This is presumably because the same hosts on botnets that are sending spam are also scanning for other victims and hosting malicious client side exploits. This really isn't 'news' - but what I find disturbing is that there doesn't seem to be any correlation in some of these defenses. Specifically, when my mail filter rejects a spam due to a hit on Spamhaus XBL (exploits/trojans list etc...), it stops. Why not send that offending IP to my firewall and blacklist it? I know there are IDS's that will send this type of information to the firewall when an alert is triggered. Are there any anti-spam technologies out there doing this? &lt;span style="font-style: italic;"&gt;If any big anti-spam vendors start doing this, be sure to send me &lt;/span&gt;&lt;a style="font-style: italic;" href="http://chris.rohlf.googlepages.com/consulting.html"&gt;consulting&lt;/a&gt;&lt;span style="font-style: italic;"&gt; work :)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I updated the &lt;a href="http://chris.rohlf.googlepages.com/spamhaus-snort.sh"&gt;Spamhaus-Snort&lt;/a&gt; correlation script today. I hope you find it useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-4057209393891029273?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/Kti33ntKaXo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/4057209393891029273/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=4057209393891029273&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/4057209393891029273?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/4057209393891029273?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/Kti33ntKaXo/updated-spamhaus-snort-correlation.html" title="Updated: Spamhaus-Snort Correlation Script" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://em386.blogspot.com/2008/02/updated-spamhaus-snort-correlation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUABRXY7fCp7ImA9WB9aEk8.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-3630656542111329565</id><published>2007-12-30T16:55:00.000-08:00</published><updated>2008-01-01T13:42:34.804-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-01T13:42:34.804-08:00</app:edited><title>2008 Blogging</title><content type="html">&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:arial;"&gt;I've decided to take some time off blogging in the first half of 2008. I will instead be using the free time I do have to concentrate on writing for more widely read publications (contact me if your interested), and of course code audits and open source stuff. I will continue to update my &lt;a href="http://chris.rohlf.googlepages.com/index.html"&gt;homepage&lt;/a&gt; as often as possible. I will return shortly ...&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-3630656542111329565?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/qted_6DDbD0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/3630656542111329565/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=3630656542111329565&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/3630656542111329565?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/3630656542111329565?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/qted_6DDbD0/2008-blogging.html" title="2008 Blogging" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/12/2008-blogging.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIHRXczfip7ImA9WB9aEEs.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-3888716937576133239</id><published>2007-12-23T14:45:00.000-08:00</published><updated>2007-12-30T16:55:34.986-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-12-30T16:55:34.986-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="exploitation" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>Ret-2-libc Without Function Calls</title><content type="html">&lt;span style=";font-family:arial;font-size:85%;"  &gt;Someone posted a link to this paper (&lt;a href="http://www.cse.ucsd.edu/%7Ehovav/papers/s07.html"&gt;http://www.cse.ucsd.edu/~hovav/papers/s07.html&lt;/a&gt;) on Full Disclosure the other day. I had not seen it before. It discusses ret-2-libc attacks without using functions. Instead the authors use what they call 'gadgets'. Which in plain technical terms means finding unintended code sequences in executable pages of memory that can be used to string together ways to execute arbitrary code. The authors present it as a way to defeat W^X protections.&lt;br /&gt;&lt;br /&gt;From the paper:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Gadgets perform well defined operations, such as a load, an xor, or a jump. Return-oriented programming consists in putting gadgets together that will perform the desired operations.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;These gadgets can be found in byte streams from libc within a process' memory. They are not injected due to W^X constraints on most platforms. &lt;/span&gt; &lt;span style="font-style: italic;"&gt;...&lt;/span&gt; &lt;span style="font-style: italic;"&gt;Each of our gadgets expects to be entered in the same way: the processor executes a ret with the stack pointer, %esp, pointing to the bottom word of the gadget. This means that, in an exploit, the first gadget should be placed so that its bottom word overwrites some functions saved return address on the stack.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The technique is an interesting one. It reminds of me certain ret-2-text techniques that may fall into the middle of a long instruction to produce a &lt;span style="font-style: italic;"&gt;jmp %reg&lt;/span&gt; trampoline. Overall the technique will vary from platform to platform because libc may be compiled differently from Fedora to Ubuntu for example.&lt;br /&gt;&lt;br /&gt;Using randomized mmap() (randomized library base mappings), PIE (Position Independent Executables) and RANDEXEC hardening make this type of exploitation technique a bit harder to pull off. The paper is worth a read if you have the time.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-3888716937576133239?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/sUwoINzbw2U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/3888716937576133239/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=3888716937576133239&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/3888716937576133239?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/3888716937576133239?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/sUwoINzbw2U/ret-2-libc-without-function-calls.html" title="Ret-2-libc Without Function Calls" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/12/ret-2-libc-without-function-calls.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUNRn45cCp7ImA9WB9VEUo.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-7409848530721818636</id><published>2007-11-27T10:30:00.000-08:00</published><updated>2007-11-27T07:44:57.028-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-27T07:44:57.028-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="format string vulnerability" /><category scheme="http://www.blogger.com/atom/ns#" term="gtk" /><category scheme="http://www.blogger.com/atom/ns#" term="gnome2" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>Your favorite "better than C" scripting language is probably implemented in C</title><content type="html">&lt;span style=";font-family:arial;font-size:85%;"  &gt;I was writing an application front-end in &lt;a href="http://ruby-gnome2.sourceforge.jp/"&gt;Ruby/Gnome2&lt;/a&gt; and I needed to produce an error message for the user that contained a string the user had previously input. My MessageDialog code looked like this:&lt;br /&gt;&lt;pre&gt;-------------------------------------------------------------------------&lt;br /&gt;dialog = Gtk::MessageDialog.new(@main_app_window, Gtk::Dialog::MODAL,&lt;br /&gt;          Gtk::MessageDialog::INFO,&lt;br /&gt;          Gtk::MessageDialog::BUTTONS_CLOSE,&lt;br /&gt;          "%s - Was your string!" % my_string)&lt;br /&gt;-------------------------------------------------------------------------&lt;br /&gt;&lt;/pre&gt;As you can see the variable my_string is placed in the message dialog text using a format specifier correctly according to the &lt;a href="http://ruby-gnome2.sourceforge.jp/hiki.cgi?cmd=view&amp;amp;p=Gtk%3A%3AMessageDialog&amp;amp;key=messagedialog"&gt;man page&lt;/a&gt;. I started to wonder what happened if this string contained a format specifier, would the underlying C libraries and bindings display it correctly? Surprise!&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_3qAE1BKfR_Y/R0iVX4r5UgI/AAAAAAAAAEo/chlBcVwHasM/s1600-h/ruby-dialog.png"&gt;&lt;img style="cursor: pointer;" src="http://bp2.blogger.com/_3qAE1BKfR_Y/R0iVX4r5UgI/AAAAAAAAAEo/chlBcVwHasM/s320/ruby-dialog.png" alt="" id="BLOGGER_PHOTO_ID_5136519612602077698" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;&lt;br /&gt;No it was not displayed correctly. In fact it was vulnerable to a format string attack straight from the year 2001. UGH! Now you might argue - "Your fault for not sanitizing your string". Well thats true to a point. But the MessageDialog interface is just a very deep abstraction layer to a &lt;span style="font-style: italic;"&gt;printf()&lt;/span&gt; style function in the GTK C library. But unlike those functions MessageDialog is not well documented as an 'easily mis-used' function.&lt;br /&gt;&lt;br /&gt;Programmers typically trust their API to correctly sanitize and display their input, especially in scripting languages. This is because in scripting languages programmers feel they are safe from traditional C language vulnerabilities. This isn't always the case when your abstraction layers don't handle data correctly. My audit to find the offending code took about ten minutes but I narrowed it down to&lt;br /&gt;&lt;br /&gt;ruby-gnome2-all-0.16.0/gtk/src/rbgtkmessagedialog.c&lt;br /&gt;&lt;br /&gt;Where it calls GTK like this:&lt;br /&gt;&lt;pre&gt;w = gtk_message_dialog_new(NIL_P(parent) ? NULL : GTK_WINDOW(RVAL2GOBJ(parent)),&lt;br /&gt;                    RVAL2GFLAGS(flags, GTK_TYPE_DIALOG_FLAGS),&lt;br /&gt;                    RVAL2GENUM(type, GTK_TYPE_MESSAGE_TYPE),&lt;br /&gt;                    RVAL2GENUM(buttons, GTK_TYPE_BUTTONS_TYPE),&lt;br /&gt;                    (const gchar*)(NIL_P(message) ? "": RVAL2CSTR(message)));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The variable 'message' is passed directly to GTK. I don't blame GTK authors for this one, it would be like blaming libc authors for &lt;span style="font-style: italic;"&gt;printf()&lt;/span&gt;'s ability to print a variable without a format specifier. The &lt;a href="http://www.gtk.org/api/2.6/gtk/GtkMessageDialog.html#gtk-message-dialog-new"&gt;GTK MessageDialog&lt;/a&gt; page shows the function prototype for gtk_message_dialog_new()&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;GtkWidget* gtk_message_dialog_new&lt;br /&gt;(GtkWindow *parent, GtkDialogFlags flags, GtkMessageType type,&lt;br /&gt;GtkButtonsType buttons, const gchar *message_format, ...);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;parent&lt;/span&gt;: transient parent, or NULL for none&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;flags&lt;/span&gt;: flags&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;type&lt;/span&gt;: type of message&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;buttons&lt;/span&gt;: set of buttons to use&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;message_format&lt;/span&gt;: printf()-style format string, or NULL&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;...&lt;/span&gt;: arguments for message_format&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;So GTK is clearly expecting a proper format string, which should be properly passed to it by whatever API called it.&lt;br /&gt;&lt;br /&gt;Example vulnerable code:&lt;br /&gt;&lt;pre&gt;-------------------------------------------------------------------------&lt;br /&gt;#!/usr/bin/env ruby&lt;br /&gt;&lt;br /&gt;# ruby rubber.rb %x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x&lt;br /&gt;&lt;br /&gt;require 'gtk2'&lt;br /&gt;&lt;br /&gt;my_string = ARGV[0]&lt;br /&gt;&lt;br /&gt;dialog = Gtk::MessageDialog.new(@main_app_window, Gtk::Dialog::MODAL,&lt;br /&gt;                        Gtk::MessageDialog::INFO,&lt;br /&gt;                        Gtk::MessageDialog::BUTTONS_CLOSE,&lt;br /&gt;                        "%s - Was your string!" % my_string)&lt;br /&gt;dialog.run&lt;br /&gt;dialog.destroy&lt;br /&gt;-------------------------------------------------------------------------&lt;/pre&gt;&lt;/span&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;To avoid this issue in your ruby code you could use the markup member. This will use the Pango markup language on your text. Its a workaround but it gets the job done.&lt;br /&gt;&lt;pre&gt;-------------------------------------------------------------------------&lt;br /&gt;my_string = ARGV[0]&lt;br /&gt;&lt;br /&gt;dialog = Gtk::MessageDialog.new(@main_app_window, Gtk::Dialog::MODAL,&lt;br /&gt;                        Gtk::MessageDialog::INFO,&lt;br /&gt;                        Gtk::MessageDialog::BUTTONS_CLOSE)&lt;br /&gt;&lt;br /&gt;dialog.markup = "#{my_string} - Was your string!"&lt;br /&gt;dialog.run&lt;br /&gt;dialog.destroy&lt;br /&gt;-------------------------------------------------------------------------&lt;br /&gt;&lt;/pre&gt;Or alternatively you could do something like "my_string = my_string.gsub(/%/, "%%")" before calling messagedialog.&lt;br /&gt;&lt;br /&gt;Using &lt;a href="http://www.google.com/codesearch"&gt;google&lt;/a&gt; we can find some other projects vulnerable to similar bugs. Most just stick #{my_string} in the message, including example applications from the official Ruby/Gnome2 website.&lt;/span&gt;&lt;span style=";font-family:arial;font-size:85%;"  &gt;&lt;span style="font-family:arial;"&gt;&lt;br /&gt;&lt;br /&gt;That about wraps up this post. Other Ruby/Gnome2 API's may have similar 'functionality'. This should teach all the scripters out there a security lesson. Always remember your favorite "better than C" scripting language is probably implemented in C. Ruby/Gnome2 authors have been notified and they have committed a patch to &lt;a href="http://ruby-gnome2.svn.sourceforge.net/viewvc/ruby-gnome2?view=rev&amp;amp;revision=2720"&gt;SVN&lt;/a&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-7409848530721818636?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/lCVlPFCDaZU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/7409848530721818636/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=7409848530721818636&amp;isPopup=true" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/7409848530721818636?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/7409848530721818636?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/lCVlPFCDaZU/your-favorite-better-than-c-scripting.html" title="Your favorite &quot;better than C&quot; scripting language is probably implemented in C" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://bp2.blogger.com/_3qAE1BKfR_Y/R0iVX4r5UgI/AAAAAAAAAEo/chlBcVwHasM/s72-c/ruby-dialog.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/11/your-favorite-better-than-c-scripting.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkQGQXo_fSp7ImA9WB9WF0Q.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-8294767354737756716</id><published>2007-11-22T23:00:00.000-08:00</published><updated>2007-11-22T19:58:40.445-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-11-22T19:58:40.445-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="memory" /><title>What Every Programmer Should Know About Memory (PDF)</title><content type="html">&lt;span style="font-size:85%;"&gt;I just came across this PDF on reddit.com titled "What every programmer should know about memory". Its written by &lt;a href="http://people.redhat.com/drepper/"&gt;Ulrich Drepper&lt;/a&gt; from RedHat, you should know who he is.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://people.redhat.com/drepper/cpumemory.pdf"&gt;Link to PDF&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;It's going to take me awhile to get through this (its 114 pages long) - but so far its a decent read. I'm currently cheating and searching through it for things that interest me. I'm currently taking in section 7.3 'Measuring Memory Usage'. This section is particularly interesting to me because I've been toying with a project of mine lately that collects massive amounts of data. Searching and sorting that data efficiently has not been easy.&lt;br /&gt;&lt;br /&gt;Ulrich states in the PDF that using libc's malloc to store a linked list you populate for later retrieval and use is probably a bad idea. This is true, because theres no guarantee malloc will return memory that is close or even near to the next member in the linked list. There are alternatives to using the traditional libc malloc library such as &lt;a href="http://en.wikipedia.org/wiki/Obstack"&gt;obstack&lt;/a&gt; and Google's &lt;a href="goog-perftools.sourceforge.net/doc/tcmalloc.html"&gt;TCMalloc&lt;/a&gt;. I have toyed with TCMalloc on several occasions. Despite all of my heap mappings being in sequential order it only seems to slow down my data hungry application.&lt;br /&gt;&lt;br /&gt;Obstack on the other hand is generally fast because it starts out mapping a larger chunk of memory, within that chunk you allocate smaller chunks to hold your data (in my case my linked list structures) which end up being in sequential order. Which is of course a lot faster to access then a list that is fragmented up.&lt;br /&gt;&lt;br /&gt;There's lots of other good stuff in his paper, take a look for yourself.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-8294767354737756716?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/k8bOCWdVLnE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/8294767354737756716/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=8294767354737756716&amp;isPopup=true" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/8294767354737756716?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/8294767354737756716?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/k8bOCWdVLnE/what-every-programmer-should-know-about.html" title="What Every Programmer Should Know About Memory (PDF)" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/11/what-every-programmer-should-know-about.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMERH85fSp7ImA9WB9RF08.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-3229192911937958062</id><published>2007-10-18T05:21:00.000-07:00</published><updated>2007-10-18T08:13:25.125-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-18T08:13:25.125-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="aslr" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="osx" /><title>OSX Leopard - ASLR?</title><content type="html">A lot of main stream media is reporting OSX will be getting ASLR (Address Space Layout Randomization). However OSX's &lt;a href="http://www.apple.com/macosx/features/300.html#security"&gt;new features page&lt;/a&gt; says 'library randomization'. Not ASLR. Im not an OSX user but I think some clarification is needed here. ASLR is a pretty vague term to apply to this. The PAX implementation for example describes ASLR as randomization on many different regions of a processes memory. The true die-hard in me reserves the term ASLR for a wider randomization implementation such as stack base, mmap, .text base and many others, not just library mappings.&lt;br /&gt;&lt;br /&gt;And now that all of this is on slashdot.org I'm sure the fanboi war will begin. Please let it be known that my official opinion is: it doesn't matter what OS you run, you can still get owned.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://pax.grsecurity.net/docs/aslr.txt"&gt;http://pax.grsecurity.net/docs/aslr.txt&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-3229192911937958062?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/JVQuHlXV5oo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/3229192911937958062/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=3229192911937958062&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/3229192911937958062?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/3229192911937958062?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/JVQuHlXV5oo/osx-leopard-aslr.html" title="OSX Leopard - ASLR?" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/10/osx-leopard-aslr.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUNSX87fyp7ImA9WB9SFEs.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-7457309299147777647</id><published>2007-10-03T05:22:00.000-07:00</published><updated>2007-10-03T19:18:18.107-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-03T19:18:18.107-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="code auditing" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>Code Auditing Checklist</title><content type="html">When I audit any code I always follow the same steps to familiarize myself with the application and give me a better sense of its internals. I was giving this advice to a friend over IM today, and I thought it would make a good blog post for others.&lt;br /&gt;&lt;br /&gt;Years ago when I would try to audit a fairly large application like Apache, I simply got lost in its many functions and data structures, unable to get a good enough grasp of how it worked. By that point I had become frustrated and would probably move onto another application. Sometimes you get lucky and sometimes you walk away angry. There were never any good guidelines from the masters, only examples of vulnerable code. But without a thorough understanding of how a program works, I don't believe its possible to get the most out of your time spent auditing it. I have written down a few simple steps to quickly understand an application in less time, which means more time auditing for vulnerabilities.&lt;br /&gt;&lt;br /&gt;1. Does the application have its own memory management? Many applications will have their own internal memory management instead of just allocating space when they need it. You will find many larger applications will have memory structures that contains a pointer to some dynamic buffer, the total size of the buffer, the length of the data in that buffer, and perhaps a pointer to a function that needs the data. This will vary greatly from app to app but understanding how this internal memory management works is absolutely key to finding any vulnerabilities related to mishandling of that memory. Its also important when exploiting a vulnerability you have found. Sometimes these &lt;a href="http://risesecurity.org/exploit/7/"&gt;higher abstraction layers can be abused&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;2. Are there any functions that the application calls repeatedly? For example during a recent code audit I did there was a function that processed and stripped HTML characters from a string of user input. This function was called repeatedly throughout the application. I reviewed the function from start to end, making notes about how it could be called insecurely. So next time I came across another block of code that called that function I already knew what it did and I knew right away if it was being used correctly or not. Don't make the beginner mistake of trying to find all instances of str/memcpy abuses - when there are plenty of home grown functions that are just as lousy and widespread.&lt;br /&gt;&lt;br /&gt;3. macros, typedef's, define's,and structures - Study them and know them well. Most larger applications are going to typedef large structs or variables they use often. Large applications have many structures that are important to understanding their internals. A variable type can make a big difference between being vulnerable and not being vulnerable. Make a list on paper if you have to.&lt;br /&gt;&lt;br /&gt;This is not an exhaustive list of how you should approach a code review. But more of a quick checklist to quickly understanding how an application works internally so you can spend more time finding bugs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-7457309299147777647?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/F3Sm0v4oX60" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/7457309299147777647/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=7457309299147777647&amp;isPopup=true" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/7457309299147777647?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/7457309299147777647?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/F3Sm0v4oX60/code-auditing-checklist.html" title="Code Auditing Checklist" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/10/code-auditing-checklist.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8ESHs5fip7ImA9WB9SE0o.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-441439014790423832</id><published>2007-10-02T18:52:00.000-07:00</published><updated>2007-10-02T19:16:49.526-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-10-02T19:16:49.526-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="blog" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="em386" /><title>1 Year Has Passed</title><content type="html">&lt;span style="font-size:85%;"&gt;I just realized this blog turned one year old a few weeks ago, and I'm still not at 50 posts. That's pretty sad, Ill have to pick up the pace. Over the past year I have blogged about various topics such as security, ELF, Linux, random security headlines and more. Sometimes even 'real' tech media will quote my posts. Does a lack of comments indicate no one finds what you have to say interesting? I hope not.&lt;br /&gt;&lt;br /&gt;The blog averages about 20-40 hits a day from various google keyword searches and links to it. From what I can tell there's an additional 75 to 100 people who subscribe to the RSS feed via feedburner, bloglines, google and a few others I've never heard of. Thanks for reading for the past year. As long as I have readers I will continue to post :)&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-441439014790423832?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/IjHl5YIdcBI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/441439014790423832/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=441439014790423832&amp;isPopup=true" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/441439014790423832?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/441439014790423832?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/IjHl5YIdcBI/1-year-has-passed.html" title="1 Year Has Passed" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/10/1-year-has-passed.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0YHRX85eip7ImA9WB9SEEU.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-8982521485038811467</id><published>2007-09-29T07:01:00.000-07:00</published><updated>2007-09-29T08:52:14.122-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-29T08:52:14.122-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="struct software" /><category scheme="http://www.blogger.com/atom/ns#" term="code" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="audit" /><title>Blackboxes and Trust</title><content type="html">&lt;span&gt;&lt;span style="font-size:85%;"&gt;I'm sure you've heard the saying "you wouldn't buy a car that had the hood sealed shut would you?" - Followed up by an open source &lt;/span&gt;&lt;del&gt;&lt;span style="font-size:85%;"&gt;zealot&lt;/span&gt;&lt;/del&gt;&lt;span style="font-size:85%;"&gt; &lt;/span&gt;&lt;del&gt;&lt;span style="font-size:85%;"&gt;fanatic&lt;/span&gt;&lt;/del&gt;&lt;span style="font-size:85%;"&gt; person explaining to you why that analogy works for software. Well I actually do agree with that analogy. &lt;a href="http://www.oreillynet.com/sysadmin/blog/2007/05/are_you_mad_are_we_all.html"&gt;Anton Chuvakin put it into better words then I ever could in this blog post&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Every single day very large and important organizations rely on software to keep themselves running (hospitals, infrastructure control, intelligence agencies, the military ... and so on). Yet nearly none of these organizations are legally allowed to see the source code of that software. There is just absolute blind trust in its ability to work correctly and be reliable. Not to mention secure.&lt;br /&gt;&lt;br /&gt;Where is the proof this software isn't full of backdoors, vulnerabilities, logic bugs or more. Organizations such as those above need to start asking (demanding) their vendors provide some real proof that the source code or binary was audited by a third party - i.e. not the original developers of the software. This proof works both ways. It gives the company the chance to say "&lt;span style="font-style: italic;"&gt;hey - we can't catch all the bugs, but we did our best, and thats why you should choose us over our competition&lt;/span&gt;". And customers are given a little more trust in the investment they just made. Because now they know their vendor went further then the competition to produce a better quality product.&lt;br /&gt;&lt;br /&gt;Lets take Windows Vista for example - many hackers have audited its source code on while on Microsoft's payroll. This is a good thing, and Microsoft can now say to customers "&lt;span style="font-style: italic;"&gt;YES we did audit our code after development&lt;/span&gt;". Which is a lot more then most other vendors out there can say. The flip side to this argument is open source. Just because the source is open doesn't mean people have reviewed it for vulnerabilities (download a random sourceforge project and you will understand what I mean). But on the other hand, it does give the customer/user the ability to inspect the software they are relying so heavily on.&lt;br /&gt;&lt;br /&gt;How many of you can honestly say the software products your company relies on have been audited by a third party?&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-8982521485038811467?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/lrOOBfOB9MY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/8982521485038811467/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=8982521485038811467&amp;isPopup=true" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/8982521485038811467?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/8982521485038811467?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/lrOOBfOB9MY/blackboxes-and-trust.html" title="Blackboxes and Trust" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/09/blackboxes-and-trust.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkAMSH04fyp7ImA9WB9TFkk.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-1886466992140329763</id><published>2007-09-24T11:00:00.000-07:00</published><updated>2007-09-24T07:39:49.337-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-24T07:39:49.337-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="virtualization" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>Some Thoughts On Virtualization and Security</title><content type="html">&lt;span style="font-size:85%;"&gt;With high profile VMWare vulnerabilities just hitting the news its easy to &lt;a href="http://blogs.zdnet.com/security/?p=532"&gt;find&lt;/a&gt; some &lt;a href="http://www.securityfocus.com/brief/593"&gt;mainstream&lt;/a&gt; &lt;a href="http://www.pcworld.com/article/id,137504-c,applicationbugs/article.html"&gt;articles&lt;/a&gt; covering the subject. This post isn't about hypervisor rootkits (because were all tired of hearing about that), but more about the assumption in corporations and academia that (virtualization == security). This is just plain WRONG. Virtualization environments are extremely complex pieces of software - and with complexity comes insecurity. In fact I would venture as far as to say that by default (virtualization == insecurity); running two operating systems within the same machine just creates more attack surface. Considering the high degree of interaction the host and guest OS must have you inherently create greater possibility of vulnerability then if they were on separate hardware. And just because VM's are easy to create and re-create doesn't mean they shouldn't be secured as well. As we have seen from this latest VMWare vulnerability, theres always the possibility your guest VM can compromise your host OS. It should also be noted that once the host OS has been hijacked ALL of your guest VM's should be considered compromised and untrusted. &lt;/span&gt;&lt;span style="font-size:85%;"&gt;In order for the attacker to completely own your virtualization environment he/she has to know exactly what host OS is being used. There needs to be more fool-proof research into this area before wide spread panic can begin. There will also hopefully be more utilization of the host OS/virtualizer as an Virtual IDS (VIDS) of sorts - to tell us when our virtual machines have been compromised. This use hasnlt been explored enough in my opinion.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;Now its true some &lt;a href="http://www.ghs.com/products/rtos/integrity_pc.html"&gt;virtualization technologies&lt;/a&gt; were designed with security in mind and others were meant to increase efficiency and productivity of hardware. This fact should be noted when trying to decide which virtualization strategy to use. But companies should also be aware of the security issues they may be introducing by improperly implementing a virtualization strategy as they may be causing more harm then its worth.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-1886466992140329763?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/DcTbqYuplgg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/1886466992140329763/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=1886466992140329763&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/1886466992140329763?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/1886466992140329763?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/DcTbqYuplgg/some-thoughts-on-virtualization-and.html" title="Some Thoughts On Virtualization and Security" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/09/some-thoughts-on-virtualization-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMAQnY8fyp7ImA9WB9TFUQ.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-4469910647597332366</id><published>2007-09-22T15:59:00.000-07:00</published><updated>2007-09-23T18:30:43.877-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-23T18:30:43.877-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="conference" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>A good presentation by FX ....</title><content type="html">&lt;span style="font-size:85%;"&gt;I just read a pretty good presentation by FX (Felix Lindner) called "Security and Attack Surface of Modern Applications". He presented it at HITB 2007 (I did not attend). As FX describes it his presentation is not about hex and 0day ;( but more about how security problems are not being fixed and things are rapidly progressing down hill. He makes some very good points such as "&lt;span style="font-style: italic;"&gt;Respect that software is there to solve real problems for people, security isn’t one of them.&lt;/span&gt; ". And this is very true, the security community tends to forget this detail most of the time. His presentation has some excellent numbers associated with vulnerability classes and what attackers focused on since the late nineties to today.&lt;br /&gt;&lt;br /&gt;One subject he touches on which is of interest to me is perimeter security. While its true most attackers focus on client side exploits today, perimeter security should not be forgotten just because we tunnel %50 of our applications over HTTP. Client side exploits allow attackers to create larger botnets. But client side vulnerabilities aren't always the first pick in a targeted attack. Well they can be (MS Office parsing vulns - google for what I mean). But targeted attacks can involve something specific to that target, a mis-configured web server or email server etc... To FX's point, combining all of these different technologies (VPN Termination, LDAP, SSL etc) into the firewall is _not_ the way to do perimeter security. Defense in depth is still entirely relevant and will be for a long time to come. And if done correctly, at the very least, can stop some &lt;/span&gt;&lt;span style="font-size:85%;"&gt;successful &lt;/span&gt;&lt;span style="font-size:85%;"&gt;client side exploits from calling home, which can minimize their impact to your network.&lt;br /&gt;&lt;br /&gt;On slide 13 FX also talks about 'Skill and Time'. He seems to put far more skill+time on finding vulnerabilities as opposed to writing exploits, which he states 'requires little skills but quite some time'. Im not sure how I feel about that slide yet. &lt;a href="http://archives.neohapsis.com/archives/dailydave/2007-q3/0171.html"&gt;Others certainly do not agree with him&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I recommend reading it. You can grab FX's presentation and others from HITB 2007 &lt;a href="http://materials.hitbsecconf.org/"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;(FX's take on the 'self defending network' is priceless)&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-4469910647597332366?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/RUXywwt6dp8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/4469910647597332366/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=4469910647597332366&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/4469910647597332366?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/4469910647597332366?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/RUXywwt6dp8/good-presentation-by-fx.html" title="A good presentation by FX ...." /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/09/good-presentation-by-fx.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkYDQXc9fCp7ImA9WB9aFkg.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-6862293478959437906</id><published>2007-09-19T17:00:00.000-07:00</published><updated>2008-01-06T12:09:30.964-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2008-01-06T12:09:30.964-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="quefuzz" /><category scheme="http://www.blogger.com/atom/ns#" term="struct software" /><category scheme="http://www.blogger.com/atom/ns#" term="fuzzing" /><title>QueFuzz</title><content type="html">&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;**Update:&lt;/span&gt; &lt;/span&gt;New version is out (v06), supports a fuzzing template file&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;- source is &lt;a href="http://code.google.com/p/quefuzz/"&gt;here&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Its a very basic C program that utilizes the libnetfilter_queue library to turn any networked application into a fuzzer. It basically works like this:&lt;br /&gt;&lt;br /&gt;- You set a specific iptables QUEUE rule like so:&lt;br /&gt;$iptables -A OUTPUT -p tcp --dport 110 -j QUEUE&lt;br /&gt;- Start it like so:&lt;br /&gt;'$./quefuzz -a -v -c USER'&lt;br /&gt;or&lt;br /&gt;'$./quefuzz -b -v -f 3'&lt;br /&gt;- Open your POP3 client and connect to the POP server you want to fuzz&lt;br /&gt;- QueFuzz picks up your packets using libnetfilter_queue, fuzzes them and sends them on the wire&lt;br /&gt;&lt;br /&gt;This works with any protocol/port. If netfilter/iptables can queue it, QueFuzz can fuzz it.&lt;br /&gt;&lt;br /&gt;QueFuzz has no protocol awareness, it expects to receive a proper packet. It has minimal command line flags such as whether or not the protocol you want to fuzz is binary or ascii, or both. If the protocol is TCP or UDP, QueFuzz will skip those headers appropriately and start fuzzing the packet data. If the protocol is not TCP or UDP then it starts fuzzing immediately after the IP header.&lt;br /&gt;&lt;br /&gt;A lot of work is needed on the tool. It was never meant to be protocol aware or intelligent, but it could certainly be cleaner. It is BETA code at best, so use at your own risk. I can guarantee its full of bugs (probably some bad ones) - so be careful! I literally whipped it up in a couple of hours. Ill be refining it over the next few weeks and releasing updates. Feel free to send me patches and suggestions by email.&lt;br /&gt;&lt;br /&gt;QueFuzz is released under the GPLv2 as is libnetfilter_queue. Some checksum routines are released under BSD-3 license from various sources.&lt;br /&gt;&lt;br /&gt;You can download the beta code &lt;a href="http://chris.rohlf.googlepages.com/index.html"&gt;here&lt;/a&gt; Enjoy&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-6862293478959437906?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/0CcacqeAIHU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/6862293478959437906/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=6862293478959437906&amp;isPopup=true" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/6862293478959437906?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/6862293478959437906?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/0CcacqeAIHU/fits-fuzzer-in-stack.html" title="QueFuzz" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/09/fits-fuzzer-in-stack.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEAR3wzfip7ImA9WB5aF04.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-2827299330789300681</id><published>2007-09-13T11:32:00.001-07:00</published><updated>2007-09-13T18:34:06.286-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-09-13T18:34:06.286-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ngrep" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><title>Ngrep is still useful</title><content type="html">&lt;span style="font-size:85%;"&gt;I just had to blog on how much I love ngrep. Despite all the advances in security, we are still left with a huge problem called data leakage. If you work in any type of operational security role, its one of your worst nightmares. I have used ngrep for a couple of years, as I'm sure most of you have too. I had a (legal) need for ngrep again over the past week while trying to assess the state of security in a specific network I protect and monitor and I thought I would post some of my more use-able ngrep queries for you. &lt;/span&gt;&lt;span style="font-size:85%;"&gt;I am not a regular expression guru like some people I know, sorry.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Looking for social security numbers:&lt;/span&gt;&lt;br /&gt;$ngrep -q -d eth0 -w '[0-9]{3}\-[0-9]{2}\-[0-9]{4}'&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Almost the same as above but searching for credit card number patterns (this one can lead some false positives if searching through http conversations):&lt;br /&gt;&lt;/span&gt;$ngrep -q -d eth0 '[0-9]{4}\-[0-9]{4}\-[0-9]{4}\-[0-9]{4}'&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Looking for 'password=':&lt;/span&gt;&lt;br /&gt;$ngrep -q -d eth0 -i 'password='&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Some storm worm executable names (this could be expanded easily):&lt;br /&gt;&lt;/span&gt;ngrep -q -d eth0 -i '(ecard|postcard|youtube|FullClip|MoreHere|FullVideo|greeting|ClickHere|NFLSeasonTracker).exe' 'port 80'&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Detect an HTTP connection to a server by IP address not FQDN (this is how bleedingthreats new storm worm download rules look):&lt;br /&gt;&lt;/span&gt;ngrep -q -d eth0 -i 'Host\: [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' 'port 80'&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Look for basic http login:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;ngrep -q -d eth0 -i '&lt;/span&gt;&lt;span style="font-size:85%;"&gt;Authorization: Basic' 'port 80'&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;These are just smaller examples of what expensive 'data leak prevention' boxes do. Hopefully they perform the regular expression look ups on reassembled packet flows, not individual packets. Otherwise its a waste of time as the data can be chunked up between different packets. Data leakage continues to be an issue to this day. And unfortunately I don't see it going away anytime soon. And thats mostly because its a human problem, and user education is a loosing battle  : \&lt;br /&gt;&lt;br /&gt;Sorry this post was soooo 2001 - please resist the urge to remove me from your RSS reader&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-2827299330789300681?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/WWzeVfs1e_U" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/2827299330789300681/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=2827299330789300681&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/2827299330789300681?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/2827299330789300681?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/WWzeVfs1e_U/ngrep-is-still-useful.html" title="Ngrep is still useful" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/09/ngrep-is-still-useful.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QDQHwzfSp7ImA9WB5VGU4.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-8081104597356536470</id><published>2007-08-10T17:12:00.000-07:00</published><updated>2007-08-12T08:09:31.285-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-08-12T08:09:31.285-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="reverse engineering" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="static analysis" /><title>Static Analysis Headaches</title><content type="html">&lt;span style="font-size:85%;"&gt;I am very interested in the static analysis of binaries. Mainly because theres no one way to do it. Theres no correct or incorrect way of analyzing compiler generated code - especially without running it. In fact most techniques only work with certain compiler constructs and function behaviors. I think thats why even today there are very few tools that do it well.&lt;br /&gt;&lt;br /&gt;I started coding static analysis tools a few years ago and have steadily been rewriting and testing pieces of one in particular over and over again that analyzes x86 ELF objects. (Yes I will eventually release it in some form). I have run into many pitfalls during its design, specifically emulating the x86 without too much overhead. Obviously I don't care to emulate every single instruction in every combination, thats not only pointless but it would take forever. There are only certain parts of the execution process I am interested in. That includes what the stack looks like, register contents, variable types, and how they all tie together. For example a programmer might say sizeof(var) - and the size of that variable is determined at runtime. Now lets suppose that size argument is used as a length argument to a function like memcpy. I can't be too sure if the call is vulnerable or not because I don't know exactly what var is or how big it is. Sometimes educated guesses must be made. For example does var get assigned a value from a packet? Is it a command line argument? When you can't  execute the binary, you have to make certain assumptions, and just hope they are correct.&lt;br /&gt;&lt;br /&gt;And sometimes, you do know certain things about the variables. I thought it might be a nice write up to show how a tool of mine evaluated a specific vulnerable call to memcpy(). This is one very non-scientific way of finding variable objects in the code and assigning them attributes such as 'size'. Another 'assumption' I had to make.&lt;br /&gt;&lt;br /&gt;Heres a function foo():&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;...&lt;br /&gt;80483de push %ebp&lt;br /&gt;  | Symbol: [foo @ 080483de]&lt;br /&gt;  | Xref: (0x80483de -&gt; [0x080483cb call 0x80483de])&lt;br /&gt;&lt;br /&gt;80483df mov %esp,%ebp&lt;br /&gt;80483e1 sub $0x18,%esp&lt;br /&gt;80483e4 mov $0x8049640,%edx&lt;br /&gt;80483e9 mov $0x80,%eax&lt;br /&gt;80483ee mov %eax,0x8(%esp)&lt;br /&gt;80483f2 movl $0x0,0x4(%esp)&lt;br /&gt;80483fa mov %edx,(%esp)&lt;br /&gt;80483fd call 0x80482d4&lt;br /&gt;   | Symbol: [memset @ plt]&lt;br /&gt;   | Analysis:&lt;br /&gt;   | EAX 0x00000080 EBX 0x00000000&lt;br /&gt;   | ECX 0x00000000 EDX 0x08049640&lt;br /&gt;   |       | Symbol: [0x8049640 buf1 @ .bss]&lt;br /&gt;   | Analysis:&lt;br /&gt;   | memset() argument indicates sizeof(0x08049640)=0x80(128 bytes)&lt;br /&gt;&lt;br /&gt;8048402 mov 0x8(%ebp),%eax&lt;br /&gt;8048405 add $0x4,%eax&lt;br /&gt;8048408 mov (%eax),%eax&lt;br /&gt;804840a mov $0x8049640,%ecx&lt;br /&gt;   | Symbol: [0x8049640 buf1 @ .bss]&lt;br /&gt;&lt;br /&gt;804840f mov %eax,%edx&lt;br /&gt;8048411 mov $0x100,%eax&lt;br /&gt;8048416 mov %eax,0x8(%esp)&lt;br /&gt;804841a mov %edx,0x4(%esp)&lt;br /&gt;804841e mov %ecx,(%esp)&lt;br /&gt;8048421 call 0x80482f4&lt;br /&gt;   | Symbol: [memcpy @ plt]&lt;br /&gt;   | Analysis:&lt;br /&gt;   | EAX 0x00000100 EBX 0x00000000&lt;br /&gt;   | ECX 0x08049640 EDX 0x00000000&lt;br /&gt;   |     | Symbol: [0x8049640 buf1 @ .bss]&lt;br /&gt;   | Analysis:&lt;br /&gt;   | memcpy() argument indicates buffer overflow at 0x08049640 by (0x80) bytes [!]&lt;br /&gt;&lt;br /&gt;8048426 mov $0x0,%eax&lt;br /&gt;804842b leave&lt;br /&gt;804842c ret&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;During its first past on the object code a size value was stored and assigned to the static object at 0x08049640 based on the arguments to memset(). This is obviously not a fool proof way of knowing what the object at 0x08049640 is or what its true size is, however at the very least it should be the objects minimum size. Its probably a global struct that contains some variables or a static character array, but its impossible for it to figure that out with any degree of certainty at this point. Following the memset() call there was a call to memcpy(), based on the prior observation I am able to determine auto-magically that there is a potential buffer overflow.&lt;br /&gt;&lt;br /&gt;Obviously I am not the only person to use this method - as its a very simple concept and easy to implement. And certainly won't catch more complex bugs that require the interaction of many functions.&lt;br /&gt;&lt;br /&gt;This requires several passes are made over the binary before any output to the user can occur. My first and second passes gather all symbol, relocation, and cross reference data, followed by function analysis routines. The third pass contains mostly output plugins that make all of the data accessible for display.&lt;br /&gt;&lt;br /&gt;Blogspot has a way of jumbling up my text, not to mention its not really formatted nicely to begin with. The vulnerability analysis plugin has lots of 'hint strings' that are basically triggered by the occurence of specific instructions plus a combination of pre-existing knowledge about the static data objects and code that has already been evaluated in previous passes. For now it works on smaller programs. Despite being written in straight C, it can sometimes take awhile to crunch all of this on a large binary like Firefox (and most of the time produces absolute nonsense). The end goal is to have an effcient tool that can process and accurately report on a larger binary.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-8081104597356536470?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/hOlnLKJMmVI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/8081104597356536470/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=8081104597356536470&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/8081104597356536470?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/8081104597356536470?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/hOlnLKJMmVI/static-analysis-headaches.html" title="Static Analysis Headaches" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/08/static-analysis-headaches.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0cHQXg-eSp7ImA9WB5VFEQ.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-7538867376529231106</id><published>2007-08-07T06:37:00.000-07:00</published><updated>2007-08-07T06:57:10.651-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-08-07T06:57:10.651-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="computer science" /><title>Summer is almost over</title><content type="html">&lt;span style="font-size:85%;"&gt;As you may have noticed, I have not written a blog entry since June. I am spending my summer relaxing for once and catching up on some reading. Some advisories and beta quality tools will be along shortly.&lt;br /&gt;&lt;br /&gt;I often help beginners in the field of information/computer security at work and on a personal level. The question I get asked most often is "what should I start with?!". Usually they are expecting some cool and interesting technique they can dive into like "breaking XYZ encryption!" but they are typically disappointed when I respond with something like "start learning C and reading the Linux kernel source". Thats when their smile fades and they realize they have to go back to stuff they ignored freshmen year of college. Today I came across this "&lt;a href="http://bottomupcs.sourceforge.net/csbu/book1.htm"&gt;Computer Science From the Bottom Up&lt;/a&gt;". Its full of good information for the beginner to computer science, which is a necessary base for computer security. Have fun.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-7538867376529231106?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/rU3Vtohj6v0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/7538867376529231106/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=7538867376529231106&amp;isPopup=true" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/7538867376529231106?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/7538867376529231106?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/rU3Vtohj6v0/summer-is-almost-over.html" title="Summer is almost over" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/08/summer-is-almost-over.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMHQHwzeyp7ImA9WB5SFko.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-589932018128431302</id><published>2007-06-08T10:40:00.000-07:00</published><updated>2007-06-12T11:53:51.283-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-06-12T11:53:51.283-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="open source" /><category scheme="http://www.blogger.com/atom/ns#" term="snort" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="ELF" /><title>Dual Licenses and more</title><content type="html">&lt;span style="font-size:85%;"&gt;There has been some good discussion on GPL and dual licensing at &lt;a href="http://www.matasano.com/log/"&gt;matasanos&lt;/a&gt; blog, and &lt;a href="http://ryanlrussell.blogspot.com/"&gt;ryan russell&lt;/a&gt; has also posted some good thoughts on this. This came right on time for me, as I've been debating lately what to do with a couple of projects I've been working on for awhile. I want to release the code, but it would also be great to sell and/or license it to companies wishing to use it commercially. These projects include a reverse engineering framework and some various network security tools. The RE framework is basically an engine written in C that securely and reliably parses, disassembles and stores massive amounts of data on any ELF object. It basically becomes usable by writing plugins for it. You can write output plugins (I will be including an HTML one with it) and plugins that hook the internal disassembler and ELF parsing routines. I have a couple of plugins ready and I want to release this code soon (1-2 months). So expect an open source version of that with a dual license for companies wishing to license it for commercial use.&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 0, 0);"&gt;** [ Start reading here if you came from bleedingthreats.net ] **&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In other news, I posted a basic &lt;a href="http://chris.rohlf.googlepages.com/spamhaus-snort.sh"&gt;script&lt;/a&gt; today that parses the snort alert file for IP addresses and then queries spamhaus' zen real time blacklist. Feel free to modify and use it in your sensor network (its certainly &lt;span style="font-weight: bold;"&gt;not&lt;/span&gt; production quality as it is now). I am very interested in receiving modifications to the script and general feedback to the idea. I have already seen some interesting trends that I think will prove useful after a few days of correlating data. Enjoy!&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Note: Spamhaus is unfortunately under DDOS as I write this though, so don't use it too heavily.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;Update&lt;/span&gt; -&lt;/span&gt; &lt;/span&gt;&lt;span&gt;I have posted a new version of the script - please contribute if you make changes&lt;/span&gt;&lt;span style="font-style: italic;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-589932018128431302?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/G_h_gABGlg8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/589932018128431302/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=589932018128431302&amp;isPopup=true" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/589932018128431302?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/589932018128431302?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/G_h_gABGlg8/dual-licenses-and-more.html" title="Dual Licenses and more" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/06/dual-licenses-and-more.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YBRno6eip7ImA9WB5TFks.&quot;"><id>tag:blogger.com,1999:blog-34826778.post-9150196649440684737</id><published>2007-05-31T18:55:00.000-07:00</published><updated>2007-05-31T19:32:37.412-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2007-05-31T19:32:37.412-07:00</app:edited><title>Its easy to overlook some bugs</title><content type="html">&lt;span style="font-size:85%;"&gt;I often hear people say source code auditing is generally easier then binary auditing. This is usually true, but certain bugs are so easy to overlook in source code form that they rarely stand out. But what about the corresponding assembly code, are the same bugs just as hard to spot? Lets take a look.&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;...&lt;br /&gt;804843b:       8b 85 e8 fb ff ff       mov    0xfffffbe8(%ebp),%eax&lt;br /&gt;8048441:       83 c0 04                add    $0x4,%eax&lt;br /&gt;8048444:       8b 00                   mov    (%eax),%eax&lt;br /&gt;8048446:       c7 44 24 08 ff 03 00    movl   $0x3ff,0x8(%esp)&lt;br /&gt;804844d:       00&lt;br /&gt;804844e:       89 44 24 04             mov    %eax,0x4(%esp)&lt;br /&gt;8048452:       8d 85 f8 fb ff ff       lea    0xfffffbf8(%ebp),%eax&lt;br /&gt;8048458:       89 04 24                mov    %eax,(%esp)&lt;br /&gt;804845b:       e8 c0 fe ff ff          call   8048320         ;strncpy@plt&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;Reverse that to C real fast. At 804843b we start setting up arguments to strncpy. Notice at 8048446 the decimal 1023 is used as the third argument to strncpy, its the length value. The size of the original char buffer was probably 1024. argv[1] to main() is used as the src argument to strncpy and finally the local char buffer as the destination.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;'&lt;span style="font-size:85%;"&gt;strncpy(buffer, argv[1], sizeof(buf)-1);'&lt;br /&gt;&lt;br /&gt;This is all fairly routine stuff, pretty boring actually. Now heres another disassembly listing.&lt;br /&gt;&lt;/span&gt;&lt;pre&gt;&lt;br /&gt;...&lt;br /&gt;804843b:       8b 85 e8 fb ff ff       mov    0xfffffbe8(%ebp),%eax&lt;br /&gt;8048441:       83 c0 04                add    $0x4,%eax&lt;br /&gt;8048444:       8b 00                   mov    (%eax),%eax&lt;br /&gt;8048446:       c7 44 24 08 04 00 00    movl   $0x4,0x8(%esp)&lt;br /&gt;804844d:       00&lt;br /&gt;804844e:       89 44 24 04             mov    %eax,0x4(%esp)&lt;br /&gt;8048452:       8d 85 f8 fb ff ff       lea    0xfffffbf8(%ebp),%eax&lt;br /&gt;8048458:       89 04 24                mov    %eax,(%esp)&lt;br /&gt;804845b:       e8 c0 fe ff ff          call   8048320         ; strncpy@plt&lt;br /&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;Notice the difference? The length argument to strncpy is wrong, its only decimal 4. The programmer (me, because this is an example) used ...&lt;br /&gt;&lt;br /&gt;'strncpy(dst, src, sizeof(dst-1));'&lt;br /&gt;&lt;br /&gt;instead of&lt;br /&gt;&lt;br /&gt;'strncpy(dst, src, sizeof(dst)-1));'&lt;br /&gt;&lt;br /&gt;In the second listing the resulting code would only copy at most 4 bytes into the destination from the source. The bug in source code can sometimes be hard to spot because its a matter of where the ')' character is placed, you may scan code for hours and easily overlook this minor (but very crucial) detail. And the bug in a disassembly listing is also hard to spot cause its just a single byte difference. Anyways, these subtleties can make a world of difference.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/34826778-9150196649440684737?l=em386.blogspot.com'/&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/EM_386/~4/91wrEGeiV_0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://em386.blogspot.com/feeds/9150196649440684737/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=34826778&amp;postID=9150196649440684737&amp;isPopup=true" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/9150196649440684737?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/34826778/posts/default/9150196649440684737?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/EM_386/~3/91wrEGeiV_0/its-easy-to-overlook-some-bugs.html" title="Its easy to overlook some bugs" /><author><name>Chris Rohlf</name><uri>http://www.blogger.com/profile/16615531060194715892</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14628976566368832315" /></author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://em386.blogspot.com/2007/05/its-easy-to-overlook-some-bugs.html</feedburner:origLink></entry></feed>
