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.

Blind <strong>SQL</strong> <strong>Injection</strong> Exploitation • Chapter 5 255<br />

The challenge of extracting all data (regardless of length or type) through DNS is<br />

tricky <strong>and</strong> solvable on an <strong>SQL</strong> Server database mainly due to T-<strong>SQL</strong>, which provides loops,<br />

conditional branching, local variables, <strong>and</strong> so on. Even though Oracle has explicit DNS<br />

functions, its more serious limitations from an attacker’s point of view (lack of PL/<strong>SQL</strong> injection<br />

in <strong>SQL</strong>) prevent the exploitation seen on <strong>SQL</strong> Server.<br />

Tools & Traps…<br />

Zoning Out<br />

In the examples covered here, we’ve assumed that the attacker controls the zone<br />

attacker.com <strong>and</strong> has full access to the authoritative server for that zone. However,<br />

when using DNS as an exfiltration channel on a regular basis for assessments or other<br />

work, using your zone’s authoritative DNS server as the staging ground for the attack<br />

seems brash. Apart from the fact that this requires granting all colleagues unfettered<br />

access to the server, it is also not flexible. We advocate creating at least one subdomain<br />

that has an NS record pointing to the machine which you grant full access to all<br />

colleagues. You could even create a subdomain per colleague with the NS pointing to<br />

a machine controlled by that colleague. Here is a quick run-through on how you can<br />

add a subdomain to the zone attacker.com in BIND. In the zone file for the domain<br />

attacker.com add the following lines:<br />

dnssucker.attacker.com. NS listen.attacker.com.<br />

listen.attaker.com. A 192.168.1.1<br />

The first line contains the NS record <strong>and</strong> the second provides a glue record. On the<br />

machine listen.attacker.com, a DNS server is installed that is authoritative for the<br />

domain dnssucker.attacker.com.<br />

Subsequent DNS exfiltration will use .dnssucker.attacker.com as a suffix.<br />

E-mail Exfiltration<br />

Both <strong>SQL</strong> Server <strong>and</strong> Oracle support sending e-mails from within the database, <strong>and</strong> e-mail<br />

presents an intriguing exfiltration channel. Quite similarly to DNS, e-mails sent using Simple<br />

Mail Transfer Protocol (SMTP) do not require a direct connection between the sender <strong>and</strong><br />

recipient. Rather, an intermediate network of mail transfer agents (MTAs), essentially e-mail<br />

servers, carries the e-mail on the sender’s behalf. The only requirement is that there exists a<br />

route from the sender to the receiver <strong>and</strong> this indirect approach is a useful channel for blind

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

Saved successfully!

Ooh no, something went wrong!