
WordPressのプラグインとテーマ向けの静的コード分析スキャナ。モジュール式で拡張可能なパターンマッチングエンジンにより、XSSやSQL injectionなどの脆弱性を検出し、重大度評価とJSONレポートを提供します。

WordPressプラグイン/テーマ(およびPHP)向け静的コード解析ツール
リポジトリをクローンし、依存関係をインストールしてスクリプトを実行するだけです。
$ git clone https://github.com/webarx-security/wpbullet wpbullet$ cd wpbullet$ pip install -r requirements.txt$ python wpbullet.py利用可能なオプション:
--path (必須) システムパスまたはダウンロードURL
例:
--path="/path/to/plugin"
--path="https://wordpress.org/plugins/example-plugin"
--path="https://downloads.wordpress.org/plugin/example-plugin.1.5.zip"
--enabled (任意) 指定したモジュールのみチェック(例: --enabled="SQLInjection,CrossSiteScripting")
--disabled (任意) 指定したモジュールをチェックしない(例: --disabled="SQLInjection,CrossSiteScripting")
--cleanup (任意) リモートからダウンロードしたプラグインをスキャン後、.tempフォルダの内容を自動的に削除する(真偽値)
--report (任意) 結果を reports/ ディレクトリにJSON形式で保存する(真偽値)
$ python wpbullet.py --path="/var/www/wp-content/plugins/plugin-name"
モジュールの作成は柔軟に行え、各モジュールで BaseClass メソッドのオーバーライドや独自メソッドの追加が可能です。
Modules ディレクトリ内の各モジュールは core.modules.BaseClass のプロパティとメソッドを実装しています。そのため、各モジュールに必要なパラメータは BaseClass のみです。
モジュールを作成したら、modules/__init__.py にインポートする必要があります。モジュールが正しく読み込まれるためには、モジュール名とクラス名を統一する必要があります。
新規モジュール追加のプルリクエストを送信する場合は、そのモジュールの単体テストも併せて提供してください。
Modules/ExampleVulnerability.py
from core.modules import BaseClass
class ExampleVulnerability(object):
# Vulnerability name
name = "Cross-site Scripting"
# Vulnerability severity
severity = "Low-Medium"
# Functions causing vulnerability
functions = [
"print"
"echo"
]
# Functions/regex that prevent exploitation
blacklist = [
"htmlspecialchars",
"esc_attr"
]
正規表現パターンは core.modules.BaseClass.build_pattern で生成されるため、各モジュールクラスでオーバーライドできます。
Modules/ExampleVulnerability.py
import copy
...
# Build dynamic regex pattern to locate vulnerabilities in given content
def build_pattern(self, content, file):
user_input = copy.deepcopy(self.user_input)
variables = self.get_input_variables(self, content)
if variables:
user_input.extend(variables)
if self.blacklist:
blacklist_pattern = r"(?!(\s?)+(.*(" + '|'.join(self.blacklist) + ")))"
else:
blacklist_pattern = ""
self.functions = [self.functions_prefix + x for x in self.functions]
pattern = r"((" + '|'.join(self.functions) + ")\s{0,}\(?\s{0,1}" + blacklist_pattern + ".*(" + '|'.join(user_input) + ").*)"
return pattern
単体テストの実行: $ python3 -m unittest