

वर्डप्रेस प्लगइन्स/थीम्स (और PHP) के लिए एक स्थैतिक कोड विश्लेषण
बस रिपॉज़िटरी को क्लोन करें, आवश्यकताएँ स्थापित करें और स्क्रिप्ट चलाएँ
$ git clone https://github.com/webarx-security/wpbullet wpbullet$ cd wpbullet$ pip install -r requirements.txt$ python wpbullet.pyउपलब्ध विकल्प:
--path (required) सिस्टम पथ या डाउनलोड URL
उदाहरण:
--path="/path/to/plugin"
--path="https://wordpress.org/plugins/example-plugin"
--path="https://downloads.wordpress.org/plugin/example-plugin.1.5.zip"
--enabled (optional) केवल दिए गए मॉड्यूलों की जाँच करें, उदा. --enabled="SQLInjection,CrossSiteScripting"
--disabled (optional) दिए गए मॉड्यूलों की जाँच न करें, उदा. --disabled="SQLInjection,CrossSiteScripting"
--cleanup (optional) दूरस्थ रूप से डाउनलोड किए गए प्लगइन को स्कैन करने के बाद .temp फ़ोल्डर की सामग्री स्वचालित रूप से हटाएँ (boolean)
--report (optional) परिणाम को reports/ निर्देशिका में JSON प्रारूप में सहेजें (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"
]
Regex पैटर्न 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(self.user_input) + ").*)"
return pattern
यूनिट टेस्ट चलाना: $ python3 -m unittest