<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mac OS X &#8211; Phocean.net</title>
	<atom:link href="/tag/mac-os-x/feed" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Computer Security Blog</description>
	<lastBuildDate>Fri, 24 Feb 2017 21:17:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.10</generator>
	<item>
		<title>My goodness, I got mainframed!</title>
		<link>/2013/05/28/my-goodness-i-got-mainframed.html</link>
		<comments>/2013/05/28/my-goodness-i-got-mainframed.html#comments</comments>
		<pubDate>Tue, 28 May 2013 12:20:17 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[hercules390]]></category>
		<category><![CDATA[ISPF]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[mainframe]]></category>
		<category><![CDATA[Network]]></category>
		<category><![CDATA[pentest]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[tn3270]]></category>
		<category><![CDATA[TSO]]></category>
		<category><![CDATA[tun]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[z/os]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1587</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1587</guid>
		<description><![CDATA[Mainframes are not dead, why not pentesting it? I just watched the presentation of Phil Young at Shmoocon 2013: &#8220;Mainframed: the secrets inside that black box&#8220;. I truly loved it. I thought mainframes where disappearing, but I was surprised to see that it still alive. I was even more surprised to find out that they...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2013/05/28/my-goodness-i-got-mainframed.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>Mainframes are not dead, why not pentesting it?</p>
<p>I just watched the presentation of <strong>Phil Young</strong> at <a href="https://www.shmoocon.org/shmoocon_2013" target="_blank">Shmoocon 2013</a>: &#8220;<a href="https://www.shmoocon.org/2013/videos/Shmoocon%202013%20-%20Mainframed%20The%20Secrets%20Inside%20that%20Black%20Box.mp4" target="_blank">Mainframed: the secrets inside that black box</a>&#8220;. I truly loved it. I thought mainframes where disappearing, but I was surprised to see that it still alive. I was even more surprised to find out that they have some Unix interface, and that there is a emulator for x86. Where it was less of a surprise is that their security is pretty low :-)</p>
<p>Anyway, don&#8217;t miss watching the video. <a href="http://mainframed767.tumblr.com" target="_blank">Phil&#8217;s blog, &#8220;Soldier of Fortran&#8221;</a>, is also a gold mine, he wrote many tips, tutos and tools.</p>
<p>It made me very curious and just in case I find some IBM Z/OS during a pentest, I though it would be nice to run it.</p>
<h1>Installing</h1>
<blockquote><p>Disclaimer:</p>
<p>Although some Z/OS files are available for download on the Internet, you must own a legal license of Z/OS. This tutorial is exclusively for education-purpose, use it only for testing, never in production nor for illegal activities.</p>
<p>Also, I am a noob in the area. So if some of you are skilled and find mistakes or improvements, please let me know in the comments. I give a great importance to your feedback and it encourages me to continue.</p></blockquote>
<p>I glued the pieces in the following steps (Mac OS oriented and tested only with it, the same should work for Linux with minor adjustments and see the reference otherwise):</p>
<ol class="split start">
<li>Download and install <a href="http://www.brown.edu/cis/tn3270/" target="_blank">tn3270</a> (Mac) or <a href="http://x3270.bgp.nu/download.html" target="_blank">x3270</a> (Windows, Linux, Mac): this will be the client terminal used to connect to the mainframe.</li>
<li>Download the emulator, <a href="http://www.hercules-390.eu" target="_blank">Hercules</a>. Install it, following the README instructions relevant to your system. Note that the instructions for Mac OS are outdated and won&#8217;t work. I followed Phil&#8217;s instructions:</li>
</ol>
<pre>git clone git://github.com/s390guy/hercules-390.git
cd hercules-390
sh autogen.sh
./configure
make
make install</pre>
<ol class="split">
<li>Take some IBM Z/OS release, and install it:</li>
</ol>
<pre>mv IBM\ ZOS\ 1.10/Z110SA/images/Z110\ -\ Copy /YOUR/PATH/HERE/Z110
cd /YOUR/PATH/HERE/Z110
mkdir PRTR
cd CONF
cp ADCD_LINUX.CONF ADCD_MAC.CONF
sed -i '' 's/\/home\/ehrocha\/hercules\/images/\/YOUR\/PATH\/HERE/g' ADCD_MAC.CONF
sed -i '' 's/CNSLPORT \{2\}23/CNSLPORT  3270/g' ADCD_MAC.CONF
sed -i '' 's/0E20.2   LCS  10.0.1.20/0E20.2 3088 CTCI \/dev\/tun0 1500 10.10.10.11 10.10.10.12 255.255.255.255/g' ADCD_MAC.CONF</pre>
<ol class="split">
<li>Getting the network to work on Mac OS require some extra steps (skip it if your are using Linux).</li>
</ol>
<p><a href="http://sourceforge.net/projects/tuntaposx/files/tuntap/20111101/">Download tuntaposx</a>, uncompress and install the package. No reboot it necessary, you should now have plenty of tun* (and tap*) interfaces:</p>
<pre>$ ls /dev/tun*
/dev/tun0 /dev/tun10 /dev/tun12 /dev/tun14 /dev/tun2 /dev/tun4 /dev/tun6 /dev/tun8
/dev/tun1 /dev/tun11 /dev/tun13 /dev/tun15 /dev/tun3 /dev/tun5 /dev/tun7 /dev/tun9</pre>
<ol class="split">
<li>Okay, now we can start the emulator (we need to sudo to access to the tun0 interface, among other reasons):</li>
</ol>
<pre>sudo hercules -f ADCD_MAC.CONF</pre>
<p>First of all, checks that the network is fine:</p>
<pre># From Mac OS:
$ ifconfig tun0
tun0: flags=8851&lt;UP,POINTOPOINT,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
 inet 10.10.10.12 --&gt; 10.10.10.11 netmask 0xff000000 
 open (pid 98687)

# From Hercules:
herc =====&gt; devlist
[...]
HHC02279I 0:0E20 3088 CTCI 10.10.10.11/10.10.10.12 (tun0) IO[0] open
HHC02279I 0:0E21 3088 CTCI 10.10.10.11/10.10.10.12 (tun0) IO[0] open</pre>
<p>Open <strong>tn3270</strong> and connect with default settings on localhost:</p>
<p><img class="size-full wp-image-1601 aligncenter" alt="tn3270 connection" src="/wp-content/uploads/2013/05/tn3270-connection.png" width="423" height="219" /></p>
<p>And then in the hercules terminal, enter <code>ipl a80</code></p>
<div id="attachment_1602" style="width: 590px" class="wp-caption aligncenter"><img class="size-medium wp-image-1602 " alt="boot zos" src="/wp-content/uploads/2013/05/boot-zos-580x474.png" width="580" height="474" srcset="/wp-content/uploads/2013/05/boot-zos-580x474.png 580w, /wp-content/uploads/2013/05/boot-zos-624x510.png 624w, /wp-content/uploads/2013/05/boot-zos.png 775w" sizes="(max-width: 580px) 100vw, 580px" /><p class="wp-caption-text">Hercules390 console: booting Z/OS</p></div>
<p><strong>It is very long to boot, don&#8217;t worry. You will actually have to use 2 terminals</strong>, so open the second one, which will show the logon screen (see screenshot below) after booting is done. It will be used for &#8220;userland&#8221; aka TSO commands.</p>
<p>The first terminal shall be kept open as the master console, which receive system logs and can be used for &#8220;system-level&#8221;* commands (e.g root level).</p>
<div id="attachment_1620" style="width: 590px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2013/05/logon-screen.png" rel="lightbox[1587]"><img class="size-medium wp-image-1620" alt="Z/OS &quot;Duza&quot; logon screen" src="/wp-content/uploads/2013/05/logon-screen-580x462.png" width="580" height="462" srcset="/wp-content/uploads/2013/05/logon-screen-580x462.png 580w, /wp-content/uploads/2013/05/logon-screen-624x498.png 624w, /wp-content/uploads/2013/05/logon-screen.png 684w" sizes="(max-width: 580px) 100vw, 580px" /></a><p class="wp-caption-text">Z/OS &#8220;Duza&#8221; logon screen</p></div>
<ol class="split">
<li>At the prompt, enter <code>TSO</code>, then <code>IBMUSER</code> as the login, and <code>SYS1</code> as the password. It will automatically launch the ISPF menu:</li>
</ol>
<div id="attachment_1619" style="width: 590px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2013/05/ispf.png" rel="lightbox[1587]"><img class="size-medium wp-image-1619" alt="ISPF menu" src="/wp-content/uploads/2013/05/ispf-580x462.png" width="580" height="462" srcset="/wp-content/uploads/2013/05/ispf-580x462.png 580w, /wp-content/uploads/2013/05/ispf-624x498.png 624w, /wp-content/uploads/2013/05/ispf.png 684w" sizes="(max-width: 580px) 100vw, 580px" /></a><p class="wp-caption-text">ISPF menu</p></div>
<ol class="split">
<li>Now, you are good to go ahead with Z/OS commands&#8230;</li>
</ol>
<p>This video demonstrates the boot process:</p>
<p><iframe src="http://player.vimeo.com/video/67114095" height="281" width="500" allowfullscreen="" frameborder="0"></iframe></p>
<p><a href="http://vimeo.com/67114095">Z/OS emulation with Hercules390</a> from <a href="http://vimeo.com/user12629826">phocean</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<ol class="split">
<li>Now, let&#8217;s get the network up.</li>
</ol>
<p><strong>Prepare Mac OS</strong>:</p>
<ul>
<li>Make sure that the Mac OS firewall is deactivated or/and that you configured pf to allow the <code>tun0</code> interface (another article coming soon on this topic).</li>
<li>Add a route to <code>tun0</code></li>
</ul>
<pre>sudo route add -net 10.10.10.0/24 -interface tun0</pre>
<ul>
<li><span style="line-height: 14px;">You may want to activate ip forwarding, to have the Z/OS reach other interfaces through the kernel:</span></li>
</ul>
<pre>sudo sysctl -w net.inet.ip.forwarding=1</pre>
<p>Now every thing is in place to allow the mainframe to reach the outside. Further routing considerations are outside the scope of this article.</p>
<p><strong>Prepare Z/OS</strong>:</p>
<ul>
<li>In TSO menu, choose 3 (utilities), 4 (Dslist)</li>
<li>Click on the line besides <code>Dsname Level</code> and type-in <code>ADCD</code> and then press <code>[Enter]</code>. ADCD is what is called a dataset.</li>
<li>In the Command column, on the left of <code>ADCD.Z110S.PROCLIB</code>, type in <code>e</code> (stands for edit, reproduce the same pattern when I say &#8220;edit&#8221; in the following steps)</li>
<li>Edit the TCPIP member, and make sure that the <code>//PROFILE</code> line looks like this:</li>
</ul>
<pre>//PROFILE DD DISP=SHR,DSN=ADCD.Z110S.TCPPARMS(DUZA)</pre>
<p>You could change the <code>DUZA</code> string, but you would have to make sure that the corresponding profile exists in <code>ADCD.Z110S.TCPPARMS</code> (see TODO section).</p>
<ul>
<li>Go back to <code>Dslist</code> page using end or exit as a command. This time, type <code>DUZA</code> as dataset.</li>
<li>Edit the <code>TCPARMS</code> member, then <code>PROFILE</code>. Once in the file, edit carefuly the following lines (at the bottom, around line 90):</li>
</ul>
<pre>000090 DEVICE CTCA1 CTC e20
000091 LINK CTC1 CTC 1 CTCA1
000092
000093 HOME
000094    10.10.10.11  CTC1
000095
000096 GATEWAY
000097    10.10.10.12  = CTC1 1492 HOST
000098
000099 DEFAULTNET 10.10.10.12 CTC1 1492 0
[...]
000109 START CTCA1</pre>
<ul>
<li>In the console window, restart the network stack:</li>
</ul>
<pre>stop tcpip
# wait for termination message
start tcpip</pre>
<ul>
<li>If every is going well, the tunnel should get up and you should be able to ping both side (use the ping command in Z/OS from the command menu).</li>
</ul>
<p>This video illustrates some of this networking stuff:</p>
<p><iframe src="http://player.vimeo.com/video/69912699" height="281" width="500" allowfullscreen="" frameborder="0"></iframe></p>
<p><a href="http://vimeo.com/69912699">Hercules390 and Z/OS, getting the network up</a> from <a href="http://vimeo.com/user12629826">phocean</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<h1>Useful commands</h1>
<ul>
<li>Ifconfig</li>
</ul>
<pre>netstat home</pre>
<ul>
<li>Shutdown</li>
</ul>
<pre># in "system" terminal:
S SHUTSYS
Z EOD

# then, once finished, in Hercules:
exit</pre>
<h1>Tips</h1>
<ul>
<li>I was stuck at an early moment during the boot process with:</li>
</ul>
<pre>IXC208I THE RESPONSE TO MESSAGE IXC420D IS INCORRECT: IS NOT A VALID 
ACTION 
 IXC420D REPLY I TO INITIALIZE SYSPLEX ADCDPL, OR R TO REINITIALIZE 
XCF.     
  REPLYING I WILL IMPACT OTHER ACTIVE SYSTEMS.</pre>
<p>You can go over it by entering this in your terminal session (tn3270):</p>
<pre>R 00, I</pre>
<ul>
<li><span style="line-height: 14px;">After the long process, I actually had to open a second connection with the terminal to get the logon screen. So, just check from time to time instead of waiting for nothing in front of the first window.</span></li>
<li>To logoff, type <code>X</code> from the ISPF main menu. The first time, you have to configure the printer. Choose <code>LOCAL</code> as print mode, and give it any name as <code>Local printer ID</code>. Then press <code>[Enter]</code>, and if you are asked for a <code>sysout class</code>, choose <code>"J"</code>. You should be back in TSO, where you can execute <code>logoff</code>. Next time, it will default to these values, so you should get straight from ISPF to TSO.</li>
<li>Don&#8217;t forget that TSO is a CLI where you can type Z/OS and Unix commands. You actually don&#8217;t need or have to use ISPF, so don&#8217;t hesitate to use it!</li>
</ul>
<p>Of course, a good source of information is the <a href="http://publib.boulder.ibm.com/infocenter/zos/basics/index.js">hercules390 forum</a> may also be of help.</p>
<p>Voilà, happy hacking! WTF, it seems I got mainframed too! Did you?</p>
<p>Big thanks again to Phil Young for catching our attention on this stuff.</p>
<h1>TODO</h1>
<ul>
<li><span style="line-height: 14px;">Understand and get rid off the DUZO profile: you probably noticed that we are using the DUZO  profile to load the network stack (which is after the name of the torrent, and does probably more stuff behind). For example, there is no DUZO profile in ADCD.Z110S.TCPPARMS, so I still have no idea how it actually gets loaded. It has been only 2 days that I work on Z/OS, so I still have to read the doc (and any help is welcome).</span></li>
<li>Change the logon screen (see references).</li>
</ul>
<h1>References</h1>
<ul>
<li><a href="http://mainframed767.tumblr.com/post/27787457789/hercules-3-08-on-mac-os-x-lion" target="_blank">Hercules 3.08 on Mac OS X Lion</a></li>
<li><a href="http://mainframed767.tumblr.com/post/40836059586/instructions-to-installing-z-os-in-hercules" target="_blank">Instructions to installing z/OS in Hercules</a></li>
<li><a href="http://pastebin.com/raw.php?i=PHiT8jmE" target="_blank">Installin&#8217; that sweet sweet big iron on your Linux laptop or server</a> (<a href="/wp-content/uploads/2013/05/install_zOS_in_Hercules.txt">local mirror</a>)</li>
<li><a href="http://kat.ph/ibm-z-os-emulation-files-t5780374.html" target="_blank">Z/OS files</a></li>
<li><a href="http://patata.homeip.net/blog/hercules-and-zos-tcp-ip-networking-for-adcd-versions" target="_blank">Hercules and Z/OS TCP/IP networking for ADCD versions</a></li>
<li><a href="http://mainframed.wordpress.com/2012/06/17/changing-the-logon-screen-on-the-mainframe-zos-vtam-in-adcd/" target="_blank">Changing the logon screen on the mainframe</a></li>
<li><a href="http://tuntaposx.sourceforge.net/">tuntaposx</a></li>
<li><a href="http://www.js">TSO tutorial</a></li>
<li><a href="http://answers.uchicago.edu/page.php?id=19482#GETTINGM" target="_blank">Mainframe &#8211; using TSO and ISPF</a></li>
<li><a href="http://publib.boulder.ibm.com/infocenter/zos/basics/index.js">IBM online documentation</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>/2013/05/28/my-goodness-i-got-mainframed.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Installing Metasploit on Mac OS X [Mountain Lion]</title>
		<link>/2013/05/05/installing-metasploit-on-os-x-mountain-lion.html</link>
		<comments>/2013/05/05/installing-metasploit-on-os-x-mountain-lion.html#comments</comments>
		<pubDate>Sun, 05 May 2013 17:08:36 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[Pentesting]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Metasploit]]></category>
		<category><![CDATA[rbenv]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[zsh]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1571</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1571</guid>
		<description><![CDATA[It happened to me a little more complex than expected, so I thought it would deserve a post. There are a few good tutorials already, but they actually did not work flawlessly for me. So while this post is mostly based on them, there are some slight differences. Getting Metasploit First, let&#8217;s fetch Metasploit. Adjust...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2013/05/05/installing-metasploit-on-os-x-mountain-lion.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><!--StartFragment-->It happened to me a little more complex than expected, so I thought it would deserve a post. There are a few <a href="http://www.darkoperator.com/installing-metasploit-in-ubunt/">good</a> <a href="http://briancanfixit.blogspot.fr/2011/12/setting-up-metasploit-and-armitage-on.html">tutorials</a> already, but they actually did not work flawlessly for me. So while this post is mostly based on them, there are some slight differences.</p>
<h1>Getting Metasploit</h1>
<p>First, let&#8217;s fetch Metasploit. Adjust the last two lines by replacing <code>.zshrc</code> (I am using Zsh) with <code>.bash_profile</code> if you are using Bash, for instance.</p>
<p>This will download, create symlinks and set the database settings path (we will come back on it later) in your environment:</p>
<pre>cd /usr/local/share/
git clone https://github.com/rapid7/metasploit-framework.git
cd metasploit-framework
for MSF in $(ls msf*); do ln -s /usr/local/share/metasploit-framework/$MSF /usr/local/bin/$MSF;done
ln -s /usr/local/share/metasploit-framework/armitage /usr/local/bin/armitage
echo export MSF_DATABASE_CONFIG=/usr/local/share/metasploit-framework/config/database.yml &gt;&gt; ~/.zshrc
source ~/.zshrc</pre>
<p>Metasploit is almost ready, but don&#8217;t run anything yet. There a still quite a few steps&#8230;</p>
<h1>Getting Postgres</h1>
<p>We use Homebrew:</p>
<pre>brew install postgresql --without-ossp-build</pre>
<p>Initialization stuff:</p>
<pre>initdb /usr/local/var/postgres</pre>
<p>To have launchd start postgresql at login:</p>
<pre>ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents</pre>
<p>But I prefer to keep my startup clean, so I added two aliases in my <code>.zshrc</code></p>
<pre>alias pg_start='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
alias pg_stop='pg_ctl stop'</pre>
<p>So you now have two commands, <code>pg_start</code> and <code>pg_stop</code>, to use for Metasploit.<br />
Finally, we create the msf user that will connect to the database from within Metasploit:</p>
<pre><code>createuser msf -P -h localhost  
createdb -O msf msf -h localhost </code></pre>
<p>While we are at the database stuff, let&#8217;s configure Metasploit to use it. Create a <code>database.yml</code> file in  <code>/usr/local/share/metasploit-framework/config/</code> and put these lines:</p>
<pre>production:
    adapter: postgresql
    database: msf
    username: msf
    password: &lt;password&gt;
    host: 127.0.0.1
    port: 5432
    pool: 75
    timeout: 5</pre>
<p>The database is ready!</p>
<h1>Getting Ruby</h1>
<p>The last big step is to install Ruby. The one provided by Mac Os is a little too old, and you don&#8217;t want to mess with system libraries, so let&#8217;s leave it untouched. You could install Ruby with Homebrew, but it happens that the latest version (2.0.0-p0) is not working with Metasploit (OpenSSL libraries conflicts). So we need to use something like the 1.9.3 version of Ruby.</p>
<p>Anyway, a good practice is to have some flexibility on the version you are going to use, so you would be able to switch between 1.9.3, 2.0.0 or whatever and that whenever you need.</p>
<p>Here comes <strong>rbenv</strong>. For the next steps, I will assume that you have a working homebrew setting.</p>
<p>Let&#8217;s go:</p>
<pre>brew install rbenv ruby-build</pre>
<p>Add this line to your .zshrc or bash_profile:</p>
<pre>eval "$(rbenv init -)"</pre>
<p>Now you should be able to list all installable versions of Ruby:</p>
<pre>rbenv install --list</pre>
<p>Let&#8217;s pick up 1.9.3:</p>
<pre>rbenv install 1.9.3-p392</pre>
<p>It takes a while, but after it is completed, you can set it as your default:</p>
<pre>rbenv rehash
rbenv global 1.9.3-p392</pre>
<p>Note that you could use the <code>local</code> command instead of <code>global</code> to set it for the current terminal only.</p>
<p>Let&#8217;s check that everything is correctly set. This is where the Ruby versions are stored:</p>
<pre>$ ls ~/.rbenv/versions/
1.9.3-p392 2.0.0-p0</pre>
<p><code>ruby</code> and <code>gem</code> MUST point to the 1.9.3 version:</p>
<pre>$ rbenv which ruby
$HOME/.rbenv/versions/1.9.3-p392/bin/ruby
$ rbenv which gem
$HOME/.rbenv/versions/1.9.3-p392/bin/gem</pre>
<p>Looks good, let&#8217;s go ahead.</p>
<p>We are now able to install up the required gems for Metasploit. They made it easy by packaging these in a Gemfile that can be read by the &#8220;bundle&#8221; utility:</p>
<pre>gem install bundle
cd /usr/local/share/metasploit-framework
rbenv rehash
bundle install</pre>
<h1>Final steps</h1>
<p>Create an <code>vncviewer</code> wrapper to facilitate use from within Metasploit:</p>
<pre>echo '#!/usr/bin/env bash'  &gt;&gt; /usr/local/bin/vncviewer   
echo open vnc://\$1 &gt;&gt; /usr/local/bin/vncviewer  
chmod +x /usr/local/bin/vncviewer</pre>
<p>Get and compile the pcaprub library (optional):</p>
<pre>cd /usr/local/share/metasploit-framework/external
git clone <a href="http://github.com/shadowbq/pcaprub.git">http://github.com/shadowbq/pcaprub.git</a>
cd ./ext/pcaprub
ruby extconf.rb &amp;&amp; make &amp;&amp; make install</pre>
<h1>Have fun!</h1>
<p>If you haven&#8217;t, don&#8217;t forget to start Postgres, and you are ready to play:</p>
<pre>sudo -E msfconsole</pre>
<p>It should deploy the database structure and then start to work without warning. Hurrah! That was not hard, but a bit long, wasn&#8217;t it?</p>
<p>In case it still fails for you, it means that something went wrong with the setup. Check the steps again, and then leave a comment as it may be the time for an update or a correction of this article.</p>
<h1>Credits</h1>
<p>As stated in the introduction, this article is mostly taken from <a href="http://www.darkoperator.com/installing-metasploit-in-ubunt/">darkoperator.com</a> with minor adjustments (it actually did not work out of the box for me), so the use of rbenv. I hope it will be helpful to other people in the same case as me.</p>
<p><em><strong>UPDATE 09/07/2013</strong>:</em></p>
<ul>
<li><em>change in pcaprub directory (./pcaprub &#8211;&gt; ./ext/pcaprub)</em></li>
</ul>
<p><em><strong>UPDATE 07/23/2013</strong>:</em></p>
<ul>
<li><em><span style="line-height: 1.714285714; font-size: 1rem;">add missing </span><span style="line-height: 1.714285714; font-size: 1rem;">rbenv rehash command (thanks @</span><span style="line-height: 1.714285714; font-size: 1rem;">amukofes)</span></em></li>
<li><em>add missing commands to retrieve pcaprub (thanks @Ton)</em></li>
<li><em>fix indentation in postgres config file</em></li>
</ul>
<p><!--EndFragment--></p>
]]></content:encoded>
			<wfw:commentRss>/2013/05/05/installing-metasploit-on-os-x-mountain-lion.html/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Rootkit in my lab? (Part III)</title>
		<link>/2012/07/22/rootkit-in-my-lab-part-iii.html</link>
		<comments>/2012/07/22/rootkit-in-my-lab-part-iii.html#comments</comments>
		<pubDate>Sun, 22 Jul 2012 07:48:06 +0000</pubDate>
		<dc:creator><![CDATA[phocean]]></dc:creator>
				<category><![CDATA[Forensic]]></category>
		<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[Reversing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[System]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Assembly]]></category>
		<category><![CDATA[BSOD]]></category>
		<category><![CDATA[crashdump]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Regshot]]></category>
		<category><![CDATA[Rootkit]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[WinDBG]]></category>

		<guid isPermaLink="false">http://www.phocean.net/?p=1317</guid>
		<guid isPermaLink="false">http://www.phocean.net/?p=1317</guid>
		<description><![CDATA[First, thanks for all the comments in the previous articles (Part I and Part II). I decided to analyze one the crash I experienced during registry analysis. I could reproduce all the time a BSOD with Regshot. I thought it would be nice to see what I could get with WinDBG. I had my environment set up...<br><i class="icon-right-hand"></i> <span class="read-more"><a href="/2012/07/22/rootkit-in-my-lab-part-iii.html">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p>First, thanks for all the comments in the previous articles (<a title="Rootkit in my lab ? (part I)" href="/2012/06/30/rootkit-in-my-lab.html">Part I</a> and <a title="Rootkit in my lab ? (part II)" href="/2012/07/11/rootkit-in-my-lab-part-ii.html">Part II</a>).</p>
<p>I decided to analyze one the crash I experienced during registry analysis.<br />
I could reproduce all the time a BSOD with Regshot. I thought it would be nice to see what I could get with WinDBG.</p>
<p>I had my environment set up with the suspicious VM configured to debug activated on the serial port, which is a simple pipe on Mac OS X.<br />
Another VM is configured with a serial port as the other end of this pipe, and WinDBG attached to it.<br />
Another method would be to just configure Windows to create a crashdump file with kernel symbols, that you can later load into WinDBG. Of course, the first method offers more opportunities to check and play with the live system.</p>
<p>Then, I just boot the target and trigger the crash, simply by starting a scan with Regshot:</p>
<p style="text-align: center;"><iframe src="http://player.vimeo.com/video/46157626" frameborder="0" width="500" height="281"></iframe></p>
<p>Windows then crashes, WinDBG catches the exception and stops.</p>
<p>So what do we have ?</p>
<p>First, the error type, <em><strong>PAGE_FAULT_IN_NONPAGED_AREA (50)</strong></em>, means that an instruction pointed to an invalid memory address. Let&#8217;s check this.</p>
<p>With <em><strong>!analyse -v</strong></em>, you get the <a href="/wp-content/uploads/2012/07/regshot-BSOD.txt">full error dump</a>.</p>
<div id="attachment_1331" style="width: 727px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/07/WinXP-ReversingBox-2.png" rel="lightbox[1317]"><img class=" wp-image-1331 " title="Crashing Instruction" src="/wp-content/uploads/2012/07/WinXP-ReversingBox-2-1024x557.png" alt="" width="717" height="390" srcset="/wp-content/uploads/2012/07/WinXP-ReversingBox-2-1024x557.png 1024w, /wp-content/uploads/2012/07/WinXP-ReversingBox-2-300x163.png 300w, /wp-content/uploads/2012/07/WinXP-ReversingBox-2.png 1206w" sizes="(max-width: 717px) 100vw, 717px" /></a><p class="wp-caption-text">Crashing Instruction</p></div>
<p>It shows the function (nt!CmpGetValueKeyFromCache, offset 0x89) and the memory address where the crash was triggered.</p>
<p>The instruction at this address is:</p>
<pre>80637807 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]</pre>
<p>This instruction is trying to copy 8 bytes at the address pointed by EDI.<br />
EDI has the value of <strong>0xe1285050</strong> at execution time.</p>
<p>And what do we have at this memory location ?</p>
<div id="attachment_1333" style="width: 727px" class="wp-caption aligncenter"><a href="/wp-content/uploads/2012/07/WinXP-ReversingBox-3.png" rel="lightbox[1317]"><img class=" wp-image-1333 " title="EDI pointing to invalid memory section" src="/wp-content/uploads/2012/07/WinXP-ReversingBox-3-1024x671.png" alt="" width="717" height="470" srcset="/wp-content/uploads/2012/07/WinXP-ReversingBox-3-1024x671.png 1024w, /wp-content/uploads/2012/07/WinXP-ReversingBox-3-300x196.png 300w, /wp-content/uploads/2012/07/WinXP-ReversingBox-3.png 1394w" sizes="(max-width: 717px) 100vw, 717px" /></a><p class="wp-caption-text">EDI pointing to invalid memory section</p></div>
<p>Nothing indeed. Note that this corruption persists at every boot.</p>
<p>So what can we conclude?<br />
We can certainly exclude hardware failure, because it is a virtual machine and because the corruption always occur at the same memory region, even after a reboot.<br />
At least, I can now be sure that something in the kernel is definitely corrupted.</p>
<p>Could it be a rootkit trick? Still the question remains, but to me it now looks very, very suspicious. Some rootkit code, poorly written, could have sat in this non-paged memory area and been paged out, causing the BSOD. I have not much knowledge about it at this time but I am going to search on this. At least, I now have good starting point to look at.</p>
<p>That&#8217;s all for today, folks. I wrote it while I am still working on it, so sorry if it looks rough and incomplete. It is sort of live, thoughts are still in process.</p>
<p>Again, I am looking forward to reading your comments and suggestions. (Hopefully) there will be a part IV!</p>
]]></content:encoded>
			<wfw:commentRss>/2012/07/22/rootkit-in-my-lab-part-iii.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
