High Level
查看源码
<?php // Is there any input? if ( array_key_exists( "default", $_GET ) && !is_null ($_GET[ 'default' ]) ) { # White list the allowable languages switch ($_GET['default']) { case "French": case "English": case "German": case "Spanish": # ok break; default: header ("location: ?default=English"); exit; } } ?>
可以看出,服务器端代码先判断defalut值是否为空,如果不为空的话,再用switch语句进行匹配,如果匹配成功,则插入case字段的相应值,如果不匹配,则插入的是默认的值。
由于开发人员现在在服务器端只列出允许的语言白名单,我们必须找到一种无需将代码发送到服务器即可运行代码的方法。
漏洞利用
URL的锚(#符号之后的任何内容)不会发送到服务器,因此无法被阻止。
访问链接:
http://127.0.0.1/dvwa/vulnerabilities/xss_d/?default=English # <script>alert(1)</script>
可以看到,我们的script脚本成功执行了。
我们查看源代码,可以看到,脚本被插入到代码中,所以执行了。