1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PEAR PHP go-pear.phar 改竄 ハッシュ確認用

Last updated at Posted at 2019-01-22

上記、問題あったらしいので確認用です。
間違いあったらコメントください。

コメントにご指摘ございましたので、記事を少々変更いたします。
公式リポジットリより、PEARをcloneし、go-pear.pharファイルのハッシュ値を比較します。

##公式リポジトリよりPEARをclone

terminal
git clone git@github.com:pear/pearweb_phars.git

##確認用スクリプト作成
https://gist.github.com/yasuken1990/9a612b62fa799aff7ec051269eb6bf91

pearCheck.php
<?php

const COMPLETE_MESSAGE = 'OK';
const ERROR_MESSAGE = 'NG';

echo checkMd5Files($argv[1], $argv[2]);

function checkMd5Files($basePath, $targetPath) {
    $baseHash = md5_file($basePath);
    $targetHash = md5_file($targetPath);
    if ($baseHash === $targetHash) {
        return COMPLETE_MESSAGE;
    } else {
        return ERROR_MESSAGE ;
    }
}

##cloneしたgo-pear.pharと、環境に設置しているgo-pear.pharを比較

terminal
// 実行例: php check.php pearweb_phars/go-pear.phar go-pear.phar 
php pearCheck.php basePath targetPath

// ハッシュ値が同じ場合 OK
// ハッシュ値が違う場合 NG
1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?