No doubt, SQL injection is one of a very dangerous hacking techniques. If observed, SQL injection started from the one thing which is actually very simple. This time we will discuss the techniques and algorithms which prevent SQL injection through $ _GET method.This paper begins to realize that for many cases of SQL injection. Besides the least awareness of the programmer and programmer confusion to fix the script. Due to the resource which at least discuss how to prevent SQL injection. While the tips and tricks to do it very much.Let's look together: http://target.com/berita.php?task=detail&id=9In most applications that are made by a novice programmer, the program code is as follows berita.php
<? Php
require_once ("connection.php");
$ Sql = "SELECT * FROM news WHERE id = '. $ _GET [' Id '];
$ Result = mysql_query ($ sql);
while ($ data = mysql_fetch_array ()) {
echo "<h2>". $ data ['title']. "</ h2>";
echo "Posting on the date:". $ data ['tanggal_posting'];
echo $ data ['content'];
}?>Let's look again, what a programmer, either out of ignorance or lazy to fix (which is never hard) does not provide the input filter $ _GET ['id']. Yet this is very dangerous if the attacker tries to do this technique.2 there is a fatal error.A. Filter does not give the variable $ _GET ['id']. So that the MySQL Server will give an error signal to the browser (If the PHP error_message = ON).2. Do not do checking on the results of the query.So, how to overcome them. How easy we modified the above script as follows:<? Php
require_once ("connection.php");
/ / -> Validate $ _GET ['id']
if (! ctype_digit ($ _GET ['id'])) {
die ("<script> alert ('Do not even try it.'); window.history.go (-1); </ script>");
}
$ Sql = "SELECT * FROM news WHERE id = '. $ _GET [' Id '];
$ Result = mysql_query ($ sql);
/ / -> Validation query results
if (mysql_num_rows ($ result) <0) {
while ($ data = mysql_fetch_array ()) {
echo "<h2>". $ data ['title']. "</ h2>";
echo "Posting on the date:". $ data ['tanggal_posting'];
echo $ data ['content'];
}
} Else {echo "The news was not found.";}?>Well, the above script has a sense about this algorithm:A. First of all, validating $ _GET ['id'], if it is worth Integer (number), then proceed. If not, display the warning "Do not try it." And subsequently re-view the first page.2. Perform Query3. Check the query results. If the result is greater than 0 (1.2, etc.), take the query and show results to the browser screen. If it does not show the message "Word not found.".Well, so our application has been pretty safe. Wait hold ya it goes.Note: This algorithm can be used tidakhanya on PHP, but can for the other web programming languages. Tentusaja with their respective syntax. For databases other than MySQL mencarifungsi stay the same or equivalent MySQL functions. (Quoted _zapto darisrandal.com)
<? Php
require_once ("connection.php");
$ Sql = "SELECT * FROM news WHERE id = '. $ _GET [' Id '];
$ Result = mysql_query ($ sql);
while ($ data = mysql_fetch_array ()) {
echo "<h2>". $ data ['title']. "</ h2>";
echo "Posting on the date:". $ data ['tanggal_posting'];
echo $ data ['content'];
}?>Let's look again, what a programmer, either out of ignorance or lazy to fix (which is never hard) does not provide the input filter $ _GET ['id']. Yet this is very dangerous if the attacker tries to do this technique.2 there is a fatal error.A. Filter does not give the variable $ _GET ['id']. So that the MySQL Server will give an error signal to the browser (If the PHP error_message = ON).2. Do not do checking on the results of the query.So, how to overcome them. How easy we modified the above script as follows:<? Php
require_once ("connection.php");
/ / -> Validate $ _GET ['id']
if (! ctype_digit ($ _GET ['id'])) {
die ("<script> alert ('Do not even try it.'); window.history.go (-1); </ script>");
}
$ Sql = "SELECT * FROM news WHERE id = '. $ _GET [' Id '];
$ Result = mysql_query ($ sql);
/ / -> Validation query results
if (mysql_num_rows ($ result) <0) {
while ($ data = mysql_fetch_array ()) {
echo "<h2>". $ data ['title']. "</ h2>";
echo "Posting on the date:". $ data ['tanggal_posting'];
echo $ data ['content'];
}
} Else {echo "The news was not found.";}?>Well, the above script has a sense about this algorithm:A. First of all, validating $ _GET ['id'], if it is worth Integer (number), then proceed. If not, display the warning "Do not try it." And subsequently re-view the first page.2. Perform Query3. Check the query results. If the result is greater than 0 (1.2, etc.), take the query and show results to the browser screen. If it does not show the message "Word not found.".Well, so our application has been pretty safe. Wait hold ya it goes.Note: This algorithm can be used tidakhanya on PHP, but can for the other web programming languages. Tentusaja with their respective syntax. For databases other than MySQL mencarifungsi stay the same or equivalent MySQL functions. (Quoted _zapto darisrandal.com)

No comments:
Post a Comment