For more information, see <G id = "1"> cracking Oracle Database passwords </G>.

Source: Internet
Author: User

For more information, see <G id = "1"> cracking Oracle Database passwords </G>.

I. Summary

The main purpose of this article is to share the decryption method to attract the attention of relevant people on network security. Database security is not only the security of the database itself, but also closely related to the entire environment of the database.

In this article, the passwords oracle9i, oracle10g, and oracle11g are cracked. Specifically, the plaintext of the oracle password is cracked by handling the communication packets between the oracle database and the client, this is different from cracking the 16-bit password stored in the oracle database. The interception of network information is often easier to operate, more difficult to prevent, and more confidential than logging on to the database to find the password ciphertext.

This article describes the three most common oracle algorithms, but does not reveal the internal details of the algorithms.

Ii. Background

With the development of information communication, networks become increasingly complex and insecure. As shown in: from the client to the database, more and more attack targets are available for attackers. The communication package between the oracle database and the client is obtained no matter which part of the process successfully intercepts or listens to the network. If the communication package exactly contains user information, it would be disastrous if encryption is not performed. This article is based on three versions of oracle (9i 10g11g ). Describes the methods and development trends of core communication content encryption.

Iii. oracle encryption principles

When Oracle initiates a connection, the Oracle client sends its own version number, including the encryption algorithm, and other information to the oracle database. The final two sides determine what encryption algorithm is used. Then perform O3logon verification. O3logon authentication is a query-response protocol. It uses DES encryption technology to protect the sesskey of this session and ensures that the sesskey is not transmitted over the network, therefore, even if someone listens to the network, the core key is not exposed. The core of O3logon verification is the sesskey.

 

