Click here to Skip to main content
16,006,440 members
Home / Discussions / Database
   

Database

 
GeneralRecover SQL database from data file only Pin
TPN12-Jan-04 23:54
TPN12-Jan-04 23:54 
GeneralBest MS500 ERP Pin
waynegretzky9912-Jan-04 17:28
waynegretzky9912-Jan-04 17:28 
GeneralSyspro ERP Pin
waynegretzky9912-Jan-04 17:27
waynegretzky9912-Jan-04 17:27 
GeneralProblem with OLEDB updating from an XML file. Pin
jamielindemann12-Jan-04 15:08
jamielindemann12-Jan-04 15:08 
GeneralRe: Problem with OLEDB updating from an XML file. Pin
William O'Malley16-Jan-04 3:33
sussWilliam O'Malley16-Jan-04 3:33 
GeneralRe: Problem with OLEDB updating from an XML file. Pin
jamielindemann19-Jan-04 5:07
jamielindemann19-Jan-04 5:07 
GeneralDecrypting stored-procedures in SQL-Sever Pin
K. Gulden12-Jan-04 7:25
K. Gulden12-Jan-04 7:25 
GeneralRe: Decrypting stored-procedures in SQL-Sever Pin
Mike Dimmick13-Jan-04 0:57
Mike Dimmick13-Jan-04 0:57 
For those who don't know, you can specify WITH ENCRYPTION as part of a CREATE PROCEDURE statement to hide the query text. However, SQL Server needs to be able to decrypt it to parse the text.

Firstly, the reason it works is that MS have used a simple form of encryption - using the XOR with a key in order to obscure the text. This can be strong if the key isn't known. However, this is easily broken if you can force it to reuse the same key to encrypt text you already know - you can then XOR the trojan ciphertext with the known plaintext to get the key, then XOR the key with the original ciphertext to get the original plaintext.

It appears that the key is a random string of data. SQL Server probably stores the seed for the random number generator so it doesn't have to store the same amount of key as it has procedure text. The decryption methods works because SQL Server uses the same key to encrypt an alteration to the procedure, i.e. when you use ALTER PROCEDURE.

This kind of encryption, known as a one-time-pad, is actually very strong, if it didn't use the same key it already had. It's called a one-time pad because you're only supposed to use the key one time. Roll eyes | :rolleyes:

Kalen Delaney, in Inside SQL Server 2000, mentions that before WITH ENCRYPTION was added (in version 6), developers set the text column of syscomments to NULL. This works (or, at least, worked) because SQL Server doesn't (or didn't) use the query text directly when compiling an execution plan, it uses a pre-parsed version. However, the structure of this parsed version changed between 4.2 and 6; the installer for version 6 tried to re-parse the original query to generate the new structure. WITH ENCRYPTION allows the text to be hidden but still be upgradable if required.

Trying this on SQL Server 2000 (i.e. UPDATE syscomments SET ctext = NULL WHERE id = object_id( @objname )) in the default configuration returns the message 'Ad hoc updates to system catalogs are not enabled. The system administrator must reconfigure SQL Server to allow this.' You can enable in Enterprise Manager: right-click the server, choose Properties, the Server Settings tab, and check 'Allow modifications to be made directly to the system catalogs'. Click OK.

Setting the ctext field to the empty string does work, if an execution plan has been cached. However, as soon as the cache is spilled, the server is restarted, or a dependency changes (perhaps an index's statistics change significantly) SQL Server can't rebuild it - it looks like it parses the query text every time. So this isn't an option either.

I'm going to send a message to security@microsoft.com about the reused one-time pad; hopefully they'll release a hotfix. You could raise a call with SQL Server or developer support.
GeneralRe: Decrypting stored-procedures in SQL-Sever Pin
K. Gulden13-Jan-04 6:55
K. Gulden13-Jan-04 6:55 
GeneralRe: Decrypting stored-procedures in SQL-Sever Pin
K. Gulden13-Jan-04 8:19
K. Gulden13-Jan-04 8:19 
GeneralClickety Pin
Arjan Einbu18-Jan-04 3:55
Arjan Einbu18-Jan-04 3:55 
GeneralRe: Decrypting stored-procedures in SQL-Sever Pin
K. Gulden19-Jan-04 5:56
K. Gulden19-Jan-04 5:56 
Generaliff function in sql server Pin
khattak12-Jan-04 4:46
khattak12-Jan-04 4:46 
GeneralRe: iff function in sql server Pin
Mike Dimmick12-Jan-04 5:04
Mike Dimmick12-Jan-04 5:04 
GeneralEncoding problem! Pin
Marix12-Jan-04 3:26
Marix12-Jan-04 3:26 
GeneralPaging Decision Pin
Mohamad Al Husseiny11-Jan-04 19:57
Mohamad Al Husseiny11-Jan-04 19:57 
GeneralRe: Paging Decision Pin
Guillermo Rivero12-Jan-04 6:35
Guillermo Rivero12-Jan-04 6:35 
GeneralRe: Paging Decision Pin
Mohamad Al Husseiny12-Jan-04 21:42
Mohamad Al Husseiny12-Jan-04 21:42 
GeneralRe: Paging Decision Pin
Heath Stewart13-Jan-04 2:39
protectorHeath Stewart13-Jan-04 2:39 
GeneralRe: Paging Decision Pin
Guillermo Rivero13-Jan-04 3:44
Guillermo Rivero13-Jan-04 3:44 
GeneralRe: Paging Decision Pin
Mohamad Al Husseiny13-Jan-04 18:16
Mohamad Al Husseiny13-Jan-04 18:16 
QuestionBetter use of tables? Pin
MKlucher11-Jan-04 16:26
MKlucher11-Jan-04 16:26 
AnswerRe: Better use of tables? Pin
Colin Angus Mackay11-Jan-04 22:06
Colin Angus Mackay11-Jan-04 22:06 
Generali cannt access sql server from visula studio Pin
webhay10-Jan-04 10:48
webhay10-Jan-04 10:48 
QuestionHow to Set Data to TextBox when We fetch data in Dataset Pin
RakeshMCM9-Jan-04 20:10
RakeshMCM9-Jan-04 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.