さくらレンタルサーバー(共有サーバー)の/home🏠はアレが見えてるよ。#知ってた?#駆け出しエンジニアと

20220909

Logging

おはようございます。今日、高知県では雨☔の地域もあったりするそうですよ🙄。

さて、今日はさくらレンタルサーバー(共有サーバー)の/home🏠の話です。さくらレンタルサーバーじゃなくても共有サーバーを借りたことがある人は知っているかも知れませんが・・・常識?🤔。

さくらレンタルサーバーの/homeの階層に複数のディレクトリが存在します。そのディレクトリのディレクトリ名はさくらレンタルサーバーのアカウント名であり、初期のドメイン名になります。

reborn9.sakura.ne.jp

なので、ディレクトリ名.sakura.ne.jpにすれば初期のドメイン名を生成することが可能ですし、ログインでXXXXX…みたいな事が出来たりしまいます。赤の他人のアカウントでログインするのはハッキングにあたりますので、しないように!

でも、初期のドメインを見ることぐらいなら、良いじゃないかなってことで?WEBサーバーな訳ですからね。

という事で、こんなコードを書きました。コマンド ls -a /homeを実行し結果をtxt.txtのファイルに保存します。そのtxtファイルをPHPで読み込み、ディレクトリ名からリンクリストを生成(index.html)という様な流れ。index.htmlの開いてリンクをクリックすれば/homeの配下の初期ドメインへ飛んでいけます😱、ちょっと悪趣味ですがね…。

コードはこんな感じになります。実行するときはls.phpを開いてください。ls.phpを読み込み完了後、index.htmlのリンクをクリックしてみてください🤐。

尚、下記のファイル全てを同じ階層のディレクトリに置くこととします。※ファイルはUTF-8で。

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="Description" content="Enter your description here"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="assets/css/style.css">
<title>Title</title>
</head>
<body>
<a href="index.html">index.html</a>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
</body>
</html>
<?php
exec("sh ls.sh",$output,$result_code);
#!/bin/sh
ls -a /home > txt.txt
/usr/local/bin/php href.php
done
<?php
ob_start();
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="Description" content="Enter your description here"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<title>lsit</title>
</head>
<body>
    <button class="btn btn-primary" type="button" id="btn">BTN</button><br>
    <?=setlist()?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.min.js"></script>
<script>
    document.getElementById("btn").addEventListener("click",function(){
        for( let i in document.getElementsByTagName("a")){
            document.getElementsByTagName("a")[i].target = document.getElementsByTagName("a")[i].href;
            document.getElementsByTagName("a")[i].click();
        }
    });
</script>
</body>
</html>
<?php
file_put_contents("index.html",ob_get_clean());
?>
<?php
function setlist(){
    $txt_data =  explode("\n",file_get_contents("txt.txt"));
    $str[] = "<ul>";
    foreach($txt_data as $key=>$val){
        $str[] = (preg_match("/\./",$val) || !$val)?"":"<li><a href='http://".trim($val).".sakura.ne.jp'>".trim($val).".sakura.ne.jp</a></li>";
    }
    $str[] = "</ul>";
    return implode("\n",$str);
}

タグ

, home, jp, ne, REBORN, sakura, xxxxx, アカウント, アレ, エンジニア, , こと, サーバー, さくら, ディレクトリ, ドメイン, ドメイン名, ハッキング, レンタル, ログイン, , , 今日, 他人, 共有, 初期, 可能, 地域, 存在, 常識, 生成, 複数, , , 階層, , 駆け出し, 高知県,