Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what does this return? 2

Status
Not open for further replies.

SQLDenis

Programmer
Oct 1, 2005
5,575
US
Try to guess it without running it...yeah right

Code:
SELECT
UPPER(RIGHT(LEFT(@@VERSION,2),1))+SUBSTRING(MiR,1,15%6)+RIGHT(LEFT
(CONVERT(VARCHAR,[c6[[447]),4),1)+CHAR(CAST(STUFF(ZuB,2,0,REPLICATE('0',
1))AS INT))+(SELECT(SUBSTRING(name,3,1))FROM[master]..[sysdatabases]
WHERE(dbid)=(SELECT(MIN(dbid))FROM[master]..[sysdatabases]))+COALESCE(
SUBSTRING([c6[[447],0^1034,((15-10)/5)-1),SPACE(1))+LEFT(SPACE(1)+RIGHT(
[rD9 005],LEN([rD9 005])-(ASCII('9')-ASCII('0'))),2)+SUBSTRING([556 X10.]
,2,1)+RIGHT(REVERSE(rNNNNNNoPZZ),1)+SUBSTRING([rD9 005],7,1)+[64]+CHAR
(ASCII(RIGHT(REVERSE(MiR),1))-14)+RIGHT(MiR,1)+CHAR(ASCII(LEFT(MiR,1))
-(ASCII(LEFT(REVERSE(MiR),1))-ASCII(LEFT(MiR,1))))+CHAR(ASCII(LEFT(
(SELECT(SUBSTRING(REVERSE(rNNNNNNoPZZ),3,2))x00R),1))-4)+RIGHT(LEFT
([c6[[447],6),2)+RIGHT([556 X10.],1)+('?')FROM(SELECT(STUFF(SUBSTRING(
DB_NAME(1),3,2),2,0,CHAR(32))),CONVERT(VARCHAR,low+high-1)FROM[master]
..[spt_values][xR234]WHERE((xR234.type)='P')AND(xR234.number)=105)
[x4401C6](MiR,ZuB),(SELECT TOP 1(0x72723668626C6C4D78785A3437),name,
(TYPE_NAME)FROM[master]..sysobjects,master..[spt_datatype_info]WHERE
CONVERT(varbinary,name)=(0x730070005F004D00530072006500740072006900)
+(0X6500760065005F007000)AND(ss_dtype)=(34)ORDER BY(id))[889R U]([c6[[447],
[rD9 005],[556 X10.]),(SELECT(MIN(SUBSTRING(name,6,5))), MAX(RIGHT(name,
1))FROM[master]..[syscolumns]WHERE(name)=CONVERT(varchar,0x646174615F707265636973696F6E
))MxxxxxB01(rNNNNNNoPZZ,[64])

Denis The SQL Menace
SQL blog:
Personal Blog:
 
Can we at least use calculator for that hexadecimal junk? [smile]

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Here is deobfuscated, partially simplified and beautified code:
Code:
SELECT UPPER(RIGHT(LEFT(@@VERSION,2),1))  -- 1
+ SUBSTRING(Col1,1,15%6) -- 2
+ RIGHT(LEFT (CONVERT(VARCHAR,Col3),4),1) -- 3
+ CHAR(CAST(STUFF(Col2,2,0,REPLICATE('0', 1))AS INT)) -- 4
+(	SELECT(SUBSTRING(name,3,1))  -- 5
	FROM[master]..[sysdatabases]
	WHERE (dbid)=
	(	SELECT(MIN(dbid))
		FROM master..sysdatabases
	)
)
+ COALESCE( SUBSTRING(Col3,0^1034,((15-10)/5)-1),SPACE(1)) -- 6
+ LEFT(SPACE(1)+RIGHT(Col4,LEN(Col4)-(ASCII('9')-ASCII('0'))),2) -- 7
+ SUBSTRING(Col5,2,1) -- 8
+ RIGHT(REVERSE(Col6),1) -- 9
+ SUBSTRING(Col4,7,1) -- 10
+ Col7 -- 11
+ CHAR(ASCII(RIGHT(REVERSE(Col1),1))-14) -- 12
+ RIGHT(Col1,1) -- 13
+ CHAR(ASCII(LEFT(Col1,1))-(ASCII(LEFT(REVERSE(Col1),1))-ASCII(LEFT(Col1,1)))) -- 14
+ CHAR(ASCII(LEFT((SELECT(SUBSTRING(REVERSE(Col6),3,2))x00R),1))-4) -- 15
+ RIGHT(Left(Col3,6),2)+RIGHT(Col5,1) -- 16
+ '?' --17
FROM
(	SELECT STUFF(SUBSTRING(DB_NAME(1),3,2),2,0,CHAR(32)) AS Col1,	CONVERT(VARCHAR,low+high-1) AS Col2
	FROM[master]..[spt_values]
	WHERE type='P' AND number=105
) blah, 
(	SELECT TOP 1 0x72723668626C6C4D78785A3437 AS Col3, name AS Col4, TYPE_NAME AS Col5
	FROM master..sysobjects, master..spt_datatype_info
	WHERE CONVERT(varbinary,name)= 0x730070005F004D00530072006500740072006900 + 0X6500760065005F007000
		AND ss_dtype = 34
	ORDER BY id 
) blah2,
(	SELECT MIN(SUBSTRING(name,6,5)) AS Col6, MAX(RIGHT(name,1)) AS Col7
	FROM master..syscolumns
	WHERE name=CONVERT(varchar, 0x646174615F707265636973696F6E)
) blah3

Quickies
1 - @@VERSION is 'Mircosoft something'... 2nd uppercased character is 'I'
5 - first DB is always master... 3rd character is 's'
17 - ?

All other concatenated values depend on FROM source(s)... cross join between blah, blah2 and blah3

blah
WHERE guarantees only one record.

blah.Col1
Col1 does not depend on spt_values. DB_NAME(1) is again 'master', SUBSTRING() returns 'st', STUFF inserts ' '. Col1 is 's t'.

2 - 15 mod 6 is 3, 3 leftmost characters of 's t' are 's t'
12 - REVERSE() returns 't s', rightmost character is 's', 14 ASCII chars lower is ... 'e'
13 - easy one, 't'
14 - CHAR(ASCII('s')-(ASCII('t')-ASCII('s'))). t-s = 1, so this is one char before 's' - 'r'

blah.Col2
Ah phuck, nobody is supposed to know that... ** cheating **... 14, 2... Col2 is '15'
4 - STUFF() inserts '0', ASCII value 105 is for 'i'.

blah3
That varbinary contains 'data_precision', MIN/MAX ensure only one row returned. Col6 is 'preci', Col7 is 'n'

blah3.Col6
9 - rightmost character from reversed string is leftmost character - 'p'
15 - REVERSE() returns 'icerp', SUBSTRING() gives 'eR', SELECT/x00R are junk, LEFT() gives 'e', -4 ASCII is 'a'

blah3.Col7
11 - 'n'

Now we don't need blah and blah3 anymore. Which gives:
Code:
SELECT 'Is t'
+ RIGHT(LEFT (CONVERT(VARCHAR,Col3),4),1) -- 3
+ 'is'
+ COALESCE( SUBSTRING(Col3,0^1034,((15-10)/5)-1),SPACE(1)) -- 6
+ LEFT(SPACE(1)+RIGHT(Col4,LEN(Col4)-(ASCII('9')-ASCII('0'))),2) -- 7
+ SUBSTRING(Col5,2,1) -- 8
+ 'p'
+ SUBSTRING(Col4,7,1) -- 10
+ 'netra'
+ RIGHT(Left(Col3,6),2)+RIGHT(Col5,1) -- 16
+ '?' --17
FROM
(	SELECT TOP 1 0x72723668626C6C4D78785A3437 AS Col3, name AS Col4, TYPE_NAME AS Col5
	FROM master..sysobjects, master..spt_datatype_info
	WHERE CONVERT(varbinary,name)= 0x730070005F004D00530072006500740072006900 + 0X6500760065005F007000
		AND ss_dtype = 34
	ORDER BY id 
) blah2

blah2
Only one record returned
sysobjects and varbinary in WHERE clause are necessary to find Col4... later, if necessary.

blah2.Col3
Col3 is constant - 'rr6hbllMxxZ47' (** blargh **)
3 - 4th character is 'h'
6 - 0 XOR 1034 = 1034, next argument is 0, SUBSTRING() returns '', COALESCE() returns ''.

blah2.Col5
Ahh... 'image'. Usually the first entry (lowest ss_dtype (34)) in that table
8 - 2nd char - 'm'
16 - chars 5-6 from Col3 = 'bl', last char from 'image' is 'e'. All together: 'ble'

Now we have:
Code:
SELECT 'Is this ' -- 5
+ LEFT(RIGHT(Col4,LEN(Col4)-(ASCII('9')-ASCII('0'))),1) -- 7
+ 'mp'
+ SUBSTRING(Col4,7,1) -- 10
+ 'netrable?'
FROM
(	SELECT TOP 1 name AS Col4
	FROM master..sysobjects
	WHERE CONVERT(varbinary,name)= 0x730070005F004D00530072006500740072006900 + 0X6500760065005F007000
	ORDER BY id 
) blah2

Both missing chars are 1 in size:

'Is this _mp_netrable?'

I can't go further... anyone... HEEELP! [pipe]

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top