First, the server calculates S_auth_sesskey on the server through oracle_hash (different versions, in 9i are username + password, and then sha1) and sesskey (a random number.

 

After obtaining the S_auth_sesskey of the server, the client calculates the random sesskey selected by the database using the hashed value (orcale_hash calculated using the same method as the server.

The client uses sesskey to generate a new hash value, and uses this value as the key and plaintext password to calculate the secret password, and then sends the secret password to the server.

The server receives the password, and generates a hash key using the sesskey to decrypt the secret password to obtain the plaintext of the password. If the password is consistent with that stored in the database, the login is successful. (See)

Iv. Instances

The above is mainly a description of the principles. The following describes the three versions of databases respectively (they are both the same and different ).

Oracle9i:

By default, you have obtained a network communication package containing Oracle logon information in some ways. Omit the information that is not closely related to password breaking. In the data packet, find three related information: AUTH_SESSKEY, username, and AUTH_PASSWORD sent from the database to the client.

After the client obtains the auth_sesskey, It computes oracle_hash. First, it performs the SHA1 operation on orcale_hash to obtain the hash value on the server. Use the hash value of the server as the key to perform 3DES decryption. You can convert the AUTH_SESSKEY sent from the server to the client to the sesskey that costs the next session.

After the server obtains the auth_password, it performs SHA1 operations on the sesskey according to certain methods to obtain the hash value of the client. The client hash value and AUTH_PASSWORD can use 3DES to calculate the password ciphertext stored in the database. Finally, the client hash value and the ciphertext can be used to restore the plaintext of the password.

9i processes the entire string and generates oracle_hash by sorting the username and password in plain text in order. Because the added parameters are fixed, their sesskey is the same even if they are not the same database as long as they are added with the same account and password. For example, the user name aabbcc password ccddee and the user name aabbcccc password ddee are the same sesskey.

Reference Code

int ORACLE_Hash (char*username, char *passwd, int passwd_len, unsigned char* oracle_hash){    char ToEncrypt[256];    char temp[256];    DES_cblock iv,iv2;    DES_key_schedule ks1, ks2;    int len=0;    int j,ulen,plen;    memset (ToEncrypt,0,sizeof(ToEncrypt));    strupr (username);    strupr (passwd);    ulen = strlen(username);    plen = passwd_len;    for (len=1,j=0; j<ulen; len++,j++)    {        ToEncrypt[len] = username[j];        len++;    }    for (j=0; j<plen; len++,j++)    {        ToEncrypt[len] = passwd[j];        len++;    }    len=len-1;    memset (iv,0,8);    memset (iv2,0,8);    DES_set_key((DES_cblock*) deskey_fixed, &ks1);    DES_ncbc_encrypt((unsigned char*) ToEncrypt, (unsigned char*)temp, len, &ks1, &iv, DES_ENCRYPT);    DES_set_key((DES_cblock*) &iv, &ks2);    DES_ncbc_encrypt((unsigned char*) ToEncrypt, (unsigned char*)temp, len, &ks2, &iv2, DES_ENCRYPT);    memcpy (oracle_hash,iv2,8)    return TRUE;}

 

Note: The above Code does not use sha1, but des, which is inconsistent with the previous article. In addition, what is receivey_fixed? Is it fixed31 below?

intORACLE_TNS_Decrypt_Password_9i (unsigned char OracleHash[8], unsigned charauth_sesskey[16], unsigned char auth_password[16], char* decrypted){unsigned char fixed31 [] ={0xA2,0xFB,0xE6,0xAD,0x4C,0x7D,0x1E,0x3D,0x6E,0xB0,0xB7,0x6C,0x97,0xEF,0xFF,0x84,0x44,0x71,0x02,0x84,0xAC,0xF1,0x3B,0x29,0x5C,0x0F,0x0C,0xB1,0x87,0x75,0xEF};unsigned chartriple_des_key[64];unsigned char sesskey[16];unsigned char obfuscated[16];int PassLen = 16;ORACLE_TNS_Create_Key_SHA1(OracleHash, 8, fixed31, sizeof(fixed31), 24, triple_des_key);ORACLE_TNS_Decrypt_3DES_CBC(auth_sesskey, 16, triple_des_key, sesskey);ORACLE_TNS_Create_Key_SHA1(sesskey, 16, NULL, 0, 40, triple_des_key);ORACLE_TNS_Decrypt_3DES_CBC(auth_password, 16, triple_des_key, obfuscated);ORACLE_TNS_DeObfuscate(triple_des_key, obfuscated, &PassLen);memcpy (decrypted, obfuscated,PassLen);return PassLen;}

Oracle10g

10G has made great changes based on 9i. Let us also assume that we have obtained a network communication package containing Oracle login information. Omit the information that is not closely related to password breaking. In the data packet, find four related information: S_AUTH_SESSKEY sent by the database to the client, username plaintext, C_AUTH_SESSKEY and AUTH_PASSWORD sent by the client to the server.

Assume that oracle_hash is obtained, which is different from 9i. Although 9i calculates two different hash values. However, because the two hash values are calculated by fixed data and oracle_hash, they are inevitably cracked and inefficient. Oracle adjusted the policy from Oracle10g. The client and database generate S_AUTH_SESSKEY and C_AUTH_SESSKEY Based on oracle_hash respectively.

The S_AUTH_SESSKEY passed by the client. Perform AES128 decryption to obtain server_sesskey. Use server_sesskey and client_sesskey as md5 to generate a combine. Use combine to generate AUTH_PASSWORD.

The server uses combine to decrypt the AUTH_PASSWORD. Compare the password. If the logon succeeds.

10G has made great improvements in processing sesskey, but the generation of oracle_hash continues the 9i method. Concatenates the user name and password to form the most critical string. Perform DES processing on the string.

Reference Code

intORACLE_TNS_Decrypt_Password_10g (unsigned char OracleHash[8], unsigned charauth_sesskey[32], unsigned char auth_sesskey_cli[32], unsigned char* auth_password,int auth_password_len, char* decrypted){    int passlen = 0;    unsigned char aes_key_bytes[32];    unsigned char decrypted_server_sesskey[32];    unsigned char decrypted_client_sesskey[32];    unsigned char combined_sesskeys[16];    char decrypted_password[64];    memset (aes_key_bytes,0,sizeof(aes_key_bytes));    memcpy (aes_key_bytes,OracleHash,8);    ORACLE_TNS_Decrypt_AES128_CBC (aes_key_bytes, auth_sesskey, 32,decrypted_server_sesskey);    ORACLE_TNS_Decrypt_AES128_CBC (aes_key_bytes, auth_sesskey_cli,32, decrypted_client_sesskey);    ORACLE_TNS_Combine_SessKeys (&decrypted_server_sesskey[16],&decrypted_client_sesskey[16], combined_sesskeys);    ORACLE_TNS_Decrypt_AES128_CBC (combined_sesskeys, auth_password,auth_password_len, (unsigned char*) decrypted_password);    passlen = terminate_ascii_string (&decrypted_password[16],auth_password_len-16);    if (passlen!= -1)        strncpy (decrypted, &decrypted_password[16], passlen);    return passlen;}

 

Oracle11g

 

On the basis of 10 Gb, 11 GB has been changed. Let us also assume that we have obtained a network communication package containing Oracle login information. Omit the information that is not closely related to password breaking. In the data packet, find four related information: S_AUTH_SESSKEY, AUTH_VFR_DATA, and C_AUTH_SESSKEY and AUTH_PASSWORD sent by the client to the server.

 

 

It is still assumed that Oracle_hash is obtained, and 11g is basically the same as 10g. The client and database generate S_AUTH_SESSKEY and C_AUTH_SESSKEY Based on Oracle_hash respectively. The S_AUTH_SESSKEY passed by the client. Perform AES192 decryption to obtain server_sesskey. Use server_sesskey and client_sesskey as md5 to generate a combine. Use combine to generate AUTH_PASSWORD. The server uses combine to decrypt the AUTH_PASSWORD. Compare the password. If the logon succeeds.

The biggest change of 11g adopts a different policy than 10G on the Oracle_hash generation. Oracle 11g introduces the random AUTH_VFR_DATA value to improve the security of Oracle_hash. The plaintext user name is canceled. The AUTH_VFR_DATA of each session is different. Fundamentally avoid the huge security risks caused by the same 9i and 10G Strings (consisting of usernames and passwords), regardless of which machine oracle_hash is consistent.

Reference Code

void ORACLE_MixCase_Hash (char*passwd, int passwd_len, unsigned char salt[10], unsigned char*oracle_mixcase_hash){    unsigned char to_hash[256];    memcpy (to_hash, passwd, passwd_len);    memcpy (to_hash+passwd_len, salt, 10);    SHA_CTX ctx;    SHA1_Init (&ctx);    SHA1_Update (&ctx, to_hash, passwd_len+10);    SHA1_Final (oracle_mixcase_hash, &ctx);}

 

V. Summary

From the changes from Oracle9i to Oracle11g, we can clearly see that the idea of oracle adjustment is more secure. Starting from 11g, all login information related to oracle and password is encrypted. Effectively increases the difficulty of cracking. As IT software practitioners and security industry practitioners, we should learn from Oracle, not only focus on the security of the software itself, but also have a certain degree of resistance to the environment. Be sure to prevent network listening. Avoid common names such as ORCL and TEST when designing SID. Try not to use ports 1521 and 1523 to increase the scanning difficulty. Using complex passwords and changing passwords regularly will help oracle Security

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.