Skip to main content

Secure your web page against SQL injection

There is a number of things you can do… I will show you a few here…
Alternative one
Lets say this is your code:
Code
<?php
$result = mysql_query(‘SELECT text FROM pages WHERE id=’ . $_GET['id']);
echo($result);
?>
This means that you are selecting the page content which is ‘text’ from ‘pages’ in the SQL database, and you are sorting out the right page content with $_GET['id'] and $_GET['id'] is the thing in the url… Example;
Code
http://google.com/index.php?id=123
This code is easily injectable… But if you do this:
Code
<?php
$result = mysql_query(‘SELECT text FROM pages WHERE id=’ . mysql_real_escape_string($_GET['id']));
echo($result);
?>
You are 100% secure
Alternative two
This one is not as good as the first one… But still works
Again we say this is your php code:
Code
<?php
$result = mysql_query(‘SELECT text FROM pages WHERE id=’ . $_GET['id']);
echo($result);
?>
Again this is very simple to inject… But if you check $_GET['id'] for “illegal” characters! Like this:
Code
<?php
$pos = strrpos(strtolower($_GET['id']), “union”);
if ($pos === false){}else
{
die;
}
$pos = strrpos(strtolower($_GET['id']), “select”);
if ($pos === false){}else
{
die;
}
$pos = strrpos(strtolower($_GET['id']), “information_”);
if ($pos === false){}else
{
die;
}
$result = mysql_query(‘SELECT text FROM pages WHERE id=’ . $_GET['id']);
echo($result);
?>

Comments

Popular posts from this blog

Valentine's week

Celebrate your Valentine's week with  Your Valentine 7 Feb Rose Day 8 Feb Propose Day 9 Feb Chocolate Day 10 Feb Teddy Day 11 Feb Promise Day 12 Feb Kiss Day 13 Feb Hug Day 14 Feb VALENTINE'S DAY 15 Feb Slap Day 16 Feb Kick Day 17 Feb Perfume Day 18 Feb Flirting Day 19 Feb Confession Day I want to confess dear sweetheart!! (*-*) 21 Feb Break Up

Free download XSS SHELL v0.3.8

XSS SHELL v0.3.8 WHAT IS XSS SHELL ? XSS Shell is powerful a XSS backdoor and zombie manager. This concept first presented by "XSS-Proxy - http://xss-proxy.sourceforge.net/  ". Normally in XSS attacks attacker has one shot, in XSS Shell you can interactively send requests and get responses from victim. you can backdoor the page.  You can steal basic auth, you can bypass IP restrictions in administration panels, you can DDoS some systems with a permanent XSS vulnerability etc. Attack possibilities are limited with ideas. Basically this tool demonstrates that you can do more with XSS. FEATURES XSS Shell has several features to gain whole access over victim. Also you can simply add your own commands.  Most of the features can enable or disabled from configuration or can be tweaked from source code. Features; - Regenerating Pages - This is one of the key and advanced features of XSS Shell. XSS Shell re-renders the infected page and keep user in virtual environment...

AutoCAD 2011 KeyGen : AutoCAD 2011′s Serial, Activation, License Key, Product Key, Patch

[ How To Use ] Install Autodesk Autocad 2011 Use as Serial 356-72378422 .. or anything matching this template Use as Product Key 001C1 Finish the installation & restart Autodesk Product Before clicking on Activate You have 2 options (Choose option a or b) : - a) Disable Your network Card, pull the network cable out or block with firewall      (this is just to disable online serial check) OR - b) Click on Activate and it will tell you that your serial is wrong, simply click on close et click on activate again. Select “I have an activation code from Autodesk” Once at the activation screen : start XFORCE Keygen 32bits version if you are installing a 32bits application and 64bits if you are installing a 64bits application. Click on Mem Patch (you should see successfully patched) Copy the request code into the keygen and press generate Now copy the activation code back to the activation screen and click Next You have a fully registered autodesk product NO LAME...