<?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/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Programming Ideas, Logics, Tips and Tricks &#187; post</title>
	<atom:link href="http://www.sajithmr.me/tag/post/feed" rel="self" type="application/rss+xml" />
	<link>http://www.sajithmr.me</link>
	<description></description>
	<lastBuildDate>Sat, 07 Apr 2012 16:30:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Session/Cookie alone does not secure your web application &#8211; CSRF</title>
		<link>http://www.sajithmr.me/csrf</link>
		<comments>http://www.sajithmr.me/csrf#comments</comments>
		<pubDate>Thu, 12 Nov 2009 19:01:17 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[csrf]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[safety]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[web application]]></category>

		<guid isPermaLink="false">http://www.sajithmr.me/?p=500</guid>
		<description><![CDATA[Guess what will happen if you add an image like below in your html page: &#60;img src=&#8221;http://mail.google.com/mail/?logout&#38;hl=en&#8221;  /&#62; It does not appear in page, but your google account in another window or another tab will get logoff. Now an external website could logout you from your gmail or orkut. IF you coded your website to [...]]]></description>
			<content:encoded><![CDATA[<p>Guess what will happen if you add an image like below in your html page:</p>
<p>&lt;img src=&#8221;http://mail.google.com/mail/?logout&amp;hl=en&#8221;  /&gt;</p>
<p>It does not appear in page, but your google account in another window or another tab will get logoff. Now an external website could logout you from your gmail or orkut.</p>
<p><img class="alignnone size-full wp-image-503" src="http://www.sajithmr.me/wp-content/uploads/2009/11/Gmail-Login-Gets-CSRF-Protection-2.jpg" alt="" width="290" height="245" /></p>
<p>IF you coded your website to delete a photo or object from the website, like this: www.domainname.com/photos/delete?id=221, you may think , since you are checking user authentication at server side, no one else can delete your file. But what if you are logged in one tab and in the second tab, you are loading another website (of hacker or attacker), he can place lots of hidden images with src = www.domainname.com/photos/delete?id=22 ( he can try with ids from 0 to 1000 or 10,000, and anyone of them may be your object)</p>
<p>Here the authentication is okay , because the cookies and session is already set in another tab, and it affects (update or delete) your content.</p>
<p>Those who think , I use POST method , so it is safe. Sorry, you are wrong. A javascript can also simulate a post method, and by using this, an external website can update your form (For example they can run a form submission for changing the email which you registered with and later they can reset password to hack your account)</p>
<p>It won&#8217;t happens if you use captcha. But for all forms it is very hard to use CAPTCHA everywhere. You can solve this attack using additional parameter (some string combination which is generated randomly) along with GET url or POST form submission.</p>
<p>For example, check the url to delete a mail in gmail.</p>
<p><span style="color: #0000ff;">http://mail.google.com/mail/?ui=2&amp;ik=42e598c952&amp;at=xn3j2ufyx273muje67ot1fsxsnbmnl&amp;<br />
view=up&amp;act=tr&amp;rt=j&amp;search=inbox</span></p>
<p>There is some extra string alone with useful information as parameter. So an external application cannot predict the exact url to delete a particular mail, so img with src= url fails here.</p>
<p>Same thing is also needed in POST method. Add one hidden field for random string and check the string before updating into database from Server.</p>
<p>This problem is called <a href="http://en.wikipedia.org/wiki/Cross-site_request_forgery" target="_blank">CSRF</a> &#8211; Cross Site Request Forgery</p>
<p>Thanks<br />
Sajith</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/csrf/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress post via email</title>
		<link>http://www.sajithmr.me/wordpress-post-via-email</link>
		<comments>http://www.sajithmr.me/wordpress-post-via-email#comments</comments>
		<pubDate>Mon, 18 Aug 2008 18:13:28 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[attachement]]></category>
		<category><![CDATA[auto]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[trigger]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.sajithmr.com/wordpress-post-via-email/</guid>
		<description><![CDATA[If you know this feature already , skip this article. But i have to ask a single question at the end of this section . For wordpress version less than 2.3 , Go to Options  &#62;  writing, and  for greater than 2.3, Go to settings &#62; writing What you have to do is create an [...]]]></description>
			<content:encoded><![CDATA[<p>If you know this feature already , skip this article. But i have to ask a single question at the end of this section .</p>
<p>For wordpress version less than 2.3 , Go to <strong>Options</strong>  &gt;  <strong>writing</strong>, and  for greater than 2.3, Go to <strong>settings</strong> &gt; <strong>writing</strong></p>
<p>What you have to do is create an email account with pop3 support</p>
<p>You can see the heading &#8220;Post via e-mail&#8221; there.</p>
<p>Enter your email server (by replacing mail.example.com)</p>
<p>Enter your pop3 port. (110 by default)</p>
<p>Enter your email login and password.</p>
<p>Choose a category to for the email entry posts</p>
<p>Finally Press update option Button</p>
<p>What you have done above is only the settings. For grabbing or pulling the content from email, you need to call/trigger an url.</p>
<p>That url is: http://yourblogdomain/wordpressinstalldir/wp-mail.php<code></code></p>
<p>Either you can call it manually. Or you can set up a cron job for that url by call the url using wget or like functions</p>
<p>Another simple mechanism to call this email trigger is use a hidden iframe in your blog template. (anywhere)</p>
<p>&lt;iframe width=&#8221;0&#8243; height=&#8221;0&#8243;  style=&#8221;display:none&#8221;  src=&#8221;http://yourblogdomain/wordpressinstalldir/wp-mail.php<a href="http://yourblogdomain/wordpressinstalldir/wp-mail.php" class="external free" title="http://yourblogdomain/wordpressinstalldir/wp-mail.php"></a>&#8220;&gt;&lt;/iframe&gt;</p>
<p>The problem with this email posting is , it <strong>strips all the html tags</strong> before entering into wordpress database.</p>
<p>The is <strong>no way</strong> to find the<strong> attachments from an email</strong>.</p>
<p>So I decided to start a <strong>wordpress plugin</strong> which does the above missing properties. If there is any &#8216;working&#8217; plugin available, please let me know, so that  I can avoid the re-inventing of wheel .</p>
<p>Thanks</p>
<p>Sajith M.R</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/wordpress-post-via-email/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>PHP post without curl</title>
		<link>http://www.sajithmr.me/php-post-without-curl</link>
		<comments>http://www.sajithmr.me/php-post-without-curl#comments</comments>
		<pubDate>Fri, 04 Apr 2008 05:07:59 +0000</pubDate>
		<dc:creator>Mr Me</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php source code]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[simulation]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://www.sajithmr.com/php-post-without-curl/</guid>
		<description><![CDATA[You can simulate the post method using php without the help of curl library. download full source code: See the code below:function do_post_request($url, $data, $optional_headers = null) { $params = array('http' =&#38;gt;; array('method' =&#38;gt;; 'POST', 'content' =&#38;gt;; $data )); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); $fp = @fopen($url, 'rb', [...]]]></description>
			<content:encoded><![CDATA[<p>You can simulate the post method using php without the help of curl library.<br />
download full source code:<br />
<a href="http://www.sajithmr.com/downloads/post_without_curl.zip"><img src="http://www.sajithmr.com/wp-content/uploads/2008/04/winzip_180x180.thumbnail.gif" alt="OpenID Integration PHP" width="42" height="42" /></a></p>
<p>See the code below:</p><pre class="crayon-plain-tag"><code>function do_post_request($url, $data, $optional_headers = null) {

$params = array('http' =&amp;gt;; array('method' =&amp;gt;; 'POST',

'content' =&amp;gt;; $data

));

if ($optional_headers !== null) {

$params['http']['header'] = $optional_headers;

}

$ctx = stream_context_create($params);

$fp = @fopen($url, 'rb', false, $ctx);

if (!$fp) {

throw new Exception(&quot;Problem with $url, $php_errormsg&quot;);

}

$response = @stream_get_contents($fp);

if ($response === false) {

throw new Exception(&quot;Problem reading data from $url, $php_errormsg&quot;);

}

return $response;

}

?&amp;gt;</code></pre><p>
Download the full source code from <a href="http://www.sajithmr.com/downloads/post_without_curl.zip" target="_blank">post_without_curl.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sajithmr.me/php-post-without-curl/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

