pen-test
[Top] [All Lists]

Re: Magic Quotes question

To: "DokFLeed" <dokfleed@dokfleed.net>, pen-test@securityfocus.com
Subject: Re: Magic Quotes question
From: Sir Mordred <sir.mordred.lists@gmail.com>
Date: Fri, 19 Jan 2007 11:43:14 +0200
Delivered-to: sp-com-lists@consult.net
Delivered-to: pentest-list2@consult.net
Delivered-to: mailing list pen-test@securityfocus.com
Delivered-to: moderator for pen-test@securityfocus.com
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:date:from:x-mailer:reply-to:x-priority:message-id:to:subject:in-reply-to:references:mime-version:content-type:content-transfer-encoding; b=eFbVdzqWw2sYFt0HiOtXQkWFLNTBqmv8V3AdOox1zQUhhzD24pAjNCedSLzxyfvV+tlqH34PJS5xQj3hGea6zXLpjotf7Bf+V9sPxWEYfBHEO6NyBoogh0hILg6h7sQzuaTnNxUHxPNzePHWycVTV9aKM71j4XaM3GuDE3vtC4k=
In-reply-to: <00a301c73a06$92806010$650fa8c0@labtop>
List-help: <mailto:pen-test-help@securityfocus.com>
List-id: <pen-test.list-id.securityfocus.com>
List-post: <mailto:pen-test@securityfocus.com>
List-subscribe: <mailto:pen-test-subscribe@securityfocus.com>
List-unsubscribe: <mailto:pen-test-unsubscribe@securityfocus.com>
Mailing-list: contact pen-test-help@securityfocus.com; run by ezmlm
References: <20070116165531.92543.qmail@cgisecurity.net> <00a301c73a06$92806010$650fa8c0@labtop>
Reply-to: Sir Mordred <sir.mordred.lists@gmail.com>
Resent-date: Fri, 19 Jan 2007 10:55:48 -0700 (MST)
Resent-from: pen-test-return-1078483428@securityfocus.com
Resent-message-id: <20070119175548.637BF15560C@outgoing2.securityfocus.com>
Resent-sender: listbounce@securityfocus.com
Sender: listbounce@securityfocus.com
> I posted this earlier to webappsec@securityfocus.com with no luck ,
> does anyone know how to bypass magic quotes? a proven working way .

> example is, in such a simple SQL like
>  "SELECT * from USERS WHERE id =$id";

Magic quotes, as well as the correct db-specific escaping functions
(like mysql_real_escape_string() for MySQL) will not work if the query
itself is written badly, as in your example. Here is the correct
syntax, which cannot be exploited if the input was escaped, or if
magic quotes are enabled:

SELECT * from USERS WHERE id='$id'

> I am looking for ways to by pass magic quotes to inject this
> INTO OUTFILE '/home/z.php'

That said, INTO OUTFILE will only work with a literal string (at least
in MySQL, not sure of others), which means you have to use ' or ",
which are escaped by magic quotes.

In other situations where a value is unquoted in the query, you use
CHAR(39,....,39) to represent quotes. To use the above vulnerability
you can try $id=id, $id=1 or 1, $id>4, unions with another table, etc.
and see if any of the selected data is displayed. If not, you'll have
to do with blind sql injection techniques.

Mordred


------------------------------------------------------------------------
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>