|
| 1 | +# frozen_string_literal: true |
| 2 | +# |
| 3 | +# ronin-vulns - A Ruby library for blind vulnerability testing. |
| 4 | +# |
| 5 | +# Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com) |
| 6 | +# |
| 7 | +# ronin-vulns is free software: you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU Lesser General Public License as published |
| 9 | +# by the Free Software Foundation, either version 3 of the License, or |
| 10 | +# (at your option) any later version. |
| 11 | +# |
| 12 | +# ronin-vulns is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +# GNU Lesser General Public License for more details. |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU Lesser General Public License |
| 18 | +# along with ronin-vulns. If not, see <https://www.gnu.org/licenses/>. |
| 19 | +# |
| 20 | + |
| 21 | +require 'ronin/vulns/importer' |
| 22 | +require 'ronin/vulns/cli/logging' |
| 23 | +require 'ronin/db/cli/database_options' |
| 24 | +require 'ronin/db/cli/printing' |
| 25 | + |
| 26 | +module Ronin |
| 27 | + module Vulns |
| 28 | + class CLI |
| 29 | + # |
| 30 | + # Mixin module which adds the ability to import web vulns into the |
| 31 | + # [ronin-db] database. |
| 32 | + # |
| 33 | + # [ronin-db]: https://github.com/ronin-rb/ronin-db#readme |
| 34 | + # |
| 35 | + # @since 0.2.0 |
| 36 | + # |
| 37 | + module Importable |
| 38 | + include DB::CLI::Printing |
| 39 | + include Logging |
| 40 | + |
| 41 | + # |
| 42 | + # Includes `Ronin::DB::CLI::DatabaseOptions` into the including command |
| 43 | + # class. |
| 44 | + # |
| 45 | + # @param [Class<Command>] command |
| 46 | + # The command class including {Importable}. |
| 47 | + # |
| 48 | + def self.included(command) |
| 49 | + command.include DB::CLI::DatabaseOptions |
| 50 | + end |
| 51 | + |
| 52 | + # |
| 53 | + # Imports a web vulnerability into the [ronin-db] database. |
| 54 | + # |
| 55 | + # [ronin-db]: https://github.com/ronin-rb/ronin-db#readme |
| 56 | + # |
| 57 | + # @param [WebVuln] vuln |
| 58 | + # The web vulnerability to import. |
| 59 | + # |
| 60 | + def import_vuln(vuln) |
| 61 | + Importer.import(vuln) |
| 62 | + |
| 63 | + vuln_name = vuln_type(vuln) |
| 64 | + location = vuln_location(vuln) |
| 65 | + |
| 66 | + if location |
| 67 | + log_info "Imported #{vuln_name} vulnerability on URL #{vuln.url} and #{location}" |
| 68 | + else |
| 69 | + log_info "Imported #{vuln_name} vulnerability on URL #{vuln.url}" |
| 70 | + end |
| 71 | + end |
| 72 | + end |
| 73 | + end |
| 74 | + end |
| 75 | +end |
0 commit comments