mssql提权
作者:freethy 发布于:2012-1-7 12:25 Saturday
今天查看MSSQL服务器日志,发现不少连接3389的记录。
出于安全考虑,于是更改3389端口,重启。
1,2,3,4,5分钟过去了,还是连不上指定端口的远程桌面,原来的端口也连不上。
完了,防火墙忘了设置,悲剧ing。难道要联系机房值班?
忽然想到不是有服务器的1433嘛。
马上连接,执行语句。一番折腾语句如下:
sp_addextendedproc 'xp_cmdshell', 'xpsql70.dll'
--恢复xp_cmdshellsp_configure 'show advanced options', 1;
go
reconfigure;
go
--设置高级选项EXEC sp_configure 'xp_cmdshell',1
--启用xp_cmdshellxp_cmdshell 'net stop sharedaccess'
-- 关闭防火墙
看到防火墙成功关闭,高兴。。。
再次连接,问题依旧。陷入僵局。。。
前想后想左想右想。。。
ipsec,一定是ipsec策略问题。
再次连接执行:
xp_cmdshell 'net stop "IPSEC Services"'
-- 关闭ipsec服务
执行成功。
再次尝试,远程桌面连接成功。
别忘了彻底关闭mssql相关功能
sql 查询一对多关系
作者:freethy 发布于:2012-1-6 12:29 Friday
我怎样查询出来
id cindex
10 21,22
11 16,17
//详解。。。。。。。。。。。。。。。。
create table tb(id int, value varchar(10))
insert into tb values(1, 'aa')
insert into tb values(1, 'bb')
insert into tb values(2, 'aaa')
insert into tb values(2, 'bbb')
insert into tb values(2, 'ccc')
go
create function dbo.f_str(@id int) returns varchar(100)
as
begin
declare @str varchar(1000)
set @str = ''
select @str = @str + ',' + cast(value as varchar) from tb where id = @id
set @str = right(@str , len(@str) - 1)
return @str
end
go
--调用函数
select id , value = dbo.f_str(id) from tb group by id