Codebase list faraday-plugins / 4acfd67
Import upstream version 1.7.0+git20220915.1.f975b7b Kali Janitor 1 year, 7 months ago
266 changed file(s) with 1194 addition(s) and 1996 deletion(s). Raw diff Collapse all Expand all
+0
-3
.flake8 less more
0 [flake8]
1 ignore = W391, E722, E303, E701, W291, E222, E241, E225, E115, E117, E122, E123, E124, E501, E261, E127, E265, F401, W292, W293, W605, E231, E221, E222, F841, E128, W504, E202, F811, E251, E226, E203, E262, E225, E305, E302, E305
2 exclude= report-collection
+0
-132
.gitignore less more
0 # Created by .ignore support plugin (hsz.mobi)
1 ### Python template
2 # Byte-compiled / optimized / DLL files
3 __pycache__/
4 *.py[cod]
5 *$py.class
6
7 # C extensions
8 *.so
9
10 # Distribution / packaging
11 .Python
12 build/
13 develop-eggs/
14 dist/
15 downloads/
16 eggs/
17 .eggs/
18 lib/
19 lib64/
20 parts/
21 sdist/
22 var/
23 wheels/
24 pip-wheel-metadata/
25 share/python-wheels/
26 *.egg-info/
27 .installed.cfg
28 *.egg
29 MANIFEST
30
31 # PyInstaller
32 # Usually these files are written by a python script from a template
33 # before PyInstaller builds the exe, so as to inject date/other infos into it.
34 *.manifest
35 *.spec
36
37 # Installer logs
38 pip-log.txt
39 pip-delete-this-directory.txt
40
41 # Unit test / coverage reports
42 htmlcov/
43 .tox/
44 .nox/
45 .coverage
46 .coverage.*
47 .cache
48 nosetests.xml
49 coverage.xml
50 *.cover
51 .hypothesis/
52 .pytest_cache/
53
54 # Translations
55 *.mo
56 *.pot
57
58 # Django stuff:
59 *.log
60 local_settings.py
61 db.sqlite3
62 db.sqlite3-journal
63
64 # Flask stuff:
65 instance/
66 .webassets-cache
67
68 # Scrapy stuff:
69 .scrapy
70
71 # Sphinx documentation
72 docs/_build/
73
74 # PyBuilder
75 target/
76
77 # Jupyter Notebook
78 .ipynb_checkpoints
79
80 # IPython
81 profile_default/
82 ipython_config.py
83
84 # pyenv
85 .python-version
86
87 # pipenv
88 # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 # install all needed dependencies.
92 #Pipfile.lock
93
94 # celery beat schedule file
95 celerybeat-schedule
96
97 # SageMath parsed files
98 *.sage.py
99
100 # Environments
101 .env
102 .venv
103 env/
104 venv/
105 ENV/
106 env.bak/
107 venv.bak/
108
109 # Spyder project settings
110 .spyderproject
111 .spyproject
112
113 # Rope project settings
114 .ropeproject
115
116 # mkdocs documentation
117 /site
118
119 # mypy
120 .mypy_cache/
121 .dmypy.json
122 dmypy.json
123
124 # Pyre type checker
125 .pyre/
126
127 .idea
128 /report-collection/
129
130 #project settings
131 *.project
+0
-7
.gitlab/ci/fetch-secrets.yml less more
0 .get_secrets:
1 script:
2 - export VAULT_TOKEN="$(vault write -field=token auth/jwt/login role=python-sast-readonly jwt=$CI_JOB_JWT)"; if [ -z "$VAULT_TOKEN" ]; then exit 1; fi
3 - if [ -z "$DEVSECOPS_WORKSPACE" ]; then export DEVSECOPS_WORKSPACE="$(vault kv get -field=DEVSECOPS_WORKSPACE secrets/gitlab/SAST)"; fi; if [ -z "$DEVSECOPS_WORKSPACE" ]; then exit 1; fi
4 - if [ -z "$FARADAY_PASSWORD" ]; then export FARADAY_PASSWORD="$(vault kv get -field=FARADAY_PASSWORD secrets/gitlab/SAST)"; fi; if [ -z "$FARADAY_PASSWORD" ]; then exit 1; fi
5 - if [ -z "$FARADAY_URL" ]; then export FARADAY_URL="$(vault kv get -field=FARADAY_URL secrets/gitlab/SAST)"; fi; if [ -z "$FARADAY_URL" ]; then exit 1; fi
6 - if [ -z "$FARADAY_USER" ]; then export FARADAY_USER="$(vault kv get -field=FARADAY_USER secrets/gitlab/SAST)"; fi; if [ -z "$FARADAY_USER" ]; then exit 1; fi
+0
-117
.gitlab-ci.yml less more
0 variables:
1 VAULT_ROLE: 'python-sast-readonly'
2 VAULT_ADDR: 'https://tluav-lb.faradaysec.com'
3 VAULT_SECRET_PATH: 'gitlab/SAST'
4
5
6 include:
7 - local: .gitlab/ci/fetch-secrets.yml
8
9 stages:
10 - SAST
11 - pre_testing
12 - testing
13 - post_testing
14 - publish
15
16 before_script:
17 - apt-get update -qy
18 - pip install pip -U
19
20 workflow:
21 rules:
22 - if: $CI_MERGE_REQUEST_ID
23 when: never
24 - when: always
25
26 .install_faraday_venv: &install_faraday_venv
27 - pip3 install virtualenv
28 - virtualenv -p python3 faraday_venv
29 - source faraday_venv/bin/activate
30 - pip3 install pytest pytest-xdist pytest-cov
31 - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/faraday.git
32 - cd faraday
33 - pip3 install $PIP_FLAGS .
34 - pip uninstall faraday-plugins -y # we need to install fardaysec for marshmallow schemas, we remove plugins from pypi
35 - cd ..
36
37 .clone_reports: &clone_reports
38 - git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/faradaysec/support/report-collection.git
39 - cd report-collection
40 - (git branch -a | grep $CI_COMMIT_BRANCH) && export REPORT_REF=$CI_COMMIT_BRANCH || export REPORT_REF=master
41 - git checkout $REPORT_REF
42 - cd ..
43
44 bandit:
45 stage: SAST
46 image: python:3
47 tags:
48 - faradaytests
49 script:
50 - pip3 install bandit
51 - mkdir /results
52 - "bandit -r ${CI_PROJECT_DIR} -o /results/output.xml -f xml"
53 after_script:
54 - curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add -
55 - apt update
56 - apt-get install software-properties-common -y
57 - apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com focal main"
58 - apt update
59 - apt install vault -y
60 - setcap cap_ipc_lock= /usr/bin/vault
61 - !reference [ .get_secrets, script ]
62 - pip3 install faraday-cli
63 - 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
64 rules:
65 - when: on_success
66 allow_failure: true
67
68 flake8:
69 image: python:3
70 stage: pre_testing
71 before_script:
72 - pip install flake8
73 # Help flake8 to find the Python files without .py extension.
74 - find . -name '*.py' >> files.txt
75 - sort -u files.txt | tee files.processed
76 script:
77 - python -m flake8 --statistics --count $(cat files.processed) --verbose
78 after_script:
79 - wc -l files.processed
80
81 .test_base:
82 stage: testing
83 coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
84 script:
85 - *clone_reports
86 - *install_faraday_venv
87 - pip3 install $PIP_FLAGS .
88 - pytest tests --capture=sys -v --cov=faraday_plugins --color=yes --disable-warnings $PYTEST_FLAGS
89
90 tests:
91 extends: .test_base
92 image: python:3
93
94 test_performance:
95 extends: .test_base
96 image: python:3
97 stage: post_testing
98 allow_failure: true
99 variables:
100 PYTEST_FLAGS: --performance
101 rules:
102 - if: '$CI_COMMIT_BRANCH == "dev"'
103 when: on_success
104
105 publish_pypi:
106 image: python:3
107 stage: publish
108 script:
109 - apt-get update -qy
110 - apt-get install twine -y
111 - python setup.py sdist bdist_wheel
112 - twine upload -u $PYPI_USER -p $PYPI_PASS dist/* --verbose
113 rules:
114 - if: '$CI_COMMIT_TAG'
115 when: on_success
116
+0
-1
CHANGELOG/1.3.0/add_appspider.md less more
0 ADD plugin AppSpider
+0
-1
CHANGELOG/1.3.0/add_cli_tests.md less more
0 Add tests to faraday-plugins cli
+0
-1
CHANGELOG/1.3.0/add_default_plugin_version.md less more
0 add a default value to plugin_version
+0
-1
CHANGELOG/1.3.0/add_output_file_to_faraday-plugins_command.md less more
0 Add --output-file parameter to faraday-plugins process command
+0
-1
CHANGELOG/1.3.0/add_prowler.md less more
0 Add plugins prowler
+0
-1
CHANGELOG/1.3.0/add_ssl_labs.md less more
0 Add plugins ssl labs
+0
-1
CHANGELOG/1.3.0/add_tenableio_support.md less more
0 Add support for tenable io
+0
-1
CHANGELOG/1.3.0/date.md less more
0 Sep 2nd, 2020
+0
-1
CHANGELOG/1.3.0/delete_old_methods.md less more
0 delete old deprecated methods
+0
-1
CHANGELOG/1.3.0/fix_Arachni.md less more
0 Bug fix: Arachni Plugin 'NoneType' object has no attribute 'find'
+0
-1
CHANGELOG/1.3.0/fix_Openvas.md less more
0 Bug fix: Openvas Plugin - Import xml from OpenVas doesnt work
+0
-1
CHANGELOG/1.3.0/fix_QualysWebapp.md less more
0 Bug fix: QualysWebApp Plugin, error in get info OPERATING_SYSTEM
+0
-1
CHANGELOG/1.3.0/fix_hydra_to_resolve_ip.md less more
0 Fix Hydra plugin to resolve ip address
+0
-1
CHANGELOG/1.3.0/fix_nessus.md less more
0 Fix Nessus mod severity HIGH for Low
+0
-1
CHANGELOG/1.3.0/fix_prowler.md less more
0 Bug Fix: Detect plugins AWS Prowler
+0
-1
CHANGELOG/1.3.0/fix_xml_nmap.md less more
0 Fix broken xml on nmap plugin
+0
-1
CHANGELOG/1.3.0/new_rdpscan_plugin.md less more
0 Add new rdpscan plugin
+0
-1
CHANGELOG/1.3.0/update_appscan.md less more
0 UPDATE xml report to appscan
+0
-1
CHANGELOG/1.3.0/update_readme.md less more
0 Update Readme
+0
-1
CHANGELOG/1.3.0/update_zap.md less more
0 Fix how ZAP genereate vulns
+0
-1
CHANGELOG/1.4.0/date.md less more
0 Dec 23rd, 2020
+0
-1
CHANGELOG/1.4.0/update_nuclei_fields.md less more
0 Update the fields of the nuclei output used to create a vuln
+0
-1
CHANGELOG/1.4.0b1/add_multilinejson_format.md less more
0 Add new plugin base class, for multi line json
+0
-1
CHANGELOG/1.4.0b1/add_ncrack.md less more
0 New ncrack plugin
+0
-1
CHANGELOG/1.4.0b1/add_nuclei.md less more
0 New nuclei plugin
+0
-1
CHANGELOG/1.4.0b1/add_sslyze_json.md less more
0 New sslyze json plugin
+0
-1
CHANGELOG/1.4.0b1/add_whatweb.md less more
0 New WhatWeb plugin
+0
-1
CHANGELOG/1.4.0b1/date.md less more
0 Dec 14th, 2020
+0
-1
CHANGELOG/1.4.0b1/fix_arachni_ip_missing.md less more
0 Fix missing ip in some arachni reports
+0
-1
CHANGELOG/1.4.0b1/fix_netsparker.md less more
0 Fix change name vuln in Netsparker plugin
+0
-1
CHANGELOG/1.4.0b1/fix_whois.md less more
0 Fix whois plugin, command whois IP not parse data
+0
-1
CHANGELOG/1.4.0b1/modify_json_reports_detection.md less more
0 Change the way we detect json reports when they are lists of dictionaries
+0
-1
CHANGELOG/1.4.0b2/date.md less more
0 Dec 15th, 2020
+0
-1
CHANGELOG/1.4.0b2/fix_nuclei.md less more
0 Fix nuclei plugin bug when url is None
+0
-1
CHANGELOG/1.4.1/add_microsoft_baseline.md less more
0 ADD microsoft baseline security analyzer plugin
+0
-1
CHANGELOG/1.4.1/add_nextnet.md less more
0 ADD nextnet plugin
+0
-1
CHANGELOG/1.4.1/add_openscap.md less more
0 ADD openscap plugin
+0
-1
CHANGELOG/1.4.1/date.md less more
0 Feb 26th, 2021
+0
-1
CHANGELOG/1.4.1/fix_nessus_plugin.md less more
0 FIX old versions of Nessus plugins bugs
+0
-1
CHANGELOG/1.4.2/date.md less more
0 Mar 10th, 2021
+0
-1
CHANGELOG/1.4.2/fix_bug_in_sslyze_output_file.md less more
0 Fix bug with sslyze output file
+0
-1
CHANGELOG/1.4.2/fix_sslyze_plugin.md less more
0 FIX change id sslyze for JSON/XML
+0
-1
CHANGELOG/1.4.3/date.md less more
0 Mar 17th, 2021
+0
-1
CHANGELOG/1.4.3/new_ignore_info_option.md less more
0 Add Ignore information vulnerabilities option
+0
-1
CHANGELOG/1.4.4/csv_plugin_dont_user_ignore_info.md less more
0 Faraday CSV Plugin do not consider ignore_info
+0
-1
CHANGELOG/1.4.4/date.md less more
0 Mar 30th, 2021
+0
-1
CHANGELOG/1.4.5/add_bandit_plugin.md less more
0 Add Bandit plugin
+0
-1
CHANGELOG/1.4.5/change_burp_fields.md less more
0 Use background for description and detail for data en Burp plugin.
+0
-1
CHANGELOG/1.4.5/date.md less more
0 Apr 15th, 2021
+0
-1
CHANGELOG/1.4.5/fix_appscan.md less more
0 Rewrite Appscan Plugin
+0
-1
CHANGELOG/1.4.5/parse_nmap_vulnes.md less more
0 Parse Nmap vulners script data
+0
-3
CHANGELOG/1.4.6/add-attribute_command_for_plugins_of_all_command.md less more
0 - add attribute "command" for the pluggins of each command
1 - adding test in test_command
2 - change some regex in self._command_regex
+0
-1
CHANGELOG/1.4.6/add_hostnames_to_cached_host.md less more
0 [FIX] add hostnames if host is already cached
+0
-1
CHANGELOG/1.4.6/add_naabu_plugin.md less more
0 Add Naabu plugin
+0
-1
CHANGELOG/1.4.6/add_sonarqube.md less more
0 Add Sonarqube plugin
+0
-1
CHANGELOG/1.4.6/change_list_plugins.md less more
0 Add version and change list_plugins style
+0
-1
CHANGELOG/1.4.6/clean_code.md less more
0 FIX unused import, innecesary list compression and unused variables
+0
-1
CHANGELOG/1.4.6/date.md less more
0 May 14th, 2021
+0
-1
CHANGELOG/1.4.6/error_when_import_report_of_metasploit_with_faraday_plugins.md less more
0 FIX metasploit report when the web-site-id is null
+0
-1
CHANGELOG/1.4.6/fix_nmap_port_status.md less more
0 Fix port stats in nmap
+0
-2
CHANGELOG/1.4.6/fixup_sslyze.md less more
0 fixup ssylze
1 sacar unknown de version=
+0
-1
CHANGELOG/1.4.6/issue_in_netsparker.md less more
0 ADD remedy into resolution
+0
-1
CHANGELOG/1.4.6/update_nuclei.md less more
0 Support for nuclei 2.3.0
+0
-1
CHANGELOG/1.4.6/when_import_report_of_nessus_we_can_get_more_data.md less more
0 ADD cve, cvss3_base_score, cvss3_vector, exploit_available when import nessus and change the structure of external_id to NESSUS-XXX
+0
-1
CHANGELOG/1.4.6/when_import_reports_of_owasp_and_zap_we_might_get_more_data.md less more
0 ADD more data like attack, params, uri, method, WASC, CWE and format externail_id
+0
-1
CHANGELOG/1.5.0/add_nipper_plugin.md less more
0 Add Nipper Plugin
+0
-1
CHANGELOG/1.5.0/add_shodan_plugin.md less more
0 add shodan plugin
+0
-1
CHANGELOG/1.5.0/date.md less more
0 Jun 28th, 2021
+0
-1
CHANGELOG/1.5.0/fix_acunetix_url_parser.md less more
0 fix acunetix url parser
+0
-1
CHANGELOG/1.5.0/fix_netsparker_multihost.md less more
0 FIX netsparker multi-host
+0
-1
CHANGELOG/1.5.0/fixup_ssylyze_desc_data.md less more
0 Add vuln details for Certificate Mismatch and move unique details to data, now vulns can be grupped
+0
-1
CHANGELOG/1.5.0/many-error-when-parse_the_xml_of_arachni_and_w3af.md less more
0 ADD more data to plugins arachni and w3af
+0
-1
CHANGELOG/1.5.0/run_date_utc.md less more
0 Use run_date in UTC
+0
-1
CHANGELOG/1.5.0/we_can_get_more_data_of_the_reports_of_openvas.md less more
0 ADD cvss_base, cpe, threat, severity into references
+0
-1
CHANGELOG/1.5.1/add_nuclei_fields.md less more
0 cwe, capec, references, tags, impact, resolution, easeofresolution
+0
-1
CHANGELOG/1.5.1/add_os_openvas.md less more
0 add os openvas
+0
-1
CHANGELOG/1.5.1/date.md less more
0 Jul 27th, 2021
+0
-1
CHANGELOG/1.5.1/fix_csv_big_fields_error.md less more
0 [FIX] Fix improt of CSV with big fields
+0
-1
CHANGELOG/1.5.1/fixx_sslyze_json_bug.md less more
0 Fix sslyze json bug with port
+0
-1
CHANGELOG/1.5.1/only_show_report_name.md less more
0 Only show report name in command data
+0
-1
CHANGELOG/1.5.10/Nuclei_metadata.md less more
0 support cve,cwe,cvss and metadata
+0
-1
CHANGELOG/1.5.10/date.md less more
0 Jan 13th, 2022
+0
-1
CHANGELOG/1.5.2/date.md less more
0 Aug 9th, 2021
+0
-1
CHANGELOG/1.5.2/new_structure_acunetix.md less more
0 add new structure acunetix
+0
-1
CHANGELOG/1.5.3/command_support_nuclei.md less more
0 Adding support for running nuclei through command / faraday-cli
+0
-1
CHANGELOG/1.5.3/date.md less more
0 Sep 7th, 2021
+0
-1
CHANGELOG/1.5.3/fix_mising_references.md less more
0 Fix missing references in nuclei
+0
-1
CHANGELOG/1.5.4/date.md less more
0 Oct 19th, 2021
+0
-1
CHANGELOG/1.5.4/nuclei_updates.md less more
0 Update nuclei parser
+0
-1
CHANGELOG/1.5.5/date.md less more
0 Oct 21st, 2021
+0
-1
CHANGELOG/1.5.5/merge_from_github.md less more
0 Merge PR from github
+0
-1
CHANGELOG/1.5.6/date.md less more
0 Nov 10th, 2021
+0
-2
CHANGELOG/1.5.6/fix_acunetix_issue.md less more
0 FIX issue with acunetix plugin
1
+0
-1
CHANGELOG/1.5.6/fix_nikto_typo.md less more
0 FIX typo in nikto plugin
+0
-1
CHANGELOG/1.5.7/date.md less more
0 Nov 19th, 2021
+0
-1
CHANGELOG/1.5.7/fix_netsparker.md less more
0 FIX extrainfo of netsparker plugin
+0
-1
CHANGELOG/1.5.7/nuclei_legacy.md less more
0 Add nuclei_legacy plugin
+0
-15
CHANGELOG/1.5.8/Add CVE to plugins.md less more
0 Add CVE to plugins
1 - acunetix
2 - appscan
3 - burp
4 - metasploit
5 - nessus
6 - netsparker
7 - nexpose
8 - nikto
9 - nipper
10 - nmap
11 - openscap
12 - qualysguard
13 - retina
14 - shodan
+0
-1
CHANGELOG/1.5.8/Add_support_for_Sslyze_5.md less more
0 Add support for Sslyze 5.0 resports
+0
-1
CHANGELOG/1.5.8/Fix appscan plugin.md less more
0 Fix errors while creating hosts with wrong regex
+0
-1
CHANGELOG/1.5.8/add_masscan_support.md less more
0 ADD masscan support to nmap plugin
+0
-1
CHANGELOG/1.5.8/date.md less more
0 Dec 13th, 2021
+0
-1
CHANGELOG/1.5.8/fix openvas.md less more
0 Fix bug in openvas plugin
+0
-1
CHANGELOG/1.5.9/add_cve_in_faraday_csv_plugin.md less more
0 Add cve in faraday_csv plugin
+0
-1
CHANGELOG/1.5.9/add_grype.md less more
0 ADD Grype plugin
+0
-1
CHANGELOG/1.5.9/date.md less more
0 Dec 27th, 2021
+0
-1
CHANGELOG/1.6.0/add_packaging.md less more
0 Add packaging to requierments in setup.py
+0
-1
CHANGELOG/1.6.0/add_severity_to_shodan.md less more
0 Add severity to shodan's plugins using cvss
+0
-1
CHANGELOG/1.6.0/date.md less more
0 Feb 3rd, 2022
+0
-1
CHANGELOG/1.6.0/fix_cve.md less more
0 check if cve exist on cve-id field
+0
-1
CHANGELOG/1.6.0/fix_fortify.md less more
0 Fix Fortify's plugin
+0
-1
CHANGELOG/1.6.0/fix_to_qualysguard.md less more
0 Change qualysguard's plugin severity_dict to refer level 2 severities as low
+0
-1
CHANGELOG/1.6.1/add_references_to_burp.md less more
0 Add references tu burp plugin
+0
-1
CHANGELOG/1.6.1/date.md less more
0 Mar 18th, 2022
+0
-1
CHANGELOG/1.6.1/fix_burp_plugin.md less more
0 Move item.detail from data to desc
+0
-1
CHANGELOG/1.6.1/update_open_status.md less more
0 update open status
+0
-1
CHANGELOG/1.6.2/add_line_indicator_to_appscan.md less more
0 Now Appscan plugin saves line and highlight of the vulns in desc and data
+0
-1
CHANGELOG/1.6.2/date.md less more
0 Apr 4th, 2022
+0
-1
CHANGELOG/1.6.3/add_zap_json.md less more
0 Add Zap Json plugin.
+0
-1
CHANGELOG/1.6.3/date.md less more
0 Apr 19th, 2022
+0
-1
CHANGELOG/1.6.4/add_location_as_param.md less more
0 Add location as params in burp's plugin
+0
-1
CHANGELOG/1.6.4/date.md less more
0 Apr 21th, 2022
+0
-1
CHANGELOG/1.6.4/fix_custom_field_regex.md less more
0 Now the faraday_csv custom_fields regex match any no whitespace character.
+0
-1
CHANGELOG/1.6.5/date.md less more
0 Apr 28th, 2022
+0
-1
CHANGELOG/1.6.5/set_severity.md less more
0 Now Openvas's plugin set severity to Critical when cvss >= 9.0
+0
-1
CHANGELOG/1.6.6/add_hostname_resolution_parameter.md less more
0 Add hostname_resolution parameter within plugins
+0
-1
CHANGELOG/1.6.6/date.md less more
0 May 20th, 2022
+0
-1
CHANGELOG/1.6.6/fix_openvas_external_id.md less more
0 Fix openvas external ID
+0
-1
CHANGELOG/1.6.7/change_hostname_resolution.md less more
0 Change hostname_restolution to dont_resolve_hostname for process-report and now test dosent resovle hostname
+0
-1
CHANGELOG/1.6.7/date.md less more
0 Jun 2nd, 2022
+0
-1
CHANGELOG/1.6.7/fix_qualyswebapp.md less more
0 Now QualysWebApp's plugin will diferenciate vulns from differents urlpaths
+0
-1
CHANGELOG/1.6.8/add_appscancsv.md less more
0 Add appscan csv
+0
-1
CHANGELOG/1.6.8/add_ignore_info_to_faradaycsv.md less more
0 Now faraday_csv's plugin uses ignore_info parameter
+0
-1
CHANGELOG/1.6.8/add_syhunt.md less more
0 Add syhunt plugin
+0
-1
CHANGELOG/1.6.8/date.md less more
0 Jul 25th, 2022
+0
-1
CHANGELOG/1.6.8/fix_appscan.md less more
0 Add cve and data fields to desc for avoid duplications
+0
-1
CHANGELOG/1.6.8/fix_nuclei.md less more
0 Now nuclei resolve hostname if the field ip is None
+0
-0
CHANGELOG/current/.keep less more
(Empty file)
0 Metadata-Version: 2.1
1 Name: faraday-plugins
2 Version: 1.7.0
3 Summary: Faraday plugins package
4 Home-page: UNKNOWN
5 Author: Faradaysec
6 Author-email: [email protected]
7 License: GNU General Public License v3
8 Platform: UNKNOWN
9 License-File: COPYING
10
11 UNKNOWN
12
0 # ![logo](https://github.com/infobyte/faraday/blob/master/docs/images/faraday_logo.svg)
1 Faraday aggregates and normalyzses the data you load, allowing exploring it into different visualizations that are useful to managers and analyst alike.
2
3 In this repository you can find [Faraday](https://github.com/infobyte/faraday/) integrations with security tools.
04 ## Install
15
26 ```shell script
+0
-215
RELEASE.md less more
0 1.6.8 [Jul 25th, 2022]:
1 ---
2 * Add appscan csv
3 * Now faraday_csv's plugin uses ignore_info parameter
4 * Add syhunt plugin
5 * Add cve and data fields to desc for avoid duplications
6 * Now nuclei resolve hostname if the field ip is None
7
8 1.6.7 [Jun 2nd, 2022]:
9 ---
10 * Change hostname_restolution to dont_resolve_hostname for process-report and now test dosent resovle hostname
11 * Now QualysWebApp's plugin will diferenciate vulns from differents urlpaths
12
13 1.6.6 [May 20th, 2022]:
14 ---
15 * Add hostname_resolution parameter within plugins
16 * Fix openvas external ID
17
18 1.6.5 [Apr 28th, 2022]:
19 ---
20 * Now Openvas's plugin set severity to Critical when cvss >= 9.0
21
22 1.6.4 [Apr 21th, 2022]:
23 ---
24 * Add location as params in burp's plugin
25 * Now the faraday_csv custom_fields regex match any no whitespace character.
26
27 1.6.3 [Apr 19th, 2022]:
28 ---
29 * Add Zap Json plugin.
30
31 1.6.2 [Apr 4th, 2022]:
32 ---
33 * Now Appscan plugin saves line and highlight of the vulns in desc and data
34
35 1.6.1 [Mar 18th, 2022]:
36 ---
37 * Add references tu burp plugin
38 * Move item.detail from data to desc
39 * update open status
40
41 1.6.0 [Feb 3rd, 2022]:
42 ---
43 * Add packaging to requierments in setup.py
44 * Add severity to shodan's plugins using cvss
45 * check if cve exist on cve-id field
46 * Fix Fortify's plugin
47 * Change qualysguard's plugin severity_dict to refer level 2 severities as low
48
49 1.5.10 [Jan 13th, 2022]:
50 ---
51 * support cve,cwe,cvss and metadata
52
53 1.5.9 [Dec 27th, 2021]:
54 ---
55 * Add cve in faraday_csv plugin
56 * ADD Grype plugin
57
58 1.5.8 [Dec 13th, 2021]:
59 ---
60 * Add CVE to plugins
61 - acunetix
62 - appscan
63 - burp
64 - metasploit
65 - nessus
66 - netsparker
67 - nexpose
68 - nikto
69 - nipper
70 - nmap
71 - openscap
72 - qualysguard
73 - retina
74 - shodan
75 * Add support for Sslyze 5.0 resports
76 * Fix errors while creating hosts with wrong regex
77 * ADD masscan support to nmap plugin
78 * Fix bug in openvas plugin
79
80 1.5.7 [Nov 19th, 2021]:
81 ---
82 * FIX extrainfo of netsparker plugin
83 * Add nuclei_legacy plugin
84
85 1.5.6 [Nov 10th, 2021]:
86 ---
87 * FIX issue with acunetix plugin
88
89 * FIX typo in nikto plugin
90
91 1.5.5 [Oct 21st, 2021]:
92 ---
93 * Merge PR from github
94
95 1.5.4 [Oct 19th, 2021]:
96 ---
97 * Update nuclei parser
98
99 1.5.3 [Sep 7th, 2021]:
100 ---
101 * Adding support for running nuclei through command / faraday-cli
102 * Fix missing references in nuclei
103
104 1.5.2 [Aug 9th, 2021]:
105 ---
106 * add new structure acunetix
107
108 1.5.1 [Jul 27th, 2021]:
109 ---
110 * cwe, capec, references, tags, impact, resolution, easeofresolution
111 * add os openvas
112 * [FIX] Fix improt of CSV with big fields
113 * Fix sslyze json bug with port
114 * Only show report name in command data
115
116 1.5.0 [Jun 28th, 2021]:
117 ---
118 * Add Nipper Plugin
119 * add shodan plugin
120 * fix acunetix url parser
121 * FIX netsparker multi-host
122 * Add vuln details for Certificate Mismatch and move unique details to data, now vulns can be grupped
123 * ADD more data to plugins arachni and w3af
124 * Use run_date in UTC
125 * ADD cvss_base, cpe, threat, severity into references
126
127 1.4.6 [May 14th, 2021]:
128 ---
129 * - add attribute "command" for the pluggins of each command
130 - adding test in test_command
131 - change some regex in self._command_regex
132 * [FIX] add hostnames if host is already cached
133 * Add Naabu plugin
134 * Add Sonarqube plugin
135 * Add version and change list_plugins style
136 * FIX unused import, innecesary list compression and unused variables
137 * FIX metasploit report when the web-site-id is null
138 * Fix port stats in nmap
139 * fixup ssylze
140 sacar unknown de version=
141 * ADD remedy into resolution
142 * Support for nuclei 2.3.0
143 * ADD cve, cvss3_base_score, cvss3_vector, exploit_available when import nessus and change the structure of external_id to NESSUS-XXX
144 * ADD more data like attack, params, uri, method, WASC, CWE and format externail_id
145
146 1.4.5 [Apr 15th, 2021]:
147 ---
148 * Add Bandit plugin
149 * Use background for description and detail for data en Burp plugin.
150 * Rewrite Appscan Plugin
151 * Parse Nmap vulners script data
152
153 1.4.4 [Mar 30th, 2021]:
154 ---
155 * Faraday CSV Plugin do not consider ignore_info
156
157 1.4.3 [Mar 17th, 2021]:
158 ---
159 * Add Ignore information vulnerabilities option
160
161 1.4.2 [Mar 10th, 2021]:
162 ---
163 * Fix bug with sslyze output file
164 * FIX change id sslyze for JSON/XML
165
166 1.4.1 [Feb 26th, 2021]:
167 ---
168 * ADD microsoft baseline security analyzer plugin
169 * ADD nextnet plugin
170 * ADD openscap plugin
171 * FIX old versions of Nessus plugins bugs
172
173 1.4.0 [Dec 23rd, 2020]:
174 ---
175 * Update the fields of the nuclei output used to create a vuln
176
177 1.4.0b2 [Dec 15th, 2020]:
178 ---
179 * Fix nuclei plugin bug when url is None
180
181 1.4.0b1 [Dec 14th, 2020]:
182 ---
183 * Add new plugin base class, for multi line json
184 * New ncrack plugin
185 * New nuclei plugin
186 * New sslyze json plugin
187 * New WhatWeb plugin
188 * Fix missing ip in some arachni reports
189 * Fix change name vuln in Netsparker plugin
190 * Fix whois plugin, command whois IP not parse data
191 * Change the way we detect json reports when they are lists of dictionaries
192
193 1.3.0 [Sep 2nd, 2020]:
194 ---
195 * ADD plugin AppSpider
196 * Add tests to faraday-plugins cli
197 * add a default value to plugin_version
198 * Add --output-file parameter to faraday-plugins process command
199 * Add plugins prowler
200 * Add plugins ssl labs
201 * Add support for tenable io
202 * delete old deprecated methods
203 * Bug fix: Arachni Plugin 'NoneType' object has no attribute 'find'
204 * Bug fix: Openvas Plugin - Import xml from OpenVas doesnt work
205 * Bug fix: QualysWebApp Plugin, error in get info OPERATING_SYSTEM
206 * Fix Hydra plugin to resolve ip address
207 * Fix Nessus mod severity HIGH for Low
208 * Bug Fix: Detect plugins AWS Prowler
209 * Fix broken xml on nmap plugin
210 * Add new rdpscan plugin
211 * UPDATE xml report to appscan
212 * Update Readme
213 * Fix how ZAP genereate vulns
214
+0
-24
default.nix less more
0 with import <nixpkgs> {};
1 pkgs.python38Packages.buildPythonPackage rec {
2 name = "env";
3
4 env = buildEnv { name = name; paths = buildInputs; };
5
6 buildInputs = [
7 (python38.buildEnv.override {
8 ignoreCollisions = true;
9 extraLibs = with python38Packages; [
10 requests
11 click
12 simplejson
13 requests
14 lxml
15 html2text
16 beautifulsoup4
17 pytz
18 python-dateutil
19 colorama
20 ];
21 })
22 ];
23 }
+0
-35
doc/development.md less more
0 ## Write you own plugins
1
2 > XML report plugin
3
4 ```python
5 class XXXPLugin(PluginXMLFormat):
6
7 def __init__(self):
8 super().__init__()
9 # Tags to be compared with the xml mail tag, can be a list or a string
10 self.identifier_tag = ["tag1", "tag2"]
11 self.id = 'SOME_PLUGIN_ID' # Can't be repeated
12 self.name = 'Some plugin name'
13 self.plugin_version = 'X.X'
14 # The extension is optional, only if its different than xml
15 self.extension = ".xxx"
16 ```
17
18 > JSON report plugin
19
20 ```python
21 class XXXPLugin(PluginJsonFormat):
22
23 def __init__(self):
24 super().__init__()
25 # keys of the json that identify the report
26 # you don't need to put all the keys, just some of them
27 # it must be a set and will be compared as a subset of the json report keys
28 self.json_keys = {"target_url", "effective_url", "interesting_findings"}
29 self.id = 'SOME_PLUGIN_ID' # Can't be repeated
30 self.name = 'Some plugin name'
31 self.plugin_version = 'X.X'
32 # The extension is optional, only if its different than json
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)
faraday_plugins/plugins/repo/burp/burp-2.0-SNAPSHOT.jar less more
Binary diff not shown
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)
0 Metadata-Version: 2.1
1 Name: faraday-plugins
2 Version: 1.7.0
3 Summary: Faraday plugins package
4 Home-page: UNKNOWN
5 Author: Faradaysec
6 Author-email: [email protected]
7 License: GNU General Public License v3
8 Platform: UNKNOWN
9 License-File: COPYING
10
11 UNKNOWN
12
0 COPYING
1 MANIFEST.in
2 README.md
3 setup.py
4 faraday_plugins/__init__.py
5 faraday_plugins/__main__.py
6 faraday_plugins/commands.py
7 faraday_plugins.egg-info/PKG-INFO
8 faraday_plugins.egg-info/SOURCES.txt
9 faraday_plugins.egg-info/dependency_links.txt
10 faraday_plugins.egg-info/entry_points.txt
11 faraday_plugins.egg-info/requires.txt
12 faraday_plugins.egg-info/top_level.txt
13 faraday_plugins/plugins/__init__.py
14 faraday_plugins/plugins/manager.py
15 faraday_plugins/plugins/plugin.py
16 faraday_plugins/plugins/plugins_utils.py
17 faraday_plugins/plugins/port_mapper.txt
18 faraday_plugins/plugins/repo/__init__.py
19 faraday_plugins/plugins/repo/acunetix/DTO.py
20 faraday_plugins/plugins/repo/acunetix/__init__.py
21 faraday_plugins/plugins/repo/acunetix/plugin.py
22 faraday_plugins/plugins/repo/acunetix_json/DTO.py
23 faraday_plugins/plugins/repo/acunetix_json/__init__.py
24 faraday_plugins/plugins/repo/acunetix_json/plugin.py
25 faraday_plugins/plugins/repo/amap/__init__.py
26 faraday_plugins/plugins/repo/amap/plugin.py
27 faraday_plugins/plugins/repo/appscan/__init__.py
28 faraday_plugins/plugins/repo/appscan/plugin.py
29 faraday_plugins/plugins/repo/appscan_csv/__init__.py
30 faraday_plugins/plugins/repo/appscan_csv/plugin.py
31 faraday_plugins/plugins/repo/appspider/__init__.py
32 faraday_plugins/plugins/repo/appspider/plugin.py
33 faraday_plugins/plugins/repo/arachni/__init__.py
34 faraday_plugins/plugins/repo/arachni/plugin.py
35 faraday_plugins/plugins/repo/arp_scan/__init__.py
36 faraday_plugins/plugins/repo/arp_scan/plugin.py
37 faraday_plugins/plugins/repo/bandit/__init__.py
38 faraday_plugins/plugins/repo/bandit/plugin.py
39 faraday_plugins/plugins/repo/beef/__init__.py
40 faraday_plugins/plugins/repo/beef/plugin.py
41 faraday_plugins/plugins/repo/brutexss/__init__.py
42 faraday_plugins/plugins/repo/brutexss/plugin.py
43 faraday_plugins/plugins/repo/burp/__init__.py
44 faraday_plugins/plugins/repo/burp/plugin.py
45 faraday_plugins/plugins/repo/checkmarx/__init__.py
46 faraday_plugins/plugins/repo/checkmarx/plugin.py
47 faraday_plugins/plugins/repo/cobalt/__init__.py
48 faraday_plugins/plugins/repo/cobalt/plugin.py
49 faraday_plugins/plugins/repo/dig/__init__.py
50 faraday_plugins/plugins/repo/dig/plugin.py
51 faraday_plugins/plugins/repo/dirb/__init__.py
52 faraday_plugins/plugins/repo/dirb/plugin.py
53 faraday_plugins/plugins/repo/dirsearch/__init__.py
54 faraday_plugins/plugins/repo/dirsearch/plugin.py
55 faraday_plugins/plugins/repo/dnsenum/__init__.py
56 faraday_plugins/plugins/repo/dnsenum/plugin.py
57 faraday_plugins/plugins/repo/dnsmap/__init__.py
58 faraday_plugins/plugins/repo/dnsmap/plugin.py
59 faraday_plugins/plugins/repo/dnsrecon/__init__.py
60 faraday_plugins/plugins/repo/dnsrecon/plugin.py
61 faraday_plugins/plugins/repo/dnswalk/__init__.py
62 faraday_plugins/plugins/repo/dnswalk/plugin.py
63 faraday_plugins/plugins/repo/faraday_csv/__init__.py
64 faraday_plugins/plugins/repo/faraday_csv/plugin.py
65 faraday_plugins/plugins/repo/fierce/__init__.py
66 faraday_plugins/plugins/repo/fierce/plugin.py
67 faraday_plugins/plugins/repo/fortify/__init__.py
68 faraday_plugins/plugins/repo/fortify/plugin.py
69 faraday_plugins/plugins/repo/ftp/__init__.py
70 faraday_plugins/plugins/repo/ftp/plugin.py
71 faraday_plugins/plugins/repo/goohost/__init__.py
72 faraday_plugins/plugins/repo/goohost/plugin.py
73 faraday_plugins/plugins/repo/grype/__init__.py
74 faraday_plugins/plugins/repo/grype/plugin.py
75 faraday_plugins/plugins/repo/hping3/__init__.py
76 faraday_plugins/plugins/repo/hping3/plugin.py
77 faraday_plugins/plugins/repo/hydra/__init__.py
78 faraday_plugins/plugins/repo/hydra/plugin.py
79 faraday_plugins/plugins/repo/impact/__init__.py
80 faraday_plugins/plugins/repo/impact/plugin.py
81 faraday_plugins/plugins/repo/ip360/__init__.py
82 faraday_plugins/plugins/repo/ip360/plugin.py
83 faraday_plugins/plugins/repo/junit/__init__.py
84 faraday_plugins/plugins/repo/junit/plugin.py
85 faraday_plugins/plugins/repo/lynis/__init__.py
86 faraday_plugins/plugins/repo/lynis/plugin.py
87 faraday_plugins/plugins/repo/maltego/__init__.py
88 faraday_plugins/plugins/repo/maltego/plugin.py
89 faraday_plugins/plugins/repo/mbsa/__init__.py
90 faraday_plugins/plugins/repo/mbsa/plugin.py
91 faraday_plugins/plugins/repo/medusa/__init__.py
92 faraday_plugins/plugins/repo/medusa/plugin.py
93 faraday_plugins/plugins/repo/metasploit/__init__.py
94 faraday_plugins/plugins/repo/metasploit/plugin.py
95 faraday_plugins/plugins/repo/naabu/__init__.py
96 faraday_plugins/plugins/repo/naabu/plugin.py
97 faraday_plugins/plugins/repo/ncrack/__init__.py
98 faraday_plugins/plugins/repo/ncrack/plugin.py
99 faraday_plugins/plugins/repo/ndiff/__init__.py
100 faraday_plugins/plugins/repo/ndiff/plugin.py
101 faraday_plugins/plugins/repo/nessus/DTO.py
102 faraday_plugins/plugins/repo/nessus/__init__.py
103 faraday_plugins/plugins/repo/nessus/plugin.py
104 faraday_plugins/plugins/repo/netdiscover/__init__.py
105 faraday_plugins/plugins/repo/netdiscover/plugin.py
106 faraday_plugins/plugins/repo/netsparker/__init__.py
107 faraday_plugins/plugins/repo/netsparker/plugin.py
108 faraday_plugins/plugins/repo/netsparkercloud/__init__.py
109 faraday_plugins/plugins/repo/netsparkercloud/plugin.py
110 faraday_plugins/plugins/repo/nexpose_full/__init__.py
111 faraday_plugins/plugins/repo/nexpose_full/plugin.py
112 faraday_plugins/plugins/repo/nextnet/__init__.py
113 faraday_plugins/plugins/repo/nextnet/plugin.py
114 faraday_plugins/plugins/repo/nikto/__init__.py
115 faraday_plugins/plugins/repo/nikto/plugin.py
116 faraday_plugins/plugins/repo/nipper/__init__.py
117 faraday_plugins/plugins/repo/nipper/plugin.py
118 faraday_plugins/plugins/repo/nmap/__init__.py
119 faraday_plugins/plugins/repo/nmap/plugin.py
120 faraday_plugins/plugins/repo/nuclei/__init__.py
121 faraday_plugins/plugins/repo/nuclei/plugin.py
122 faraday_plugins/plugins/repo/nuclei_legacy/__init__.py
123 faraday_plugins/plugins/repo/nuclei_legacy/plugin.py
124 faraday_plugins/plugins/repo/openscap/__init__.py
125 faraday_plugins/plugins/repo/openscap/plugin.py
126 faraday_plugins/plugins/repo/openvas/__init__.py
127 faraday_plugins/plugins/repo/openvas/plugin.py
128 faraday_plugins/plugins/repo/pasteanalyzer/__init__.py
129 faraday_plugins/plugins/repo/pasteanalyzer/plugin.py
130 faraday_plugins/plugins/repo/peepingtom/__init__.py
131 faraday_plugins/plugins/repo/peepingtom/plugin.py
132 faraday_plugins/plugins/repo/ping/__init__.py
133 faraday_plugins/plugins/repo/ping/plugin.py
134 faraday_plugins/plugins/repo/propecia/__init__.py
135 faraday_plugins/plugins/repo/propecia/plugin.py
136 faraday_plugins/plugins/repo/prowler/__init__.py
137 faraday_plugins/plugins/repo/prowler/plugin.py
138 faraday_plugins/plugins/repo/qualysguard/__init__.py
139 faraday_plugins/plugins/repo/qualysguard/plugin.py
140 faraday_plugins/plugins/repo/qualyswebapp/__init__.py
141 faraday_plugins/plugins/repo/qualyswebapp/plugin.py
142 faraday_plugins/plugins/repo/rdpscan/__init__.py
143 faraday_plugins/plugins/repo/rdpscan/plugin.py
144 faraday_plugins/plugins/repo/reconng/__init__.py
145 faraday_plugins/plugins/repo/reconng/plugin.py
146 faraday_plugins/plugins/repo/retina/__init__.py
147 faraday_plugins/plugins/repo/retina/plugin.py
148 faraday_plugins/plugins/repo/reverseraider/__init__.py
149 faraday_plugins/plugins/repo/reverseraider/plugin.py
150 faraday_plugins/plugins/repo/shodan/__init__.py
151 faraday_plugins/plugins/repo/shodan/plugin.py
152 faraday_plugins/plugins/repo/skipfish/__init__.py
153 faraday_plugins/plugins/repo/skipfish/plugin.py
154 faraday_plugins/plugins/repo/sonarqubeapi/__init__.py
155 faraday_plugins/plugins/repo/sonarqubeapi/plugin.py
156 faraday_plugins/plugins/repo/sourceclear/__init__.py
157 faraday_plugins/plugins/repo/sourceclear/plugin.py
158 faraday_plugins/plugins/repo/sshdefaultscan/__init__.py
159 faraday_plugins/plugins/repo/sshdefaultscan/plugin.py
160 faraday_plugins/plugins/repo/ssl_labs/__init__.py
161 faraday_plugins/plugins/repo/ssl_labs/plugin.py
162 faraday_plugins/plugins/repo/sslyze/__init__.py
163 faraday_plugins/plugins/repo/sslyze/plugin.py
164 faraday_plugins/plugins/repo/sslyzejson/__init__.py
165 faraday_plugins/plugins/repo/sslyzejson/plugin.py
166 faraday_plugins/plugins/repo/syhunt/__init__.py
167 faraday_plugins/plugins/repo/syhunt/plugin.py
168 faraday_plugins/plugins/repo/telnet/__init__.py
169 faraday_plugins/plugins/repo/telnet/plugin.py
170 faraday_plugins/plugins/repo/theharvester/__init__.py
171 faraday_plugins/plugins/repo/theharvester/plugin.py
172 faraday_plugins/plugins/repo/traceroute/__init__.py
173 faraday_plugins/plugins/repo/traceroute/plugin.py
174 faraday_plugins/plugins/repo/trivy_json/DTO.py
175 faraday_plugins/plugins/repo/trivy_json/__init__.py
176 faraday_plugins/plugins/repo/trivy_json/plugin.py
177 faraday_plugins/plugins/repo/w3af/__init__.py
178 faraday_plugins/plugins/repo/w3af/plugin.py
179 faraday_plugins/plugins/repo/wapiti/__init__.py
180 faraday_plugins/plugins/repo/wapiti/plugin.py
181 faraday_plugins/plugins/repo/wcscan/__init__.py
182 faraday_plugins/plugins/repo/wcscan/plugin.py
183 faraday_plugins/plugins/repo/webfuzzer/__init__.py
184 faraday_plugins/plugins/repo/webfuzzer/plugin.py
185 faraday_plugins/plugins/repo/webinspect/__init__.py
186 faraday_plugins/plugins/repo/webinspect/plugin.py
187 faraday_plugins/plugins/repo/wfuzz/__init__.py
188 faraday_plugins/plugins/repo/wfuzz/plugin.py
189 faraday_plugins/plugins/repo/whatweb/__init__.py
190 faraday_plugins/plugins/repo/whatweb/plugin.py
191 faraday_plugins/plugins/repo/whitesource/__init__.py
192 faraday_plugins/plugins/repo/whitesource/plugin.py
193 faraday_plugins/plugins/repo/whois/__init__.py
194 faraday_plugins/plugins/repo/whois/plugin.py
195 faraday_plugins/plugins/repo/wpscan/__init__.py
196 faraday_plugins/plugins/repo/wpscan/plugin.py
197 faraday_plugins/plugins/repo/x1/__init__.py
198 faraday_plugins/plugins/repo/x1/plugin.py
199 faraday_plugins/plugins/repo/xsssniper/__init__.py
200 faraday_plugins/plugins/repo/xsssniper/plugin.py
201 faraday_plugins/plugins/repo/zap/__init__.py
202 faraday_plugins/plugins/repo/zap/plugin.py
203 faraday_plugins/plugins/repo/zap_json/DTO.py
204 faraday_plugins/plugins/repo/zap_json/__init__.py
205 faraday_plugins/plugins/repo/zap_json/plugin.py
0 [console_scripts]
1 faraday-plugins = faraday_plugins.commands:cli
2
0 Click
1 beautifulsoup4
2 colorama
3 html2text
4 lxml
5 packaging
6 python-dateutil
7 pytz
8 requests
9 simplejson
10 tabulate
0 [egg_info]
1 tag_build =
2 tag_date = 0
3
+0
-53
tests/commands.json less more
0 {
1 "commands": [
2 {"plugin_id": "ping", "command": "ping -c4 faradaysec.com", "command_result": "ping"},
3 {"plugin_id": "whois", "command": "whois fradaysec.com", "command_result": "whois"},
4 {"plugin_id": "nmap", "command": "nmap fradaysec.com", "command_result": "nmap"},
5 {"plugin_id": "skipfish", "command": "skipfish http://fradaysec.com", "command_result": "skipfish"},
6 {"plugin_id": "sslyze_json", "command": "sslyze www.google.com --json_out=x.json", "command_result": "sslyze"},
7 {"plugin_id": "Amap", "command": "amap www.google.com", "command_result": "amap"},
8 {"plugin_id": "arp-scan", "command": "arp-scan www.google.com", "command_result": "arp-scan"},
9 {"plugin_id": "Beef", "command": "beef www.google.com", "command_result": "beef"},
10 {"plugin_id": "brutexss", "command": "brutexss www.google.com", "command_result": "brutexss"},
11 {"plugin_id": "dig", "command": "dig www.google.com", "command_result": "dig"},
12 {"plugin_id": "dirsearch", "command": "python3 dirsearch.py -u https://target", "command_result": "python3 dirsearch.py"},
13
14 {"plugin_id": "Dnsenum", "command": "dnsenum www.google.com", "command_result": "Dnsenum"},
15 {"plugin_id": "Dnsmap", "command": "dnsmap www.google.com", "command_result": "Dnsmap"},
16 {"plugin_id": "Dnsrecon", "command": "dnsrecon www.google.com", "command_result": "Dnsrecon"},
17 {"plugin_id": "Dnswalk", "command": "dnswalk www.google.com", "command_result": "Dnswalk"},
18 {"plugin_id": "Fierce", "command": "fierce www.google.com", "command_result": "Fierce"},
19 {"plugin_id": "fruitywifi", "command": "fruitywifi www.google.com", "command_result": "fruitywifi"},
20 {"plugin_id": "ftp", "command": "ftp www.google.com", "command_result": "ftp"},
21 {"plugin_id": "Goohost", "command": "goohost.sh www.google.com", "command_result": "goohost.sh"},
22 {"plugin_id": "Hping3", "command": "hping3 www.google.com", "command_result": "Hping3"},
23 {"plugin_id": "Hydra", "command": "hydra www.google.com", "command_result": "Hydra"},
24 {"plugin_id": "Lynis", "command": "lynis www.google.com", "command_result": "Lynis"},
25 {"plugin_id": "Medusa", "command": "medusa www.google.com", "command_result": "Medusa"},
26 {"plugin_id": "Ndiff", "command": "ndiff www.google.com", "command_result": "Ndiff"},
27 {"plugin_id": "Netdiscover", "command": "netdiscover www.google.com", "command_result": "Netdiscover"},
28 {"plugin_id": "nextnet", "command": "nextnet www.google.com", "command_result": "nextnet"},
29 {"plugin_id": "Nikto", "command": "nikto www.google.com", "command_result": "Nikto"},
30 {"plugin_id": "Nmap", "command": "nmap www.google.com", "command_result": "Nmap"},
31 {"plugin_id": "pasteAnalyzer", "command": "pasteAnalyzer www.google.com", "command_result": "pasteAnalyzer"},
32 {"plugin_id": "peepingtom", "command": "./peepingtom.py www.google.com", "command_result": "./peepingtom.py"},
33 {"plugin_id": "propecia", "command": "propecia www.google.com", "command_result": "propecia"},
34 {"plugin_id": "rdpscan", "command": "rdpscan www.google.com", "command_result": "rdpscan"},
35 {"plugin_id": "Reverseraider", "command": "./reverseraider www.google.com", "command_result": "./reverseraider"},
36 {"plugin_id": "Skipfish", "command": "skipfish www.google.com", "command_result": "Skipfish"},
37 {"plugin_id": "sshdefaultscan", "command": "./sshdefaultscan.py www.google.com", "command_result": "./sshdefaultscan.py"},
38 {"plugin_id": "Telnet", "command": "telnet www.google.com", "command_result": "telnet"},
39 {"plugin_id": "Theharvester", "command": "./theHarvester.py www.google.com", "command_result": "./theharvester.py"},
40 {"plugin_id": "Traceroute", "command": "traceroute www.google.com", "command_result": "Traceroute"},
41 {"plugin_id": "W3af", "command": "w3af www.google.com", "command_result": "W3af"},
42 {"plugin_id": "Wapiti", "command": "wapiti www.google.com", "command_result": "Wapiti"},
43 {"plugin_id": "Wcscan", "command": "wcscan www.google.com", "command_result": "Wcscan"},
44 {"plugin_id": "Webfuzzer", "command": "webfuzzer www.google.com", "command_result": "Webfuzzer"},
45 {"plugin_id": "Wfuzz", "command": "wfuzz www.google.com", "command_result": "Wfuzz"},
46 {"plugin_id": "whois", "command": "whois www.google.com", "command_result": "whois"},
47 {"plugin_id": "X1", "command": "./x1 www.google.com", "command_result": "./x1"},
48 {"plugin_id": "xsssniper", "command": "xsssniper www.google.com", "command_result": "xsssniper"},
49 {"plugin_id": "dirb", "command": "dirb google.com", "command_result": "dirb"},
50 {"plugin_id": "Arachni", "command": "arachni www.google.com", "command_result": "Arachni"}
51 ]
52 }
+0
-21
tests/conftest.py less more
0 import pytest
1
2
3 def pytest_addoption(parser):
4 parser.addoption(
5 "--performance", action="store_true", default=False, help="run performance tests"
6 )
7
8
9 def pytest_configure(config):
10 config.addinivalue_line("markers", "performance: mark test as performance")
11
12
13 def pytest_collection_modifyitems(config, items):
14 if config.getoption("--performance"):
15 # --performance given in cli: do not skip performance tests
16 return
17 performance = pytest.mark.skip(reason="need --performance option to run")
18 for item in items:
19 if "performance" in item.keywords:
20 item.add_marker(performance)
+0
-90
tests/generate_reports_summary.py less more
0 #!/usr/bin/env python
1 import hashlib
2 import os
3 import shutil
4 import json
5 import click
6 import colorama
7 from faraday_plugins.plugins.manager import PluginsManager, ReportAnalyzer
8 from faraday_plugins.plugins.plugin import PluginBase
9
10 colorama.init(autoreset=True)
11
12 BLACK_LIST = [
13 'LICENSE',
14 'README.md',
15 '.gitignore',
16 '.gitkeep',
17 'faraday_plugins_tests',
18 ]
19
20 REPORT_COLLECTION_DIR = '../report-collection'
21 FARADAY_PLUGINS_TESTS_DIR = 'faraday_plugins_tests'
22 REPORTS_CHECKSUM = []
23
24 def list_report_files():
25 report_filenames = os.walk(os.path.join(REPORT_COLLECTION_DIR))
26 for root, directory, filenames in report_filenames:
27 if '.git' in directory or FARADAY_PLUGINS_TESTS_DIR in root:
28 continue
29 for filename in filenames:
30 if filename in BLACK_LIST:
31 continue
32 if '.git' in root:
33 continue
34 yield os.path.join(root, filename)
35
36
37 @click.command()
38 @click.option('--force', is_flag=True)
39 @click.option('--debug', is_flag=False)
40 def generate_reports_tests(force, debug):
41 generated_summaries = 0
42 analysed_reports = 0
43 click.echo(f"{colorama.Fore.GREEN}Generate Faraday Plugins Tests Summary")
44 plugins_manager = PluginsManager(hostname_resolution=False)
45 analyzer = ReportAnalyzer(plugins_manager)
46 for report_file_path in list_report_files():
47 if debug:
48 click.echo(f"File: {report_file_path}")
49 plugin: PluginBase = analyzer.get_plugin(report_file_path)
50 if not plugin:
51 click.echo(f"{colorama.Fore.YELLOW}Plugin for file: ({report_file_path}) not found")
52 else:
53 with open(report_file_path, 'rb') as f:
54 m = hashlib.md5(f.read())
55 file_checksum = m.hexdigest()
56 if file_checksum not in REPORTS_CHECKSUM:
57 REPORTS_CHECKSUM.append(file_checksum)
58 else:
59 click.echo(f"{colorama.Fore.YELLOW}Ignore duplicated file: ({report_file_path})")
60 continue
61 analysed_reports += 1
62 report_file_name = os.path.basename(report_file_path)
63 plugin_name = plugin.id
64 plugin_path = os.path.join(REPORT_COLLECTION_DIR, FARADAY_PLUGINS_TESTS_DIR, plugin_name)
65 if not os.path.isdir(plugin_path):
66 os.mkdir(plugin_path)
67 dst_report_file_path = os.path.join(plugin_path, report_file_name)
68 summary_needed = False
69 summary_file = f"{os.path.splitext(dst_report_file_path)[0]}_summary.json"
70 if not os.path.isfile(dst_report_file_path) or force:
71 summary_needed = True
72 shutil.copyfile(report_file_path, dst_report_file_path)
73 if not os.path.isfile(summary_file) or force:
74 summary_needed = True
75 if summary_needed:
76 try:
77 plugin.processReport(report_file_path)
78 click.echo(f"{colorama.Fore.GREEN}Generate Summary for: {dst_report_file_path} [{plugin}]")
79 summary = plugin.get_summary()
80 with open(summary_file, "w") as f:
81 json.dump(summary, f)
82 generated_summaries += 1
83 except Exception as e:
84 click.echo(f"{colorama.Fore.RED}Error generating summary for file: {report_file_path} [{plugin}]: [{e}]")
85 click.echo(f"Generated {generated_summaries} summaries of {analysed_reports} reports")
86
87
88 if __name__ == "__main__":
89 generate_reports_tests()
+0
-98
tests/test_cli.py less more
0 import json
1 import os
2 import re
3 import pytest
4 from click.testing import CliRunner
5 from faraday_plugins.commands import list_plugins, detect_command, process_command, detect_report, process_report
6
7
8 def test_list_plugins():
9 runner = CliRunner()
10 result = runner.invoke(list_plugins)
11 assert result.exit_code == 0
12 loaded_plugins = re.search(r'Loaded Plugins: (?P<loaded_plugins>\d+)', result.output)
13 assert loaded_plugins
14 assert int(loaded_plugins.groupdict().get('loaded_plugins', 0)) > 0
15
16
17 def test_detect_invalid_command():
18 runner = CliRunner()
19 result = runner.invoke(detect_command, args=['invalid_command'])
20 assert result.exit_code == 0
21 assert result.output.strip() == "Failed to detect command: invalid_command"
22
23
24 @pytest.mark.skip(reason="issue with docker image")
25 def test_detect_command():
26 runner = CliRunner()
27 result = runner.invoke(detect_command, args=['ping -c 1 www.google.com'])
28 assert result.exit_code == 0
29 assert result.output.strip() == "Faraday Plugin: ping"
30
31
32 @pytest.mark.skip(reason="issue with docker image")
33 def test_process_command():
34 runner = CliRunner()
35 result = runner.invoke(process_command, args=['ping -c 1 www.google.com', '--summary'])
36 assert result.exit_code == 0, result.output
37 summary = json.loads(result.output.strip())
38 assert summary['hosts'] == 1
39
40
41 @pytest.mark.skip(reason="issue with docker image")
42 def test_process_command_ping():
43 runner = CliRunner()
44 result = runner.invoke(process_command, args=['ping -c 1 www.google.com'])
45 assert result.exit_code == 0, result.output
46 summary = json.loads(result.output.strip())
47
48 assert summary['command']["command"] == 'ping'
49
50
51 @pytest.mark.skip(reason="issue with docker image")
52 def test_process_command_to_file():
53 runner = CliRunner()
54 with runner.isolated_filesystem() as file_system:
55 output_file = os.path.join(file_system, "test.json")
56 result = runner.invoke(process_command, args=['ping -c 1 www.google.com', '-o', output_file])
57 assert result.exit_code == 0, result.output
58 assert os.path.isfile(output_file)
59 with open(output_file) as f:
60 vuln_json = json.load(f)
61 assert len(vuln_json['hosts']) == 1
62
63
64 def test_detect_report():
65 report_file = os.path.join('./report-collection', 'faraday_plugins_tests', 'Nmap', 'nmap_5.21.xml')
66 runner = CliRunner()
67 result = runner.invoke(detect_report, args=[report_file])
68 assert result.exit_code == 0
69 assert "Faraday Plugin: Nmap" == result.output.strip()
70
71
72 def test_detect_report_dont_exists():
73 report_file = os.path.join('./report-collection', 'faraday_plugins_tests', 'Nmap', 'invalid_report.xml')
74 runner = CliRunner()
75 result = runner.invoke(detect_report, args=[report_file])
76 assert result.exit_code == 0
77 assert "Don't Exists" in result.output.strip()
78
79
80 def test_process_report_summary():
81 report_file = os.path.join('./report-collection', 'faraday_plugins_tests', 'Nmap', 'nmap_5.21.xml')
82 summary_file = os.path.join('./report-collection', 'faraday_plugins_tests', 'Nmap', 'nmap_5.21_summary.json')
83 runner = CliRunner()
84 result = runner.invoke(process_report, args=[report_file, '--summary'])
85 assert result.exit_code == 0
86 summary = json.loads(result.output.strip())
87 with open(summary_file) as f:
88 saved_summary = json.load(f)
89 vuln_hashes = set(summary['vuln_hashes'])
90 saved_vuln_hashes = set(saved_summary.get('vuln_hashes', []))
91 assert summary['hosts'] == saved_summary['hosts']
92 assert summary['services'] == saved_summary['services']
93 assert summary['hosts_vulns'] == saved_summary['hosts_vulns']
94 assert summary['services_vulns'] == saved_summary['services_vulns']
95 assert summary['severity_vulns'] == saved_summary['severity_vulns']
96 assert vuln_hashes == saved_vuln_hashes
97
+0
-29
tests/test_commands.py less more
0 import json
1 import pytest
2 from faraday_plugins.plugins.manager import PluginsManager, CommandAnalyzer
3 from faraday_plugins.plugins.plugin import PluginBase
4
5
6 plugins_manager = PluginsManager()
7 analyzer = CommandAnalyzer(plugins_manager)
8
9 COMMANDS_FILE = './tests/commands.json'
10
11 def list_commands():
12 with open(COMMANDS_FILE) as f:
13 commands_dict = json.load(f)
14 for command_data in commands_dict["commands"]:
15 yield command_data
16
17
18 @pytest.mark.parametrize("command_data", list_commands())
19 def test_autodetected_on_commands(command_data):
20 plugin_id = command_data["plugin_id"]
21 command_string = command_data["command"]
22 command_result = command_data["command_result"]
23
24 plugin: PluginBase = analyzer.get_plugin(command_string)
25 assert plugin, command_string
26 assert plugin.id.lower() == plugin_id.lower()
27 assert plugin.command.lower() == command_result.lower()
28
+0
-124
tests/test_engine_plugins.py less more
0 from faraday_plugins.plugins.plugin import PluginBase
1
2
3 def test_get_host_cache_id_with_same_host():
4 host_1 = {'ip': '127.0.0.1'}
5 host_2 = {'ip': '127.0.0.1', 'description': 'test desc'}
6 cache_id_1 = PluginBase.get_host_cache_id(host_1)
7 cache_id_2 = PluginBase.get_host_cache_id(host_2)
8
9 assert cache_id_1 == cache_id_2
10
11
12 def test_get_host_cache_id_with_diffent_ip():
13 host_1 = {'ip': '127.0.0.1'}
14 host_2 = {'ip': '192.168.0.1', 'description': 'test desc'}
15 cache_id_1 = PluginBase.get_host_cache_id(host_1)
16 cache_id_2 = PluginBase.get_host_cache_id(host_2)
17
18 assert cache_id_1 != cache_id_2
19
20
21 def test_get_host_service_cache_id_same_objects():
22 host_1 = {'ip': '127.0.0.1'}
23 host_cache_id_1 = PluginBase.get_host_cache_id(host_1)
24 service_1 = {'protocol': 'tcp', 'port': 80}
25 host_2 = {'ip': '127.0.0.1'}
26 host_cache_id_2 = PluginBase.get_host_cache_id(host_2)
27 service_2 = {'protocol': 'tcp', 'port': 80}
28
29 cache_1 = PluginBase.get_host_service_cache_id(host_cache_id_1, service_1)
30 cache_2 = PluginBase.get_host_service_cache_id(host_cache_id_2, service_2)
31
32 assert cache_1 == cache_2
33
34
35 def test_get_host_service_cache_id_different_host():
36 host_1 = {'ip': '127.0.0.1'}
37 host_cache_id_1 = PluginBase.get_host_cache_id(host_1)
38 service_1 = {'protocol': 'tcp', 'port': 80}
39 host_2 = {'ip': '192.168.0.1'}
40 host_cache_id_2 = PluginBase.get_host_cache_id(host_2)
41 service_2 = {'protocol': 'tcp', 'port': 80}
42
43 cache_1 = PluginBase.get_host_service_cache_id(host_cache_id_1, service_1)
44 cache_2 = PluginBase.get_host_service_cache_id(host_cache_id_2, service_2)
45
46 assert cache_1 != cache_2
47
48
49 def test_get_host_vuln_cache_id_severity_does_not_affect_duplicate():
50 host_1 = {'ip': '127.0.0.1'}
51 host_cache_id_1 = PluginBase.get_host_cache_id(host_1)
52 vuln_1 = {'name': 'test', 'desc': 'test', 'severity': 'low'}
53
54 host_2 = {'ip': '127.0.0.1'}
55 host_cache_id_2 = PluginBase.get_host_cache_id(host_2)
56 vuln_2 = {'name': 'test', 'desc': 'test', 'severity': 'high'}
57
58
59 cache_1 = PluginBase.get_host_vuln_cache_id(host_cache_id_1, vuln_1)
60 cache_2 = PluginBase.get_host_vuln_cache_id(host_cache_id_2, vuln_2)
61
62 assert cache_1 == cache_2
63
64
65 def test_get_host_vuln_cache_id_description_makes_different_cache_ids():
66 host_1 = {'ip': '127.0.0.1'}
67 host_cache_id_1 = PluginBase.get_host_cache_id(host_1)
68 vuln_1 = {'name': 'test', 'desc': 'test', 'severity': 'low'}
69
70 host_2 = {'ip': '127.0.0.1'}
71 host_cache_id_2 = PluginBase.get_host_cache_id(host_2)
72 vuln_2 = {'name': 'test', 'new desc': 'test', 'severity': 'high'}
73
74
75 cache_1 = PluginBase.get_host_vuln_cache_id(host_cache_id_1, vuln_1)
76 cache_2 = PluginBase.get_host_vuln_cache_id(host_cache_id_2, vuln_2)
77
78 assert cache_1 != cache_2
79
80
81 def test_get_service_vuln_cache_id_severity_does_not_affect_cache_id():
82 host_1 = {'ip': '127.0.0.1'}
83 host_cache_id_1 = PluginBase.get_host_cache_id(host_1)
84 service_1 = {'protocol': 'tcp', 'port': 80}
85
86 host_2 = {'ip': '127.0.0.1'}
87 host_cache_id_2 = PluginBase.get_host_cache_id(host_2)
88 host_2 = {'ip': '127.0.0.1'}
89 host_cache_id_2 = PluginBase.get_host_cache_id(host_2)
90 service_2 = {'protocol': 'tcp', 'port': 80}
91
92 service_cache_1 = PluginBase.get_host_service_cache_id(host_cache_id_1, service_1)
93 service_cache_2 = PluginBase.get_host_service_cache_id(host_cache_id_2, service_2)
94
95 vuln_2 = {'name': 'test', 'desc': 'test', 'severity': 'high', 'method': 'GET'}
96 vuln_1 = {'name': 'test', 'desc': 'test', 'severity': 'low', 'method': 'GET'}
97
98 cache_1 = PluginBase.get_service_vuln_cache_id(host_cache_id_1, service_cache_1, vuln_1)
99 cache_2 = PluginBase.get_service_vuln_cache_id(host_cache_id_2, service_cache_2, vuln_2)
100
101 assert cache_1 == cache_2
102
103 def test_get_service_vuln_cache_id_with_different_service_return_different_id():
104 host_1 = {'ip': '127.0.0.1'}
105 host_cache_id_1 = PluginBase.get_host_cache_id(host_1)
106 service_1 = {'protocol': 'tcp', 'port': 80}
107
108 host_2 = {'ip': '127.0.0.1'}
109 host_cache_id_2 = PluginBase.get_host_cache_id(host_2)
110 host_2 = {'ip': '127.0.0.1'}
111 host_cache_id_2 = PluginBase.get_host_cache_id(host_2)
112 service_2 = {'protocol': 'tcp', 'port': 22}
113
114 service_cache_1 = PluginBase.get_host_service_cache_id(host_cache_id_1, service_1)
115 service_cache_2 = PluginBase.get_host_service_cache_id(host_cache_id_2, service_2)
116
117 vuln_2 = {'name': 'test', 'desc': 'test', 'severity': 'high', 'method': 'GET'}
118 vuln_1 = {'name': 'test', 'desc': 'test', 'severity': 'low', 'method': 'GET'}
119
120 cache_1 = PluginBase.get_service_vuln_cache_id(host_cache_id_1, service_cache_1, vuln_1)
121 cache_2 = PluginBase.get_service_vuln_cache_id(host_cache_id_2, service_cache_2, vuln_2)
122
123 assert cache_1 != cache_2
+0
-165
tests/test_report_collection.py less more
0 import os
1 import socket
2 import json
3 import pytest
4 from pathlib import Path
5 from faraday_plugins.plugins.manager import PluginsManager, ReportAnalyzer
6 from faraday_plugins.plugins.plugin import PluginBase
7 from faraday.server.api.modules.bulk_create import BulkCreateSchema
8
9 BLACK_LIST = [
10 'LICENSE',
11 'README.md',
12 '.gitignore',
13 '.gitkeep',
14 'faraday_plugins_tests',
15
16 ]
17
18 plugins_manager = PluginsManager(hostname_resolution=False)
19 analyzer = ReportAnalyzer(plugins_manager)
20
21 PLUGINS_CACHE = {}
22 REPORTS_JSON_CACHE = {}
23
24 SKIP_IP_PLUGINS = ['Fortify']
25
26 REPORTS_SUMMARY_DIR = './report-collection/faraday_plugins_tests'
27
28
29 def get_plugin_from_cache(report_file):
30 plugin = PLUGINS_CACHE.get(report_file)
31 if not plugin:
32 plugin: PluginBase = analyzer.get_plugin(report_file)
33 if plugin:
34 save_plugin_in_cache(report_file, plugin)
35 return plugin
36
37
38 def save_plugin_in_cache(report_file, plugin):
39 if report_file not in PLUGINS_CACHE:
40 PLUGINS_CACHE[report_file] = plugin
41
42
43 def get_report_json_from_cache(report_file):
44 plugin_json = REPORTS_JSON_CACHE.get(report_file)
45 if not plugin_json:
46 plugin = get_plugin_from_cache(report_file)
47 if plugin:
48 plugin.processReport(Path(report_file))
49 plugin_json = json.loads(plugin.get_json())
50 REPORTS_JSON_CACHE[report_file] = plugin_json
51 else:
52 plugin = get_plugin_from_cache(report_file)
53 return plugin, plugin_json
54
55
56 def list_report_files():
57 report_filenames = os.walk(REPORTS_SUMMARY_DIR)
58 for plugin_folder, directory, filenames in report_filenames:
59 if '.git' in directory or 'faraday_plugins_tests' in directory:
60 continue
61 for filename in filenames:
62 if filename in BLACK_LIST:
63 continue
64 if '.git' in plugin_folder:
65 continue
66 if not filename.endswith('_summary.json'):
67 yield Path(plugin_folder).name, os.path.join(plugin_folder, filename)
68
69
70 def is_valid_ipv4_address(address):
71 try:
72 socket.inet_pton(socket.AF_INET, address)
73 except AttributeError: # no inet_pton here, sorry
74 try:
75 socket.inet_aton(address)
76 except OSError:
77 return False
78 return address.count('.') == 3
79 except OSError: # not a valid address
80 return False
81 return True
82
83
84 def is_valid_ipv6_address(address):
85 try:
86 socket.inet_pton(socket.AF_INET6, address)
87 except OSError: # not a valid address
88 return False
89 return True
90
91
92 def is_valid_ip_address(address):
93 return (is_valid_ipv4_address(address) or is_valid_ipv6_address(address))
94
95 def test_reports_collection_exists():
96 assert os.path.isdir(REPORTS_SUMMARY_DIR) is True, "Please clone the report-collection repo!"
97
98 @pytest.mark.parametrize("report_filename_and_folder", list_report_files())
99 def test_autodetected_on_all_report_collection(report_filename_and_folder):
100 plugin_folder = report_filename_and_folder[0]
101 report_filename = report_filename_and_folder[1]
102 plugin: PluginBase = get_plugin_from_cache(report_filename)
103 assert plugin, report_filename
104 assert plugin.id == plugin_folder
105
106
107 @pytest.mark.parametrize("report_filename_and_folder", list_report_files())
108 def test_schema_on_all_reports(report_filename_and_folder):
109 report_filename = report_filename_and_folder[1]
110 plugin, plugin_json = get_report_json_from_cache(report_filename)
111 if plugin_json:
112 serializer = BulkCreateSchema()
113 res = serializer.loads(json.dumps(plugin_json))
114 assert set(res.keys()) == {'hosts', 'command'}
115
116
117
118
119 @pytest.mark.skip(reason="Skip validate ip format")
120 @pytest.mark.parametrize("report_filename_and_folder", list_report_files())
121 def test_host_ips_all_reports(report_filename_and_folder):
122 report_filename = report_filename_and_folder[1]
123 plugin, plugin_json = get_report_json_from_cache(report_filename)
124 if plugin_json:
125 if plugin.id not in SKIP_IP_PLUGINS:
126 for host in plugin_json['hosts']:
127 assert is_valid_ip_address(host['ip']) is True
128
129
130 @pytest.mark.parametrize("report_filename_and_folder", list_report_files())
131 def test_summary_reports(report_filename_and_folder):
132 report_filename = report_filename_and_folder[1]
133 plugin, plugin_json = get_report_json_from_cache(report_filename)
134 if plugin_json:
135 summary_file = f"{os.path.splitext(report_filename)[0]}_summary.json"
136 assert os.path.isfile(summary_file) is True
137 with open(summary_file) as f:
138 saved_summary = json.load(f)
139 summary = plugin.get_summary()
140 vuln_hashes = set(summary['vuln_hashes'])
141 saved_vuln_hashes = set(saved_summary.get('vuln_hashes', []))
142 assert summary['hosts'] == saved_summary['hosts']
143 assert summary['services'] == saved_summary['services']
144 assert summary['hosts_vulns'] == saved_summary['hosts_vulns']
145 assert summary['services_vulns'] == saved_summary['services_vulns']
146 assert summary['severity_vulns'] == saved_summary['severity_vulns']
147 assert vuln_hashes == saved_vuln_hashes
148
149
150 @pytest.mark.performance
151 @pytest.mark.parametrize("report_filename_and_folder", list_report_files())
152 def test_detected_tools_on_all_report_collection(report_filename_and_folder, benchmark):
153 report_filename = report_filename_and_folder[1]
154 plugins_manager = PluginsManager()
155 analyzer = ReportAnalyzer(plugins_manager)
156 plugin: PluginBase = analyzer.get_plugin(report_filename)
157 if not plugin:
158 return
159 assert plugin, report_filename
160 benchmark(plugin.processReport, report_filename)
161 plugin_json = json.loads(plugin.get_json())
162 assert "hosts" in plugin_json
163 assert "command" in plugin_json
164 assert os.path.isfile(report_filename) is True