The character that htmlspecialchars
fails to encode the critical character
(NUL byte),
(backspace), as well as the
character.
In order to exploit this, you need a statement with multiple injection points. With this you can escape the closing delimiter of one string literal and thus expand it up to the next starting delimiter of the next string literal. Three string literals each with an injection point can then be transformed into two string literals.
For example:
SELECT * from user WHERE (name='$login' OR email='$login') AND password='$password'
Now with the following values:
login: ) OR 1=1 /*
password: */--
The resulting statement looks like this:
SELECT * from user WHERE (name=') OR 1=1 /*' OR email=') OR 1=1 /*') AND password='*/--'
Which is equivalent to:
SELECT * from user WHERE (name=') OR 1=1 /*' OR email=') OR 1=1
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…