Visit Our New Site

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Showing posts with label Learn Ethcial Hacking. Show all posts
Showing posts with label Learn Ethcial Hacking. Show all posts

Thursday, 28 July 2011

Avoiding SQL Injection Detailed Learn Ethical Hacking

Avoiding SQL Injection

 
SQL injections are among the flaws the most widespread and dangerous in PHP.
This tutorial will explain clearly the concept of SQL Injection and how to avoid 
them once and for all.

--------------------------------------------------------------------

>>>>>>
Summary of tutorial:
I) Presentation of the problem.
=> The variables containing strings
II)Security .
=> Explanation
=> Numeric variables
.Method 1
.Method 2
>>>>>>

--------------------------------------------------------------------


I) Presentation of the problem.
___________________________

There are two types of SQL injection:

* Injection into the variables that contain strings;
* Injection into numeric variables.

These are two very different types and to avoid them, it will act
differently for each of these types.

######################
The variables containing strings:
######################

Imagine a PHP script that fetches the age of a member according to its
nickname. This nickname has gone from one page to another via the URL
(by $ _GET what: p). This script should look like this:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...
$pseudo = $_GET['pseudo'];
$requete = mysql_query("SELECT age FROM membres WHERE pseudo='$pseudo'");
...
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Well keep you well, this script is a big SQL injection vulnerability.
Suffice it to a bad boy putting in place the username in the URL a query
like this:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' UNION SELECT password FROM membres WHERE id=1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
It is to arrive to show (just an example), for example the password for
the member with the id 1. I will not explain in detail the operation for
fear that someone is not nice to walk around. Well, so let us go to the
security:).

II) Security .
_______________

To secure this type of injection is simple. You use the function
mysql_real_escape_string ().

######################
Uh ... It does what it?
######################

This feature adds the "\" character to the following characters:

+++++++++++++++++++++++++++++++++++++++++++++++++
NULL, \ x00, \ n, \ r, \, ', "and \ X1A
++++++++++++++++++++++++++++++++++++++++++++++++++++
######################
And what's the point?
######################

