-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53329e6
commit 368f959
Showing
10 changed files
with
728 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ Arguments: | |
Commands: | ||
completion | ||
config | ||
help | ||
irb | ||
new | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-config.1' | ||
|
||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
# | ||
# 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 | ||
# | ||
def run(worker) | ||
load_config | ||
|
||
@config.workers.delete(worker) | ||
|
||
save_config | ||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
# 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 | ||
# | ||
# Gets the concurrency or a param for a worker. | ||
# | ||
# ## Usage | ||
# | ||
# ronin-recon config get [options] {--concurrency WORKER | --param WORKER.NAME} | ||
# | ||
# ## Options | ||
# | ||
# -C, --config-file FILE Loads the configuration file | ||
# -c, --concurrency WORKER Gets the concurrency of a worker | ||
# -p, --param WORKER.PARAM Gets a param for a worker | ||
# -h, --help Print help information | ||
# | ||
# @since 0.2.0 | ||
# | ||
class Get < ConfigCommand | ||
|
||
usage '[options] {--concurrency WORKER | --param WORKER.NAME}' | ||
|
||
option :concurrency, short: '-c', | ||
value: { | ||
type: String, | ||
usage: 'WORKER' | ||
}, | ||
desc: 'Gets the concurrency for the worker' do |worker| | ||
@mode = :concurrency | ||
@worker = worker | ||
end | ||
|
||
option :param, short: '-p', | ||
value: { | ||
type: /\A[^\.\=\s]+\.[^=\s]+\z/, | ||
usage: 'WORKER.PARAM' | ||
}, | ||
desc: 'Gets the param for the worker' do |str| | ||
@mode = :param | ||
@worker, @param = str.split('.',2) | ||
end | ||
|
||
description 'Gets the concurrency or a param for a worker' | ||
|
||
man_page 'ronin-recon-config-get.1' | ||
|
||
# Specifies whether to unset the worker's concurrency or param. | ||
# | ||
# @return [:concurrency, :param, nil] | ||
attr_reader :mode | ||
|
||
# The worker name. | ||
# | ||
# @return [String, nil] | ||
attr_reader :worker | ||
|
||
# The param name to unset. | ||
# | ||
# @return [String, nil] | ||
attr_reader :param | ||
|
||
# | ||
# Runs the `ronin-recon config set` command. | ||
# | ||
def run | ||
load_config | ||
|
||
case @mode | ||
when :concurrency | ||
if (concurrency = @config.concurrency[@worker]) | ||
puts concurrency | ||
end | ||
when :param | ||
if (params = @config.params[@worker]) && | ||
(value = params[@param]) | ||
puts value | ||
end | ||
else | ||
print_error "--concurrency or --param options must be given" | ||
exit(1) | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.