若気の至り若気の過ちか?Mr.ROBOT🤖

2022.09.11

Logging

こんばんは、深夜便で東京に向かってます(嘘です)。

今日は緊急で動画廻してます(記事を書いています)。私が昔書いたコードに大きな脆弱性が合ったので、そのコードの穴だけ塞ぎました。まだ、色々な所に穴があるかもしれないですが・・・。

この脆弱性に関しては知っていたのですが、昔のコードをそのままにしていたのを失念していたのです、それが大きな過ち…。仕事では重大インシデントになりますね😱。

<?php
 function defence_xss($data=""){
    if(is_array($data)){
        foreach ($data as $key => $value) {
            $data[$key] = strip_tags($value);
            $data[$key] = htmlspecialchars($data[$key],ENT_QUOTES);
        }
    }else{
        $data = strip_tags($data);
        $data = htmlspecialchars($data,ENT_QUOTES);
    }
    return $data;
}

今回、塞いだのは初歩の脆弱性です、、、POSTやGETで送られるデータに悪意のあるコードなどを埋め込んでハッキングを行う手法です。またセッションジャックとかそういうのもありますので、気になる方は調べてみてください。

SQLインジェクション判決、オニギリペイ、これらをつなぐセミナーにかける思いを語る
徳丸浩のウェブセキュリティ講座

追記して書いときます。昔勤めていた会社でも何度か、この手の手法でハッキングに合いました。脆弱性が解消されているかは分かりません。XSS攻撃は防げても、これではSQLインジェクション攻撃は防げません、昔のコードで動いているとしたら修正箇所は無数にあるので一日では直せないでしょう。

昔勤めていた会社はShopifyへシステムを移行しているようですが、それが良いのかは分かりません、自分だったら物足りなさを感じると思います😌。

タグ

array, as, data, defence, foreach, function, gt, htmlspecialchars, if, is, key, lt, Mr, php, quot, ROBOT, strip, tags, value, xss, インシデント, コード, それ, 今日, 仕事, 動画, , 失念, , , 東京, 深夜便, , , 緊急, 脆弱性, 色々, 若気, 記事,

沈黙は金、雄弁は銀:トーマス・カーライル

2021.01.12

Logging

Speech is silver, silence is golden.
沈黙は金、雄弁は銀

トーマス・カーライル

この言葉、よく聞く言葉だと思います、ついつい話ししてしまうこともあるでしょう。SNSでよく呟いているひとは金というより銀ですね。じぶんもどちらかと言えば銀の傾向があります。ついつい話してしまう、、、。でも昔は沈黙の方の人でした、沈黙することのほうが自分は楽ですけどね。

ほとんどの人は話すことのほうが楽なんでしょうけど、自分は話さない方が楽な性だったので沈黙でいることは苦しくないです。SNSもこの頃はシェアと日常生活のつぶやきに変わっています。SNSもブログは続けていくと思いますが、助言などは徐々に減らしていくようにしています。

正直なところ、話さないほうが良いこともあるですよ。沈黙は金、雄弁は銀とは違いますが、プログラミングは答えを教えても全然意味がない。答えを自分で導き出せる方法やアルゴリズムをじぶんで組み立てることのほうが重要です。

答えを言っても全然、じぶんの技術にはならないのです、教えることは大事ですが、答えを言うは正解ではないと思います。答えに近づく考え方をアドバイスするという事が一番大事になると思います。

最後に「沈黙は金、雄弁は銀」という言葉はこれから先も変わらない名言かと思います。

タグ

golden, is, silence, silver, SNS, Speech, アルゴリズム, カーライル, こと, シェア, じぶん, トーマス, ところ, どちらか, ひと, ブログ, プログラミング, ほとんど, , 傾向, 助言, , 意味, , 方法, 日常, , 正直, 沈黙, 生活, 答え, 自分, 言葉, , , 雄弁, ,

ファンです。Yoojung Lee:)

2020.10.22

Logging

Pure Water – Mustard, Migos / Yoojung Lee Choreography

