Created
May 3, 2012 04:44
-
-
Save taku0/2583211 to your computer and use it in GitHub Desktop.
Re: 平成24年度春期情報セキュリティスペシャリスト試験のXSS問題 / 単引用符のエスケープだけではだめな場合
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EscapeTest { | |
protected static String escape(String word) { | |
return word.replaceAll("'", "\\u0027"); // '等のエスケープは省略 | |
} | |
public static void main(String [] args) { | |
String word = "\" onmouseover=\"alert(document.cookie)\" onmousedown=\""; | |
System.out.println("<a name=\"#\" onclick=\"alert('" + escape(word) + "')\">"); | |
System.out.println("previous search word"); | |
System.out.println("</a>"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment