|
| 1 | +# frozen_string_literal: true |
| 2 | +# |
| 3 | +# Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com) |
| 4 | +# |
| 5 | +# Ronin is free software: you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License as published by |
| 7 | +# the Free Software Foundation, either version 3 of the License, or |
| 8 | +# (at your option) any later version. |
| 9 | +# |
| 10 | +# Ronin is distributed in the hope that it will be useful, |
| 11 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | +# GNU General Public License for more details. |
| 14 | +# |
| 15 | +# You should have received a copy of the GNU General Public License |
| 16 | +# along with Ronin. If not, see <https://www.gnu.org/licenses/>. |
| 17 | +# |
| 18 | + |
| 19 | +require_relative '../value_processor_command' |
| 20 | + |
| 21 | +require 'ronin/support/network/defang' |
| 22 | + |
| 23 | +module Ronin |
| 24 | + class CLI |
| 25 | + module Commands |
| 26 | + # |
| 27 | + # Defangs a URL, hostname, or IP address. |
| 28 | + # |
| 29 | + # ## Usage |
| 30 | + # |
| 31 | + # ronin defang [options] [{URL | HOST | IP} ...] |
| 32 | + # |
| 33 | + # ## Options |
| 34 | + # |
| 35 | + # -f, --file FILE Optional file to read values from |
| 36 | + # -h, --help Print help information |
| 37 | + # |
| 38 | + # ## Arguments |
| 39 | + # |
| 40 | + # [URL | HOST | IP ...] A URL, hostname, or IP address |
| 41 | + # |
| 42 | + # ## Examples |
| 43 | + # |
| 44 | + # ronin defang https://www.evil.com/foo/bar/baz |
| 45 | + # ronin defang www.example.com |
| 46 | + # ronin defang 192.168.1.1 |
| 47 | + # ronin defang --file urls.txt |
| 48 | + # |
| 49 | + # @since 2.2.0 |
| 50 | + # |
| 51 | + class Defang < ValueProcessorCommand |
| 52 | + |
| 53 | + usage '[options] [{URL | HOST | IP} ...]' |
| 54 | + |
| 55 | + argument :value, required: false, |
| 56 | + repeats: true, |
| 57 | + usage: 'URL | HOST | IP', |
| 58 | + desc: 'A URL, hostname, or IP address' |
| 59 | + |
| 60 | + examples [ |
| 61 | + 'https://www.evil.com/foo/bar/baz', |
| 62 | + 'www.example.com', |
| 63 | + '192.168.1.1', |
| 64 | + '--file urls.txt' |
| 65 | + ] |
| 66 | + |
| 67 | + description 'Defangs a URLs, hostnames, or IP addresses' |
| 68 | + |
| 69 | + man_page 'ronin-defang.1' |
| 70 | + |
| 71 | + # |
| 72 | + # Defangs a URL, hostname, or IP address. |
| 73 | + # |
| 74 | + # @param [String] value |
| 75 | + # The value to defang. |
| 76 | + # |
| 77 | + def process_value(value) |
| 78 | + puts Support::Network::Defang.defang(value) |
| 79 | + end |
| 80 | + |
| 81 | + end |
| 82 | + end |
| 83 | + end |
| 84 | +end |
0 commit comments