I am a fan of Yoojung Lee. Her dance moves are sharp and beautiful.
And I like her coolness.
I’m sharing her dance moves with you.
If you’ve been following my Twitter timeline, you’ll have an idea of what I’m talking about.
It’s the type of person I like quite a bit.
These days, I’ve been thinking that the women I like are very similar to each other.
There are about three patterns, though.

She is as unattainable as the stars, so I’m a fan of hers.

I just want to watch her.

Sunflower – Post Malone, Swae Lee / Yoojung Lee Choreography
Nights With You – MØ / Yoojung Lee Choreography

https://www.youtube.com/channel/UCw8ZhLPdQ0u_Y-TLKd61hGA

タグ

about, AM, an, and, are, as, beautiful, been, bit, coolness, dance, days, each, fan, following, have, her, I'm, I've, idea, if, is, It's, Lee, like, moves, My, of, other, patterns, person, quite, sharing, sharp, She, similar, STAR, talking, that, The, There, These, thinking, though, three, timeline, To, Twitter, type, unattainable, very, what, with, women, Yoojung, You, you'll, you've, ファン,

April Fools' Day :)

2020.04.01

Logging

Today is April Fool’s Day, isn’t it? Let’s all be careful not to be deceived by lies and hoaxes. Incidentally, I think Google will also release their annual lie app.

Johnny Depp HOLLYWOOD Inspierd Hairstyle. Men´s haircut inspiration

The video is not particularly meaningful.It’s just that it was the name of a channel on YOUTUBE that has the same name as where I live.

Modern Undercut | Cool and Popular Hairstyle | Hair For Men

Click here to register your channel on YOUTUBE.
https://www.youtube.com/channel/UCN2C94LXAg1tXUVdyfz3Itw

※Postscript
Google cancels its infamous April Fools’ jokes this year
https://www.theverge.com/2020/3/27/21197260/google-cancels-april-fools-jokes-2020-coronavirus-covid19-pranks

タグ

:, , 2, , all, also, and, annual, App, April, as, be, BY, careful, channel-, click, com, day, deceived, Fools', Google, has, here, hoaxes, https, Incidentally, is, isn't, IT, It's, Itw, just, Let's, lie, lies, live, LXAg, meaningful, name, not, of, ON, particularly, register, release, same, that, The, their, think, To, Today, tXUVdyfz, UCN, video, was, where, will, www, Your, youtube,

あるキーワードをライクするTwitter API。

2019.11.06

Logging

さくらレンタルサーバー、もともとmecab(メカブ)が入っているらしい。
自動であるキーワードに対してライクする方法(Twitter API)です。
たぶん、こんなコードはなかったと思います、
過去記事「ワードプレス過去記事のツイートをボット化する方法。」と併用してお使いください。
そうでないと動きませんので…。
知り合いエンジニアさんとかに組み込んでもらってください。

<?php
function mecab_tw_like($txt="",$connection=Null){
    if(!$txt)return false;
    if(!is_object($connection))return false;
    $cmd = "echo "$txt" | mecab";
    exec($cmd, $opt, $return_ver);
    //var_dump($opt);
    foreach($opt as $key=>$val){
        $r = explode("t",$val);
        if(preg_match("/名詞/",$r[1])){
            $statuses = $connection->get(
                'search/tweets',
                array(
                    'q'                 => $r[0],
                    'count'             => '3',
                    'lang'              => 'ja',
                    'locale'            => 'ja',
                    'result_type'       => 'recent',
                    'include_entities'  => 'false'
                )
            );
            if(is_array($statuses->statuses) and $statuses->statuses){
                foreach( $statuses->statuses as $tweet ){
                    $id = $tweet->id;
                    $result = $connection->post(
                        'favorites/create',
                        array(
                            'id' => $id
                        )
                    );
                }
            }
        }
    }
}

タグ

