TOP ▲
itcore TOP
> TIPS
> find_hp.php
タグ:移行 find パーミッション HP移行において、書き込み権限や実行件のあるファイルを探す。httpの絶対パスを探す。 | itcore 2019年
実行方法
http://.../xxx.php?p=パスワード
プログラム
<?php
//--------------------------
// 2019-03-09 find itcore
//--------------------------
$password = "***"; // セキュリティのため値を指定してください。
$pw=uForm("p");
if ($pw != $password) {
echo "エラー";
exit;
}
// もし画面に出ない場合はファイルへ出力する。
echo "[httpの絶対パスがあるファイル]<br>\n";
$cmd = "grep -iRl http:\/\/www\.xxx . ";
print "cmd=" . htmlspecialchars($cmd) . "<br>\n";
$ret = shell_exec($cmd);
print nl2br(htmlspecialchars($ret)) . "<br>\n";
echo "[30日以内に更新されたファイル]<br>\n";
$cmd = "find .. -mtime -30 -follow -type f | xargs -r ls -l";
print "cmd=" . htmlspecialchars($cmd) . "<br>\n";
$ret = shell_exec($cmd);
print nl2br(htmlspecialchars($ret)) . "<br>\n";
echo "[Webから書き込み権限のあるファイル]<br>\n";
$cmd = "find . -type f -perm -g=w | xargs -r ls -l";
print "cmd=" . htmlspecialchars($cmd) . "<br>\n";
$ret = shell_exec($cmd);
print nl2br(htmlspecialchars($ret)) . "<br>\n";
echo "[CGIなど実行権のあるファイル]<br>\n";
$cmd = "find . -type f -perm -g=x | xargs -r ls -l";
print "cmd=" . htmlspecialchars($cmd) . "<br>\n";
$ret = shell_exec($cmd);
print nl2br(htmlspecialchars($ret)) . "<br>\n";
?>
<?php
function uForm($var) {
if (isset($_POST[$var])) return $_POST[$var];
if (isset($_GET[$var])) return $_GET[$var];
return "";
}
?>