加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell – 网页上的“ps aux”输出?

发布时间:2020-12-15 20:55:28 所属栏目:安全 来源:网络整理
导读:我想知道将ps aux放入数组然后在网络上显示的这种安全方法吗?或者可以采取哪些措施来改善它? 例: table width="900px" border="1" tr td PID /td td CPU /td td Mem /td td Start /td td Command/td /tr ?php exec("ps aux | grep -v grep | grep process
我想知道将ps aux放入数组然后在网络上显示的这种安全方法吗?或者可以采取哪些措施来改善它?

例:

<table width="900px" border="1">
    <tr> 
        <td> PID </td>
        <td> CPU </td>
        <td> Mem </td>
        <td> Start </td>
        <td> Command</td>
    </tr>
    <?php
    exec("ps aux | grep -v grep | grep  process.php",$psOutput);
    if (count($psOutput) > 0) {
        foreach ($psOutput as $ps) {
            $ps = preg_split('/ +/',$ps);
            $pid = $ps[1];
            $cpu = $ps[2];
            $mem = $ps[3];
            $time = $ps[8];
            $command = $ps[10] . " " . $ps[11];
            echo "<tr>";
              echo "<td>" . $pid . "</td>";
              echo "<td>" . $cpu . "</td>";
              echo "<td>" . $mem . "</td>";
              echo "<td>" . $time . "</td>";
              echo "<td>" . $command . "</td>";
            echo "</tr>";
        }
    }
    ?>
</table>

解决方法

I am wondering is this safe way to put ps aux into array and then display on the web? Or what could be done to improve it?

就我所知,没有什么.如果这是实际代码并且命令不是从用户输入创建的,那么除了< table width =“900px”>的事实之外,这个代码绝对没有任何问题.通常由CSS控制,而不是HTML.但这就是我能想到的所有批评.

编辑:Quentin提出了一个非常有效的观点,你应该在用HTML显示之前使用htmlspecialchars.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读