API, cmd, connection, echo, exec, false, function, if, is, like, lt, Mecab, null, object, opt, php, quot, return, tw, Twitter, txt, ver, エンジニア, キーワード, コード, サーバー, さくら, ツイート, プレス, ボット, メカブ, ライク, レンタル, ワード, 併用, 方法, 自動, 記事, 過去,

映画、ウィンストン・チャーチル/ヒトラーから世界を救った男 (字幕版)を観ましたよ。

2019.03.09

Logging

ウィンストン・チャーチル/ヒトラーから世界を救った男 (字幕版) – 予告編

映画、ウィンストン・チャーチル/ヒトラーから世界を救った男 (字幕版)を観ましたよ。これは良かった。

成功は決定的ではなく、失敗は致命的ではない。大切なのは続ける勇気だ
Success is not final, failure is not fatal: it is the courage to continue that counts

 

タグ

5, 50, com, continue, counts, courage, failure, fatal, FINAL, is, IT, lSG, MIoE, nbsp, not, success, that, The, To, youtube, ウィンストン, コレ, チャーチル, ヒトラー, 世界, 勇気, 大切, 失敗, 字幕, 成功, 映画, ,

Gmail未読一括既読、最終形態みたいなものです。

2018.07.15

Logging


Gmail未読一括既読、最終形態みたいなものです。
どうぞ、お使いください。
前回のプログラムをトリガー呼び出すと下記のエラーが表示されますが
今回のコードを実行してもプログラムエラーは表示されません。
よって未読メールから既読メールになります。

[object Object] を (class) に変換できません。

前回のコードはこちらです。
見比べてみると違いがわかると思います、
ちなみにエラーで落ちていた所は、3行目になります。

function gmailbat () {
  gm = GmailApp.search("is:unread");
  if(gm.length){
    gm.forEach(function(m,i,a){
      if(m.isUnread()){
        m.markRead();
      }
    });
  }
  if(gm.length){
      return gmailbat();
  }
  return true;
}

タグ

class, function, function gmailbat, gm, gm.forEach, gm.length, GmailApp.search, Gmail未読一括既読, if, is, m.isUnread, m.markRead, object Object, quot, return gmailbat, return true, unread&quot, エラー, トリガー, 既読メール,

たった数行のプログラムでドツボにはまる。

2018.04.14

Logging

<?php
$command = "ls -m img";
exec($command,$val,$chk);
//imglist
$imglist = explode(",",implode("",$val));
if(is_array($imglist)){
    foreach ($imglist as $key => $value) {
        $img64[$key] = base64_encode(file_get_contents("img/".trim($value)));
        $path_parts = pathinfo($value);
        $path_parts['extension']=="jpeg"?"jpg":$path_parts['extension'];
?>
<div><a href="./img/<?=trim($value)?>"><?=$value?></a><br><img src="data:image/<?=$path_parts['extension']?>;base64,<?=$img64[$key]?>"></div>
<?php
    }
}
$obj["imglist"] = implode("\n\n",$img64);

ls -m というコマンドをPHPのexecという関数を使用し
画像リストを取得しようとしてどつぼにハマった・・・。
この関数、exec(“ls -m”)と書くと$valの中に配列として返却されるのだが、複数の配列に別れて返却される。なので一度、implodeを使用して一度、文字列に戻す必要がある。そしてカンマ区切りで再度、文字列分離する。

これでほっと一息つくとアウトだ!
配列化した値の前後に空白部分が入っていたり改行コードが入っていたりして画像を参照することが出来ないのだ。そのため、trim関数を使用して取り除く必要がある。

コマンドを使用して画像をリスト化して参照するメリットは何かと言えば数百枚の画像を列挙するときなどに高速で参照化することが出来るのだ。因みにコマンドでファイルの検索を行うという事なので本領発揮すると思います。

是非、お試しあれ。

タグ

-Command, -m, , 39, 64, array, as, base, chk, contents, encode, exec, explode, extension, file, foreach, GET, gt, if, img, imglist, implode, is, jpeg, jpg, key, ls, lt, parts, path, pathinfo, php, quot, trim, val, value, ドツボ, プログラム, 数行,