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

<channel>
	<title>Abhi&#039;s Weblog &#187; Security</title>
	<atom:link href="http://abhinavsingh.com/blog/tag/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://abhinavsingh.com/blog</link>
	<description>PHP, Memcached, XMPP and Web Development</description>
	<lastBuildDate>Mon, 27 Feb 2012 09:12:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to add content verification using hmac in PHP</title>
		<link>http://abhinavsingh.com/blog/2009/12/how-to-add-content-verification-using-hmac-in-php/</link>
		<comments>http://abhinavsingh.com/blog/2009/12/how-to-add-content-verification-using-hmac-in-php/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 13:53:46 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[hmac]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=538</guid>
		<description><![CDATA[Many times a requirement arises where we are supposed to expose an API for intended users, who can use these API endpoints to GET/POST data on our servers. But how do we verify that only the intended users are using these API&#8217;s and not any hacker or attacker. In this blog post, I will show [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F12%2Fhow-to-add-content-verification-using-hmac-in-php%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F12%2Fhow-to-add-content-verification-using-hmac-in-php%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=hmac,PHP,Security&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Many times a requirement arises where we are supposed to expose an API for intended users, who can use these API endpoints to GET/POST data on our servers. But how do we verify that only the intended users are using these API&#8217;s and not any hacker or attacker. In this blog post, I will show you the most elegant way of adding content verification using <a href="http://php.net/manual/en/function.hash-hmac.php">hash_hmac</a> (Hash-based Message Authentication Code) in PHP. This will allow us to restrict possible misuse of our API by simply issuing an API key for intended users.</p>
<p>Here are the steps for adding content verification using hmac in PHP:</p>
<ul>
<li>Issue <code>$private_key</code> and <code>$public_key</code> for users allowed to post data using our API. You can use the method similar to one <a href="http://abhinavsingh.com/blog/2009/08/how-to-generate-random-password-like-wordpress-using-php/">described here</a> for generating public and private keys.</li>
<li>Users having these keys can now use following sample script (<code>hmac-sender.php</code>) to submit data:
<pre class="php" name="code">        // User Public/Private Keys
        $private_key = 'private_key_user_id_9999';
        $public_key = 'public_key_user_id_9999';

        // Data to be submitted
        $data = 'This is a HMAC verification demonstration';

        // Generate content verification signature
        $sig = base64_encode(hash_hmac('sha1', $data, $private_key, TRUE));

        // Prepare json data to be submitted
        $json_data = json_encode(array('data'=>$data, 'sig'=>$sig, 'pubKey'=>$public_key));

        // Finally submit to api end point
        submit_to_api_end_point("http://yoursite.com/hmac-receiver.php?data=".urlencode($json_data));</pre>
</li>
<li>At <code>hmac-receiver.php</code>, we validate the incoming data in following fashion:
<pre class="php" name="code">        function get_private_key_for_public_key($public_key) {
                // extract private key from database or cache store
                return 'private_key_user_id_9999';
        }

        // Data submitted
        $data = $_GET['data'];
        $data = json_decode(stripslashes($data), TRUE);

        // User hit the end point API with $data, $signature and $public_key
        $message = $data['data'];
        $received_signature = $data['sig'];
        $private_key = get_private_key_for_public_key($data['pubKey']);
        $computed_signature = base64_encode(hash_hmac('sha1', $message, $private_key, TRUE));

        if($computed_signature == $received_signature) {
                echo "Content Signature Verified";
        }
        else {
                echo "Invalid Content Verification Signature";
        }
</pre>
</li>
</ul>
<p><strong style="font-size:18px;"><u>Where to use such verification?</u></strong><br />
This is an age old method for content verification which is used widely in a variety of applications. Below are a few places where hmac verification finds a place:</p>
<ul>
<li>If you have exposed an API for your vendors to submit requested data</li>
<li>If you are looking to enable third party applications in your website. Similar to developer application model of facebook.</li>
</ul>
<p>Hope you liked the post. Do leave your comments.<br />
Enjoy!</p>
<div id="paidTxtLinkAds">The <a href="http://www.testking.org/N10-004.htm">testking N10-004</a> tutorials and <a href="http://www.testking.org/640-822.htm">testking 640-822</a> demos will help you to learn php to develop dynamic web pages. With our <a href="http://www.testking.org/642-813.htm">testking 642-813</a> dumps, you find complete information on php functions.</div>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F12%2Fhow-to-add-content-verification-using-hmac-in-php%2F","http:\/\/php.net\/manual\/en\/function.hash-hmac.php","http:\/\/www.testking.org\/N10-004.htm","http:\/\/www.testking.org\/640-822.htm","http:\/\/www.testking.org\/642-813.htm"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzEyL2hvdy10by1hZGQtY29udGVudC12ZXJpZmljYXRpb24tdXNpbmctaG1hYy1pbi1waHAvPHdwdGI%2BSG93IHRvIGFkZCBjb250ZW50IHZlcmlmaWNhdGlvbiB1c2luZyBobWFjIGluIFBIUDx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/10/web-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities/" title="Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities">Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities</a> (14)</li><li><a href="http://abhinavsingh.com/blog/2010/08/php-code-setup-and-demo-of-jaxl-boshchat-application/" title="PHP Code, Setup and Demo of Jaxl boshchat application">PHP Code, Setup and Demo of Jaxl boshchat application</a> (80)</li><li><a href="http://abhinavsingh.com/blog/2010/08/releasing-jaxl-2-0-object-oriented-xmpp-framework-in-php/" title="Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP">Releasing Jaxl 2.0 &#8211; Object oriented XMPP framework in PHP</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/04/setting-nginx-php-fastcgi-and-xcache-on-a-new-ubuntu/" title="Setting Nginx, PHP Fastcgi and XCache on a new Ubuntu">Setting Nginx, PHP Fastcgi and XCache on a new Ubuntu</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2010/02/writing-your-first-facebook-chat-bot-in-php-using-jaxl-library/" title="Writing your first facebook chat bot in PHP using Jaxl library">Writing your first facebook chat bot in PHP using Jaxl library</a> (58)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/12/how-to-add-content-verification-using-hmac-in-php/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities</title>
		<link>http://abhinavsingh.com/blog/2009/10/web-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities/</link>
		<comments>http://abhinavsingh.com/blog/2009/10/web-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 19:13:18 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Demo]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Spam]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/?p=532</guid>
		<description><![CDATA[Have your API calls ever being used directly by someone without your permission? If yes, read on to find out how can we protect our API&#8217;s from such spammers and hackers. Before we go ahead and see a possible solution for this, lets try to list out a few cases, when our API&#8217;s can be [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F10%2Fweb-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F10%2Fweb-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=API,Demo,PHP,Security,Spam&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Have your API calls ever being used directly by someone without your permission? If yes, read on to find out how can we protect our API&#8217;s from such spammers and hackers. Before we go ahead and see a possible solution for this, lets try to list out a few cases, when our API&#8217;s can be accessed without our permissions.</p>
<p><strong style="font-size:18px;"><u>Common cases of vulnerable API/Ajax calls</u></strong></p>
<ul>
<li><u>Ajax calls having no user authentication</u>: This is the first place where a spammer will try to find out a loop hole. Take this example, suppose I created a group chat plugin for my blog. Since it&#8217;s a group chat plugin, I don&#8217;t really want the blog viewers to register before they can write a messages. Blog viewer only need to provide their name, email and url (just like wordpress comments). Thereafter, they can write messages which are submitted on the server side using ajax calls. And here is the &#8220;problem&#8221;. Anyone can pick up the ajax url, write a curl script, post the required parameters and fill up my database with millions of messages.</li>
<li><u>Ajax calls having user authentication</u>: One day I realize my group chat plugin has received more than 1 million messages last night (all spams). Hence I decide to make my blog viewers to register before they can post a message on the group chat plugin, simply because someone is filling up my database by simulating ajax calls through a curl script. Anyone can write a script, since these ajax call do not authenticate the user making the call. But are my ajax calls safe after forcing users to register? NO, a registered user too can simulate these ajax calls and passing authentication by sending the right cookies.</li>
</ul>
<p><strong style="font-size:18px;"><u>Possible solutions and their flaws</u></strong><br />
If you look around on web, you will find a bunch of solution to such problems. But then every solution have it&#8217;s own problem which forces you not to use them. Listed below are 2 possible solutions to our problem:</p>
<ul>
<li><u>Using X-Requested-With to protect ajax calls</u>: All famous javascript frameworks like JQuery, YUI, Mootools etc sends an additional header parameter while making an XHR request. These libraries set &#8220;X-Requested-With=XMLHttpRequest&#8221; header, which can then be used on the server side to detect if the call was made through an ajax call. But a programmer can easily pass these headers using a curl script, making the server believe that the call was made through an XHR request.</li>
<li><u>Using HTTP Referrer</u>: This solution comes in handy for cases when a spammer/hacker try to POST data into your site&#8217;s. We can check for the referrer page, before we go ahead and accept the POST data. If the POST data is coming from a page within your site, you go ahead and accept the data, otherwise reject it. But this solution again have it&#8217;s shortcomings. HTTP Referrer can be tampered in certain browsers using javascript and they can also be stripped away by some proxies and firewalls.</li>
</ul>
<p><strong style="font-size:18px"><u>Using crumbs</u></strong><br />
Finally the idea is to have crumbs. A unique electronic key which is shared between server and client, and which have a short life time. But how are these useful? Suppose, in my group chat module, upon page load i generate a crumb whose life time is 30 minutes (tunable). Why 30 minutes? Because, I assume my blog viewers to either engage into the group chat module or leave that specific blog post within 30 minutes.</p>
<p>Now whenever a user writes a message, this crumb is passed back to the server side. If user writes a message before 30 minutes, this crumb will be validated and user shout submitted. (30 minutes should take care of 99.99% of the cases). In response, server api sends back the new crumb which should be sent back with the next ajax call.</p>
<p>Now when a spammer try to simulate the ajax request using curl calls, he will not be able to succeed because of the absence of the crumb. But he can capture the crumb from the site and simulate the effect, right? YES he can, but we can take care of this by reducing the life time of the generated crumb.</p>
<p><strong style="font-size:18px;"><u>Generating crumbs using PHP</u></strong><br />
Here are the two functions, I use to generate and verify crumbs in PHP:</p>
<pre class="php" name="code">        // user for whom crumb is to be generated
        $uid = "mailsforabhinav@gmail.com";

        // usually $salt = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
        $salt = "abcdefghijklmnopqrstuvwxyz";

        function challenge($data) {
                global $salt;
                return hash_hmac('md5', $data, $salt);
        }

        function issue_crumb($ttl, $action = -1) {
                global $uid;

                // ttl
                $i = ceil(time() / $ttl);

                // log
                echo "Generating crumb at time:".time().", i:".$i.", action:".$action.", uid:".$uid.PHP_EOL;

                // return crumb
                return substr(challenge($i . $action . $uid), -12, 10);
        }

        function verify_crumb($ttl, $crumb, $action = -1) {
                global $uid;

                // ttl
                $i = ceil(time() / $ttl);

                // log
                echo "Verifying crumb:".$crumb." at time:".time().", i:".$i.", action:".$action.", uid:".$uid.PHP_EOL;

                // verify crumb
                if(substr(challenge($i . $action . $uid), -12, 10) == $crumb || substr(challenge(($i - 1) . $action . $uid), -12, 10) == $crumb)
                        return true;
                return false;
        }
</pre>
<p>I can generate crumbs with a simple call:</p>
<pre class="php" name="code">$crumb = issue_crumb(300, "group_chat_module");</pre>
<p>where $ttl = 300 (required), $action = &#8220;group_chat_module&#8221; (optional, defaults to -1)</p>
<p>Later on I can verify the crumb using another call:</p>
<pre class="php" name="code">var_dump(verify_crumb(300, $crumb, "group_chat_module"));</pre>
<p>I hope this helps you protecting your API&#8217;s. Let me know of better methods to stop such attacks.<br />
Enjoy!</p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2009%2F10%2Fweb-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities%2F"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA5LzEwL3dlYi1zZWN1cml0eS11c2luZy1jcnVtYnMtdG8tcHJvdGVjdC15b3VyLXBocC1hcGktYWpheC1jYWxsLWZyb20tY3Jvc3Mtc2l0ZS1yZXF1ZXN0LWZvcmdlcnktY3NyZnhzcmYtYW5kLW90aGVyLXZ1bG5lcmFiaWxpdGllcy88d3B0Yj5XZWIgU2VjdXJpdHkgOiBVc2luZyBjcnVtYnMgdG8gcHJvdGVjdCB5b3VyIFBIUCBBUEkgKEFqYXgpIGNhbGwgZnJvbSBDcm9zcy1zaXRlIHJlcXVlc3QgZm9yZ2VyeSAoQ1NSRi9YU1JGKSBhbmQgb3RoZXIgdnVsbmVyYWJpbGl0aWVzPHdwdGI%2BaHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZzx3cHRiPkFiaGkmIzAzOTtzIFdlYmxvZw%3D%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2008/07/photo-cropper-api-how-is-it-achieved/" title="Photo Cropper API: How is it achieved?">Photo Cropper API: How is it achieved?</a> (6)</li><li><a href="http://abhinavsingh.com/blog/2008/06/photo-tagging-api-easy-plugin-for-your-websites-and-blogs/" title="Photo Tagging API : Easy plugin for your websites and blogs">Photo Tagging API : Easy plugin for your websites and blogs</a> (16)</li><li><a href="http://abhinavsingh.com/blog/2008/05/gmail-type-attachment-how-to-make-one/" title="Gmail Type Attachment &#8211; How to make one?">Gmail Type Attachment &#8211; How to make one?</a> (21)</li><li><a href="http://abhinavsingh.com/blog/2010/01/jaxl-bosh-demo-im-chat-client-for-all-wordpress-blogs/" title="JAXL BOSH Demo: IM chat client for all Wordpress blogs">JAXL BOSH Demo: IM chat client for all Wordpress blogs</a> (35)</li><li><a href="http://abhinavsingh.com/blog/2010/01/wordpress-style-duplicate-comment-detected-using-memcached-and-php/" title="Wordpress style &quot;Duplicate comment detected&quot; using Memcached and PHP">Wordpress style &quot;Duplicate comment detected&quot; using Memcached and PHP</a> (9)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2009/10/web-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Warning for Google Chrome Users : Chrome&#039;s &#039;Save As&#039; Flaw Could Give Attackers Control</title>
		<link>http://abhinavsingh.com/blog/2008/09/warning-for-google-chrome-users-chromes-save-as-flaw-could-give-attackers-control/</link>
		<comments>http://abhinavsingh.com/blog/2008/09/warning-for-google-chrome-users-chromes-save-as-flaw-could-give-attackers-control/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 13:09:33 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Tech News]]></category>
		<category><![CDATA[Chrome]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Warning]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/2008/09/warning-for-google-chrome-users-chromes-save-as-flaw-could-give-attackers-control/</guid>
		<description><![CDATA[Bach Khoa Internetwork Security, a security-research firm in Vietnam, claims to be the first to discover a critical vulnerability in Google&#8217;s Chrome browser. &#8220;This is the first critical Chrome vulnerability permitting [a] hacker to perform a remote code-execution attack and take complete control of the affected system,&#8221; the firm wrote in its Sept. 5 advisory. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F09%2Fwarning-for-google-chrome-users-chromes-save-as-flaw-could-give-attackers-control%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F09%2Fwarning-for-google-chrome-users-chromes-save-as-flaw-could-give-attackers-control%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Chrome,Google,Security,Warning&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Bach Khoa Internetwork Security, a security-research firm in Vietnam, claims to be the first to discover a critical vulnerability in Google&#8217;s Chrome browser.</p>
<p>&#8220;This is the first critical Chrome vulnerability permitting [a] hacker to perform a remote code-execution attack and take complete control of the affected system,&#8221; the firm wrote in its Sept. 5 advisory. While four Chrome vulnerabilities were discovered, Bach Khoa said the &#8220;Save As&#8221; flaw is the only one that can allow an attacker to launch remote attacks from a victim&#8217;s PC. Other vulnerabilities just crash the browser.</p>
<p>The vulnerability is caused by a boundary error when handling the &#8220;Save As&#8221; function. When a user saves a malicious page with a title tag in the HTML code, the program causes a&nbsp; stack-based overflow, according to Bach Khoa. A hacker could construct a specially crafted Web page that contains malicious code, trick a user into visiting that Web site, and<br />
convince the user to save the page. That will execute the code and give the attacker privileges to remotely use the infected system.</p>
<p>A Google spokesperson said, &#8220;&#8221;We have released a fix to address this vulnerability. Users will get this fix through an automated update to the browser, so they will not have to take any action to be protected.&#8221;</p>
<p>Well I haven&#8217;t got any fix till now, atleast I didn&#8217;t see my Google Chrome updating atleast.</p>
<p><a href="http://news.yahoo.com/s/nf/20080908/tc_nf/61724" target="_blank">Read more on this news&#8230;.</a></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F09%2Fwarning-for-google-chrome-users-chromes-save-as-flaw-could-give-attackers-control%2F","http:\/\/news.yahoo.com\/s\/nf\/20080908\/tc_nf\/61724"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA4LzA5L3dhcm5pbmctZm9yLWdvb2dsZS1jaHJvbWUtdXNlcnMtY2hyb21lcy1zYXZlLWFzLWZsYXctY291bGQtZ2l2ZS1hdHRhY2tlcnMtY29udHJvbC88d3B0Yj5XYXJuaW5nIGZvciBHb29nbGUgQ2hyb21lIFVzZXJzIDogQ2hyb21lJiMwMzk7cyAmIzAzOTtTYXZlIEFzJiMwMzk7IEZsYXcgQ291bGQgR2l2ZSBBdHRhY2tlcnMgQ29udHJvbDx3cHRiPmh0dHA6Ly9hYmhpbmF2c2luZ2guY29tL2Jsb2c8d3B0Yj5BYmhpJiMwMzk7cyBXZWJsb2c%3D";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2009/12/how-to-add-content-verification-using-hmac-in-php/" title="How to add content verification using hmac in PHP">How to add content verification using hmac in PHP</a> (20)</li><li><a href="http://abhinavsingh.com/blog/2009/10/web-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities/" title="Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities">Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities</a> (14)</li><li><a href="http://abhinavsingh.com/blog/2009/06/seo-analyzer-v-12-adding-support-for-bing-along-with-google-and-yahoo/" title="SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo">SEO Analyzer v 1.2 &#8211; Adding support for Bing along with Google and Yahoo</a> (24)</li><li><a href="http://abhinavsingh.com/blog/2009/04/getting-google-page-rank-using-javascript-for-adobe-air-apps/" title="Getting Google Page Rank using Javascript &#8211; For Adobe AIR Apps">Getting Google Page Rank using Javascript &#8211; For Adobe AIR Apps</a> (2)</li><li><a href="http://abhinavsingh.com/blog/2008/12/how-to-integrate-google-friend-connect-in-pictures/" title="How to integrate Google Friend Connect &#8211; In Pictures">How to integrate Google Friend Connect &#8211; In Pictures</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2008/09/warning-for-google-chrome-users-chromes-save-as-flaw-could-give-attackers-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gain admin access on windows system using your guest account</title>
		<link>http://abhinavsingh.com/blog/2008/07/gain-admin-access-on-windows-system-using-your-guest-account/</link>
		<comments>http://abhinavsingh.com/blog/2008/07/gain-admin-access-on-windows-system-using-your-guest-account/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 19:30:00 +0000</pubDate>
		<dc:creator>Abhinav Singh</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://abhinavsingh.com/blog/2008/07/gain-admin-access-on-windows-system-using-your-guest-account/</guid>
		<description><![CDATA[Hello All, Ever thought of how to get into your friend&#8217;s system and see the access denied files and folders? Or ever wanted to hack into someone&#8217;s admin account? Well here is a method which exploits yet another windows bug. Have you ever noticed that if you press your system&#8217;s SHIFT key &#62;= 5 times [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F07%2Fgain-admin-access-on-windows-system-using-your-guest-account%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F07%2Fgain-admin-access-on-windows-system-using-your-guest-account%2F&amp;source=imoracle&amp;style=normal&amp;service=bit.ly&amp;service_api=R_f027b5a79a20a49b713f16282f1e0857&amp;hashtags=Hack,Security,Windows&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Hello All,</p>
<p>Ever thought of how to get into your friend&#8217;s system and see the access denied files and folders? Or ever wanted to hack into someone&#8217;s admin account? Well here is a method which exploits yet another windows bug.</p>
<ol>
<li>Have you ever noticed that if you press your system&#8217;s<span style="font-weight: bold;"> SHIFT key &gt;= 5</span> times continuously a pop up windows occurs with the name &#8220;Sticky Keys&#8221;? If it doesn&#8217;t pop up on your comp, then may be your shortcut is turned off. For enabling it, goto <span style="font-weight: bold;">Control<br />
Panel -&gt; Accessibility Options</span>. In the accessibility options under the<br />
keyboard tab, in sticky keys , click on settings and enable the<br />
shortcut for sticky keys. And u can do this even with a guest account.</li>
<li>Finally if the following 2 requirements are setup on your system, then you are all set to enter into your admin&#8217;s account.</li>
</ol>
<ul>
<li>On Pressing SHIFT &gt;= 5 times, a pop up should appear.</li>
<li>The windows System32 directory should be writable.</li>
</ul>
<p><span style="font-weight: bold; color: rgb(51, 51, 255); text-decoration: underline;">Concept:<br />
</span>When u press, the SHIFT key &gt;= 5 times, a file with the name <span style="font-weight: bold;">&#8220;sethc.exe&#8221;</span> is<br />
executed.&nbsp; You can verify this in TASK manager (don&#8217;t close the pop up<br />
window). This file is located in C:\WINDOWS\system32 folder, or<br />
where ever your windows is installed.</p>
<p><img src="http://abhinavsingh.com/library/images/XP1.JPG" style="margin: 0px auto 10px; display: block; text-align: center;" title="" alt="" /></p>
<p><b style="color: rgb(51, 51, 255); text-decoration: underline;">The Vulnerability<br />
</b>
<ol>
<li>When SHIFT key is pressed &gt;=5 times, windows executes a file named<br />
&#8220;sethc.exe&#8221; located in system32 folder. It doesn&#8217;t even check if its the<br />
same file. Also it runs with the privilege of the CURRENT USER<br />
which is executing the file i.e if u have logged on as a guest then in<br />
the TASK manager under processes, it shows your user name as guest.</li>
<li>The file executes even if u log off, and have the windows login screen is<br />
showed up, BUT THIS TIME SINCE NO USER HAS LOGGED IN IT RUNS WITH<br />
SYSTEM PRIVILEGE.</li>
</ol>
<p><b style="color: rgb(51, 51, 255); text-decoration: underline;">Exploitation<br />
</b>If u understand this much, then the exploitation is very simple for you. What we will do is that,<br />
we pick cmd.exe , copy it at a folder other than system32, (because windows<br />
won&#8217;t allow u to copy) rename it to sethc.exe, go to system32 folder,<br />
and paste it. Windows will ask, &#8220;that another file exists, do u want to<br />
replace?&#8221; and after pressing OK, you have replaced the sethc.exe with ur own<br />
cmd.exe. Now if u press SHIFT key &gt;=5 times, a command prompt will<br />
pop-up.</p>
<p><img src="http://abhinavsingh.com/library/images/XP2.JPG" style="margin: 0pt auto 10px; display: block; text-align: center;" title="" alt="" /><br />
<img src="http://abhinavsingh.com/library/images/XP3.JPG" style="margin: 0px auto 10px; display: block; text-align: center;" title="" alt="" /></p>
<p><span style="font-weight: bold; color: rgb(51, 51, 255); text-decoration: underline;">Finally</span></p>
<ol>
<li>Now log-off or restart. When you reach the windows<br />
login screen, press the shift key &gt;=5 times. A command prompt will<br />
pop up with SYSTEM privilege.</li>
<li>Enter the normal commands as follows:</li>
<li>net user username /add</li>
<li>net user localgroup administrators username /add</li>
<li>And a new user called username with admin privilege will be added.</li>
</ol>
<p>And thats it, you have admin privilege of the system and you can do what ever you want to with it.</p>
<p><span style="font-weight: bold; color: rgb(51, 51, 255);"><span style="text-decoration: underline;">Hiding your fake admin profile<br />
</span></span><span style="color: rgb(51, 0, 51);">Now you surely don&#8217;t want the real admin to track you. Here is what you will have to do to hide yourself from login screens as well as from control panel<br />
</span>
<ol>
<li>Goto registry editor and open this place.</li>
<li>[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList]</li>
<li>Here create a new DWORD value, write its name as the &#8220;user name&#8221; that u created for your admin account.</li>
</ol>
<p>Thats it now you are invisible but still admin of the system. Live as admin forever and keep screwing the real admin forever.</p>
<p><img src="http://abhinavsingh.com/library/images/XP4.JPG" style="margin: 0pt auto 10px; display: block; text-align: center;" title="" alt="" /><br />
<img src="http://abhinavsingh.com/library/images/XP5.JPG" style="margin: 0pt auto 10px; display: block; text-align: center;" title="" alt="" /><br />
<img src="http://abhinavsingh.com/library/images/XP6.JPG" style="margin: 0pt auto 10px; display: block; text-align: center;" title="" alt="" /></p>
<p><span style="font-weight: bold; text-decoration: underline; color: rgb(51, 51, 255);">Last but not the least (IMPORTANT)<br />
</span>Windows has two type of login screens:</p>
<ol>
<li>Where the accounts are listed with some pictures.</li>
<li>Where u have to write username and password.</li>
</ol>
<p>After making the hidden account u will have to login through the 2nd step only. If ur login screen is of Type 1, press ALT-CTRL-DEL twice to get the 2nd type screen.</p>
<p>Thats it!!!<br />
<br style="color: rgb(255, 0, 0);" /><span style="font-weight: bold; color: rgb(255, 102, 102); text-decoration: underline;"><span style="color: rgb(255, 0, 0);">NOTE:</span><br />
</span>This is a sureshot way to gain admin, if u r a lamer or a newbie<br />
then please do some googling.<br />
I have written almost every detail.</p>
<p>Thanks for reading this far <img src='http://abhinavsingh.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Make a comment if you liked this one.</p>
<p>Thanks for digging and shouting it out to your friends.<br />
<span style="color: rgb(51, 0, 51);"></span><span style="font-weight: bold; color: rgb(51, 51, 255);"></span><br/><br/></p>
<script type="text/javascript">var wordpress_toolbar_urls = ["http:\/\/api.tweetmeme.com\/share?url=http%3A%2F%2Fabhinavsingh.com%2Fblog%2F2008%2F07%2Fgain-admin-access-on-windows-system-using-your-guest-account%2F"];var wordpress_toolbar_url = "http://abhinavsingh.com/blog/wp-content/plugins/wordpress-toolbar/toolbar.php";var wordpress_toolbar_oinw = "oinw";var wordpress_toolbar_hash = "aHR0cDovL2FiaGluYXZzaW5naC5jb20vYmxvZy8yMDA4LzA3L2dhaW4tYWRtaW4tYWNjZXNzLW9uLXdpbmRvd3Mtc3lzdGVtLXVzaW5nLXlvdXItZ3Vlc3QtYWNjb3VudC88d3B0Yj5HYWluIGFkbWluIGFjY2VzcyBvbiB3aW5kb3dzIHN5c3RlbSB1c2luZyB5b3VyIGd1ZXN0IGFjY291bnQ8d3B0Yj5odHRwOi8vYWJoaW5hdnNpbmdoLmNvbS9ibG9nPHdwdGI%2BQWJoaSYjMDM5O3MgV2VibG9n";</script><ul class="related_post"><li><a href="http://abhinavsingh.com/blog/2008/07/windows-text-to-speech-convertor-try-at-home/" title="Windows Text to Speech Convertor: Try at Home">Windows Text to Speech Convertor: Try at Home</a> (19)</li><li><a href="http://abhinavsingh.com/blog/2009/12/how-to-add-content-verification-using-hmac-in-php/" title="How to add content verification using hmac in PHP">How to add content verification using hmac in PHP</a> (20)</li><li><a href="http://abhinavsingh.com/blog/2009/10/web-security-using-crumbs-to-protect-your-php-api-ajax-call-from-cross-site-request-forgery-csrfxsrf-and-other-vulnerabilities/" title="Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities">Web Security : Using crumbs to protect your PHP API (Ajax) call from Cross-site request forgery (CSRF/XSRF) and other vulnerabilities</a> (14)</li><li><a href="http://abhinavsingh.com/blog/2009/01/memcached-and-n-things-you-can-do-with-it/" title="Memcached and &quot;N&quot; things you can do with it &#8211; Part 1">Memcached and &quot;N&quot; things you can do with it &#8211; Part 1</a> (19)</li><li><a href="http://abhinavsingh.com/blog/2008/09/warning-for-google-chrome-users-chromes-save-as-flaw-could-give-attackers-control/" title="Warning for Google Chrome Users : Chrome&#039;s &#039;Save As&#039; Flaw Could Give Attackers Control">Warning for Google Chrome Users : Chrome&#039;s &#039;Save As&#039; Flaw Could Give Attackers Control</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://abhinavsingh.com/blog/2008/07/gain-admin-access-on-windows-system-using-your-guest-account/feed/</wfw:commentRss>
		<slash:comments>117</slash:comments>
		</item>
	</channel>
</rss>

