怎样运行存储过程?

xiaoqin1999 2011-04-19 12:01:08
我想查看本机SQL SERVER的SA的密码,
在网上搜索了一段存储过程的代码,
请问这个存储过程的代码要怎样运行呢?
代码如下:
alter proc p_GetPassword2 
@username sysname=null, --用户名,如果不指定,则列出所有用户
@pwdlen int=2 --要破解的密码的位数,默认是2位及以下的
as
set nocount on

if object_id(N'tempdb..#t') is not null
drop table #t
if object_id(N'tempdb..#pwd') is not null
drop table #pwd

set @pwdlen=case when isnull(@pwdlen,0)<1 then 1 else @pwdlen-1 end

declare @ss varchar(256)
--select @ss= '123456789'
select @ss= 'abcdefghijklmnopqrstuvwxyz'
select @ss=@ss+ '`0123456789-=[]\;,./'
select @ss=@ss+ '~!@#$%^&*()_+{}|:<>?'
--select @ss=@ss+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

create table #t(c char(1) not null)
alter table #t add constraint PK_#t primary key CLUSTERED (c)
declare @index int
select @index=1
while (@index <=len(@ss))
begin
insert #t select SUBSTRING(@ss, @index, 1)
select @index = @index +1
end

select name,password
,type=case when xstatus&2048=2048 then 1 else 0 end
,jm=case when password is null then 1 else 0 end
,pwdstr=cast('' as sysname)
,pwd=cast('' as varchar(8000))
,times =cast('' as varchar(8000))
into #pwd
from master.dbo.sysxlogins a
where srvid is null
and name=isnull(@username,name)
declare @s1 varchar(8000),@s2 varchar(8000),@s3 varchar(8000), @stimes varchar(8000)

declare @l int, @t bigint

select @t = count(1)*POWER(len(@ss),1) from #pwd

select @l=0
,@s1='aa.c'
,@s2='cast(ASCII(aa.c) as varchar)'
,@s3=',#t aa'
,@stimes='1th,' + cast(@t as varchar(20)) + 'rows'

exec('
update pwd set jm=1,pwdstr='+@s1+'
,pwd='+@s2+'
from #pwd pwd'+@s3+'
where pwd.jm=0
and pwdcompare('+@s1+',pwd.password,pwd.type)=1
')
while exists(select 1 from #pwd where jm=0 and @l<@pwdlen)
begin
select @l=@l+1
select @t = count(1)*POWER(len(@ss),@l+1) from #pwd
print @t

select
@s1=@s1+'+'+char(@l/26+97)+char(@l%26+97)+'.c'
,@s2=@s2+'+'',''+cast(ASCII('+char(@l/26+97)+char(@l%26+97)+'.c) as varchar)'
,@s3=@s3+',#t '+char(@l/26+97)+char(@l%26+97)
,@stimes=@stimes+';'+ cast(@l+1 as varchar(1)) + 'th,' + cast(@t as varchar(20)) + 'rows'

exec('
update pwd set jm=1,pwdstr='+@s1+'
,pwd='+@s2+'
,times='''+@stimes+'''
from #pwd pwd'+@s3+'
where pwd.jm=0
and pwdcompare('+@s1+',pwd.password,pwd.type)=1
')
end
select 用户名=name,密码=pwdstr,密码ASCII=pwd, 查询次数和行数=times
from #pwd

if object_id(N'tempdb..#t') is not null
drop table #t
if object_id(N'tempdb..#pwd') is not null
drop table #pwd
...全文
118 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
叶子 2011-04-19
  • 打赏
  • 举报
回复
exec 存储过程名 参数
快溜 2011-04-19
  • 打赏
  • 举报
回复
你需要将alter proc p_GetPassword2改为create proc p_GetPassword2
然后F5
然后输入exec p_GetPassword2
然后再F5
然后再下面就会看到一些东西。
xuam 2011-04-19
  • 打赏
  • 举报
回复
exec  p_GetPassword2
--小F-- 2011-04-19
  • 打赏
  • 举报
回复
把你这段直接拿去查询分析器执行就可以了

exec p_GetPassword2
mabailin 2011-04-19
  • 打赏
  • 举报
回复
先输入drop proc p_GetPassword2
按键盘F5 删除本句
然后需要将alter proc p_GetPassword2改为create proc p_GetPassword2
然后F5 删除本句
然后输入exec p_GetPassword2
然后再F5
然后再下面就会看到一些东西。

22,299

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