As you have noticed in previous injection, the attacker uses the quote
(to close the 'around $ nick): if she is prevented from doing that, the
bad boy will only have to look elsewhere . This means that if one
applies a mysql_real_escape_string () to the variable name like this ...

+++++++++++++++++++++++++++++++++++++++++++++++++++++...
$pseudo = mysql_real_escape_string($_GET['pseudo']);
$requete = mysql_query("SELECT age FROM membres WHERE pseudo='$pseudo'");
...
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The application is completely secure.
Explanation

######################
Injection hacker to recall:
######################

+++++++++++++++++++++++++++++++++++++++++++++++++++
' UNION SELECT password FROM membres WHERE id=1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Well if we apply mysql_real_escape_string () to the variable $ name used
in the query is what will the injection:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
\' UNION SELECT password FROM membres WHERE id=1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This means that we do not even come out of assessments around $ nick in
the request because the \ has been added. There is another function
somewhat similar to mysql_real_escape_string () is addslashes (), why
not have used? Well recently, a security hole was discovered on this if
it is used on a PHP 4.3.9 installation with magic_quotes_gpc enabled.

######################
Numeric variables:
######################

This type of injection is less known than the previous one, making it
more frequent, and it starts as just now with an example. This time, it
displays the age of a member according to its id, and by passing it by a
form ($ _POST) to change:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++...
$id = $_POST['id'];
$requete = mysql_query("SELECT age FROM membres WHERE id=$id");
...
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
mysql_real_escape_string () would be nothing here, since if an attacker
wants to inject SQL code, it will not need to use quotes, because the
variable $ id is not surrounded by quotes. Simple example of
exploitation:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 UNION SELECT password FROM membres WHERE id=1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This injection did exactly the same as the previous one, except that
here, to avoid it, there are two solutions:

* Change the contents of the variable so it contains only numbers;
* Check if the variable actually contains a number before using it in a query.

##########
Method 1:
##########

We'll use a function , intval () This function returns regardless of the
contents of a variable its numerical value. For example:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$variable = '1e10';  // $variable vaut '1e10'
$valeur_numerique = intval($variable); // $valeur_numerique vaut 1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Now back to our sheep:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$id = intval($_POST['id']);
$requete = mysql_query("SELECT age FROM membres WHERE id=$id");
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
That is: you can stop there and is more than enough, but I recommend you
continue to find another method, or you have air beast if you find this
method on a code that is not yours without understand it.

############
Méthode 2:
###########

Here we use a function that returns TRUE when a variable contains only
numbers and FALSE if it is not the case this function is is_numeric (),
we will use it in a condition that checks whether is_numeric ( ) returns
TRUE well.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
$id = $_POST['id'];
if (is_numeric($id))
{
$requete = mysql_query("SELECT age FROM membres WHERE id=$id");
}
else
{
echo "Trying to hack me ? Your ip is recorded Ksecurity-Team";
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
##################################################################
What is the best, depending intval () and is_numeric ()?
##################################################################

Well I will say that they are both equally effective, they are equal.
But I prefer inval () since with is_numeric () write more code, and if
the variable does not contain only numbers, the request is canceled (in
principle, but of course you can run the same query by choosing an
default value for the variable used). Well that's it! You know all about
securing your applications. If you apply these methods, there is
absolutely no risk of having a fault type SQL injection on its website
(or PHP).

Monday, 11 July 2011

Learn Hacking on your mobile Get daily updates on your cell phone in india and pakistan

Dear Friends many friends told me for updates so i am ready to give this Service,
i can Give you updates on mobile Fone,
just msg me or email me

My Facebook Profile, http://www.facebook.com/jumbohacker
My email :TheUmerRock@yahoo.com
My MSN : jumboboy@live.com

How To Set Up A Secure & Free Proxy Server Learn Ethcial HAcking


WinProxyA proxy server is a kind of server/software that sits between a network and another client machine and handles communication between the two. That one function is the primary use of a free proxy server ““ to act as a proxy for a client machine.
Proxy servers can also be configured to store (cache) webpages which the client machines frequently request. So when a client requests a webpage for the first time, the proxy downloads and caches the webpage and when a second request comes for the same page,the proxy serves it up from its cache instead of downloading it from the Internet, thus saving the user a hefty download bill and the agonizing wait. Such servers are called caching proxies.
Proxy servers also serve another very important purpose ““ they act as the first line of defense between the bad guys on the other side and the client machines.
The threat becomes even greater when you replace the network on the other side with the Internet and the client machines with a couple of non-technical home users. Broadband connections and multiple computers accessing the Internet in every home have only increased the threat. Setting up a secure caching proxy server for free is an easy way to mitigate the threat and also save some money in the process.
I’ll be using a popular windows based software, Win Proxy, to tell you how you can setup your very own free caching proxy server.

Download Win Proxy to the computer that you want to act as a proxy and run the setup executable. The only question that you have to answer during the setup is to select the way you want to install Win Proxy as (as a normal application or as a service). Unless you’re using Windows NT, you should choose the option titled common application.

free proxy server
The setup program for Win Proxy is one of the simplest that I’ve seen and I’m sure you won’t have a problem getting Win Proxy installed on your computer. When the setup completes, run Win Proxy from the Programs menu and your server is all set.
Congratulations. You’ve just setup your first free proxy server.
free proxy server
Win Proxy comes, by default, all set up to start acting as a proxy for your network. To take advantage of its caching capabilities though, you’ll have to instruct your browser to use it as a proxy.
If you use Firefox, go to the Tools menu and click on the Options link. Now, Under the Advanced options, select the Network tab and click on Settings.
free web proxy server
Enter the IP address or hostname of the machine where you installed Win Proxy in the HTTP Proxy text field and set the port to 3128. That’s all. Firefox is now set up to access the Internet through Win Proxy.
The default set of options that Win Proxy installs with are good enough for most users but if you want to tweak it for even more performance, launch your browser from any computer on the network and point it to http://PROXY_MACHINE:3129, where PROXY_MACHINE is the IP address of the machine running the proxy server. This will bring up the web based configuration panel for Win Proxy. Most users will never need to use it, but it’s there if you want to.
free web proxy serverAs you can see, Win Proxy has a number of advanced features built in that you can configure through the admin panel. For example, if you connect to the Internet using a dial-up account, you can configure Win Proxy to dial up your ISP automatically every time it receives a request from a client for a webpage which is not present in its cache.
You can also configure Win Proxy to give access to only a few websites and/or restrict access to a couple of individuals by creating accounts for each user.
The MUO Network manual also talks about Internet connection sharing which is the name given to the simple proxy functionality built in to Windows.