

WordPress 플러그인/테마(및 PHP)를 위한 정적 코드 분석
저장소를 클론하고, 요구 사항을 설치한 다음, 스크립트를 실행하기만 하면 됩니다.
$ git clone https://github.com/webarx-security/wpbullet wpbullet$ cd wpbullet$ pip install -r requirements.txt$ python wpbullet.py사용 가능한 옵션:
--path (required) System path or download URL
Examples:
--path="/path/to/plugin"
--path="https://wordpress.org/plugins/example-plugin"
--path="https://downloads.wordpress.org/plugin/example-plugin.1.5.zip"
--enabled (optional) Check only for given modules, ex. --enabled="SQLInjection,CrossSiteScripting"
--disabled (optional) Don't check for given modules, ex. --disabled="SQLInjection,CrossSiteScripting"
--cleanup (optional) Automatically remove content of .temp folder after scanning remotely downloaded plugin (boolean)
--report (optional) Saves result inside reports/ directory in JSON format (boolean)
$ 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