README.md

December 4, 2022 · View on GitHub

SQL Injections - The final solution to

Description

Stop SQL Injections

More Info

Submitted On
Bymarcojetson
LevelBeginner
User Rating5.0 (25 globes from 5 users)
CompatibilityPHP 4.0, PHP 5.0
CategorySecurity
WorldPHP
Archive File

Source Code

Here is a simple, yet effective, solution for avoiding SQL Injections.

Let's see a SQL Injection vulnerable sentence:
r=mysqlquery("SELECTFROMsWHEREid=".r = mysql_query("SELECT * FROM s WHERE id = "._GET['id']."");

And the solution:
r=mysqlquery("SELECTFROMsWHEREid=UNHEX(".bin2hex(r = mysql_query("SELECT * FROM s WHERE id = UNHEX('".bin2hex(_GET['id'])."')");

By converting the var in php, and reconverting it in the SQL sentence there's no chance to inject code.


tehwebmaster.blogspot.com / logikk.com.ar