<?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>The #Shell &#187; MacOSX</title>
	<atom:link href="http://blog.rootshell.ir/tag/macosx/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rootshell.ir</link>
	<description>Hey, It&#039;s root, Take care</description>
	<lastBuildDate>Sun, 25 Dec 2011 07:20:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Get Your Interactive Reverse Shell on a Webhost</title>
		<link>http://blog.rootshell.ir/2010/08/get-your-interactive-reverse-shell-on-a-webhost/</link>
		<comments>http://blog.rootshell.ir/2010/08/get-your-interactive-reverse-shell-on-a-webhost/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 20:40:05 +0000</pubDate>
		<dc:creator>root</dc:creator>
				<category><![CDATA[Believe Me]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[RootShell]]></category>

		<guid isPermaLink="false">http://blog.rootshell.ir/?p=209</guid>
		<description><![CDATA[Sometimes you purchase a web host and the only thing you have to control it, is an ftp account. For those familiar with unix-like shells, it would be really cool to have an SSH session on your account, but most of web hosts don&#8217;t allow this option. It makes the life much easier for maintaining [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you purchase a web host and the only thing you have to control it, is an ftp account. For those familiar with unix-like shells, it would be really cool to have an SSH session on your account, but most of web hosts don&#8217;t allow this option. It makes the life much easier for maintaining the files and permissions.</p>
<p>First step is to investigate whether your php service bans the functions to execute a process or not. I&#8217;m talking about the exec and system and popen function series. You may write your own test or install a php script called &#8220;PHP Shell&#8221;. PHP Shell receives the shell commands through the web browser and executes them and finally delivers the output right at the browser window. There are lots of php shells out there. I used <a href="http://mgeisler.net/php-shell/">this one</a> developed by Martin Geisler. Download one of them and upload it using your ftp account.</p>
<p>For simple operations, you can get an interactive shell using <a href="http://sourceforge.net/projects/netcat/">GNU netcat</a> (Note the GNU word, there are lots of other versions and most of them do not support executing commands). If you run the following command on your machine, it would create a simple tcp listener on an specific port :</p>
<p><strong><span style="font-size: x-small;"><span style="font-family: courier new,courier;">netcat -l -p 8999 -v</span></span></strong></p>
<p>As you see, we have provided the verbose option to get notified when some one connects to your listener. Then by running the following line, we can the simply connect from the phpshell to our local listener and receive a shell :</p>
<p><strong><span style="font-family: courier new,courier;"><span style="font-size: x-small;">netcat my.pc.ip.address 8999 -e &#8220;/bin/bash -i&#8221;</span></span></strong></p>
<p>The above netcat command will connect to your pc at home and execute an interactive bash shell. At this stage you have a command and see the resulting shell (i call it semi interactive). Soon you&#8217;ll notice that special terminal commands such as Ctrl+D, Ctrl+C and arrow keys don&#8217;t work as expected.</p>
<p>We&#8217;ll use <a href="http://www.dest-unreach.org/socat/">socat</a> to overcome this problem. socat can connect almost every two streams you find in the world. From files to sockets, Terminals to udp connections, process output to tcp connection and it supports SSL connections too. But it is not installed on most distributions by default. So the first step is to get the source and compile it. We need it both on our local pc and on the web server. Well, the pc part is easy, but for the web server side you should first find out that whether the build tools (compiler, make, etc) are installed on the web server or not. Test it simply by running g++ and make in your php shell. If yes, you&#8217;re all set and follow these steps to get it running :</p>
<ol>
<li>run <strong>wget http://www.dest-unreach.org/socat/download/socat-1.7.1.3.tar.gz</strong></li>
<li>extract the file using <strong>tar -xf socat-1.7.1.3.tar.gz</strong></li>
<li><strong>cd socat-1.7.13</strong></li>
<li><strong>./configure</strong></li>
<li><strong>make</strong></li>
</ol>
<p>if everything went smoothly and fine, you would have the socat binary right under the socat-1.7.13 folder. Note that if your web host doesn&#8217;t have the build tools installed, you should compile the package locally and upload the binary file. The final part is to setup the listener, this time using socat and connect to it from the webhost, run the following command to get the listener :</p>
<p><span style="font-family: courier new,courier;"><span style="font-size: x-small;"><strong>socat file:`tty`,raw,echo=0 tcp-listen:8999</strong><br />
</span></span></p>
<p>and run this one from the php-shell to get the terminal.</p>
<p><strong><span style="font-size: x-small;"><span style="font-family: courier new,courier;">./socat tcp-connect:my.pc.ip.address:80 exec:&#8217;bash -li&#8217;,pty,stderr,setsid,sigint,sane</span></span></strong></p>
<p>The first socat command, connected a tcp socket (which is yet listening) to your current TTY and second one, connects the bash process to your tcp listener. Now, you have a fully functional TTY Terminal connected to your account in the web-host. Almost all terminal commands work and you can run vim, nano, screen and Midnight commander  <img src='http://blog.rootshell.ir/wp-includes/images/smilies/icon_cool.gif' alt='8-)' class='wp-smiley' /> . There are few differences between an SSH session and this reverse shell. The most  important ones are :</p>
<ol>
<li>Your session is not encrypted, you may use SSL capabilities of socat</li>
<li>SSH automatically forwards some of useful shell variables, you may set them your self or put them in the .bash_profile or .bash_rc of the web hosting account, such as<br />
<span style="font-family: courier new,courier;">export TERM=&#8221;xterm-color&#8221;</span></li>
</ol>
<ul>
<li>For simplicity purposes, you may put the second socat command line in a new php script to avoid using php shell each time. Note that you should either secure your php shell or delete it when everything finished to avoid others, access your account.</li>
<li>Some web servers run using a different user id than your current account. It would cause that you don&#8217;t have permission to create and edit files using the php shell. In such situations, creating a world wide writable directory (Enable All Permissions for All) would do the job.</li>
</ul>
<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.rootshell.ir%2F2010%2F08%2Fget-your-interactive-reverse-shell-on-a-webhost%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.rootshell.ir/2010/08/get-your-interactive-reverse-shell-on-a-webhost/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.rootshell.ir/2010/08/get-your-interactive-reverse-shell-on-a-webhost/"  data-text="Get Your Interactive Reverse Shell on a Webhost" data-count="horizontal" data-via="nadalizadeh">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://blog.rootshell.ir/2010/08/get-your-interactive-reverse-shell-on-a-webhost/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Experimental Write Support for Ext2 on Mac</title>
		<link>http://blog.rootshell.ir/2010/05/experimental-write-support-for-ext2-ext3-ext4-filesystems-on-mac/</link>
		<comments>http://blog.rootshell.ir/2010/05/experimental-write-support-for-ext2-ext3-ext4-filesystems-on-mac/#comments</comments>
		<pubDate>Sun, 23 May 2010 18:31:24 +0000</pubDate>
		<dc:creator>root</dc:creator>
				<category><![CDATA[Believe Me]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://blog.rootshell.ir/?p=188</guid>
		<description><![CDATA[Userspace Filesystem Drivers are becoming more and more popular since they&#8217;re portable and have less headache of platform specific filesystem driver issues. For example, NTFS-3G project provides the full read/write support for NTFS under Linux and MacOSX while living in userspace. I recently discovered an open source project called &#8220;fuse-ext2&#8221; which is an implementation of [...]]]></description>
			<content:encoded><![CDATA[<p>Userspace Filesystem Drivers are becoming more and more popular since  they&#8217;re portable and have less headache of platform specific filesystem  driver issues. For example, NTFS-3G project provides the full read/write support for NTFS under Linux and MacOSX while living in userspace.</p>
<p>I recently discovered an open source project called &#8220;<a href="http://sourceforge.net/projects/fuse-ext2/">fuse-ext2</a>&#8221; which is an implementation of Ext2/Ext3/Ext4 filesystem driver in userspace. Before this one, there was an ext2-only native kernel extension (kext) implementation. So I had no write access to my Ext3 and no read access to Ext4 file-system at all.</p>
<p>To use and enable experimental write support for your Ext2 partition, follow these steps :</p>
<ol>
<li>Download and install <strong>NTFS-3G</strong> Package which includes <strong>FUSE libraries</strong>.<br />
AFAIK NTFS-3G has been renamed into Tuxera NTFS and is a shareware now. But any way you can download the old GPL version <a href="http://www.rootshell.ir/downloads/MacOSX/NTFS-3G_2009.4.4-catacombae.dmg">here</a>. it works in both Leopard and Snow Leopard.<br />
<span style="color: #ffcc00;">.</span></li>
<li>Download<a href="http://sourceforge.net/projects/fuse-ext2/"> fuse-ext2 </a>package<br />
<span style="color: #ffcc00;">.</span></li>
<li>Use <strong>Disk Utility</strong> to un-mount current Ext2 filesystems if there are any<br />
<span style="color: #ffcc00;">.</span></li>
<li>Remove any old filesystem drivers for ext2 from <strong>/System/Library/FileSystems</strong> (it was ext2.fs for me)<br />
<span style="color: #ffcc00;">.</span></li>
<li>Install fuse-ext2 package<br />
<span style="color: #ffcc00;">.</span></li>
<li>Since write support is experimental, it is not enabled by default. To enable it, open <strong>/System/Library/Filesystems/fuse-ext2.fs/fuse-ext2.util</strong> for edit while having super user privileges.<br />
<span style="color: #ffcc00;">.</span></li>
<li>Edit the OPTIONS variable at line 207 from<br />
<code>OPTIONS="auto_xattr,defer_permissions"</code><br />
to<br />
<code>OPTIONS="auto_xattr,defer_permissions,rw+"</code><br />
<span style="color: #ffcc00;">.</span></li>
<li>Open Disk Utility and choose Mount for your filesystem and have fun !</li>
</ol>
<div class="bottomcontainerBox" style="">
			<div style="float:left; width:85px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.rootshell.ir%2F2010%2F05%2Fexperimental-write-support-for-ext2-ext3-ext4-filesystems-on-mac%2F&amp;layout=button_count&amp;show_faces=false&amp;width=85&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width=85px; height:21px;" allowTransparency="true"></iframe></div>
			<div style="float:left; width:80px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<g:plusone size="medium" href="http://blog.rootshell.ir/2010/05/experimental-write-support-for-ext2-ext3-ext4-filesystems-on-mac/"></g:plusone>
			</div>
			<div style="float:left; width:95px;padding-right:10px; margin:4px 4px 4px 4px;height:30px;">
			<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://blog.rootshell.ir/2010/05/experimental-write-support-for-ext2-ext3-ext4-filesystems-on-mac/"  data-text="Experimental Write Support for Ext2 on Mac" data-count="horizontal" data-via="nadalizadeh">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div>]]></content:encoded>
			<wfw:commentRss>http://blog.rootshell.ir/2010/05/experimental-write-support-for-ext2-ext3-ext4-filesystems-on-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

