Skip to content

Commit

Permalink
Added the ronin-recon config command (closes #178).
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Sep 6, 2024
1 parent 33a5d69 commit 0e198d4
Show file tree
Hide file tree
Showing 25 changed files with 1,571 additions and 1 deletion.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Arguments:
Commands:
completion
config
help
irb
new
Expand Down Expand Up @@ -215,6 +216,24 @@ Save the recon results to a PDF image:
$ ronin-recon run -o output.pdf example.com
```

Enable an optional worker by default:

```shell
$ ronin-recon config enable api/hunter_io
```

Set the default concurrency for a worker:

```shell
$ ronin-recon config set --concurrency web/spider=4
```

Set the API key for a worker:

```shell
$ ronin-recon config set --param api/hunter_io.api_key=...
```

Generate a boilerplate recon worker file, with some custom information:

```shell
Expand Down
7 changes: 7 additions & 0 deletions gemspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ generated_files:
- data/completions/ronin-recon
- man/ronin-recon.1
- man/ronin-recon-completion.1
- man/ronin-recon-config.1
- man/ronin-recon-config-disable.1
- man/ronin-recon-config-enable.1
- man/ronin-recon-config-get.1
- man/ronin-recon-config-list.1
- man/ronin-recon-config-set.1
- man/ronin-recon-config-unset.1
- man/ronin-recon-irb.1
- man/ronin-recon-new.1
- man/ronin-recon-workers.1
Expand Down
92 changes: 92 additions & 0 deletions lib/ronin/recon/cli/commands/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# frozen_string_literal: true
#
# ronin-recon - A micro-framework and tool for performing reconnaissance.
#
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
#
# ronin-recon is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ronin-recon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ronin-recon. If not, see <https://www.gnu.org/licenses/>.
#

require_relative '../command'

require 'command_kit/commands/auto_load'

module Ronin
module Recon
class CLI
module Commands
#
# Get and set ronin-recon configuration.
#
# ## Usage
#
# ronin-recon config [options] [COMMAND [ARGS...]]
#
# ## Options
#
# -h, --help Print help information
#
# ## Arguments
#
# [COMMAND] The command name to run
# [ARGS ...] Additional arguments for the command
#
# ## Commands
#
# disable
# enable
# get
# help
# list
# set
# unset
#
# ## Examples
#
# ronin-recon config list
# ronin-recon config enable api/hunter_io
# ronin-recon config disable api/hunter_io
# ronin-recon config set --param api/hunter_io.api_key=...
# ronin-recon config set --concurrency web/spider=10
# ronin-recon config unset --param web/spider.proxy
# ronin-recon config unset --concurrency web/spider
#
# @since 0.2.0
#
class Config < Command

include CommandKit::Commands::AutoLoad.new(
dir: "#{__dir__}/config",
namespace: "#{self}"
)

examples [
'list',
'enable api/hunter_io',
'disable api/hunter_io',
'set --param api/hunter_io.api_key=...',
'set --concurrency web/spider=10',
'unset --param web/spider.proxy',
'unset --concurrency web/spider'
]

description 'Get and set ronin-recon configuration'

man_page 'ronin-recon-config.1'

end
end
end
end
end
74 changes: 74 additions & 0 deletions lib/ronin/recon/cli/commands/config/disable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# frozen_string_literal: true
#
# ronin-recon - A micro-framework and tool for performing reconnaissance.
#
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
#
# ronin-recon is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ronin-recon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ronin-recon. If not, see <https://www.gnu.org/licenses/>.
#

require_relative '../../config_command'

module Ronin
module Recon
class CLI
module Commands
class Config < Command
#
# Disables a worker in the configuration file.
#
# ## Usage
#
# ronin-recon config disable [options] WORKER
#
# ## Options
#
# -C, --config-file FILE Loads the configuration file
# -h, --help Print help information
#
# ## Arguments
#
# WORKER The worker ID to disable
#
# @since 0.2.0
#
class Disable < ConfigCommand

argument :worker, required: true,
desc: 'The worker ID to disable'

description "Disables a worker in the configuration file"

man_page 'ronin-recon-config-disable.1'

#
# Runs the `ronin-recon config disable` command.
#
# @param [String] worker
# The worker ID to disable.
#
def run(worker)
load_config

@config.workers.delete(worker)

save_config
end

end
end
end
end
end
end
73 changes: 73 additions & 0 deletions lib/ronin/recon/cli/commands/config/enable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# frozen_string_literal: true
#
# ronin-recon - A micro-framework and tool for performing reconnaissance.
#
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
#
# ronin-recon is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ronin-recon is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with ronin-recon. If not, see <https://www.gnu.org/licenses/>.
#

require_relative '../../config_command'

module Ronin
module Recon
class CLI
module Commands
class Config < Command
#
# Enables a worker in the configuration file.
#
# ## Usage
#
# ronin-recon config enable [options] WORKER
#
# ## Options
#
# -C, --config-file FILE Loads the configuration file
# -h, --help Print help information
#
# ## Arguments
#
# WORKER The worker ID to enable
#
# @since 0.2.0
#
class Enable < ConfigCommand

argument :worker, required: true,
desc: 'The worker ID to enable'

description "Enables a worker in the configuration file"

man_page 'ronin-recon-config-enable.1'

#
# Runs the `ronin-recon config enable` command.
#
# @param [String] worker
#
def run(worker)
load_config

@config.workers.add(worker)

save_config
end

end
end
end
end
end
end
Loading

0 comments on commit 0e198d4

Please sign in to comment.