<?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>Php Development &#187; hacking</title>
	<atom:link href="http://www.maheshchari.com/tag/hacking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maheshchari.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 17 Jan 2012 02:42:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>md5 php</title>
		<link>http://www.maheshchari.com/md5-php/</link>
		<comments>http://www.maheshchari.com/md5-php/#comments</comments>
		<pubDate>Sun, 08 May 2011 06:55:59 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[PHP/mysql]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[password]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=654</guid>
		<description><![CDATA[php salt random password generation with md5 At present we are going to learn password hashing with random php string. Even we state this for PHP ,but this logic can be applied to any programming language. hashing means generating one way encrypting the given string, which is impossible to get the original string from the [...]]]></description>
			<content:encoded><![CDATA[<h1>php  salt random password generation with md5</h1>
<p>At present we are going to learn  password hashing with random php string. Even we state this for PHP ,but this logic can be applied to any programming language. hashing means generating one way encrypting the given string, which is impossible to get the original string from the hash. this helps to prevent the brute force attaks. This hashing can be used not only password hashing ,it can be applied to user sensitive data .main goal for hashing a string is get uniqueness one data for given fixed lenngth string and generating at minimum time and miniumum application resources. </p>
<h2>Why hashing a string or password?</h2>
<p>for example we take the authentication system where we store the user name and password in plain format. when hacker get into our application got access to database, then he can see the user password. in this case not only hacker can see that passwords,but also other webmasters, coder,designer ..etc can also see the password.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$username</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO tbl_user (username,password) VALUES ('<span style="color: #006699; font-weight: bold;">$username</span>','<span style="color: #006699; font-weight: bold;">$password</span>')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/** sample tbl_user data
*username , password
*mahesh,mypassword1
*chari,password2
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>So we must encrypt the password by using php famouse algorithms like <strong>md5</strong>,<strong>sha1</strong>..etc. for example. </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000088;">$username</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span><span style="color: #339933;">=</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO tbl_user (username,password) VALUES ('<span style="color: #006699; font-weight: bold;">$username</span>','<span style="color: #006699; font-weight: bold;">$password</span>')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/** sample tbl_user data
*username , password
*mahesh,0d28e4080dc8f64fc9603639bb7aa1b9
*chari,6cb75f652a9b52798eb6cf2201057c73
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>With this method hacker who may access database  can not gues the password, but he can know that password with brute force algorithms. This algorithm guess the key with all available alphabet combinations. like a,b,c,&#8230;..aa,ab,ac&#8230;aaa..aab&#8230;etc. So this is also use less or weak implementation of authentication. </p>
<p>Now we add a application secrete that can be called plain hash to user password and do the encrypt, now brute force attack takes much time compared to previous one, it is some what strong compared to other. but if the hacker get to know this secret it is make easy again. </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HASH'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mysecretehash'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span><span style="color: #339933;">=</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">HASH</span><span style="color: #339933;">.</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO tbl_user (username,password) VALUES ('<span style="color: #006699; font-weight: bold;">$username</span>','<span style="color: #006699; font-weight: bold;">$password</span>')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/** sample tbl_user data
*username , password
*mahesh,4e71c452f4aa24c19bf807a957986fc8
*chari,c645f52b2d8fcfc25e78ed73fc030bd3
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Since this plain salt is also weak, we generate a strong one that contains special symbols,numbers,capital letter,small letters and more lengthy and keep in mind that it wont take much time to encrypt and application resources. </p>
<p>Now we use salt with md5 ,then it get more strong.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HASH'</span><span style="color: #339933;">,</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysecretehash'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span><span style="color: #339933;">=</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">HASH</span><span style="color: #339933;">.</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO tbl_user (username,password) VALUES ('<span style="color: #006699; font-weight: bold;">$username</span>','<span style="color: #006699; font-weight: bold;">$password</span>')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/** sample tbl_user data
*username , password
*mahesh,4e71c452f4aa24c19bf807a957986fc8
*chari,c645f52b2d8fcfc25e78ed73fc030bd3
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Now even though above password is so strong but there is still a chance to know if attacker waits for a long time. </p>
<p>Now we use more customized salt generation for individual user liek , we combine user name also into salt. </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HASH'</span><span style="color: #339933;">,</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysecretehash'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span><span style="color: #339933;">=</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #990000;">HASH</span><span style="color: #339933;">.</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO tbl_user (username,password) VALUES ('<span style="color: #006699; font-weight: bold;">$username</span>','<span style="color: #006699; font-weight: bold;">$password</span>')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/** sample tbl_user data
*username , password
*mahesh,4e71c452f4aa24c19bf807a957986fc8
*chari,c645f52b2d8fcfc25e78ed73fc030bd3
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Now it is 98% is stronger than previous ones. remaining is there chance if attaker wait long time. </p>
<p>now we use individaul random salt that is totally unique for each user, so it become more powerfull and strong. now we deal with real solution with customized solution for each individual salt . </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #666666; font-style: italic;">//generate unique random string with given length</span>
<span style="color: #000000; font-weight: bold;">function</span> salt<span style="color: #009900;">&#40;</span><span style="color: #000088;">$length</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #990000;">srand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>double<span style="color: #009900;">&#41;</span><span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1000000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$randsymbols</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;!@#$%^&amp;*()_+=-';:,&lt;.&gt;`~?[]{}&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$randchar</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&quot;</span><span style="color: #339933;">;</span> 
		<span style="color: #000088;">$salt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$length</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$str</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$length</span><span style="color: #339933;">%</span><span style="color:#800080;">3</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span> ? <span style="color: #000088;">$randsymbols</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$randchar</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$salt</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$str</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color:#800080;">.04</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$length</span><span style="color: #339933;">--;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #990000;">shuffle</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$salt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">mt_srand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
		<span style="color: #b1b100;">return</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$salt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">//hash the string with favorite encrypt algorithm, here i used md5, you can consider sha1 or else	</span>
<span style="color: #000000; font-weight: bold;">function</span> password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #339933;">,</span> <span style="color: #000088;">$salt</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$salt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Now we have two functions one do gives unique string ,other do hashing the password. now we add one column to our <strong>tbl_user</strong> , called <strong>customsalt</strong> as varchar(45) , now we add the user to as below</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HASH'</span><span style="color: #339933;">,</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysecretehash'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$customsalt</span><span style="color: #339933;">=</span>salt<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span><span style="color: #339933;">=</span>password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #990000;">HASH</span><span style="color: #339933;">.</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$customsalt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$result</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;INSERT INTO tbl_user (username,password,customsalt) VALUES ('<span style="color: #006699; font-weight: bold;">$username</span>','<span style="color: #006699; font-weight: bold;">$password</span>','<span style="color: #006699; font-weight: bold;">$customsalt</span>')&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span>
<span style="color: #009933; font-style: italic;">/** sample tbl_user data
*username , password,customsalt
*mahesh,4e71c452f4aa24c19bf807a957986fc8,c645f52b2d8fcfc25e78ed73fc030bd3
*chari,c645f52b2d8fcfc25e78ed73fc030bd3,4e71c452f4aa24c19bf807a957986fc8
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</p>
<p>Okay , now we consider fetching the user data and validating the user given user name and password for log in functionality. </p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HASH'</span><span style="color: #339933;">,</span><span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysecretehash'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$username</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$password</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span><span style="color: #339933;">=</span><span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM tbl_user WHERE username='<span style="color: #006699; font-weight: bold;">$username</span>'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$hashed</span><span style="color: #339933;">=</span>password<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #990000;">HASH</span><span style="color: #339933;">.</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">customsalt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$hashed</span><span style="color: #339933;">!==</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Invalid password.'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Remember you must put your <strong>hash</strong> constant in non <strong>public directory </strong>and put that file into running script. </p>
<p>This is my idea only  where i implemented on my projects , each developer has own methods as per their application level security level. </p>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=654&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/md5-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>real ip address</title>
		<link>http://www.maheshchari.com/real-ip-address/</link>
		<comments>http://www.maheshchari.com/real-ip-address/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 13:02:18 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[PHP/mysql]]></category>
		<category><![CDATA[anti spam]]></category>
		<category><![CDATA[hacking]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=226</guid>
		<description><![CDATA[A simple function to find the real IP address of the client with php As the internet growing as long as spamming,hacking,fishing,bots also increasing,there by normal user can easly decepted by with them. in many security application we need to find the real ip address to ban or record the ip related activities.here we use [...]]]></description>
			<content:encoded><![CDATA[<h1>A simple function to find the real IP address of the client with php</h1>
<p>As  the internet growing as long as spamming,hacking,fishing,bots also increasing,there by normal user can easly decepted by with them. in many security application we need to find the real <strong>ip address</strong> to ban or record the ip related activities.here we use small function that returns and modify the PHP global r<strong>emote address </strong>variable.</p>
<p>Usually we&#8217;ll use $_SERVER['REMOTE_ADDR'] to get clients IP address. But this doesn&#8217;t return the real IP address all time. Basically when someone using PROXY that valiable returns proxy IP the client using. So here&#8217;s a function you can use to detect real ip address of client. Here are extra Server variable which might be available to determine the exact IP address of the client’s machine in PHP, they are HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> real_ip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_FORWARDED_FOR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_REAL_IP'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'HTTP_X_REAL_IP'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=226&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/real-ip-address/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>hack password</title>
		<link>http://www.maheshchari.com/hack-password/</link>
		<comments>http://www.maheshchari.com/hack-password/#comments</comments>
		<pubDate>Wed, 27 May 2009 11:38:41 +0000</pubDate>
		<dc:creator>mahesh chari</dc:creator>
				<category><![CDATA[Html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[hacking]]></category>

		<guid isPermaLink="false">http://www.maheshchari.com/?p=128</guid>
		<description><![CDATA[how to hack stored passwords in web browser for websites. &#160; Yes ,you can hack any stored password in any browser ,any web site with in five seconds.Even you don&#8217;t know any basic programming language.but it works for only stored passwords in browser only. hack stored password for Orkut ,Gmail and Google Account Open the [...]]]></description>
			<content:encoded><![CDATA[<h1>how to hack stored passwords in web browser for websites.</h1>
<p>&nbsp;</p>
<p>Yes ,you can <strong>hack</strong> any stored <strong>password</strong> in any browser ,any web site with in five seconds.Even you don&#8217;t know any<strong> basic programming language</strong>.but it works for only stored <strong>passwords</strong> in browser only. </p>
<p>  <a href="http://www.maheshchari.com/wp-content/uploads/2009/05/orkut.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2009/05/orkut.jpg" alt="Gmail ,Orkut Account before hack" title="Gmail ,Orkut Account before hack" width="150" height="144" class="alignleft size-full wp-image-129" /></a><a href="http://www.maheshchari.com/wp-content/uploads/2009/05/orkut-hacked-password.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2009/05/orkut-hacked-password.jpg" alt="Orkut,Gmail forma after hack" title="Orkut,Gmail forma after hack" width="150" height="144" class="alignleft size-full wp-image-130" /></a></p>
<h3>hack stored password for Orkut ,Gmail and Google Account </h3>
<p>Open the login page of the orkut that stored ,then paste the below code in URL bar or Address bar,simple you can see the password</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Passwd'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">type</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'text'</span><span style="color: #339933;">;</span>void<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>hack stored password for Yahoo mail</h3>
<p><a href="http://www.maheshchari.com/wp-content/uploads/2009/05/yahoo.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2009/05/yahoo.jpg" alt="yahoo mail hack" title="yahoo mail hack" width="150" height="144" class="alignnone size-full wp-image-132" /></a><a href="http://www.maheshchari.com/wp-content/uploads/2009/05/yahoo-password-hack.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2009/05/yahoo-password-hack.jpg" alt="yahoo mail password hack" title="yahoo mail password hack" width="150" height="144" class="alignleft size-full wp-image-133" /></a></p>
<p>Open the login page of the yahoo  that stored ,then paste the below code in URL bar or Address bar,simple you can see the password
</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span>document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'passwd'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">type</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'text'</span><span style="color: #339933;">;</span>void<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>hack any web site password</h3>
<p>Yes ,again it is true you can hack any sites password,simple follow the below steps.<br />
  1.open login page of any web site that stored .<br />
  <div id="attachment_135" class="wp-caption alignleft" style="width: 160px"><a href="http://www.maheshchari.com/wp-content/uploads/2009/05/password-hack.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2009/05/password-hack-150x49.jpg" alt="open login page of any site that stored" title="password-hack" width="150" height="49" class="size-thumbnail wp-image-135" /></a><p class="wp-caption-text">open login page of any site that stored</p></div></p>
<p>2.Open context menu by right clicking on the page,then select <strong>view source</strong> from that you can see a new window that has code,search for<br />
  a word <strong>type=&#8221;password&#8221;</strong> ,beside you can find <strong>id</strong> also <a href="http://www.maheshchari.com/wp-content/uploads/2009/05/password-hack-source-code.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2009/05/password-hack-source-code-300x13.jpg" alt="password-hack-source-code" title="password-hack-source-code" width="300" height="13" class="alignleft size-medium wp-image-136" /></a><br />
  <br/><br />
  then replace with password with that id<br />
paste it in address bar of the browser,then press enter or return key on your key board. <a href="http://www.maheshchari.com/wp-content/uploads/2009/05/browser-password-hack.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2009/05/browser-password-hack-300x17.jpg" alt="browser-password-hack" title="browser-password-hack" width="300" height="17" class="alignleft size-medium wp-image-137" /></a> </p>
<p>3.Its done you can see hidden password <a href="http://www.maheshchari.com/wp-content/uploads/2009/05/password-hacked-any-site.jpg"><img src="http://www.maheshchari.com/wp-content/uploads/2009/05/password-hacked-any-site-300x23.jpg" alt="password-hacked-any-site" title="password-hacked-any-site" width="300" height="23" class="alignleft size-medium wp-image-138" /></a><br />
  <br/>
</p>
<h3>Please note this article is informative purpose only.!!!</h3>
<h3>So don&#8217;t store your passwords on any public computer.</h3>
<img src="http://www.maheshchari.com/?ak_action=api_record_view&id=128&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.maheshchari.com/hack-password/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

