I study SQLInjection testing it on one site, that use Microsoft SQL Server 2008.
sqlmap-dev$ python sqlmap.py -u "https://site?id=239" --current-user --current-db -b --users --privileges --passwords
Receive users login and hashed password:
Like this: 0x01005847e7a1ffa21b9c6811420f0e502612c8dd976f685f63a6
The question is, how I can know it?
I understand that I cannot really reverse the hashed string.
I find this: https://stackoverflow.com/a/18154134/2264941
As I understand:
0x0100 - use SHA1
5847e7a1 - salt
ffa21b9c6811420f0e502612c8dd976f685f63a6 - hashed password with salt
Is this algoritm correct for MS SQL 2008 ?
Maybe there is some online instruments that can help me?
You cannot do this. That is literally the whole point in hashing and salting... You could try a password cracker but it will take A LONG TIME.
Related
I want to decrypt password in SQL Server 2012 using DES to send that password in the mail using a SQL Server job.
Can anyone help me?
Thanks in advance.
You shouldn't really be de-encrypting passwords. And either not send passwords thru the emails!
And no, there's usually a random salt in the encryption, so you cannot decrypt it like that. Only Brute Force, because it's weak encryption method nowadays.
For Brute Force you can use for example pwdcompare - More at MSDN pwdcompare
Have a good day everybody, I'm working with SQL SERVER 2008, developing a simple login. Now I'm encrypting the password with this funtion
SUBSTRING(sys.fn_sqlvarbasetostr(HASHBYTES('MD5', #cont)),3,32)
It's work perfect, if I put pass = 123 then return 202cb962ac59075b964b07152d234b70, but I need to know how to decrypt and return again 123
I hope somebody can help me, Thanks
MD5 is a hash, its like an Identifier of a value, so it might or might not contain the actual data.
I want to decrypt passwords stored in my database on Sql Server 2008 which were encrypted using Exec master.dbo.xp_sha1 #Password, #EncPassword output .Is it possible to decrypt?
encrypted passwords look like this : xxstgggettebbqyyayujjweee
Thanks
xp_sha1 is a not standard master stored procedure, it is not included in any sql server i've seen, but doing a quick google i came across: http://www.xpcrypt.com/xpho/xp_sha1.htm
As I stated in my answer/comments in your question Encrypt passwords on Sql Server 2008 using SHA1 encryption is not the same thing as hashing. SHA1 is a hash, not an encryption. Encryption can be undone, hashing cannot.
The links called out in the answer for the last question go through this in some detail, but here are several articles specifically around the differences between encryption and hashing:
Difference between Hashing a Password and Encrypting it
http://www.darkreading.com/safely-storing-user-passwords-hashing-vs-encrypting/a/d-id/1269374
Please Understand that there is a fundamental difference between encrypting and hashing.
If you encrypt "password" to "123809dsfajsfoiwj" as an example, knowing the key and encryption method, you can arrive back at "password" through an appropriate decrypt.
Using SHA1 and hashing "password" there is no way to ever reverse the hashed "jdsfioajd0f98uas" (example) back to the original "password". Hashes are created the same each time given the same input, so hashes are compared to hashes for "validating passwords". You never arrive back at the original.
I start working on an old software of which I just forget the password. I go through the SQL Server 2008 database and found it is saved in the encrypted form
0xA77F9B75A183A3836540FBBE11963F771ED41BBE
there. I want to decrypt the password column and want to know the real password. So that I can access my application.
Thanks in advance
therewere no way you can decrypted, but if MD5 you could try the fallowing http://www.md5online.org/ they will cracked for you. but if you were unhappy with this answer and your programm is valuable for, try this http://www.devart.com/dbforge/sql/sqldecryptor/
i have a column of varbinary(max) type and used a salt of nvarchar(60) type that is generated randomly. I saved the salt in db and saved password using hashbyte(password+ salt).
Now I want to compare user password and authenticate him.
I tried taking his password and running this query--
SELECT [email] from admin where
[password]=HashBytes('SHA1','xxxxxx' +'/KsDnXdU+_a<t19wYCnEi/lxmXmAutR3DVA$#]~dSBskRMB?sb#41+=MFRpE')
It is not returning me email. I ran it directly on sql server management studio. But It gave me blank. Why is it so?
When im selecting by email im getting role, this means email is registered.
Is something wrong in my salt or query?
I fixed it. Actualy adding salt directly was causing me a bug, though it was getting added directly and hash was computed and no error was returned from sql server.
When i ran this query
Select role from admin where salt='/KsDnXdU+_a<t19wYCnEi/lxmXmAutR3DVA$#]~dSBskRMB?sb#41+=MFRpE'
I got no result. I realised, it was some Conversion problem. I used then Convert(nvarchar(60),'%?r>%Vb+$hUZO8}=38/_J[#q#1mf^rz!V&q~\dLH5nQ&/edR\c[6ya|q$e%r')
and ran my query as
SELECT [email] from admin where
[password]=HashBytes('SHA1', 'xxxxxx'+Convert(nvarchar(60),'%?r>%Vb+$hUZO8}=38/_J[#q#1mf^rz!V&q~\dLH5nQ&/edR\c[6ya|q$e%r'))
This returned me email. I am really not sure why this happened, but using sqlserver 2005, and above query i fixed it. I request moderators, If it is any bug in sql server 2005, please do let other know.
You need to use the same code when reading and when writing:
INSERT INTO dbo.admin (email, password, salt)
VALUES(#email,HashBytes('SHA2_512',#password+#salt),#salt);
and
SELECT email FROM dbo.admin
WHERE password = HashBytes('SHA2_512',#password+salt);
The only difference is that the select references the stored salt instead of a passed in salt.
You also should use the SHA2 algorithm as SHA1 is not secure anymore (http://www.md5decrypter.co.uk/sha1-decrypt.aspx). For SHA2_512 your column needs to be 64 bytes (http://msdn.microsoft.com/en-us/library/ms174415.aspx). You should use the specific length instead of (MAX) if possible.
As Aaron noted, SHA2 is not supported before SQL 2012. You can use a CLR implementation instead. This can get you started: http://geekswithblogs.net/hroggero/archive/2009/09/19/strong-password-hashing-with-sql-server.aspx However, it is using only 256 bits.