|
| 1 | +""" |
| 2 | +Faraday Penetration Test IDE |
| 3 | +Copyright (C) 2013 Infobyte LLC (http://www.infobytesec.com/) |
| 4 | +See the file 'doc/LICENSE' for the license information |
| 5 | +""" |
| 6 | + |
| 7 | +import sys |
| 8 | +import io |
| 9 | +from faraday_plugins.plugins.plugin import PluginCSVFormat |
| 10 | +import csv |
| 11 | + |
| 12 | + |
| 13 | +__author__ = "Erodriguez" |
| 14 | +__copyright__ = "Copyright (c) 2019, Infobyte LLC" |
| 15 | +__credits__ = ["Erodriguez"] |
| 16 | +__license__ = "" |
| 17 | +__version__ = "1.0.0" |
| 18 | +__maintainer__ = "Erodriguez" |
| 19 | +__email__ = "erodriguez@faradaysec.com" |
| 20 | +__status__ = "Development" |
| 21 | + |
| 22 | + |
| 23 | +class SecScoreCard(PluginCSVFormat): |
| 24 | + """ |
| 25 | + Example plugin to parse SecScoreBoard_CSV output. |
| 26 | + """ |
| 27 | + |
| 28 | + def __init__(self, *arg, **kwargs): |
| 29 | + super().__init__(*arg, **kwargs) |
| 30 | + self.csv_headers = [{"LABEL"}, {"PROVIDER"}] |
| 31 | + self.id = "SecScoreCard_CSV" |
| 32 | + self.name = "SecScoreCard_CSV Output Plugin" |
| 33 | + self.plugin_version = "0.0.1" |
| 34 | + self.version = "0.0.1" |
| 35 | + self.framework_version = "1.0.1" |
| 36 | + |
| 37 | + def parseOutputString(self, output): |
| 38 | + try: |
| 39 | + csv.field_size_limit(sys.maxsize) |
| 40 | + print(str(output)) |
| 41 | + csv_file = io.StringIO(output) |
| 42 | + reader = csv.DictReader(csv_file, delimiter=",") |
| 43 | + for row in reader: |
| 44 | + path = row.get("FINAL URL", "") |
| 45 | + if not path: |
| 46 | + path = row.get("IP ADDRESS", "") |
| 47 | + if not path: |
| 48 | + path = row.get("HOSTNAME", "") |
| 49 | + if not path: |
| 50 | + continue |
| 51 | + |
| 52 | + # Skip if HOSTNAME is empty or not a valid IP |
| 53 | + hostname = row.get("HOSTNAME", "") |
| 54 | + |
| 55 | + name = row.get("ISSUE TYPE TITLE", "") |
| 56 | + |
| 57 | + # Handle references |
| 58 | + references = [] |
| 59 | + cve = row.get("CVE", "") |
| 60 | + if cve: |
| 61 | + references.append(cve) |
| 62 | + |
| 63 | + # Handle description |
| 64 | + desc = row.get("DESCRIPTION", "") |
| 65 | + |
| 66 | + # Create host and vulnerability |
| 67 | + h_id = self.createAndAddHost( |
| 68 | + name=path, |
| 69 | + hostnames=hostname, |
| 70 | + ) |
| 71 | + self.createAndAddVulnToHost( |
| 72 | + host_id=h_id, |
| 73 | + name=name, |
| 74 | + desc=desc, |
| 75 | + resolution=str(row.get("ISSUE RECOMMENDATION", "")), |
| 76 | + external_id=str(row.get("ISSUE ID", "")), |
| 77 | + cve=str(cve), |
| 78 | + severity=str(row.get("ISSUE TYPE SEVERITY", "")), |
| 79 | + ref=references, |
| 80 | + data=str(row.get("DATA", "")), |
| 81 | + ) |
| 82 | + |
| 83 | + except Exception as e: |
| 84 | + print(f"Error parsing output: {str(e)}") |
| 85 | + return None |
| 86 | + |
| 87 | + |
| 88 | +def createPlugin(*args, **kargs): |
| 89 | + return SecScoreCard(*args, **kargs) |
0 commit comments