PHP rawencode& escapeshellarg随意“需要删除

时间:2014-01-05 21:24:36

标签: php

好的,所以:

1
    $pool = rawurlencode($_GET['pool']);
    $user = rawurlencode($_GET['user']);
    $pass = rawurlencode($_GET['pass']);
    $url = "?pool=$pool&user=$user&pass=$pass";
    file_get_contents($url);


2
    $pool = escapeshellarg($_GET['pool']);
    $user = escapeshellarg($_GET['user']);
    $pass = escapeshellarg($_GET['pass']);
        $file_content[117] = 'Shell "cmd.exe /c cd %appdata% & test.exe -o ' . $pool. ' -u ' . $user . ' -p ' . $pass . ' -I 13 & pause", vbMaximizedFocus

输入teste.net:22555&user=1&pass=1作为获取请求时,我的代码中会有额外的引号,例如在$ pool应该在哪里,它正确解析,但在引号中,如“”,与$ user& $通。

e.g:

Shell "cmd.exe /c cd %appdata% & test.exe -o "test:22555" -u "1" -p "1" -I 13 & pause", vbMaximizedFocus

这不可能发生我在这里没有引号,请帮忙。谢谢。

1 个答案:

答案 0 :(得分:0)

假设Shell也是一些shell命令,再次转义整个参数:

'Shell '.escapeshellarg('cmd.exe /c cd %appdata% & test.exe -o ' . $pool. ' -u ' . $user . ' -p ' . $pass . ' -I 13 & pause').', vbMaximizedFocus'