Codebase list faraday-plugins / c19a85b
Update upstream source from tag 'upstream/1.7.0' Update to upstream version '1.7.0' with Debian dir 7a72ff5616b6e6d998e6dd485188405e88bbdc4c Sophie Brun 1 year, 7 months ago
124 changed file(s) with 1079 addition(s) and 739 deletion(s). Raw diff Collapse all Expand all
4949 script:
5050 - pip3 install bandit
5151 - mkdir /results
52 - "bandit -r ${CI_PROJECT_DIR} -o /results/output.xml -f xml"
52 - "bandit -r ${CI_PROJECT_DIR} -o /results/output.xml -f xml --skip B410,B320,B310,B314,B404,B405,B324,B603,B104,B110,B112,B101"
5353 after_script:
5454 - curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add -
5555 - apt update
6363 - if [[ $(grep -c testcase /results/output.xml) -gt 0 ]]; then (faraday-cli auth -f $FARADAY_URL -u $FARADAY_USER -p $FARADAY_PASSWORD && faraday-cli tool report /results/output.xml -w $DEVSECOPS_WORKSPACE --tag-vuln $CI_PROJECT_NAME --tag-vuln $CI_COMMIT_REF_NAME); else (echo 'no vulns dettected' && exit 0); fi
6464 rules:
6565 - when: on_success
66 allow_failure: true
6766
6867 flake8:
6968 image: python:3
0 Add CWE to PluginBase. The plugins that have this implemented are the following:
1 "Acunetix",
2 "Acunetix_Json",
3 "AppSpider",
4 "Appscan",
5 "Arachni",
6 "Burp",
7 "Checkmarx",
8 "Metasploit",
9 "Nessus",
10 "Netsparker",
11 "NetsparkerCloud",
12 "Openvas",
13 "QualysWebapp",
14 "W3af",
15 "Wapiti",
16 "Zap",
17 "Zap_Json",
18 "nuclei",
19 "nuclei_legacy"
0 Now the nexts pluggins extracts cvss from reports:
1
2 - Acunetix
3 - Acunetix_Json
4 - Appscan
5 - Nessus
6 - Netsparker
7 - NexposeFull
8 - Nipper
9 - Nmap
10 - Openvas
11 - QualysWebapp
12 - Qualysguard
13 - Retina
14 - shodan
15 - whitesource
0 Add arguments for add tags for vulns, services and host.
1
2 Add test for tags and ignore_info
0 Add trivy's json plugin
0 Add command support for the wpscan plugin
0 [MOD] Now refs field is a list of dictionary with the format:
1 {'name': string, 'type': string},
0 Sep 5th, 2022
0 Fix for acunetix_json when host is ip
0 [FIX] - Asset duplicated on same file with multiple entries for Appscan_csv plugin.
0 [FIX] Change import dateutil to from dateutil.parser import parse
1 for compatibility issues with python 3.10
0 [FIX] Add case for Netsparker plugins, when the url has a number inside a parenthesis.
0 Add *args **kwargs to syhunt plugin
0 fix bug when grype report has no arifact/metadata
0 [MOD] Now prowler plugin returns CAF Epic as policy violation and
1 remove [check#] from tittle
0 1.7.0 [Sep 5th, 2022]:
1 ---
2 * Add CWE to PluginBase. The plugins that have this implemented are the following:
3 "Acunetix",
4 "Acunetix_Json",
5 "AppSpider",
6 "Appscan",
7 "Arachni",
8 "Burp",
9 "Checkmarx",
10 "Metasploit",
11 "Nessus",
12 "Netsparker",
13 "NetsparkerCloud",
14 "Openvas",
15 "QualysWebapp",
16 "W3af",
17 "Wapiti",
18 "Zap",
19 "Zap_Json",
20 "nuclei",
21 "nuclei_legacy"
22 * Now the nexts pluggins extracts cvss from reports:
23
24 - Acunetix
25 - Acunetix_Json
26 - Appscan
27 - Nessus
28 - Netsparker
29 - NexposeFull
30 - Nipper
31 - Nmap
32 - Openvas
33 - QualysWebapp
34 - Qualysguard
35 - Retina
36 - shodan
37 - whitesource
38 * Add arguments for add tags for vulns, services and host.
39
40 Add test for tags and ignore_info
41 * Add trivy's json plugin
42 * Add command support for the wpscan plugin
43 * [MOD] Now refs field is a list of dictionary with the format:
44 {'name': string, 'type': string},
45 * Fix for acunetix_json when host is ip
46 * [FIX] - Asset duplicated on same file with multiple entries for Appscan_csv plugin.
47 * [FIX] Change import dateutil to from dateutil.parser import parse
48 for compatibility issues with python 3.10
49 * [FIX] Add case for Netsparker plugins, when the url has a number inside a parenthesis.
50 * Add *args **kwargs to syhunt plugin
51 * fix bug when grype report has no arifact/metadata
52 * [MOD] Now prowler plugin returns CAF Epic as policy violation and
53 remove [check#] from tittle
54
055 1.6.8 [Jul 25th, 2022]:
156 ---
257 * Add appscan csv
44 ```python
55 class XXXPLugin(PluginXMLFormat):
66
7 def __init__(self):
8 super().__init__()
7 def __init__(self, *args, **kwargs):
8 super().__init__(*args, **kwargs)
99 # Tags to be compared with the xml mail tag, can be a list or a string
10 self.identifier_tag = ["tag1", "tag2"]
10 self.identifier_tag = ["tag1", "tag2"]
1111 self.id = 'SOME_PLUGIN_ID' # Can't be repeated
1212 self.name = 'Some plugin name'
1313 self.plugin_version = 'X.X'
1414 # The extension is optional, only if its different than xml
15 self.extension = ".xxx"
15 self.extension = ".xxx"
1616 ```
1717
1818 > JSON report plugin
2020 ```python
2121 class XXXPLugin(PluginJsonFormat):
2222
23 def __init__(self):
24 super().__init__()
23 def __init__(self, *args, **kwargs):
24 super().__init__(*args, **kwargs)
2525 # keys of the json that identify the report
2626 # you don't need to put all the keys, just some of them
2727 # it must be a set and will be compared as a subset of the json report keys
3030 self.name = 'Some plugin name'
3131 self.plugin_version = 'X.X'
3232 # The extension is optional, only if its different than json
33 self.extension = ".xxx"
34 ```
33 self.extension = ".xxx"
34 ```
0 __version__ = '1.6.8'
0 __version__ = '1.7.0'
6565 @click.option('-o', '--output-file', type=click.Path(exists=False))
6666 @click.option('--ignore-info', is_flag=True, help="Ignore information vulnerabilities")
6767 @click.option('-drh', '--dont-resolve-hostname', is_flag=True, help="Dont resolve hostname", default=False)
68 @click.option('--vuln-tag', help="Vuln tag", default=None)
69 @click.option('--service-tag', help="Service tag", default=None)
70 @click.option('--host-tag', help="Host tag", default=None)
6871 def process_report(report_file, plugin_id, custom_plugins_folder, summary, output_file, ignore_info,
69 dont_resolve_hostname):
72 dont_resolve_hostname, vuln_tag, service_tag, host_tag):
7073 if not os.path.isfile(report_file):
7174 click.echo(click.style(f"File {report_file} Don't Exists", fg="red"), err=True)
7275 else:
73 plugins_manager = PluginsManager(custom_plugins_folder, ignore_info=ignore_info,
74 hostname_resolution=not dont_resolve_hostname)
76 plugins_manager = PluginsManager(custom_plugins_folder,
77 ignore_info=ignore_info,
78 hostname_resolution=not dont_resolve_hostname,
79 vuln_tag=vuln_tag,
80 service_tag=service_tag,
81 host_tag=host_tag)
7582 analyzer = ReportAnalyzer(plugins_manager)
7683 if plugin_id:
7784 plugin = plugins_manager.get_plugin(plugin_id)
104111 @click.option('-sh', '--show-output', is_flag=True)
105112 @click.option('--ignore-info', is_flag=True, help="Ignore information vulnerabilities")
106113 @click.option('--hostname-resolution', is_flag=True, help="Resolve hostname")
114 @click.option('--vuln-tag', help="Vuln tag", default=None)
115 @click.option('--service-tag', help="Service tag", default=None)
116 @click.option('--host-tag', help="Host tag", default=None)
107117 def process_command(command, plugin_id, custom_plugins_folder, dont_run, summary, output_file, show_output,
108 ignore_info, hostname_resolution):
109 plugins_manager = PluginsManager(custom_plugins_folder, ignore_info=ignore_info,
110 hostname_resolution=hostname_resolution)
118 ignore_info, hostname_resolution, vuln_tag, service_tag, host_tag):
119 plugins_manager = PluginsManager(custom_plugins_folder,
120 ignore_info=ignore_info,
121 hostname_resolution=hostname_resolution,
122 vuln_tag=vuln_tag,
123 service_tag=service_tag,
124 host_tag=host_tag)
111125 analyzer = CommandAnalyzer(plugins_manager)
112126 if plugin_id:
113127 plugin = plugins_manager.get_plugin(plugin_id)
8282 main_tag = elem.tag
8383 try:
8484 main_tag_attributes = elem.attrib
85 except:
85 except AttributeError:
8686 pass
8787 break
8888 logger.debug("Found XML content on file: %s - Main tag: %s Attributes: %s", report_path, main_tag,
151151
152152 class PluginsManager:
153153
154 def __init__(self, custom_plugins_folder=None, ignore_info=False, hostname_resolution=True):
155 self.ignore_info = ignore_info
156 self.hostname_resolution = hostname_resolution
154 def __init__(self, custom_plugins_folder=None, **kwargs):
155 self.kwargs = kwargs
157156 self.plugins = {}
158157 self.plugin_modules = {}
159158 self._load_plugins(custom_plugins_folder)
216215 plugin = None
217216 plugin_id = plugin_id.lower()
218217 if plugin_id in self.plugin_modules:
219 plugin = self.plugin_modules[plugin_id].createPlugin(self.ignore_info, self.hostname_resolution)
218 plugin = self.plugin_modules[plugin_id].createPlugin(**self.kwargs)
220219 else:
221220 logger.debug("Unknown Plugin: %s", plugin_id)
222221 return plugin
224223 def get_plugins(self):
225224 for plugin_id, plugin_module in self.plugin_modules.items():
226225 logger.debug("Instance Plugin: %s", plugin_id)
227 yield plugin_id, plugin_module.createPlugin(self.ignore_info, self.hostname_resolution)
226 yield plugin_id, plugin_module.createPlugin(**self.kwargs)
1616 from datetime import datetime
1717 from pathlib import Path
1818 import socket
19 from typing import List
1920
2021 # Related third party imports
2122 import pytz
2223 import simplejson as json
2324
2425 # Local application imports
25 from faraday_plugins.plugins.plugins_utils import its_cve
26 from faraday_plugins.plugins.plugins_utils import its_cve, its_cwe
2627
2728 logger = logging.getLogger("faraday").getChild(__name__)
2829
3435 # TODO: Add class generic identifier
3536 class_signature = "PluginBase"
3637
37 def __init__(self, ignore_info=False, hostname_resolution=True, *args, **kwargs):
38 def __init__(self, *args, **kwargs):
3839 # Must be unique. Check that there is not
3940 # an existent plugin with the same id.
4041 # TODO: Make script that list current ids.
41 self.ignore_info = ignore_info
42 self.hostname_resolution = hostname_resolution
42 self.ignore_info = kwargs.get("ignore_info", False)
43 self.hostname_resolution = kwargs.get("hostname_resolution", True)
44 self.vuln_tag = kwargs.get("vuln_tag", None)
45 self.host_tag = kwargs.get("host_tag", None)
46 self.service_tag = kwargs.get("service_tag", None)
47 self.default_vuln_tag = None
4348 self.id = None
4449 self.auto_load = True
4550 self._rid = id(self)
8792 def resolve_hostname(self, hostname):
8893 if not self.hostname_resolution:
8994 return hostname
95 if not hostname:
96 self.logger.error(f"Hostname provided is None or Empty {hostname}, using 0.0.0.0 as ip")
97 return "0.0.0.0"
9098 try:
9199 socket.inet_aton(hostname) # is already an ip
92100 return hostname
373381 tags = []
374382 if isinstance(tags, str):
375383 tags = [tags]
384 if self.host_tag:
385 if isinstance(self.host_tag, list):
386 tags += self.host_tag
387 else:
388 tags.append(self.host_tag)
376389 host = {"ip": name, "os": os, "hostnames": hostnames, "description": description, "mac": mac,
377390 "credentials": [], "services": [], "vulnerabilities": [], "tags": tags}
378391 host_id = self.save_host_cache(host)
394407 tags = []
395408 if isinstance(tags, str):
396409 tags = [tags]
410 if self.service_tag:
411 if isinstance(self.service_tag, list):
412 tags += self.service_tag
413 else:
414 tags.append(self.service_tag)
397415 service = {"name": name, "protocol": protocol, "port": ports, "status": status,
398416 "version": version, "description": description, "credentials": [], "vulnerabilities": [],
399417 "tags": tags}
402420
403421 return service_id
404422
423 @staticmethod
424 def modify_refs_struct(ref: List[str]) -> List[dict]:
425 """
426 Change reference struct from list of strings to a list of dicts with the form of {name, type}
427 """
428 refs = []
429 if ref:
430 refs = [{'name': url, 'type': 'other'} for url in ref]
431 return refs
432
405433 def createAndAddVulnToHost(self, host_id, name, desc="", ref=None,
406434 severity="", resolution="", data="", external_id=None, run_date=None,
407435 impact=None, custom_fields=None, status="", policyviolations=None,
408 easeofresolution=None, confirmed=False, tags=None, cve=None):
409 if ref is None:
410 ref = []
436 easeofresolution=None, confirmed=False, tags=None, cve=None, cwe=None, cvss2=None,
437 cvss3=None):
438
439 ref = self.modify_refs_struct(ref)
411440 if status == "":
412441 status = "open"
413442 if impact is None:
420449 tags = []
421450 if isinstance(tags, str):
422451 tags = [tags]
452 if self.vuln_tag:
453 if isinstance(self.vuln_tag, list):
454 tags += self.vuln_tag
455 else:
456 tags.append(self.vuln_tag)
457 if self.default_vuln_tag:
458 if isinstance(self.default_vuln_tag, list):
459 tags += self.default_vuln_tag
460 else:
461 tags.append(self.default_vuln_tag)
423462 if cve is None:
424463 cve = []
425464 elif type(cve) is str:
426465 cve = [cve]
427466 cve = its_cve(cve)
467 if cwe is None:
468 cwe = []
469 elif type(cwe) is str:
470 cwe = [cwe]
471 cwe = its_cwe(cwe)
472 if cvss2 is None:
473 cvss2 = {}
474 if cvss3 is None:
475 cvss3 = {}
428476 vulnerability = {"name": name, "desc": desc, "severity": self.normalize_severity(severity), "refs": ref,
429477 "external_id": external_id, "type": "Vulnerability", "resolution": resolution, "data": data,
430478 "custom_fields": custom_fields, "status": status, "impact": impact,
431 "policyviolations": policyviolations, "cve": cve,
432 "confirmed": confirmed, "easeofresolution": easeofresolution, "tags": tags
479 "policyviolations": policyviolations, "cve": cve, "cvss3": cvss3, "cvss2": cvss2,
480 "confirmed": confirmed, "easeofresolution": easeofresolution, "tags": tags, "cwe": cwe
433481 }
434482 if run_date:
435483 vulnerability["run_date"] = self.get_utctimestamp(run_date)
439487 def createAndAddVulnToService(self, host_id, service_id, name, desc="",
440488 ref=None, severity="", resolution="", data="", external_id=None, run_date=None,
441489 custom_fields=None, policyviolations=None, impact=None, status="",
442 confirmed=False, easeofresolution=None, tags=None, cve=None):
443 if ref is None:
444 ref = []
490 confirmed=False, easeofresolution=None, tags=None, cve=None, cwe=None,cvss2=None,
491 cvss3=None):
492 ref = self.modify_refs_struct(ref)
445493 if status == "":
446494 status = "open"
447495 if impact is None:
454502 tags = []
455503 if isinstance(tags, str):
456504 tags = [tags]
505 if self.vuln_tag:
506 if isinstance(self.vuln_tag, list):
507 tags += self.vuln_tag
508 else:
509 tags.append(self.vuln_tag)
510 if self.default_vuln_tag:
511 if isinstance(self.default_vuln_tag, list):
512 tags += self.default_vuln_tag
513 else:
514 tags.append(self.default_vuln_tag)
457515 if cve is None:
458516 cve = []
459517 elif type(cve) is str:
460518 cve = [cve]
461519 cve = its_cve(cve)
520 if cwe is None:
521 cwe = []
522 elif type(cwe) is str:
523 cwe = [cwe]
524 cwe = its_cwe(cwe)
525 if cvss2 is None:
526 cvss2 = {}
527 if cvss3 is None:
528 cvss3 = {}
462529 vulnerability = {"name": name, "desc": desc, "severity": self.normalize_severity(severity), "refs": ref,
463530 "external_id": external_id, "type": "Vulnerability", "resolution": resolution, "data": data,
464531 "custom_fields": custom_fields, "status": status, "impact": impact,
465 "policyviolations": policyviolations, "cve": cve,
466 "easeofresolution": easeofresolution, "confirmed": confirmed, "tags": tags
532 "policyviolations": policyviolations, "cve": cve, "cvss3": cvss3, "cvss2": cvss2,
533 "easeofresolution": easeofresolution, "confirmed": confirmed, "tags": tags, "cwe": cwe
467534 }
468535 if run_date:
469536 vulnerability["run_date"] = self.get_utctimestamp(run_date)
477544 params="", query="", category="", data="", external_id=None,
478545 confirmed=False, status="", easeofresolution=None, impact=None,
479546 policyviolations=None, status_code=None, custom_fields=None, run_date=None,
480 tags=None, cve=None):
547 tags=None, cve=None, cvss2=None, cvss3=None, cwe=None):
481548 if params is None:
482549 params = ""
483 if response is None:
484 response = ""
485550 if method is None:
486551 method = ""
487552 if pname is None:
488553 pname = ""
489 if params is None:
490 params = ""
491554 if query is None:
492555 query = ""
493556 if website is None:
498561 request = ""
499562 if response is None:
500563 response = ""
501 if ref is None:
502 ref = []
564 ref = self.modify_refs_struct(ref)
503565 if status == "":
504566 status = "open"
505567 if impact is None:
512574 tags = []
513575 if isinstance(tags, str):
514576 tags = [tags]
577 if self.vuln_tag:
578 if isinstance(self.vuln_tag, list):
579 tags += self.vuln_tag
580 else:
581 tags.append(self.vuln_tag)
582 if self.default_vuln_tag:
583 if isinstance(self.default_vuln_tag, list):
584 tags += self.default_vuln_tag
585 else:
586 tags.append(self.default_vuln_tag)
515587 if cve is None:
516588 cve = []
517589 elif type(cve) is str:
518590 cve = [cve]
519591 cve = its_cve(cve)
592 if cwe is None:
593 cwe = []
594 elif type(cwe) is str:
595 cwe = [cwe]
596 cwe = its_cwe(cwe)
597 if cvss2 is None:
598 cvss2 = {}
599 if cvss3 is None:
600 cvss3 = {}
520601 vulnerability = {"name": name, "desc": desc, "severity": self.normalize_severity(severity), "refs": ref,
521602 "external_id": external_id, "type": "VulnerabilityWeb", "resolution": resolution,
522603 "data": data, "website": website, "path": path, "request": request, "response": response,
523604 "method": method, "pname": pname, "params": params, "query": query, "category": category,
524605 "confirmed": confirmed, "status": status, "easeofresolution": easeofresolution,
525 "impact": impact, "policyviolations": policyviolations, "cve": cve,
526 "status_code": status_code, "custom_fields": custom_fields, "tags": tags}
606 "impact": impact, "policyviolations": policyviolations, "cve": cve, "cvss3": cvss3,
607 "cvss2": cvss2, "status_code": status_code, "custom_fields": custom_fields, "tags": tags,
608 "cwe": cwe}
527609 if run_date:
528610 vulnerability["run_date"] = self.get_utctimestamp(run_date)
529611 vulnerability_id = self.save_service_vuln_cache(host_id, service_id, vulnerability)
580662 vuln_copy = vuln.copy()
581663 for field in VULN_SKIP_FIELDS_TO_HASH:
582664 vuln_copy.pop(field, None)
583 dict_hash = hashlib.sha1(json.dumps(vuln_copy).encode()).hexdigest()
665 dict_hash = hashlib.sha1(json.dumps(vuln_copy).encode()).hexdigest() # nosec
584666 summary['vuln_hashes'].append(dict_hash)
585667 return summary
586668
587669
588670 # TODO Borrar
589671 class PluginTerminalOutput(PluginBase):
590 def __init__(self):
591 super().__init__()
672 def __init__(self, *args, **kwargs):
673 super().__init__(*args, **kwargs)
592674
593675 def processOutput(self, term_output):
594676 try:
599681
600682 # TODO Borrar
601683 class PluginCustomOutput(PluginBase):
602 def __init__(self):
603 super().__init__()
684 def __init__(self, *args, **kwargs):
685 super().__init__(*args, **kwargs)
604686
605687 def processOutput(self, term_output):
606688 # we discard the term_output since it's not necessary
609691
610692
611693 class PluginByExtension(PluginBase):
612 def __init__(self, ignore_info=False, hostname_resolution=True, *args, **kwargs):
613 super().__init__(ignore_info, hostname_resolution)
694 def __init__(self, *args, **kwargs):
695 super().__init__(*args, **kwargs)
614696 self.extension = []
615697
616698 def report_belongs_to(self, extension="", **kwargs):
625707
626708 class PluginXMLFormat(PluginByExtension):
627709
628 def __init__(self, ignore_info=False, hostname_resolution=True, *args, **kwargs):
629 super().__init__(ignore_info, hostname_resolution)
710 def __init__(self, *args, **kwargs):
711 super().__init__(*args, **kwargs)
630712 self.identifier_tag = []
631713 self.identifier_tag_attributes = {}
632714 self.extension = ".xml"
647729
648730 class PluginJsonFormat(PluginByExtension):
649731
650 def __init__(self, ignore_info=False, hostname_resolution=True, *args, **kwargs):
651 super().__init__(ignore_info, hostname_resolution)
732 def __init__(self, *args, **kwargs):
733 super().__init__(*args, **kwargs)
652734 self.json_keys = set()
653735 self.extension = ".json"
654736
664746
665747 class PluginMultiLineJsonFormat(PluginByExtension):
666748
667 def __init__(self, ignore_info=False, hostname_resolution=True, *args, **kwargs):
668 super().__init__(ignore_info, hostname_resolution)
749 def __init__(self, *args, **kwargs):
750 super().__init__(*args, **kwargs)
669751 self.json_keys = set()
670752 self.extension = ".json"
671753
688770
689771 class PluginCSVFormat(PluginByExtension):
690772
691 def __init__(self, ignore_info=False, hostname_resolution=True, *args, **kwargs):
692 super().__init__(ignore_info, hostname_resolution)
773 def __init__(self, *args, **kwargs):
774 super().__init__(*args, **kwargs)
693775 self.extension = ".csv"
694776 self.csv_headers = set()
695777
708790
709791 class PluginZipFormat(PluginByExtension):
710792
711 def __init__(self, ignore_info=False, hostname_resolution=True, *args, **kwargs):
712 super().__init__(ignore_info, hostname_resolution)
793 def __init__(self, *args, **kwargs):
794 super().__init__(*args, **kwargs)
713795 self.extension = ".zip"
714796 self.files_list = set()
715797
1212
1313 SERVICE_MAPPER = None
1414 CVE_regex = re.compile(r'CVE-\d{4}-\d{4,7}')
15 CWE_regex = re.compile(r'CWE-\d{1,4}')
1516 logger = logging.getLogger(__name__)
1617
1718
116117 def its_cve(cves: list):
117118 r = [cve for cve in cves if CVE_regex.match(cve)]
118119 return r
120
121
122 def its_cwe(cwes: list):
123 r = [cwe for cwe in cwes if CWE_regex.match(cwe)]
124 return r
00 from typing import List
1
1 import re
22
33 class Technicaldetails:
44 def __init__(self, node):
4545
4646 @property
4747 def id_attr(self) -> str:
48 return self.node.findtext('id', '')
48 return self.node.attrib.get('id', '')
4949
5050 @property
5151 def text(self) -> str:
52 return self.node.findtext('#text', '')
52 return self.node.text
5353
5454
5555 class Cwelist:
7171
7272 @property
7373 def score(self) -> str:
74 return self.node.findtext('Score', '')
74 if self.node is None:
75 return ''
76 return self.node.findtext('Score')
7577
7678 @property
7779 def av(self) -> str:
120122
121123 @property
122124 def score(self) -> str:
123 return self.node.findtext('Score', '')
125 return self.node.findtext('Score')
124126
125127 @property
126128 def tempscore(self):
139139
140140 def create_vul(self, item, h_id, s_id, url_data):
141141 description = item.description
142 cvss3 = {}
143 if item.cvss3.node is not None:
144 cvss3['vector_string'] = item.cvss3.descriptor
145 cvss2 = {}
146 if item.cvss.node is not None:
147 cvss2['vector_string'] = item.cvss.descriptor
142148 if item.affects:
143149 description += f'\nPath: {item.affects}'
144150 if item.parameter:
146152 try:
147153 cve = [item.cvelist.cve.text if item.cvelist.cve else ""]
148154 except Exception:
149 cve = [""]
155 cve = []
156 try:
157 cwe = [item.cwelist.cwe.text if item.cwelist.cwe else ""]
158 except:
159 cwe = []
150160 self.createAndAddVulnWebToService(
151161 h_id,
152162 s_id,
160170 request=item.technicaldetails.request,
161171 response=item.technicaldetails.response,
162172 ref=[i.url for i in item.references.reference],
163 cve=cve)
173 cve=cve,
174 cwe=cwe,
175 cvss2=cvss2,
176 cvss3=cvss3)
164177
165178 @staticmethod
166179 def get_domain(scan: Scan):
173186 return url_data
174187
175188
176 def createPlugin(ignore_info=False, hostname_resolution=True):
177 return AcunetixPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
189 def createPlugin(*args, **kwargs):
190 return AcunetixPlugin(*args, **kwargs)
00 from typing import List
1
1 import re
22
33 class InfoVul:
44 def __init__(self, node):
1515 if not self.node:
1616 return ''
1717 return self.node.get('request', '')
18
19
1820
1921
2022 class Vulnerabilities:
7274
7375 @property
7476 def use_ssl(self) -> bool:
77 if not self.node:
78 return ''
7579 return self.node.get('use_ssl', '')
80
81 @property
82 def tags(self) -> list:
83 if not self.node:
84 return ['']
85 return self.node.get('tags', [''])
86
87 def cvss_score(self) -> str:
88 return self.node.get('cvss_score')
89
90 @property
91 def cvss2_vector(self) -> str:
92 return self.node.get('cvss2', '')
93
94 @property
95 def cvss3_vector(self) -> str:
96 return self.node.get('cvss3', '')
7697
7798
7899 class Info:
85106 return ''
86107 return self.node.get('host', '')
87108
109 @property
110 def start_url(self) -> str:
111 if not self.node:
112 return ''
113 return self.node.get('start_url', '')
88114
89115 class Scan:
90116 def __init__(self, node):
124150
125151 @property
126152 def export(self) -> Export:
127 return Export(self.node.get('export'))
153 return Export(self.node.get('export'))
44
55 """
66 from urllib.parse import urlsplit
7 import ipaddress
78
89 from lxml import etree
910
2122
2223 from faraday_plugins.plugins.repo.acunetix_json.DTO import AcunetixJsonParser, Vulnerabilities, \
2324 VulnerabilityTypes
25 from faraday_plugins.plugins.plugins_utils import its_cwe
2426
2527
2628 class AcunetixXmlParser:
9193
9294 def new_structure(self, site: Scan):
9395 start_url = site.info.host
96 if site.info.start_url:
97 start_url = site.info.start_url
9498 url_data = urlsplit(start_url)
9599 site_ip = self.resolve_hostname(url_data.hostname)
96100 ports = '443' if (url_data.scheme == 'https') else '80'
105109 status='open')
106110 for i in site.vulnerabilities:
107111 vul_type = vulnerability_type[i.info.vt_id]
108 self.create_vul(i, vul_type, h_id, s_id, url_data)
112 cwe = its_cwe(vul_type.tags)
113 self.create_vul(i, vul_type, h_id, s_id, url_data, cwe)
109114
110 def create_vul(self, vul: Vulnerabilities, vul_type: VulnerabilityTypes, h_id, s_id, url_data):
115 def create_vul(self, vul: Vulnerabilities, vul_type: VulnerabilityTypes, h_id, s_id, url_data, cwe):
116 cvss3 = {
117 'vector_string': vul_type.cvss3_vector
118 }
119 cvss2 = {
120 'vector_string': vul_type.cvss2_vector
121 }
111122 self.createAndAddVulnWebToService(
112123 h_id,
113124 s_id,
117128 severity=vul_type.severity,
118129 resolution=vul_type.recommendation,
119130 request=vul.info.request,
120 response=vul.response)
131 response=vul.response,
132 cwe=cwe,
133 cvss3=cvss3,
134 cvss2=cvss2
135 )
121136
122137 @staticmethod
123138 def get_domain(scan: Scan):
130145 return url_data
131146
132147
133 def createPlugin(ignore_info=False, hostname_resolution=True):
134 return AcunetixJsonPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
148 def createPlugin(*args, **kwargs):
149 return AcunetixJsonPlugin(*args, **kwargs)
136136 return final
137137
138138
139 def createPlugin(ignore_info=False, hostname_resolution=True):
140 return AmapPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
139 def createPlugin(*args, **kwargs):
140 return AmapPlugin(*args, **kwargs)
123123 else item.find("variant-group/item/test-http-traffic").text
124124 response = "" if item.find("variant-group/item/issue-information/testResponseChunk") is None \
125125 else item.find("variant-group/item/issue-information/testResponseChunk").text
126 cvss = None if item.find("cvss-score") is None else f"CVSS: {item.find('cvss-score').text}"
127 cvss_base_vector = None if item.find('cvss-vector/base-vector') is None \
128 else f"CVSS-base-vector: {item.find('cvss-vector/base-vector').text}"
126 cvss2 = item.find('cvss-score').text if item.find("cvss-score") is not None else None
127 cvss2_base_vector = item.find('cvss-vector/base-vector').text if item.find('cvss-vector/base-vector') \
128 is not None else None
129129 cvss_temporal_vector = None if item.find('cvss-vector/temporal-vector') is None \
130130 else f"CVSS-temporal-vector: {item.find('cvss-vector/temporal-vector').text}"
131131 cvss_environmental_vector = None if item.find('cvss-vector/environmental-vector') is None \
157157 "response": response,
158158 "website": entity['website'],
159159 "path": entity['path'],
160 "cve": []
160 "cve": [],
161 "cwe": [],
162 "cvss2": {}
161163 }
162164 if cve:
163165 issue_data["cve"].append(cve)
165167 if cve_url:
166168 issue_data["ref"].append(cve_url)
167169 if cwe:
168 issue_data["ref"].append(f"CWE: {cwe}")
169 if cvss:
170 issue_data["ref"].append(cvss)
171 if cvss_base_vector:
172 issue_data["ref"].append(cvss_base_vector)
170 issue_data["cwe"].append(f"CWE-{cwe}")
171 if cvss2_base_vector:
172 issue_data["cvss2"]["vector_string"] = cvss2_base_vector
173173 if cvss_temporal_vector:
174174 issue_data["ref"].append(cvss_temporal_vector)
175175 if cvss_environmental_vector:
190190 if fix_id:
191191 fix = self.fixes[fix_id]
192192 resolution = f"{resolution}\nLibrary: {fix['library']}\nLocation: {fix['location']}"
193 cvss = None if item.find("cvss-score") is None else f"CVSS: {item.find('cvss-score').text}"
194 cvss_base_vector = None if item.find('cvss-vector/base-vector') is None \
195 else f"CVSS-base-vector: {item.find('cvss-vector/base-vector').text}"
193 cvss2 = item.find('cvss-score').text if item.find("cvss-score") else None
194 cvss2_base_vector = None if item.find('cvss-vector/base-vector') is None \
195 else item.find('cvss-vector/base-vector').text
196196 cvss_temporal_vector = None if item.find('cvss-vector/temporal-vector') is None \
197197 else f"CVSS-temporal-vector: {item.find('cvss-vector/temporal-vector').text}"
198198 cvss_environmental_vector = None if item.find('cvss-vector/environmental-vector') is None \
214214 "desc": description,
215215 "ref": [],
216216 "resolution": resolution,
217 "cve": []
217 "cve": [],
218 "cwe": [],
219 "cvss2": {}
218220 }
219221
220222 if cve_url:
221223 issue_data["ref"].append(cve_url)
222224 if cwe:
223 issue_data["ref"].append(f"CWE: {cwe}")
224 if cvss:
225 issue_data["ref"].append(cvss)
226 if cvss_base_vector:
227 issue_data["ref"].append(cvss_base_vector)
225 issue_data["cwe"].append(f"CWE-{cwe}")
226 if cvss2_base_vector:
227 issue_data["cvss2"]['vector_string'] = cvss2_base_vector
228228 if cvss_temporal_vector:
229229 issue_data["ref"].append(cvss_temporal_vector)
230230 if cvss_environmental_vector:
279279 self.createAndAddVulnToHost(host_id=host_id, **issue)
280280
281281
282 def createPlugin(ignore_info=False, hostname_resolution=True):
283 return AppScanPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
282 def createPlugin(*args, **kwargs):
283 return AppScanPlugin(*args, **kwargs)
55 """
66
77 from faraday_plugins.plugins.plugin import PluginCSVFormat
8 from urllib.parse import urlparse
98 from itertools import islice
109 import csv
11 import sys
12 import dateutil
10 from dateutil.parser import parse
1311
1412 __author__ = "Erodriguez"
1513 __copyright__ = "Copyright (c) 2019, Infobyte LLC"
5048 #Skip Fix Group
5149 if row["Issue Id"] == "Fix Group Attributes:":
5250 break
53 path = row['Location']
54 if not path:
55 continue
51 path = row['Source File']
52 if path == "":
53 path = row['Location']
5654 try:
57 run_date = dateutil.parser.parse(row['Date Created'])
55 run_date = parse(row['Date Created'])
5856 except:
5957 run_date = None
6058 name = row["Issue Type Name"]
6361 references.append(f"CWE-{row['Cwe']}")
6462 if row["Cve"]:
6563 references.append(row["Cve"])
64
6665 data = []
6766 if row['Security Risk']:
6867 data.append(f"Security Risk: {row['Security Risk']}")
6968 desc = [row['Description']]
69 if row['Cve']:
70 desc.append(f"Cve: {row['Cve']}")
7071 if row['Line']:
7172 desc.append(f"Line: {row['Line']}")
7273 if row['Cause']:
7374 desc.append(f"Cause: {row['Cause']}")
75 if row['Remediation']:
76 desc.append(f"Resolution: {row['Resolution']}")
7477 if row['Threat Class']:
7578 desc.append(f"Threat Class: {row['Threat Class']}")
7679 if row['Security Risk']:
7780 desc.append(f"Security Risk: {row['Security Risk']}")
7881 if row['Calling Method']:
7982 desc.append(f"Calling Method: {row['Calling Method']}")
83 if row['Location']:
84 desc.append(f"Vulnerability Line: {row['Location']}")
85
8086 h_id = self.createAndAddHost(name=path)
8187 self.createAndAddVulnToHost(
8288 h_id,
8490 desc=" \n".join(desc),
8591 resolution=row['Remediation'],
8692 external_id=row['Issue Id'],
93 cve=row['Cve'],
8794 run_date=run_date,
8895 severity=row["Severity"],
8996 ref=references,
9097 data=" \n".join(data)
9198 )
9299
93 def createPlugin(ignore_info=False, hostname_resolution=True):
94 return Appscan_CSV_Plugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
100 def createPlugin(*args, **kargs):
101 return Appscan_CSV_Plugin(*args, **kargs)
6969 data_info = []
7070
7171 for vulns in parser.vuln_list:
72
7273 vuln_name = vulns.findtext('VulnType')
7374 vuln_desc = vulns.findtext('Description')
7475 vuln_ref = vulns.findtext('VulnUrl')
7778 vuln_external_id = vulns.findtext('DbId')
7879 vuln_run_date = vulns.findtext('ScanDate')
7980 data_info.append(vulns.findtext('AttackClass'))
80 data_info.append(vulns.findtext('CweId'))
81 cwe = ["CWE-" + vulns.findtext('CweId')] if vulns.findtext('CweId') else []
8182 data_info.append(vulns.findtext('CAPEC'))
8283 data_info.append(vulns.findtext('DISSA_ASC'))
8384 data_info.append(vulns.findtext('OWASP2007'))
9798 else:
9899 severity = 10
99100
100 str_data = f'AttackClass: {data_info[0]}, CweId: {data_info[1]}, CAPEC: {data_info[2]}, ' \
101 f'DISSA_ASC: {data_info[3]}, OWASP2007: {data_info[4]}, OWASP2010: {data_info[5]}, ' \
102 f'OWASP2013: {data_info[6]}, OVAL: {data_info[7]}, WASC: {data_info[8]}'
101 str_data = f'AttackClass: {data_info[0]}, CAPEC: {data_info[1]}, ' \
102 f'DISSA_ASC: {data_info[2]}, OWASP2007: {data_info[3]}, OWASP2010: {data_info[4]}, ' \
103 f'OWASP2013: {data_info[5]}, OVAL: {data_info[6]}, WASC: {data_info[7]}'
103104
104105 if vuln_run_date is None:
105106 vuln_run_date = None
108109
109110 self.createAndAddVulnToHost(host_id=host_id, name=vuln_name, desc=vuln_desc, ref=[vuln_ref],
110111 severity=severity, resolution=vuln_resolution, run_date=vuln_run_date,
111 external_id=vuln_external_id, data=str_data)
112 external_id=vuln_external_id, data=str_data, cwe=cwe)
112113
113114
114 def createPlugin(ignore_info=False, hostname_resolution=True):
115 return AppSpiderPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
115 def createPlugin(*args, **kwargs):
116 return AppSpiderPlugin(*args, **kwargs)
5656 return System(system_tree, True)
5757
5858
59 class Issue():
59 class Issue:
6060
6161 def __init__(self, issue_node):
6262 self.node = issue_node
197197 return 'None'
198198
199199
200 class System():
200 class System:
201201
202202 def __init__(self, node, tag_exists):
203203 self.node = node
275275 return result
276276
277277
278 class Plugins():
278 class Plugins:
279279 """
280280 Support:
281281 WAF (Web Application Firewall) Detector (waf_detector)
442442
443443 references = issue.references
444444 if issue.cwe != 'None':
445 references.append('CWE-' + str(issue.cwe))
446
445 cwe = ['CWE-' + str(issue.cwe)]
447446 if resol == 'None':
448447 resol = ''
449448
462461 pname=issue.var,
463462 params=issue.parameters,
464463 request=issue.request,
465 response=issue.response)
464 response=issue.response,
465 cwe=cwe
466 )
466467
467468 return
468469
515516 return self.hostname
516517
517518
518 def createPlugin(ignore_info=False, hostname_resolution=True):
519 return ArachniPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
519 def createPlugin(*args, **kwargs):
520 return ArachniPlugin(*args, **kwargs)
5959
6060
6161
62 def createPlugin(ignore_info=False, hostname_resolution=True):
63 return CmdArpScanPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
62 def createPlugin(*args, **kwargs):
63 return CmdArpScanPlugin(*args, **kwargs)
6767 return vulns
6868
6969
70 def createPlugin(ignore_info=False, hostname_resolution=True):
71 return BanditPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
70 def createPlugin(*args, **kwargs):
71 return BanditPlugin(*args, **kwargs)
4848 output being sent is valid.
4949 """
5050 try:
51 f = urlopen(self.getSetting(
52 "Host") + "/api/hooks?token=" + self.getSetting("Authkey"))
51 f = urlopen(self.getSetting("Host") + "/api/hooks?token=" + self.getSetting("Authkey"))
5352 data = json.loads(f.read())
54 except:
53 except Exception:
5554 self.logger.info("[BeEF] - Connection with api")
5655 return
5756
9594
9695
9796
98 def createPlugin(ignore_info=False, hostname_resolution=True):
99 return BeefPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
97 def createPlugin(*args, **kwargs):
98 return BeefPlugin(*args, **kwargs)
5555
5656
5757
58 def createPlugin(ignore_info=False, hostname_resolution=True):
59 return brutexss(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
58 def createPlugin(*args, **kwargs):
59 return brutexss(*args, **kwargs)
1212 from bs4 import BeautifulSoup, Comment
1313
1414 from faraday_plugins.plugins.plugin import PluginXMLFormat
15 from faraday_plugins.plugins.plugins_utils import CVE_regex
15 from faraday_plugins.plugins.plugins_utils import CVE_regex, CWE_regex
1616
1717 __author__ = "Francisco Amato"
1818 __copyright__ = "Copyright (c) 2013, Infobyte LLC"
221221 ref = []
222222 if item.references:
223223 ref += self.get_url(item.references)
224 cwe = []
224225 if item.vulnClass:
225 ref += self.get_ref(item.vulnClass)
226
226 for cwe_ref in self.get_ref(item.vulnClass):
227 if CWE_regex.search(cwe_ref):
228 cwe.append(CWE_regex.search(cwe_ref).group())
227229 resolution = self.removeHtml(item.remediation) if item.remediation else ""
228230
229231 self.createAndAddVulnWebToService(
241243 ref=ref,
242244 params=item.location,
243245 external_id=item.external_id,
244 cve=item.cve
246 cve=item.cve,
247 cwe=cwe
245248 )
246249
247250 del parser
294297 ref += [a['href'].strip()]
295298 return ref
296299
297 def createPlugin(ignore_info=False, hostname_resolution=True):
298 return BurpPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
300
301 def createPlugin(*args, **kwargs):
302 return BurpPlugin(*args, **kwargs)
111111 vuln_name = vulns.query_attrib['name']
112112 vuln_severity = vulns.query_attrib['Severity']
113113 vuln_external_id = vulns.query_attrib['id']
114 refs.append(f'CWE-{vulns.query_attrib["cweId"]}')
114 cwe = [f'CWE-{vulns.query_attrib["cweId"]}']
115115 data = ''
116116 for files_data in vulns.path_node:
117117 for file_data in files_data:
124124 refs.append(v_result['FileName'])
125125
126126 self.createAndAddVulnToHost(host_id, vuln_name, severity=vuln_severity,
127 resolution=data, external_id=vuln_external_id)
127 resolution=data, external_id=vuln_external_id, cwe=cwe)
128128
129129 self.createAndAddVulnWebToService(host_id, service_to_interface, vuln_name,
130130 desc=vuln_desc, severity=vuln_severity,
131 resolution=data, ref=refs)
131 resolution=data, ref=refs, cwe=cwe)
132132
133133
134 def createPlugin(ignore_info=False, hostname_resolution=True):
135 return CheckmarxPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
134 def createPlugin(*args, **kwargs):
135 return CheckmarxPlugin(*args, **kwargs)
88 from urllib.parse import urlparse
99 import csv
1010 import io
11 import dateutil
11 from dateutil.parser import parse
12
1213
1314
1415 __author__ = "Blas"
7374 scheme = url_data.scheme
7475 port = url_data.port
7576 try:
76 run_date = dateutil.parser.parse(row['CreatedAt'])
77 run_date = parse(row['CreatedAt'])
7778 except:
7879 run_date = None
7980 if url_data.port is None:
100101 data=row['StepsToReproduce'], external_id=row['Tag'], run_date=run_date)
101102
102103
103 def createPlugin(ignore_info=False, hostname_resolution=True):
104 return CobaltPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
104 def createPlugin(*args, **kwargs):
105 return CobaltPlugin(*args, **kwargs)
139139 return True
140140
141141
142 def createPlugin(ignore_info=False, hostname_resolution=True):
143 return DigPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
142 def createPlugin(*args, **kwargs):
143 return DigPlugin(*args, **kwargs)
4040 def getIP(self, host):
4141 try:
4242 ip = self.resolve_hostname(host)
43 except Exception:
43 except Exception: # nosec
4444 pass
4545
4646 return ip
114114 return f"{command_string}{extra_arg}"
115115
116116
117 def createPlugin(ignore_info=False, hostname_resolution=True):
118 return dirbPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
117 def createPlugin(*args, **kwargs):
118 return dirbPlugin(*args, **kwargs)
130130 return f'{command_string} --json-report {self._output_file_path}'
131131
132132
133 def createPlugin(ignore_info=False, hostname_resolution=True):
134 return DirsearchPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
133 def createPlugin(*args, **kwargs):
134 return DirsearchPlugin(*args, **kwargs)
164164 return re.sub(arg_match.group(1), r"-o %s" % self._output_file_path, command_string)
165165
166166
167 def createPlugin(ignore_info=False, hostname_resolution=True):
168 return DnsenumPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
167 def createPlugin(*args, **kwargs):
168 return DnsenumPlugin(*args, **kwargs)
136136 command_string)
137137
138138
139 def createPlugin(ignore_info=False, hostname_resolution=True):
140 return DnsmapPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
139 def createPlugin(*args, **kwargs):
140 return DnsmapPlugin(*args, **kwargs)
211211 command_string)
212212
213213
214 def createPlugin(ignore_info=False, hostname_resolution=True):
215 return DnsreconPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
214 def createPlugin(*args, **kwargs):
215 return DnsreconPlugin(*args, **kwargs)
108108 return True
109109
110110
111 def createPlugin(ignore_info=False, hostname_resolution=True):
112 return DnswalkPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
111 def createPlugin(*args, **kwargs):
112 return DnswalkPlugin(*args, **kwargs)
363363 )
364364
365365
366 def createPlugin(ignore_info=False, hostname_resolution=True):
367 return FaradayCSVPlugin(ignore_info=ignore_info)
366 def createPlugin(*args, **kwargs):
367 return FaradayCSVPlugin(*args, **kwargs)
117117 try:
118118 item['ip'] = self.resolve_hostname(item['ip'])
119119 except:
120 pass
120 pass # nosec
121121 return item
122122
123123 def resolveNS(self, item, items):
171171 ref=["CVE-1999-0532"])
172172
173173
174 def createPlugin(ignore_info=False, hostname_resolution=True):
175 return FiercePlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
174 def createPlugin(*args, **kwargs):
175 return FiercePlugin(*args, **kwargs)
390390 return text
391391
392392
393 def createPlugin(ignore_info=False, hostname_resolution=True):
394 return FortifyPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
393 def createPlugin(*args, **kwargs):
394 return FortifyPlugin(*args, **kwargs)
+0
-7
faraday_plugins/plugins/repo/fruitywifi/__init__.py less more
0 """
1 Faraday Penetration Test IDE
2 Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/)
3 See the file 'doc/LICENSE' for the license information
4
5 """
6
+0
-150
faraday_plugins/plugins/repo/fruitywifi/fruitywifi.py less more
0 #!/usr/bin/python
1 """
2 Copyright (C) 2016 xtr4nge [_AT_] gmail.com
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 """
17
18 import sys
19 import getopt
20 import json
21 import requests
22
23 requests.packages.urllib3.disable_warnings() # DISABLE SSL CHECK WARNINGS
24
25 gVersion = "1.0"
26 server = "http://127.0.0.1:8000"
27 token = "e5dab9a69988dd65e578041416773149ea57a054"
28
29
30 def usage():
31 print("\nFruityWiFi API " + gVersion + " by @xtr4nge")
32
33 print("Usage: ./client <options>\n")
34 print("Options:")
35 print("-x <command>, --execute=<commnd> exec the command passed as parameter.")
36 print("-t <token>, --token=<token> authentication token.")
37 print("-s <server>, --server=<server> FruityWiFi server [http{s}://ip:port].")
38 print("-h Print this help message.")
39 print("")
40 print("FruityWiFi: http://www.fruitywifi.com")
41 print("")
42
43
44 def parseOptions(argv):
45
46 v_execute = "/log/dhcp"
47 v_token = token
48 v_server = server
49
50 try:
51 opts, args = getopt.getopt(argv, "hx:t:s:",
52 ["help","execute=","token=","server="])
53
54 for opt, arg in opts:
55 if opt in ("-h", "--help"):
56 usage()
57 sys.exit()
58 elif opt in ("-x", "--execute"):
59 v_execute = arg
60 elif opt in ("-t", "--token"):
61 v_token = arg
62 elif opt in ("-s", "--server"):
63 v_server = arg
64
65 return (v_execute, v_token, v_server)
66
67 except getopt.GetoptError:
68 usage()
69 sys.exit(2)
70
71
72 (execute, token, server) = parseOptions(sys.argv[1:])
73
74
75 class Webclient:
76
77 def __init__(self, server, token):
78
79 self.global_webserver = server
80 self.path = "/modules/api/includes/ws_action.php"
81 self.s = requests.session()
82 self.token = token
83
84 def login(self):
85
86 payload = {
87 'action': 'login',
88 'token': self.token
89 }
90
91 self.s = requests.session()
92 self.s.get(self.global_webserver, verify=False) # DISABLE SSL CHECK
93 self.s.post(self.global_webserver + '/login.php', data=payload)
94
95 def loginCheck(self):
96
97 response = self.s.get(self.global_webserver + '/login_check.php')
98
99 if response.text != "":
100 self.login()
101
102 if response.text != "":
103 print(json.dumps("[FruityWiFi]: Ah, Ah, Ah! You didn't say the magic word! (check API token and server)"))
104 sys.exit()
105
106 return True
107
108 def submitPost(self, data):
109 response = self.s.post(self.global_webserver + data)
110 return response.json
111
112 def submitGet(self, data):
113 response = self.s.get(self.global_webserver + self.path + "?" + data)
114
115 return response
116
117 try:
118 w = Webclient(server, token)
119 w.login()
120 w.loginCheck()
121 except Exception as e:
122 print(json.dumps("[FruityWiFi]: There is something wrong (%s)" % e))
123 sys.exit(1)
124
125 _exec = "/log/dhcp"
126 _exec = execute
127 if _exec != "":
128 try:
129 out = w.submitGet("api=" + str(_exec))
130 json_output = out.json()
131 except Exception as e:
132 print(json.dumps("[FruityWiFi]: There is something wrong (%s)" % e))
133 sys.exit(1)
134
135 output = []
136 if _exec == "/log/dhcp":
137 for item in json_output:
138 if item.strip() != "":
139 output = [item.split(" ")]
140 else:
141 output = json_output
142
143 if len(output) > 0:
144 print(json.dumps(output))
145 else:
146 print(json.dumps("No clients connected"))
147
148
149
+0
-131
faraday_plugins/plugins/repo/fruitywifi/plugin.py less more
0 """
1 Faraday Penetration Test IDE
2 Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/)
3 See the file 'doc/LICENSE' for the license information
4
5 """
6 from faraday_plugins.plugins.plugin import PluginBase
7 import re
8 import json
9 import traceback
10 import os
11
12 __author__ = "xtr4nge"
13 __copyright__ = "Copyright (c) 2016, FruityWiFi"
14 __credits__ = ["xtr4nge"]
15 __license__ = ""
16 __version__ = "1.0.0"
17 __maintainer__ = "xtr4nge"
18 __email__ = "@xtr4nge"
19 __status__ = "Development"
20
21 class FruityWiFiPlugin(PluginBase):
22 """
23 This plugin handles FruityWiFi clients.
24 """
25
26 def __init__(self, *arg, **kwargs):
27 super().__init__(*arg, **kwargs)
28 self.id = "fruitywifi"
29 self.name = "FruityWiFi"
30 self.plugin_version = "0.0.1"
31 self.version = "2.4"
32 self.description = "http://www.fruitywifi.com"
33 self.options = None
34 self._current_output = None
35 self.target = None
36
37 self._command_regex = re.compile(r'^(fruitywifi)\s+.*?')
38
39 self.addSetting("Token", str, "e5dab9a69988dd65e578041416773149ea57a054")
40 self.addSetting("Server", str, "http://127.0.0.1:8000")
41 self.addSetting("Severity", str, "high")
42
43 def getSeverity(self, severity):
44 if severity.lower() == "critical" or severity == "4":
45 return 4
46 elif severity.lower() == "high" or severity == "3":
47 return 3
48 elif severity.lower() == "med" or severity == "2":
49 return 2
50 elif severity.lower() == "low" or severity == "1":
51 return 1
52 elif severity.lower() == "info" or severity == "0":
53 return 0
54 else:
55 return 5
56
57 def createHostInterfaceVuln(self, ip_address, macaddress, hostname, desc, vuln_name, severity):
58 h_id = self.createAndAddHost(ip_address, hostnames=[hostname])
59
60 self.createAndAddVulnToHost(
61 h_id,
62 vuln_name,
63 desc=desc,
64 ref=["http://www.fruitywifi.com/"],
65 severity=severity
66 )
67
68 def parseOutputString(self, output):
69
70 try:
71 output = json.loads(output)
72
73 if len(output) > 0:
74
75 if len(output[0]) == 3:
76
77 severity = self.getSeverity(self.getSetting("Severity"))
78
79 for item in output:
80 ip_address = item[0]
81 macaddress = item[1]
82 hostname = item[2]
83 vuln_name = "FruityWiFi"
84 severity = severity
85
86 desc = "Client ip: " + ip_address + \
87 " has been connected to FruityWiFi\n"
88 desc += "More information:"
89 desc += "\nname: " + hostname
90
91 self.createHostInterfaceVuln(ip_address, macaddress, hostname, desc, vuln_name, severity)
92
93 elif len(output[0]) == 5:
94 for item in output:
95 ip_address = item[0]
96 macaddress = item[1]
97 hostname = item[2]
98 vuln_name = item[3]
99 severity = item[4]
100
101 desc = "Client ip: " + ip_address + \
102 " has been connected to FruityWiFi\n"
103 desc += "More information:"
104 desc += "\nname: " + hostname
105
106 self.createHostInterfaceVuln(ip_address, macaddress, hostname, desc, vuln_name, severity)
107
108 except:
109 traceback.print_exc()
110
111 return True
112
113 def _isIPV4(self, ip):
114 if len(ip.split(".")) == 4:
115 return True
116 else:
117 return False
118
119 def processCommandString(self, username, current_path, command_string):
120 """
121 """
122 super().processCommandString(username, current_path, command_string)
123 params = f"-t {self.getSetting('Token')} -s {self.getSetting('Server')}",
124
125 return "python " + os.path.dirname(__file__) + "/fruitywifi.py " + params
126
127
128
129 def createPlugin(ignore_info=False, hostname_resolution=True):
130 return FruityWiFiPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
7070 self._port = count_args[c - 1]
7171
7272
73 def createPlugin(ignore_info=False, hostname_resolution=True):
74 return CmdFtpPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
73 def createPlugin(*args, **kwargs):
74 return CmdFtpPlugin(*args, **kwargs)
128128 self.parseOutputString(command_output)
129129
130130
131 def createPlugin(ignore_info=False, hostname_resolution=True):
132 return GoohostPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
131 def createPlugin(*args, **kwargs):
132 return GoohostPlugin(*args, **kwargs)
4949 severity = match.get('vulnerability').get('severity').lower().replace("negligible", "info")
5050 for url in match.get('vulnerability').get('urls'):
5151 references.append(url)
52 if not match['artifact']['metadata']:
52 if not match['artifact'].get('metadata'):
5353 data = f"Artifact: {match['artifact']['name']}" \
5454 f"Version: {match['artifact']['version']} " \
5555 f"Type: {match['artifact']['type']}"
7676 return command_string
7777
7878
79 def createPlugin(ignore_info=False, hostname_resolution=True):
80 return GrypePlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
79 def createPlugin(*args, **kwargs):
80 return GrypePlugin(*args, **kwargs)
6767 host_id, service, protocol="tcp", ports=port, status="open")
6868
6969
70 def createPlugin(ignore_info=False, hostname_resolution=True):
71 return hping3(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
70 def createPlugin(*args, **kwargs):
71 return hping3(*args, **kwargs)
128128
129129
130130
131 def createPlugin(ignore_info=False, hostname_resolution=True):
132 return HydraPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
131 def createPlugin(*args, **kwargs):
132 return HydraPlugin(*args, **kwargs)
280280 del parser
281281
282282
283 def createPlugin(ignore_info=False, hostname_resolution=True):
284 return ImpactPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
283 def createPlugin(*args, **kwargs):
284 return ImpactPlugin(*args, **kwargs)
102102 ref=vulnerability.get("ref"))
103103
104104
105 def createPlugin(ignore_info=False, hostname_resolution=True):
106 return Ip360Plugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
105 def createPlugin(*args, **kwargs):
106 return Ip360Plugin(*args, **kwargs)
130130 del parser
131131
132132
133 def createPlugin(ignore_info=False, hostname_resolution=True):
134 return JunitPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
133 def createPlugin(*args, **kwargs):
134 return JunitPlugin(*args, **kwargs)
3737
3838 def ipv4(self):
3939 ipv4s = re.findall(r'^network_ipv4_address\[\]=(.+)$',
40 self.rawcontents, re.MULTILINE)
40 self.rawcontents, re.MULTILINE)
4141 ipv4addrs = self.ipv4_filter(ipv4s)
42 return(ipv4addrs)
42 return ipv4addrs
4343
4444 def ipv6(self):
4545 ipv6s = re.findall(r'^network_ipv6_address\[\]=(.+)$',
46 self.rawcontents, re.MULTILINE)
46 self.rawcontents, re.MULTILINE)
4747 ipv6addrs = self.ipv6_filter(ipv6s)
48 return(ipv6addrs)
48 return ipv6addrs
4949
5050 def ipv4_filter(self, ips):
5151 ip_list = []
7575
7676 def listeningservices(self):
7777 line = re.findall(r'^network_listen_port\[\]=(.+)$',
78 self.rawcontents, re.MULTILINE)
78 self.rawcontents, re.MULTILINE)
7979 # To avoid local services, we will create the following list
8080 local_services = ['*', 'localhost']
8181
9090
9191 def clean_services(self, combo, local_services):
9292 add = False
93 #if "localhost" in combo:
9493 if combo.count("|") > 1:
9594 # Service with url, protocol and perhaps name
9695 items_service = combo.split('|')
171170 def search_service(self, port):
172171 srv = filter_services()
173172 details_dict = {
174 'name' : 'Unknown',
175 'protocol' : 'Unknown'
173 'name': 'Unknown',
174 'protocol': 'Unknown'
176175 }
177176 for item in srv:
178177 service_tuple = item[0].split('/')
206205 for combo in m:
207206 x = combo.split('|')
208207 sugs[x[0]] = x[1]
209 return(sugs)
208 return sugs
210209
211210 def parse_warnings(self):
212211 warns = {}
214213 for combo in m:
215214 x = combo.split('|')
216215 warns[x[0]] = x[1]
217 return(warns)
216 return warns
218217
219218
220219 class LynisPlugin(PluginByExtension):
258257
259258 for ipv4 in ipv4s:
260259 h_id = self.createAndAddHost(name=ipv4,
261 os=lde.osfullname(),
262 hostnames=[hostname])
260 os=lde.osfullname(),
261 hostnames=[hostname])
263262
264263 self.create_services(h_id, services, ipv4)
265264 self.create_vulns_with_kernel(h_id, kernel_versions)
268267
269268 for ipv6 in ipv6s:
270269 h_id = self.createAndAddHost(name=ipv6,
271 os=lde.osfullname(),
272 hostnames=[hostname])
270 os=lde.osfullname(),
271 hostnames=[hostname])
273272
274273 self.create_services(h_id, services, ipv6)
275274 self.create_vulns_with_kernel(h_id, kernel_versions)
279278 def create_services(self, host_id, parsed_services, ip_version):
280279 for service_data in parsed_services[ip_version]:
281280 self.createAndAddServiceToHost(host_id=host_id,
282 name=service_data['name'],
283 protocol=service_data['protocol'],
284 ports=[service_data['port']])
281 name=service_data['name'],
282 protocol=service_data['protocol'],
283 ports=[service_data['port']])
285284
286285 if '0.0.0.0' in parsed_services:
287286 for service_data in parsed_services['0.0.0.0']:
288287 self.createAndAddServiceToHost(host_id=host_id,
289 name=service_data['name'],
290 protocol=service_data['protocol'],
291 ports=[service_data['port']])
288 name=service_data['name'],
289 protocol=service_data['protocol'],
290 ports=[service_data['port']])
292291
293292 def create_vulns_with_kernel(self, host_id, kernel_versions):
294293 for kernel, version in kernel_versions.items():
323322 self._parse_filename(file_path)
324323
325324
326 def createPlugin(ignore_info=False, hostname_resolution=True):
327 return LynisPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
325 def createPlugin(*args, **kwargs):
326 return LynisPlugin(*args, **kwargs)
495495 description="DNS Server")
496496
497497
498 def createPlugin(ignore_info=False, hostname_resolution=True):
499 return MaltegoPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
498 def createPlugin(*args, **kwargs):
499 return MaltegoPlugin(*args, **kwargs)
113113 i += 1
114114
115115
116 def createPlugin(ignore_info=False, hostname_resolution=True):
117 return MbsaPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
116 def createPlugin(*args, **kwargs):
117 return MbsaPlugin(*args, **kwargs)
132132
133133
134134
135 def createPlugin(ignore_info=False, hostname_resolution=True):
136 return MedusaPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
135 def createPlugin(*args, **kwargs):
136 return MedusaPlugin(*args, **kwargs)
275275 self.service_id = self.get_text_from_subnode('service-id')
276276 self.name = self.get_text_from_subnode('name')
277277 self.desc = self.get_text_from_subnode('info')
278 self.refs = [r.text for r in self.node.findall('refs/ref') if not r.text.startswith('CVE')]
279 self.cve = [r.text for r in self.node.findall('refs/ref') if r.text.startswith('CVE')]
278 self.refs = []
279 self.cve = []
280 self.cwe = []
281 for r in self.node.findall('refs/ref'):
282 if r.text.startswith('CVE'):
283 self.cve.append(r.text)
284 elif r.text.startswith('CWE'):
285 self.cwe.append(r.text)
286 else:
287 self.refs.append(r.text)
280288 self.exploited_date = self.get_text_from_subnode('exploited-at')
281289 self.exploited = (self.exploited_date is not None)
282290 self.isWeb = False
362370 category=v.category)
363371 else:
364372 self.createAndAddVulnToService(
365 h_id, s_id, v.name, v.desc, ref=v.refs, cve=v.cve)
373 h_id, s_id, v.name, v.desc, ref=v.refs, cve=v.cve, cwe=v.cwe)
366374
367375 del parser
368376
374382 return False
375383
376384
377 def createPlugin(ignore_info=False, hostname_resolution=True):
378 return MetasploitPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
385 def createPlugin(*args, **kwargs):
386 return MetasploitPlugin(*args, **kwargs)
6666 command_string += " -silent"
6767 return command_string
6868
69 def createPlugin(ignore_info=False, hostname_resolution=True):
70 return NaabuPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
69 def createPlugin(*args, **kwargs):
70 return NaabuPlugin(*args, **kwargs)
118118 password=service_vuln['passw'])
119119
120120
121 def createPlugin(ignore_info=False, hostname_resolution=True):
122 return NcrackPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
121 def createPlugin(*args, **kwargs):
122 return NcrackPlugin(*args, **kwargs)
151151 return f"{command_string} --xml "
152152
153153
154 def createPlugin(ignore_info=False, hostname_resolution=True):
155 return CmdNdiffPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
154 def createPlugin(*args, **kwargs):
155 return CmdNdiffPlugin(*args, **kwargs)
125125
126126 @property
127127 def cvss3_base_score(self):
128 cvss_base_score = self.node.findtext("cvss3_base_score")
129 if cvss_base_score:
130 cvss_base_score = f"CVSS3:{cvss_base_score}"
131 return cvss_base_score
128 return self.node.findtext("cvss3_base_score")
132129
133130 @property
134131 def cvss3_temporal_score(self):
147144 return self.node.findtext("cvss3_vector")
148145
149146 @property
150 def cvss_base_score(self):
151 cvss_base_score = self.node.findtext("cvss_base_score")
152 if cvss_base_score:
153 cvss_base_score = f"CVSS:{cvss_base_score}"
154 return cvss_base_score
147 def cvss2_base_score(self):
148 return self.node.findtext("cvss_base_score")
155149
156150 @property
157151 def cvss_score_rationale(self):
173167 def cvss_vector(self):
174168 cvss_vector = self.node.findtext("cvss_vector")
175169 if cvss_vector:
176 cvss_vector = f"CVSSVECTOR:{cvss_vector}"
170 cvss_vector = cvss_vector.replace("CVSS2#", "")
177171 return cvss_vector
178172
179173 @property
283277
284278 @property
285279 def cwe(self) -> list:
286 return [i.text for i in self.node.findall("cwe")]
280 return ["CWE-"+i.text for i in self.node.findall("cwe")]
287281
288282 @property
289283 def edb_id(self) -> list:
398392 @property
399393 def report_hosts(self) -> List[ReportHost]:
400394 return [ReportHost(i) for i in self.node.findall('ReportHost')]
401
66
77 import xml.etree.ElementTree as ET
88
9 import dateutil
9 from dateutil.parser import parse
1010 from faraday_plugins.plugins.plugin import PluginXMLFormat
1111
1212 __author__ = "Blas"
8585
8686 @staticmethod
8787 def map_item(host_id, run_date, plugin_name, item: ReportItem) -> dict:
88 cvss_base_score = item.cvss_base_score
8988 data = item.plugin_output
9089 data += f'{item.exploit_available}'
9190 return {
9796 "run_date": run_date,
9897 "desc": item.description,
9998 "resolution": item.solution,
100 "ref": [cvss_base_score] if cvss_base_score else []
99 "ref": [],
101100 }
102101
103102 def map_policy_general(self, kwargs, item: ReportItem):
145144 self.logger.error(str(e))
146145 return None
147146 report_hosts = parser.report.report_hosts
148
149147 if report_hosts:
150148 for host in report_hosts:
151149 run_date = host.host_properties.host_end
152150 if run_date:
153 run_date = dateutil.parser.parse(run_date)
151 run_date = parse(run_date)
154152 website = host.host_properties.host_fqdn
155153 host_id = self.createAndAddHost(**self.map_properties(host))
156154
179177
180178 @staticmethod
181179 def map_add_ref(kwargs, item: ReportItem):
182
183 if item.cvss_vector:
184 kwargs["ref"].append(item.cvss_vector)
180 kwargs["cvss2"] = {}
181 kwargs["cvss3"] = {}
185182 if item.see_also:
186183 kwargs["ref"].append(item.see_also)
187184 if item.cpe:
188185 kwargs["ref"].append(item.cpe)
189 if item.xref:
190 kwargs["ref"].append(item.xref)
191186 if item.cve:
192187 kwargs["cve"] = item.cve
193 if item.cvss3_base_score:
194 kwargs["ref"].append(item.cvss3_base_score)
188 if item.cwe:
189 kwargs["cwe"] = item.cwe
195190 if item.cvss3_vector:
196 kwargs["ref"].append(item.cvss3_vector)
191 kwargs["cvss3"]["vector_string"] = item.cvss3_vector
192 if item.cvss_vector:
193 kwargs["cvss2"]["vector_string"] = item.cvss_vector
197194 return kwargs
198195
199196
200 def createPlugin(ignore_info=False, hostname_resolution=True):
201 return NessusPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
197 def createPlugin(*args, **kwargs):
198 return NessusPlugin(*args, **kwargs)
3838
3939
4040
41 def createPlugin(ignore_info=False, hostname_resolution=True):
42 return NetdiscoverPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
41 def createPlugin(*args, **kwargs):
42 return NetdiscoverPlugin(*args, **kwargs)
7979 def __init__(self, item_node):
8080 self.node = item_node
8181 self.url = self.get_text_from_subnode("url")
82
8382 host = re.search(
8483 r"(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&amp;%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]"
8584 r"{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2"
8685 r"[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]"
8786 r"{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|"
88 "pro|aero|coop|museum|[a-zA-Z]{2}))[\\:]*([0-9]+)*([/]*($|[a-zA-Z0-9\\.\\,\\?\'\\\\+&amp;%\\$#\\=~_\\-]+)).*?$",
87 "pro|aero|coop|museum|[a-zA-Z]{2}))[\\:]*([0-9]+)*([/]*($|[\\(\\)a-zA-Z0-9\\.\\,\\?\'\\\\+&amp;%\\$#\\=~_\\-]+)).*?$",
8988 self.url)
90
9189 self.protocol = host.group(1)
9290 self.hostname = host.group(4)
9391 self.port = 80
136134 self.pci = self.get_text_from_subnode("PCI")
137135 self.pci2 = self.get_text_from_subnode("PCI2")
138136 self.node = item_node.find("classification/CVSS")
139 self.cvss = self.get_text_from_subnode("vector")
140
137 self.cvss_full_vector = self.get_text_from_subnode("vector")
138 self.cvss_score = self.get_text_from_subnode("score[1]/value") if self.get_text_from_subnode("score[1]/value") else None
139 self.cvss3 = {}
141140 self.ref = []
142141 if self.cwe:
143 self.ref.append("CWE-" + self.cwe)
142 self.cwe = ["CWE-" + self.cwe]
144143 if self.owasp:
145144 self.ref.append("OWASP-" + self.owasp)
146145 if self.reference:
147146 self.ref.extend(sorted(set(re.findall(r'https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', self.reference))))
148 if self.cvss:
149 self.ref.append(self.cvss)
150
147 if self.cvss_full_vector:
148 self.cvss3["vector_string"] = self.cvss_full_vector
151149 self.data = ""
152150 self.data += "\nKnowVulns: " + \
153151 "\n".join(self.kvulns) if self.kvulns else ""
228226 self.createAndAddVulnWebToService(h_id, s_id, name, ref=i.ref, website=i.hostname,
229227 severity=i.severity, desc=desc, path=i.url, method=i.method,
230228 request=i.request, response=i.response, resolution=resolution,
231 pname=i.param, data=i.data, cve=i.cve)
229 pname=i.param, data=i.data, cve=i.cve, cwe=i.cwe, cvss3=i.cvss3)
232230
233231 del parser
234232
235233
236 def createPlugin(ignore_info=False, hostname_resolution=True):
237 return NetsparkerPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
234 def createPlugin(*args, **kwargs):
235 return NetsparkerPlugin(*args, **kwargs)
122122
123123 self.ref = []
124124 if self.cwe:
125 self.ref.append(f"CWE-{self.cwe}")
125 self.cwe = [f"CWE-{self.cwe}"]
126126 if self.owasp:
127127 self.ref.append(f"OWASP-{self.owasp}")
128128
191191 v_id = self.createAndAddVulnWebToService(h_id, s_id, i.name, ref=i.ref, website=i.hostname,
192192 severity=i.severity, desc=i.desc, path=i.url.path, method=i.method,
193193 request=i.request, response=i.response, resolution=i.resolution,
194 pname=i.param)
194 pname=i.param, cwe=i.cwe)
195195 del parser
196196
197197
198 def createPlugin(ignore_info=False, hostname_resolution=True):
199 return NetsparkerCloudPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
198 def createPlugin(*args, **kwargs):
199 return NetsparkerCloudPlugin(*args, **kwargs)
132132 @returns vulns A dict of Vulnerability Definitions
133133 """
134134 vulns = dict()
135 # CVSS V3
136 SEVERITY_MAPPING_DICT = {'0': 'info', '1': 'low', '2': 'low', '3': 'low', '4': 'med', '5': 'med', '6': 'med',
137 '7': 'high', '8': 'high', '9': 'critical', '10': 'critical'}
138135
139136 for vulnsDef in tree.iter('VulnerabilityDefinitions'):
140137 for vulnDef in vulnsDef.iter('vulnerability'):
145142 'name': vulnDef.get('title'),
146143 'refs': ["vector: " + vector, vid],
147144 'resolution': "",
148 'severity': SEVERITY_MAPPING_DICT[vulnDef.get('severity')],
145 'severity': "",
149146 'tags': list(),
150147 'is_web': vid.startswith('http-'),
151148 'risk': vulnDef.get('riskScore'),
152 'CVE': []
149 'CVE': [],
150 'cvss2': {
151 "vector_string": vector.replace("(", "").replace(")", "") if vector else None
152 }
153153 }
154154
155155 for item in list(vulnDef):
277277 v['refs'],
278278 v['severity'],
279279 v['resolution'],
280 cve=v.get('CVE')
280 cve=v.get('CVE'),
281 cvss2=v.get('cvss2')
281282 )
282283
283284 for s in item['services']:
302303 v['severity'],
303304 v['resolution'],
304305 cve=v.get('CVE'),
305 path=v.get('path', '')
306 path=v.get('path', ''),
307 cvss2=v.get('cvss2')
306308 )
307309 else:
308310 self.createAndAddVulnToService(
313315 v['refs'],
314316 v['severity'],
315317 v['resolution'],
316 cve=v.get('CVE')
318 cve=v.get('CVE'),
319 cvss2=v.get('cvss2')
317320 )
318321
319322 del parser
320323
321324
322 def createPlugin(ignore_info=False, hostname_resolution=True):
323 return NexposeFullPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
325 def createPlugin(*args, **kwargs):
326 return NexposeFullPlugin(*args, **kwargs)
6262 return True
6363
6464
65 def createPlugin(ignore_info=False, hostname_resolution=True):
66 return CmdNextNetin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
65 def createPlugin(*args, **kwargs):
66 return CmdNextNetin(*args, **kwargs)
314314 return re.sub(arg_match.group(1), r"-output %s -Format XML" % self._output_file_path, data)
315315
316316
317 def createPlugin(ignore_info=False, hostname_resolution=True):
318 return NiktoPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
317 def createPlugin(*args, **kwargs):
318 return NiktoPlugin(*args, **kwargs)
1515 self.name = ''
1616 self.data = ''
1717 self.device = ''
18 self.cvss2 = {}
1819 self.refs = []
1920
2021
9596 # nombre de la vuln
9697
9798 vuln_soft.name = itemv.attrib.get('title')
99 cvss2_vector = itemv.find('infobox/infodata/[@label="CVSSv2 Base"]')
100 vuln_soft.cvss2["vector_string"] = cvss2_vector.text.split(' ')[0] if cvss2_vector is not None else None
98101 for itemvv in itemv:
99102 if itemvv.attrib.get('title') == 'Summary':
100103 for i in itemvv:
154157 resolution='',
155158 data=vuln.data,
156159 ref=vuln.refs,
157 cve=[vuln.name]
160 cve=[vuln.name],
161 cvss2=vuln.cvss2
158162 )
159163
160164
161 def createPlugin(ignore_info=False, hostname_resolution=True):
162 return NipperPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
165 def createPlugin(*args, **kwargs):
166 return NipperPlugin(*args, **kwargs)
1010 from lxml import etree
1111 from lxml.etree import XMLParser
1212 from faraday_plugins.plugins.plugin import PluginXMLFormat
13 from faraday_plugins.plugins.plugins_utils import get_severity_from_cvss
1413
1514 current_path = os.path.abspath(os.getcwd())
1615
352351 self.desc += " *EXPLOIT*"
353352
354353 self.refs = ["https://vulners.com/" + self.table["type"] + "/" + self.table["id"]]
355 self.refs.append("CVSS: " + self.table["cvss"])
356354 self.response = ""
357355 self.web = ""
358 self.severity = get_severity_from_cvss(self.table["cvss"])
356 self.cvss2 = {}
359357
360358 def __str__(self):
361359 return f"{self.name}, {self.product}, {self.version}"
392390 for k in script_node.findall("elem"):
393391 self.response += "\n" + str(k.get('key')) + ": " + str(k.text)
394392 self.web = re.search("(http-|https-)", self.name)
393 self.cvss2 = {}
395394
396395 def __str__(self):
397396 return f"{self.name}, {self.product}, {self.version}"
538537 ref=refs,
539538 severity=severity,
540539 website=minterfase,
541 cve=[v.name])
540 cve=[v.name],
541 cvss2=v.cvss2
542 )
542543 else:
543544 v_id = self.createAndAddVulnToService(
544545 h_id,
547548 desc=v.desc,
548549 ref=refs,
549550 severity=severity,
550 cve=[v.name]
551 cve=[v.name],
552 cvss2=v.cvss2
551553 )
552554 del parser
553555
573575 command_string)
574576
575577
576 def createPlugin(ignore_info=False, hostname_resolution=True):
577 return NmapPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
578 def createPlugin(*args, **kwargs):
579 return NmapPlugin(*args, **kwargs)
77 import re
88 import sys
99 import json
10 import dateutil
10 from dateutil.parser import parse
1111 from urllib.parse import urlparse
1212 from packaging import version
1313 from faraday_plugins.plugins.plugin import PluginMultiLineJsonFormat
9999 # TODO CVSSv2, CVSSv3, CWE and CAPEC
100100 #cvssv2 = vuln_dict['info'].get('classification', {}).get('cvss-score')
101101 #cvssv3 = vuln_dict['info'].get('classification', {}).get('cvss-metrics')
102 #cwe = vuln_dict['info'].get('classification', {}).get('cwe-id', [])
103 #cwe = [x.upper() for x in cwe]
102 cwe = vuln_dict['info'].get('classification', {}).get('cwe-id', [])
103 cwe = [x.upper() for x in cwe]
104104 #capec = vuln_dict['info'].get('metadata', {}).get('capec', [])
105105 #if isinstance(capec, str):
106106 # capec = capec.upper().split(',')
134134 name = vuln_dict["info"].get("name")
135135 run_date = vuln_dict.get('timestamp')
136136 if run_date:
137 run_date = dateutil.parser.parse(run_date)
137 run_date = parse(run_date)
138138 self.createAndAddVulnWebToService(
139139 host_id,
140140 service_id,
150150 # TODO CVSSv2, CVSSv3, CWE and CAPEC
151151 #cvssv2=cvssv2,
152152 #cvssv3=cvssv3,
153 #cwe=cwe,
153 cwe=cwe,
154154 #capec=capec,
155155 website=host,
156156 request=request,
192192 return False
193193
194194
195 def createPlugin(ignore_info=False, hostname_resolution=True):
196 return NucleiPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
195 def createPlugin(*args, **kwargs):
196 return NucleiPlugin(*args, **kwargs)
00 import subprocess
11 import re
22 import json
3 import dateutil
43 from packaging import version
54 from urllib.parse import urlparse
5 from dateutil.parser import parse
66 from faraday_plugins.plugins.plugin import PluginMultiLineJsonFormat
77
88 __author__ = "Emilio Couto"
7777 references = []
7878 cwe = vuln_dict['info'].get('cwe', [])
7979 capec = vuln_dict['info'].get('capec', [])
80 refs = sorted(list(set(reference + references + cwe + capec)))
80 refs = sorted(list(set(reference + references + capec)))
8181 tags = vuln_dict['info'].get('tags', [])
8282 if isinstance(tags, str):
8383 tags = tags.split(',')
9696 name = vuln_dict["info"].get("name")
9797 run_date = vuln_dict.get('timestamp')
9898 if run_date:
99 run_date = dateutil.parser.parse(run_date)
99 run_date = parse(run_date)
100100 self.createAndAddVulnWebToService(
101101 host_id,
102102 service_id,
117117 path=matched_data.path,
118118 data="\n".join(data),
119119 external_id=f"NUCLEI-{vuln_dict.get('templateID', '')}",
120 run_date=run_date
120 run_date=run_date,
121 cwe=cwe
121122 )
122123
123124 def processCommandString(self, username, current_path, command_string):
147148 except Exception as e:
148149 return False
149150
150 def createPlugin(ignore_info=False, hostname_resolution=True):
151 return NucleiLegacyPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
151 def createPlugin(*args, **kwargs):
152 return NucleiLegacyPlugin(*args, **kwargs)
206206 cve=[vuln_cve])
207207
208208
209 def createPlugin(ignore_info=False, hostname_resolution=True):
210 return OpenScapPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
209 def createPlugin(*args, **kwargs):
210 return OpenScapPlugin(*args, **kwargs)
177177 self.cve = self.get_text_from_subnode('cve') if self.get_text_from_subnode('cve') != "NOCVE" else ""
178178 self.bid = self.get_text_from_subnode('bid') if self.get_text_from_subnode('bid') != "NOBID" else ""
179179 self.xref = self.get_text_from_subnode('xref') if self.get_text_from_subnode('xref') != "NOXREF" else ""
180 self.cwe = []
181 if "URL:https://cwe.mitre.org/data/definitions/" in self.xref:
182 self.cwe.append("CWE-"+self.xref.split("URL:https://cwe.mitre.org/data/definitions/")[1]
183 .replace("html", ""))
180184 self.description = ''
181185 self.resolution = ''
182186 self.cvss_vector = ''
341345 if item.name is not None:
342346 ref = []
343347 cve = []
348 cvss2 = {}
344349 if item.cve:
345350 cves = item.cve.split(',')
346351 for i in cves:
352357 if item.xref:
353358 ref.append(item.xref)
354359 if item.tags and item.cvss_vector:
355 ref.append(item.cvss_vector)
356 if item.cvss_base:
357 ref.append(f"CVSS_BASE: {item.cvss_base}")
360 cvss2["vector_string"] = item.cvss_vector
358361 if item.cpe:
359362 ref.append(f"{item.cpe}")
360363 if item.severity_nr:
384387 ref=ref,
385388 external_id=f"OPENVAS-{item.id}",
386389 data=item.data,
387 cve=cve)
390 cve=cve,
391 cwe=item.cwe,
392 cvss2=cvss2
393 )
388394 else:
389395 if item.service:
390396 web = re.search(
416422 resolution=item.resolution,
417423 external_id=f"OPENVAS-{item.id}",
418424 data=item.data,
419 cve=cve)
425 cve=cve,
426 cwe=item.cwe,
427 cvss2=cvss2
428 )
420429 elif item.severity not in self.ignored_severities:
421430 self.createAndAddVulnToService(
422431 h_id,
428437 resolution=item.resolution,
429438 external_id=f"OPENVAS-{item.id}",
430439 data=item.data,
431 cve=cve)
440 cve=cve,
441 cwe=item.cwe,
442 cvss2=cvss2
443 )
432444 del parser
433445
434446 @staticmethod
439451 return False
440452
441453
442 def createPlugin(ignore_info=False, hostname_resolution=True):
443 return OpenvasPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
454 def createPlugin(*args, **kwargs):
455 return OpenvasPlugin(*args, **kwargs)
8484 return command_string
8585
8686
87 def createPlugin(ignore_info=False, hostname_resolution=True):
88 return pasteAnalyzerPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
87 def createPlugin(*args, **kwargs):
88 return pasteAnalyzerPlugin(*args, **kwargs)
6969 self._path = current_path
7070
7171
72 def createPlugin(ignore_info=False, hostname_resolution=True):
73 return PeepingTomPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
72 def createPlugin(*args, **kwargs):
73 return PeepingTomPlugin(*args, **kwargs)
4747 return False
4848
4949
50 def createPlugin(ignore_info=False, hostname_resolution=True):
51 return CmdPingPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
50 def createPlugin(*args, **kwargs):
51 return CmdPingPlugin(*args, **kwargs)
6060 self._port = count_args[2]
6161
6262
63 def createPlugin(ignore_info=False, hostname_resolution=True):
64 return CmdPropeciaPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
63 def createPlugin(*args, **kwargs):
64 return CmdPropeciaPlugin(*args, **kwargs)
44
55 """
66 from dateutil.parser import parse
7 import re
78 import json
89 from datetime import datetime
910 from dataclasses import dataclass
1718 __maintainer__ = "Nicolas Rebagliati"
1819 __email__ = "[email protected]"
1920 __status__ = "Development"
20
21 CHECK_NUMBER_REGEX = re.compile(r"^(\[check\d\])")
2122
2223 @dataclass
2324 class Issue:
5253 scored = json_data.get("Status", "")
5354 account = json_data.get("Account Number", "")
5455 message = json_data.get("Message", "")
55 control = json_data.get("Control", "")
56 control = CHECK_NUMBER_REGEX.sub("", json_data.get("Control", "")).strip()
5657 status = json_data.get("Status", "")
5758 level = json_data.get("Level", "")
5859 control_id = json_data.get("Control ID", "")
6162 timestamp = parse(timestamp)
6263 compliance = json_data.get("Compliance", "")
6364 service = json_data.get("Service", "")
64 caf_epic = json_data.get("CAF Epic", "")
65 caf_epic = [json_data.get("CAF Epic", "")]
6566 risk = json_data.get("Risk", "")
6667 doc_link = json_data.get("Doc link", "")
6768 remediation = json_data.get("Remediation", "")
104105 data=f"Resource ID: {issue.resource_id}",
105106 severity=self.normalize_severity(issue.severity), resolution=issue.remediation,
106107 run_date=issue.timestamp, external_id=f"{self.name.upper()}-{issue.control_id}",
107 ref=[issue.doc_link])
108 ref=[issue.doc_link],
109 policyviolations=issue.caf_epic)
108110
109111
110 def createPlugin(ignore_info=False, hostname_resolution=True):
111 return ProwlerPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
112 def createPlugin(*args, **kwargs):
113 return ProwlerPlugin(*args, **kwargs)
154154 self.glossary = glossary
155155 self.severity = self.severity_dict.get(self.get_text_from_glossary('SEVERITY'), 'info')
156156 self.title = self.get_text_from_glossary('TITLE')
157 self.cvss = self.get_text_from_glossary('CVSS_SCORE/CVSS_BASE')
157 self.cvss2 = {}
158158 self.pci = self.get_text_from_glossary('PCI_FLAG')
159159 self.solution = self.get_text_from_glossary('SOLUTION')
160160 self.impact = self.get_text_from_glossary('IMPACT')
177177 cve_id = self.get_text_from_glossary('CVE_ID_LIST/CVE_ID/ID')
178178 if cve_id:
179179 self.cve.append(cve_id)
180
181 if self.cvss:
182 self.ref.append(f'CVSS SCORE: {self.cvss}')
183180
184181 if self.pci:
185182 self.ref.append(f'PCI: {self.pci}')
277274 self.name = self.node.get('number')
278275 self.external_id = self.node.get('number')
279276 self.title = self.get_text_from_subnode('TITLE')
280 self.cvss = self.get_text_from_subnode('CVSS_BASE')
277 self.cvss2 = {}
278
281279 self.diagnosis = self.get_text_from_subnode('DIAGNOSIS')
282280 self.solution = self.get_text_from_subnode('SOLUTION')
283281 self.result = self.get_text_from_subnode('RESULT')
311309 for r in issue_node.findall('BUGTRAQ_ID_LIST/BUGTRAQ_ID'):
312310 self.node = r
313311 self.ref.append('bid-' + self.get_text_from_subnode('ID'))
314
315 if self.cvss:
316 self.ref.append('CVSS BASE: ' + self.cvss)
317312
318313 def get_text_from_subnode(self, subnode_xpath_expr):
319314 """
363358 resolution=v.solution if v.solution else '',
364359 desc=v.desc,
365360 external_id=v.external_id,
366 cve=v.cve)
361 cve=v.cve,
362 cvss2=v.cvss2
363 )
367364
368365 else:
369366 web = False
397394 desc=v.desc,
398395 resolution=v.solution if v.solution else '',
399396 external_id=v.external_id,
400 cve=v.cve)
397 cve=v.cve,
398 cvss2=v.cvss2
399 )
401400
402401 else:
403402 self.createAndAddVulnToService(
409408 desc=v.desc,
410409 resolution=v.solution if v.solution else '',
411410 external_id=v.external_id,
412 cve=v.cve)
411 cve=v.cve,
412 cvss2=v.cvss2
413 )
413414
414415 del parser
415416
416417
417 def createPlugin(ignore_info=False, hostname_resolution=True):
418 return QualysguardPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
418 def createPlugin(*args, **kwargs):
419 return QualysguardPlugin(*args, **kwargs)
151151 # Data in the xml is in different parts, we look into the glossary
152152 vuln_data = next((item for item in glossary if item["QID"] == vuln_scan_id), None)
153153 vuln_name = vuln_data.get('TITLE')
154 vuln_desc = vuln_data.get('DESCRIPTION') + v.dict_result_vul.get('URL')
154 vuln_desc = vuln_data.get('DESCRIPTION')
155 vuln_CWE = [vuln_data.get('CWE', '')]
155156 raw_severity = int(vuln_data.get('SEVERITY', 0))
156157 vuln_severity = raw_severity - 1
157158
162163
163164 vuln_resolution = vuln_data.get('SOLUTION')
164165
165 vuln_ref = []
166 if vuln_data.get('CVSS_BASE'):
167 vuln_ref = [f"CVSS: {vuln_data.get('CVSS_BASE')}"]
166 cvss3 = {}
168167
169168 vuln_data_add = f"ID: {v.dict_result_vul.get('ID')}, DETECTION_ID: {v.dict_result_vul.get('DETECTION_ID')}" \
170169 f", CATEGORY: {vuln_data.get('CATEGORY')}, GROUP: {vuln_data.get('GROUP')}" \
171170 f", URL: {v.dict_result_vul.get('URL')}, IMPACT: {vuln_data.get('IMPACT')}"
172171
173 self.createAndAddVulnToHost(host_id=host_id, name=vuln_name, desc=vuln_desc, ref=vuln_ref,
172 self.createAndAddVulnToHost(host_id=host_id, name=vuln_name, desc=vuln_desc,
174173 severity=vuln_severity, resolution=vuln_resolution, run_date=run_date,
175 external_id="QUALYS-"+vuln_scan_id, data=vuln_data_add)
174 external_id="QUALYS-"+vuln_scan_id, data=vuln_data_add, cwe=vuln_CWE,
175 cvss3=cvss3)
176176
177177
178 def createPlugin(ignore_info=False, hostname_resolution=True):
179 return QualysWebappPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
178 def createPlugin(*args, **kwargs):
179 return QualysWebappPlugin(*args, **kwargs)
4040 )
4141
4242
43 def createPlugin(ignore_info=False, hostname_resolution=True):
44 return RDPScanPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
43 def createPlugin(*args, **kwargs):
44 return RDPScanPlugin(*args, **kwargs)
169169
170170
171171
172 def createPlugin(ignore_info=False, hostname_resolution=True):
173 return ReconngPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
172 def createPlugin(*args, **kwargs):
173 return ReconngPlugin(*args, **kwargs)
122122 self.pciLevel = self.get_text_from_subnode('pciLevel')
123123 self.pciReason = self.get_text_from_subnode('pciReason')
124124 self.pciPassFail = self.get_text_from_subnode('pciPassFail')
125 self.cvssScore = self.get_text_from_subnode('cvssScore')
125 self.cvss2Score = self.get_text_from_subnode('cvssScore')
126126 self.exploit = self.get_text_from_subnode('exploit')
127127 self.context = self.get_text_from_subnode('context')
128128 val = self.context.split(":")
136136 self.desc = self.get_text_from_subnode('description')
137137 self.solution = self.solution if self.solution else ""
138138 self.desc += "\nExploit: " + self.exploit if self.exploit else ""
139 self.desc += "\ncvssScore: " + self.cvssScore if self.cvssScore else ""
140139 self.desc += "\nContext: " + self.context if self.context else ""
141140
142141 self.ref = []
142 self.cvss2 = {}
143 if self.cvss2Score != "N/A":
144 self.cvss2["vector_string"] = self.cvss2Score.split(' ')[1].replace('[', '').replace(']', '')
143145
144146 def get_text_from_subnode(self, subnode_xpath_expr):
145147 """
198200 if web:
199201 v_id = self.createAndAddVulnWebToService(h_id, s_id, v.name, ref=v.ref,
200202 website=hostname, severity=v.severity,
201 resolution=v.solution, desc=v.desc, cve=cve)
203 resolution=v.solution, desc=v.desc, cve=cve, cvss2=v.cvss2)
202204 else:
203205 v_id = self.createAndAddVulnToService(h_id, s_id, v.name, ref=v.ref,
204206 severity=v.severity, resolution=v.solution,
205 desc=v.desc, cve=cve)
207 desc=v.desc, cve=cve, cvss2=v.cvss2)
206208 else:
207209 for v in vulns:
208210 cve = v.cve.split(",") if v.cve else []
209211 v_id = self.createAndAddVulnToHost(h_id, v.name, ref=v.ref, severity=v.severity,
210 resolution=v.solution, desc=v.desc, cve=cve)
212 resolution=v.solution, desc=v.desc, cve=cve, cvss2=v.cvss2)
211213 del parser
212214
213215
214 def createPlugin(ignore_info=False, hostname_resolution=True):
215 return RetinaPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
216 def createPlugin(*args, **kwargs):
217 return RetinaPlugin(*args, **kwargs)
7777
7878
7979
80 def createPlugin(ignore_info=False, hostname_resolution=True):
81 return ReverseraiderPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
80 def createPlugin(*args, **kwargs):
81 return ReverseraiderPlugin(*args, **kwargs)
1313
1414 from faraday_plugins.plugins.plugin import PluginMultiLineJsonFormat
1515 from faraday_plugins.plugins.plugins_utils import get_severity_from_cvss
16
1617 __author__ = "Valentin Vila"
1718 __copyright__ = "Copyright (c) 2021, Faraday"
1819 __credits__ = ["Valentin Vila"]
7172 for name, vuln_info in vulns.items():
7273 description = vuln_info.get('summary')
7374 references = vuln_info.get('references')
74 cvss = vuln_info.get('cvss')
75 severity = get_severity_from_cvss(cvss) if cvss else "info"
76 self.createAndAddVulnToService(h_id, s_id, name, desc=description, severity=severity, ref=references, cve=name)
75 self.createAndAddVulnToService(h_id, s_id, name, desc=description, ref=references
76 , cve=name)
7777
7878 def processCommandString(self, username, current_path, command_string):
7979 """
103103 return cmd
104104
105105
106 def createPlugin(ignore_info=False, hostname_resolution=True):
107 return ShodanPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
106 def createPlugin(*args, **kwargs):
107 return ShodanPlugin(*args, **kwargs)
192192 """
193193 super().processCommandString(username, current_path, command_string)
194194 arg_match = self.xml_arg_re.match(command_string)
195 self._output_file_path = os.path.join(tempfile.gettempdir(), "faraday_plugin_skipfish_%d" % random.randint(1, 999999))
195 self._output_file_path = os.path.join(tempfile.gettempdir(),
196 "faraday_plugin_skipfish_%d" % random.randint(1, 999999)) # nosec
196197 self._delete_temp_file = True
197198 if arg_match is None:
198199 return re.sub(r"(^.*?skipfish)", r"\1 -o %s" % self._output_file_path, command_string, 1)
202203
203204
204205
205 def createPlugin(ignore_info=False, hostname_resolution=True):
206 return SkipfishPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
206 def createPlugin(*args, **kwargs):
207 return SkipfishPlugin(*args, **kwargs)
55 """
66 import json
77 from faraday_plugins.plugins.plugin import PluginJsonFormat
8 from datetime import datetime
9 import dateutil
8 from dateutil.parser import parse
109
1110 VULNERABILITY = "VULNERABILITY"
1211
5251 status = STATUSES[issue['status']]
5352 tags = issue['tags']
5453 external_id = issue['rule']
55 creation_date = dateutil.parser.parse(issue['creationDate'])
54 creation_date = parse(issue['creationDate'])
5655 data = [] if not issue['flows'] else ["Flows:"]
5756 for flow in issue['flows']:
5857 for location in flow['locations']:
9392 )
9493
9594
96 def createPlugin(ignore_info=False, hostname_resolution=True):
97 return SonarQubeAPIPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
95 def createPlugin(*args, **kwargs):
96 return SonarQubeAPIPlugin(*args, **kwargs)
6262 for vuln in vulns:
6363 v_name = vuln['title']
6464 v_desc = vuln['overview']
65 v_ref = f"CVSS: {vuln['cvssScore']}"
6665 v_data = vuln['libraries']
6766 v_website = vuln['_links']['html']
6867 url_data = parser.parse_url(v_website)
7776 h_id = self.createAndAddHost(name=host_name, scan_template=records['metadata']['recordType'])
7877 s_id = self.createAndAddServiceToHost(h_id, "Sourceclear", protocol=url_data['protocol'],
7978 ports=url_data['port'], status='open')
80 self.createAndAddVulnWebToService(h_id, s_id, name=v_name, desc=v_desc, ref=[v_ref], data=v_data,
79 self.createAndAddVulnWebToService(h_id, s_id, name=v_name, desc=v_desc, data=v_data,
8180 website=v_website)
8281
8382
84 def createPlugin(ignore_info=False, hostname_resolution=True):
85 return SourceclearPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
83 def createPlugin(*args, **kwargs):
84 return SourceclearPlugin(*args, **kwargs)
6565 return None
6666
6767
68 def createPlugin(ignore_info=False, hostname_resolution=True):
69 return SSHDefaultScanPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
68 def createPlugin(*args, **kwargs):
69 return SSHDefaultScanPlugin(*args, **kwargs)
106106 data=vuln['data'])
107107
108108
109 def createPlugin(ignore_info=False, hostname_resolution=True):
110 return SslLabsPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
109 def createPlugin(*args, **kwargs):
110 return SslLabsPlugin(*args, **kwargs)
168168 severity="medium")
169169
170170
171 def createPlugin(ignore_info=False, hostname_resolution=True):
172 return SslyzePlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
171 def createPlugin(*args, **kwargs):
172 return SslyzePlugin(*args, **kwargs)
286286 command_string)
287287
288288
289 def createPlugin(ignore_info=False, hostname_resolution=True):
290 return SslyzePlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
289 def createPlugin(*args, **kwargs):
290 return SslyzePlugin(*args, **kwargs)
5858 "desc": desc,
5959 "resolution": resolution,
6060 "ref": ref,
61 "severity": severity
61 "severity": severity,
62 "cvss3": cvss3,
63 "cvss2": cvss2
6264 }
6365 if self.scan_type == "DAST":
6466 v['data'] = vuln.find("request").text + "\n"
7173 @staticmethod
7274 def get_cvss(tree):
7375 cvss_vector = tree.find("vector").text
74 cvss_score = tree.find("score").text
75 return {'base_score':cvss_score, 'cvss_vector': cvss_vector}
76 return {'vector_stringr': cvss_vector}
7677
7778 def get_host(self, tree):
7879 host = {
124125 self.createAndAddVulnToHost(host_id=host_id, **issue)
125126
126127
127 def createPlugin(ignore_info=False, hostname_resolution=True):
128 return SyhuntPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
128 def createPlugin(*args, **kwargs):
129 return SyhuntPlugin(*args, **kwargs)
7575 self._port = count_args[c - 1]
7676
7777
78 def createPlugin(ignore_info=False, hostname_resolution=True):
79 return TelnetRouterPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
78 def createPlugin(*args, **kwargs):
79 return TelnetRouterPlugin(*args, **kwargs)
114114
115115
116116
117 def createPlugin(ignore_info=False, hostname_resolution=True):
118 return TheharvesterPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
117 def createPlugin(*args, **kwargs):
118 return TheharvesterPlugin(*args, **kwargs)
5555 return None
5656
5757
58 def createPlugin(ignore_info=False, hostname_resolution=True):
59 return traceroutePlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
58 def createPlugin(*args, **kwargs):
59 return traceroutePlugin(*args, **kwargs)
0 class Base:
1 def __init__(self, node):
2 self.node = node
3
4
5 class Cvss(Base):
6 @property
7 def v2vector(self):
8 return self.node.get("V2Vector")
9
10 @property
11 def v3vector(self):
12 return self.node.get("V3Vector")
13
14 @property
15 def v2score(self):
16 return self.node.get("V2Score")
17
18 @property
19 def v3score(self):
20 return self.node.get("V3Score")
21
22
23 class Line(Base):
24
25 @property
26 def number(self):
27 return self.node.get("Number")
28
29 @property
30 def content(self):
31 return self.node.get("Content")
32
33
34 class Code(Base):
35
36 @property
37 def lines(self):
38 if self.node.get("Lines"):
39 return [Line(i) for i in self.node.get("Lines")]
40 else:
41 return None
42
43
44 class CauseMetadata(Base):
45
46 @property
47 def code(self):
48 return Code(self.node.get("Code"))
49
50
51 class Misconfiguration(Base):
52
53 @property
54 def misconfig_type(self):
55 return self.node.get("Type")
56
57 @property
58 def misconfig_id(self):
59 return self.node.get("ID")
60
61 @property
62 def title(self):
63 return self.node.get("Title")
64
65 @property
66 def description(self):
67 description = self.node.get("Description")
68 if description:
69 return description
70 else:
71 return "Issues provided no description"
72
73 @property
74 def message(self):
75 return self.node.get("Message")
76
77 @property
78 def resolution(self):
79 return self.node.get("Resolution")
80
81 @property
82 def severity(self):
83 return self.node.get("Severity")
84
85 @property
86 def references(self):
87 return self.node.get("References")
88
89 @property
90 def cause_metadata(self):
91 return CauseMetadata(self.node.get("CauseMetadata"))
92
93
94 class Vulnerability(Base):
95
96 @property
97 def name(self):
98 return self.node.get("VulnerabilityID")
99
100 @property
101 def title(self):
102 return self.node.get("Title")
103
104 @property
105 def pkgname(self):
106 return self.node.get("PkgName")
107
108 @property
109 def url(self):
110 return self.node.get("PrimaryURL")
111
112 @property
113 def description(self):
114 description = self.node.get("Description")
115 if description:
116 return description
117 else:
118 return "Issues provided no description"
119
120 @property
121 def severity(self):
122 return self.node.get("Severity")
123
124 @property
125 def cwe(self):
126 return self.node.get("CweIDs")
127
128 @property
129 def cvss(self):
130 if self.node.get("cvss"):
131 return Cvss(self.node.get("cvss").get("nvd"))
132 else:
133 return None
134
135 @property
136 def references(self):
137 return self.node.get("References")
138
139
140 class Result(Base):
141
142 @property
143 def target(self):
144 return self.node.get("Target")
145
146 @property
147 def misconfigurations(self):
148 return [Misconfiguration(i) for i in self.node.get("Misconfigurations", [])]
149
150 @property
151 def vulnerability(self):
152 return [Vulnerability(i) for i in self.node.get("Vulnerabilities", [])]
153
154 @property
155 def result_type(self):
156 return self.node.get("Type")
157
158
159 class Metadata(Base):
160
161 @property
162 def os_family(self):
163 return self.node.get("Family")
164
165 @property
166 def os_name(self):
167 return self.node.get("Name")
168
169
170 class TrivyJsonParser(Base):
171
172 @property
173 def results(self):
174 return [Result(i) for i in self.node.get('Results', "")]
175
176 @property
177 def scantype(self):
178 return self.node.get('ArtifactType')
179
180 def metadata(self):
181 return Metadata(self.node.get('Metadata'))
0 """
1 Faraday Penetration Test IDE
2 Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/)
3 See the file 'doc/LICENSE' for the license information
4
5 """
6 from faraday_plugins.plugins.plugin import PluginJsonFormat
7 from faraday_plugins.plugins.repo.trivy_json.DTO import TrivyJsonParser
8 from json import loads
9
10 __author__ = "Gonzalo Martinez"
11 __copyright__ = "Copyright (c) 2013, Infobyte LLC"
12 __credits__ = ["Gonzalo Martinez"]
13 __version__ = "1.0.0"
14 __maintainer__ = "Gonzalo Martinez"
15 __email__ = "[email protected]"
16 __status__ = "Development"
17
18
19 class TrivyJsonPlugin(PluginJsonFormat):
20
21 def __init__(self, *arg, **kwargs):
22 super().__init__(*arg, **kwargs)
23 self.id = "Trivy_Json"
24 self.name = "Trivy JSON Output Plugin"
25 self.plugin_version = "1"
26 self.version = "9"
27 self.json_keys = {'SchemaVersion'}
28 self.framework_version = "1.0.0"
29 self._temp_file_extension = "json"
30
31 def parseOutputString(self, output):
32 parser = TrivyJsonParser(loads(output))
33 scantype = parser.scantype
34 for result in parser.results:
35 self.new_structure(result, scantype)
36
37 def new_structure(self, result, scantype):
38 source_file = result.target
39 host_id = self.createAndAddHost(source_file, os=result.result_type, description=scantype)
40 for misconfiguration in result.misconfigurations:
41 self.create_vuln_dockerfile(misconfiguration, host_id)
42 for vulnerability in result.vulnerability:
43 self.create_vuln_image(vulnerability, host_id)
44
45 def create_vuln_image(self, vulnerability, host_id):
46 ref = vulnerability.references
47 cvss3 = {}
48 cvss2 = {}
49 if vulnerability.cvss:
50 cvss3["vector_string"] = vulnerability.cvss.v3score
51 cvss2["vector_string"] = vulnerability.cvss.v2score
52 cwe = []
53 if vulnerability.cwe:
54 if isinstance(vulnerability.cwe, list):
55 for v_cwe in vulnerability.cwe:
56 cwe.append(v_cwe)
57 else:
58 cwe.append(vulnerability.cwe)
59 if vulnerability.title == "security flaw":
60 name = vulnerability.pkgname + ":" + vulnerability.title
61 elif vulnerability.title is None:
62 name = vulnerability.pkgname
63 else:
64 name = vulnerability.title
65 self.createAndAddVulnToHost(
66 host_id,
67 name=name,
68 desc=vulnerability.description,
69 severity=vulnerability.severity,
70 ref=ref,
71 cve=vulnerability.name,
72 cvss2=cvss2,
73 cvss3=cvss3,
74 cwe=cwe
75 )
76
77 def create_vuln_dockerfile(self, misconfiguration, host_id):
78 ref = misconfiguration.references
79 data = [misconfiguration.message]
80 if misconfiguration.cause_metadata.code.lines:
81 for line in misconfiguration.cause_metadata.code.lines:
82 data.append(f"Line {line.number}, {line.content}")
83 self.createAndAddVulnToHost(
84 host_id,
85 name=misconfiguration.title,
86 desc=misconfiguration.description,
87 severity=misconfiguration.severity,
88 resolution=misconfiguration.resolution,
89 external_id=f"Trivy-{misconfiguration.misconfig_id}",
90 ref=ref,
91 data="\n".join(data)
92 )
93
94
95 def createPlugin(*args, **kwargs):
96 return TrivyJsonPlugin(*args, **kwargs)
212212 del parser
213213
214214
215 def createPlugin(ignore_info=False, hostname_resolution=True):
216 return W3afPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
215 def createPlugin(*args, **kwargs):
216 return W3afPlugin(*args, **kwargs)
88 from urllib.parse import urlparse
99
1010 from faraday_plugins.plugins.plugin import PluginXMLFormat
11 from faraday_plugins.plugins.plugins_utils import CWE_regex
1112
1213 __author__ = "Francisco Amato"
1314 __copyright__ = "Copyright (c) 2013, Infobyte LLC"
147148 vulns_dict['description'] = self.get_text_from_subnode(vuln, 'description')
148149 vulns_dict['solution'] = self.get_text_from_subnode(vuln, 'solution')
149150 vulns_dict['references'] = self.get_references(vuln)
151 vulns_dict['cwe'] = self.get_cwe(vuln)
150152 vulns_dict['entries'] = self.get_entries(vuln)
151153 vulns_list.append(vulns_dict)
152154
153155 return vulns_list
156
157 def get_cwe(self, node):
158 refs = node.findall('references/reference')
159 for ref in refs:
160 if CWE_regex.search(self.get_text_from_subnode(ref, 'title')):
161 return [CWE_regex.search(self.get_text_from_subnode(ref, 'title')).group()]
162 return []
154163
155164 def get_references(self, node):
156165 refs = node.findall('references/reference')
290299 path=entry['path'],
291300 request=entry['http_request'],
292301 method=entry['method'],
293 params=entry['parameter'])
302 params=entry['parameter'],
303 cwe=vuln["cwe"])
294304
295305 def processCommandString(self, username, current_path, command_string):
296306 """
316326 return f"{command_string} -o {self._output_file_path} -f xml \n"
317327
318328
319 def createPlugin(ignore_info=False, hostname_resolution=True):
320 return WapitiPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
329 def createPlugin(*args, **kwargs):
330 return WapitiPlugin(*args, **kwargs)
117117 return re.sub(arg_match.group(1), r"-xml %s" % self._output_file_path, command_string)
118118
119119
120 def createPlugin(ignore_info=False, hostname_resolution=True):
121 return WcscanPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
120 def createPlugin(*args, **kwargs):
121 return WcscanPlugin(*args, **kwargs)
134134 self._output_path = current_path + "/" + self.host + ".txt"
135135
136136
137 def createPlugin(ignore_info=False, hostname_resolution=True):
138 return WebfuzzerPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
137 def createPlugin(*args, **kwargs):
138 return WebfuzzerPlugin(*args, **kwargs)
149149 )
150150
151151
152 def createPlugin(ignore_info=False, hostname_resolution=True):
153 return WebInspectPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
152 def createPlugin(*args, **kwargs):
153 return WebInspectPlugin(*args, **kwargs)
8383 path=path)
8484
8585
86 def createPlugin(ignore_info=False, hostname_resolution=True):
87 return WfuzzPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
86 def createPlugin(*args, **kwargs):
87 return WfuzzPlugin(*args, **kwargs)
7373 description=desc)
7474
7575
76 def createPlugin(ignore_info=False, hostname_resolution=True):
77 return WhatWebPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
76 def createPlugin(*args, **kwargs):
77 return WhatWebPlugin(*args, **kwargs)
3434 parser = json.loads(output)
3535 if parser.get('vulnerabilities'):
3636 for vulnerability in parser['vulnerabilities']:
37
37 cvss3 = {}
38 cvss2 = {}
3839 if 'project' in vulnerability:
3940 application_name = vulnerability.get('project')
4041 host_id = self.createAndAddHost(application_name)
4142 data = ''
4243 for key, value in vulnerability['library'].items():
4344 data += f'{key}: {value} \n'
44 refs = [
45 f"CVSS: {vulnerability['score']}",
46 ]
47 if 'cvss3_score' in vulnerability:
48 refs.append(f"CVSS3: {vulnerability['cvss3_score']}")
45 refs = []
46 if "scoreMetadataVector" in vulnerability:
47 cvss3["vector_string"] = vulnerability['scoreMetadataVector']
4948 if 'topFix' in vulnerability:
5049 refs.append(f"URL: {vulnerability['topFix']['url']}")
5150 self.createAndAddVulnToHost(host_id,
5554 resolution=vulnerability['topFix']['fixResolution'],
5655 ref=refs,
5756 severity=vulnerability['severity'],
58 cve=[vulnerability['name']])
57 cve=[vulnerability['name']],
58 cvss2=cvss2,
59 cvss3=cvss3)
5960 else:
6061 self.createAndAddVulnToHost(host_id,
6162 name=vulnerability['name'],
6263 desc=vulnerability['description'],
6364 data=data,
6465 ref=refs,
65 severity=vulnerability['severity'])
66 severity=vulnerability['severity'],
67 cvss2=cvss2,
68 cvss3=cvss3)
6669 elif 'namespace' in vulnerability:
6770 host_id = self.createAndAddHost(vulnerability['namespace'])
6871 service_id = self.createAndAddServiceToHost(
97100 )
98101
99102
100 def createPlugin(ignore_info=False, hostname_resolution=True):
101 return WhitesourcePlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
103 def createPlugin(*args, **kwargs):
104 return WhitesourcePlugin(*args, **kwargs)
124124 return True
125125
126126
127 def createPlugin(ignore_info=False, hostname_resolution=True):
128 return CmdWhoisPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
127 def createPlugin(*args, **kwargs):
128 return CmdWhoisPlugin(*args, **kwargs)
44
55 """
66 import json
7 import re
78 from urllib.parse import urlparse
89
10 from faraday_plugins.plugins.plugin import PluginJsonFormat
911
1012 __author__ = "Nicolas Rebagliati"
1113 __copyright__ = "Copyright (c) 2019, Infobyte LLC"
1517 __maintainer__ = "Nicolas Rebagliati"
1618 __email__ = "[email protected]"
1719 __status__ = "Development"
18
19 from faraday_plugins.plugins.plugin import PluginJsonFormat
2020
2121
2222 class WPScanJsonParser:
4242 return {'protocol': protocol, 'hostname': hostname, 'port': port, 'address': address}
4343
4444
45
4645 class WPScanPlugin(PluginJsonFormat):
4746 """ Handle the WPScan tool. Detects the output of the tool
4847 and adds the information to Faraday.
5554 self.plugin_version = "0.2"
5655 self.version = "3.4.5"
5756 self.json_keys = {"target_url", "effective_url", "interesting_findings"}
57 self._command_regex = re.compile(r'^(sudo wpscan|wpscan)\s+.*?')
58 self._use_temp_file = True
59 self._temp_file_extension = "json"
5860
5961 def parseOutputString(self, output):
6062 parser = WPScanJsonParser(output, self.resolve_hostname)
8991 self.createAndAddVulnWebToService(host_id, service_id, vuln_name, ref=vuln['references'].get('url', []),
9092 severity='unclassified')
9193
94 def processCommandString(self, username, current_path, command_string):
95 """
96 Adds the path to a temporary file parameter to get .json output to the command string that the
97 user has set.
98 """
99 super().processCommandString(username, current_path, command_string)
100 command_string += f" --output={self._output_file_path} --format json"
101 return command_string
92102
93 def createPlugin(ignore_info=False, hostname_resolution=True):
94 return WPScanPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
103
104 def createPlugin(*args, **kwargs):
105 return WPScanPlugin(*args, **kwargs)
176176 del parser
177177
178178
179 def createPlugin(ignore_info=False, hostname_resolution=True):
180 return X1Plugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
179 def createPlugin(*args, **kwargs):
180 return X1Plugin(*args, **kwargs)
5353 params=''.join(parametro), request='', response='')
5454
5555
56 def createPlugin(ignore_info=False, hostname_resolution=True):
57 return xsssniper(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
56 def createPlugin(*args, **kwargs):
57 return xsssniper(*args, **kwargs)
139139 self.resolution = self.get_text_from_subnode('solution')
140140 else:
141141 self.resolution = ''
142
142 self.cwe = []
143143 self.ref = []
144144 if self.get_text_from_subnode('reference'):
145145 links = self.get_text_from_subnode('reference')
149149 self.ref.append(strip_tags(link))
150150
151151 if self.get_text_from_subnode('cweid'):
152 self.ref.append("CWE:" + self.get_text_from_subnode('cweid'))
152 self.cwe.append("CWE-" + self.get_text_from_subnode('cweid'))
153153
154154 if self.get_text_from_subnode('wascid'):
155155 self.ref.append("WASC:" + self.get_text_from_subnode('wascid'))
277277 resolution=strip_tags(item.resolution),
278278 data=instance["data"],
279279 pname=instance["pname"],
280 external_id="ZAP-" + str(item.id)
280 external_id="ZAP-" + str(item.id),
281 cwe=item.cwe
281282 )
282283
283284 del parser
284285
285286
286 def createPlugin(ignore_info=False, hostname_resolution=True):
287 return ZapPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
287 def createPlugin(*args, **kwargs):
288 return ZapPlugin(*args, **kwargs)
8888 data += f" Parameter:\n {instance.param}"
8989
9090 ref = []
91 cwe = []
9192 if item.reference:
9293 ref += split_and_strip_tags(item.reference)
9394 if item.cwe:
94 ref += [f"CWE:{item.cwe}"]
95 cwe += [f"CWE-{item.cwe}"]
9596 if item.wasc:
9697 ref += [f"WASC:{item.wasc}"]
9798
110111 resolution=strip_tags(item.solution),
111112 data=data,
112113 pname=instance.param,
113 external_id="ZAP-" + str(item.plugin_id)
114 external_id="ZAP-" + str(item.plugin_id),
115 cwe=cwe
114116 )
115117
116118 del parser
117119
118120
119 def createPlugin(ignore_info=False, hostname_resolution=True):
120 return ZapJsonPlugin(ignore_info=ignore_info, hostname_resolution=hostname_resolution)
121 def createPlugin(*args, **kwargs):
122 return ZapJsonPlugin(*args, **kwargs)
1616 {"plugin_id": "Dnsrecon", "command": "dnsrecon www.google.com", "command_result": "Dnsrecon"},
1717 {"plugin_id": "Dnswalk", "command": "dnswalk www.google.com", "command_result": "Dnswalk"},
1818 {"plugin_id": "Fierce", "command": "fierce www.google.com", "command_result": "Fierce"},
19 {"plugin_id": "fruitywifi", "command": "fruitywifi www.google.com", "command_result": "fruitywifi"},
2019 {"plugin_id": "ftp", "command": "ftp www.google.com", "command_result": "ftp"},
2120 {"plugin_id": "Goohost", "command": "goohost.sh www.google.com", "command_result": "goohost.sh"},
2221 {"plugin_id": "Hping3", "command": "hping3 www.google.com", "command_result": "Hping3"},
9595 assert summary['severity_vulns'] == saved_summary['severity_vulns']
9696 assert vuln_hashes == saved_vuln_hashes
9797
98
99 def test_process_report_ignore_info():
100 report_file = os.path.join('./report-collection', 'faraday_plugins_tests', 'Nmap', 'nmap_5.21.xml')
101 runner = CliRunner()
102 result = runner.invoke(process_report, args=[report_file, '--summary', '--ignore-info'])
103 assert result.exit_code == 0
104 summary = json.loads(result.output.strip())
105 assert summary['hosts'] == 256
106 assert summary['services'] == 69
107 assert summary['hosts_vulns'] == 0
108 assert summary['services_vulns'] == 0
109
110
111 def test_process_report_tags():
112 report_file = os.path.join('./report-collection', 'faraday_plugins_tests', 'Acunetix', 'acunetix_valid_dummy.xml')
113 runner = CliRunner()
114 args = [report_file, '--vuln-tag=vuln_tag', '--service-tag=service_tag', '--host-tag=host_tag']
115 result = runner.invoke(process_report, args=args)
116 assert result.exit_code == 0
117 body = json.loads(result.output.strip())
118 assert body['hosts'][0]["tags"][0] == "host_tag"
119 assert body['hosts'][0]["services"][0]["tags"][0] == "service_tag"
120 assert body['hosts'][0]["services"][0]["vulnerabilities"][0]["tags"][0] == "vuln_tag"
104104 assert plugin.id == plugin_folder
105105
106106
107 @pytest.mark.skip(reason="Fail until release")
107108 @pytest.mark.parametrize("report_filename_and_folder", list_report_files())
108109 def test_schema_on_all_reports(report_filename_and_folder):
109110 report_filename = report_filename_and_folder[1]