DVWA之XSS(反射型)

版权声明:孤 https://blog.csdn.net/Wu000999/article/details/83998907

服务器代码 LOW
在这里插入图片描述

array_key_exists(key,array)函数检查某个数组中是否存在指定的键名,如果键名存在则返回 true,如果键名不存在则返回 false。可以看出代码只是判断name是否存在是否为空,并没有任何的过滤。

漏洞利用

在这里插入图片描述

url:http://localhost/DVWA/vulnerabilities/xss_r/index.php?name=<script>alert(%2Fxss%2F)<%2Fscript>#

服务器端代码Medium
在这里插入图片描述

str_replace(find,replace,string,count) 函数替换字符串中的一些字符(区分大小写),count可选。一个变量,对替换数进行计数。类似黑名单的思想。

1.大小写混淆绕过

在这里插入图片描述

url:http://localhost/DVWA/vulnerabilities/xss_r/index.php?name=<ScRipt>alert(%2Fxss%2F)<%2Fscript>#

2.双写绕过
<sc< script>ript>alert(/xss/)
在这里插入图片描述

url:http://localhost/DVWA/vulnerabilities/xss_r/index.php?name=<sc<script>ript>alert(%2Fxss%2F)<%2Fscript>#

服务器段代码High
在这里插入图片描述

preg_replace ( mixed $pattern , mixed $replacement , mixed $subject)函数执行一个正则表达式的搜索和替换。这使得双写绕过、大小写混淆绕过(正则表达式中i表示不区分大小写)不再有效。

无法使用< script>标签注入XSS代码,但是可以通过img、body等标签的事件或者iframe等标签的src注入恶意的js代码。

< img src=1 onerror=alert(/xss/)>

在这里插入图片描述

url: http://localhost/DVWA/vulnerabilities/xss_r/index.php?name=<img+src%3D1+onerror%3Dalert(%2Fxss%2F)>#

服务器端代码Impossible
在这里插入图片描述

htmlspecialchars() 函数把预定义的字符转换为 HTML 实体。防止浏览器将其作为HTML元素。

预定义的字符是:

& (和号)成为 &
" (双引号)成为 "
' (单引号)成为 '
< (小于)成为 <
> (大于)成为 >

猜你喜欢

转载自blog.csdn.net/Wu000999/article/details/83998907