ronin-recon 0.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.document +4 -0
  3. data/.github/workflows/ruby.yml +46 -0
  4. data/.gitignore +20 -0
  5. data/.rspec +1 -0
  6. data/.rubocop.yml +44 -0
  7. data/.ruby-version +1 -0
  8. data/.yardopts +1 -0
  9. data/COPYING.txt +165 -0
  10. data/ChangeLog.md +36 -0
  11. data/Gemfile +62 -0
  12. data/README.md +391 -0
  13. data/Rakefile +74 -0
  14. data/bin/ronin-recon +16 -0
  15. data/data/completions/ronin-recon +95 -0
  16. data/data/templates/worker.rb.erb +67 -0
  17. data/data/wordlists/raft-small-directories.txt.gz +0 -0
  18. data/data/wordlists/subdomains-1000.txt.gz +0 -0
  19. data/examples/recon.rb +24 -0
  20. data/gemspec.yml +57 -0
  21. data/lib/ronin/recon/builtin/dns/lookup.rb +65 -0
  22. data/lib/ronin/recon/builtin/dns/mailservers.rb +64 -0
  23. data/lib/ronin/recon/builtin/dns/nameservers.rb +61 -0
  24. data/lib/ronin/recon/builtin/dns/reverse_lookup.rb +63 -0
  25. data/lib/ronin/recon/builtin/dns/srv_enum.rb +178 -0
  26. data/lib/ronin/recon/builtin/dns/subdomain_enum.rb +105 -0
  27. data/lib/ronin/recon/builtin/dns/suffix_enum.rb +168 -0
  28. data/lib/ronin/recon/builtin/net/ip_range_enum.rb +65 -0
  29. data/lib/ronin/recon/builtin/net/port_scan.rb +84 -0
  30. data/lib/ronin/recon/builtin/net/service_id.rb +75 -0
  31. data/lib/ronin/recon/builtin/ssl/cert_enum.rb +109 -0
  32. data/lib/ronin/recon/builtin/ssl/cert_grab.rb +76 -0
  33. data/lib/ronin/recon/builtin/ssl/cert_sh.rb +77 -0
  34. data/lib/ronin/recon/builtin/web/dir_enum.rb +121 -0
  35. data/lib/ronin/recon/builtin/web/email_addresses.rb +70 -0
  36. data/lib/ronin/recon/builtin/web/spider.rb +93 -0
  37. data/lib/ronin/recon/builtin.rb +34 -0
  38. data/lib/ronin/recon/cli/command.rb +40 -0
  39. data/lib/ronin/recon/cli/commands/completion.rb +61 -0
  40. data/lib/ronin/recon/cli/commands/irb.rb +57 -0
  41. data/lib/ronin/recon/cli/commands/new.rb +203 -0
  42. data/lib/ronin/recon/cli/commands/run.rb +420 -0
  43. data/lib/ronin/recon/cli/commands/test.rb +99 -0
  44. data/lib/ronin/recon/cli/commands/worker.rb +114 -0
  45. data/lib/ronin/recon/cli/commands/workers.rb +80 -0
  46. data/lib/ronin/recon/cli/debug_option.rb +45 -0
  47. data/lib/ronin/recon/cli/printing.rb +122 -0
  48. data/lib/ronin/recon/cli/ruby_shell.rb +51 -0
  49. data/lib/ronin/recon/cli/worker_command.rb +105 -0
  50. data/lib/ronin/recon/cli.rb +50 -0
  51. data/lib/ronin/recon/config.rb +371 -0
  52. data/lib/ronin/recon/dns_worker.rb +41 -0
  53. data/lib/ronin/recon/engine.rb +639 -0
  54. data/lib/ronin/recon/exceptions.rb +45 -0
  55. data/lib/ronin/recon/graph.rb +127 -0
  56. data/lib/ronin/recon/importer.rb +224 -0
  57. data/lib/ronin/recon/input_file.rb +81 -0
  58. data/lib/ronin/recon/message/job_completed.rb +60 -0
  59. data/lib/ronin/recon/message/job_failed.rb +69 -0
  60. data/lib/ronin/recon/message/job_started.rb +60 -0
  61. data/lib/ronin/recon/message/shutdown.rb +38 -0
  62. data/lib/ronin/recon/message/value.rb +76 -0
  63. data/lib/ronin/recon/message/worker_started.rb +51 -0
  64. data/lib/ronin/recon/message/worker_stopped.rb +51 -0
  65. data/lib/ronin/recon/mixins/dns.rb +639 -0
  66. data/lib/ronin/recon/mixins/http.rb +58 -0
  67. data/lib/ronin/recon/mixins.rb +21 -0
  68. data/lib/ronin/recon/output_formats/dir.rb +94 -0
  69. data/lib/ronin/recon/output_formats/dot.rb +155 -0
  70. data/lib/ronin/recon/output_formats/graph_format.rb +48 -0
  71. data/lib/ronin/recon/output_formats/graphviz_format.rb +115 -0
  72. data/lib/ronin/recon/output_formats/pdf.rb +43 -0
  73. data/lib/ronin/recon/output_formats/png.rb +43 -0
  74. data/lib/ronin/recon/output_formats/svg.rb +43 -0
  75. data/lib/ronin/recon/output_formats.rb +48 -0
  76. data/lib/ronin/recon/registry.rb +35 -0
  77. data/lib/ronin/recon/root.rb +33 -0
  78. data/lib/ronin/recon/scope.rb +112 -0
  79. data/lib/ronin/recon/value/parser.rb +113 -0
  80. data/lib/ronin/recon/value.rb +110 -0
  81. data/lib/ronin/recon/value_status.rb +87 -0
  82. data/lib/ronin/recon/values/cert.rb +168 -0
  83. data/lib/ronin/recon/values/domain.rb +88 -0
  84. data/lib/ronin/recon/values/email_address.rb +114 -0
  85. data/lib/ronin/recon/values/host.rb +137 -0
  86. data/lib/ronin/recon/values/ip.rb +123 -0
  87. data/lib/ronin/recon/values/ip_range.rb +155 -0
  88. data/lib/ronin/recon/values/mailserver.rb +61 -0
  89. data/lib/ronin/recon/values/nameserver.rb +61 -0
  90. data/lib/ronin/recon/values/open_port.rb +190 -0
  91. data/lib/ronin/recon/values/url.rb +218 -0
  92. data/lib/ronin/recon/values/website.rb +200 -0
  93. data/lib/ronin/recon/values/wildcard.rb +140 -0
  94. data/lib/ronin/recon/values.rb +32 -0
  95. data/lib/ronin/recon/version.rb +26 -0
  96. data/lib/ronin/recon/web_worker.rb +35 -0
  97. data/lib/ronin/recon/worker.rb +433 -0
  98. data/lib/ronin/recon/worker_pool.rb +203 -0
  99. data/lib/ronin/recon/workers.rb +260 -0
  100. data/lib/ronin/recon.rb +22 -0
  101. data/man/ronin-recon-completion.1 +76 -0
  102. data/man/ronin-recon-completion.1.md +78 -0
  103. data/man/ronin-recon-irb.1 +27 -0
  104. data/man/ronin-recon-irb.1.md +26 -0
  105. data/man/ronin-recon-new.1 +58 -0
  106. data/man/ronin-recon-new.1.md +59 -0
  107. data/man/ronin-recon-run.1 +137 -0
  108. data/man/ronin-recon-run.1.md +115 -0
  109. data/man/ronin-recon-test.1 +53 -0
  110. data/man/ronin-recon-test.1.md +55 -0
  111. data/man/ronin-recon-worker.1 +32 -0
  112. data/man/ronin-recon-worker.1.md +34 -0
  113. data/man/ronin-recon-workers.1 +29 -0
  114. data/man/ronin-recon-workers.1.md +31 -0
  115. data/man/ronin-recon.1 +57 -0
  116. data/man/ronin-recon.1.md +57 -0
  117. data/ronin-recon.gemspec +62 -0
  118. data/scripts/setup +58 -0
  119. metadata +364 -0
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon 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-recon 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-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/recon/cli/command'
22
+ require 'ronin/recon/registry'
23
+
24
+ module Ronin
25
+ module Recon
26
+ class CLI
27
+ module Commands
28
+ #
29
+ # Lists the available recon workers.
30
+ #
31
+ # ## Usage
32
+ #
33
+ # ronin-recon help [options]
34
+ #
35
+ # ## Options
36
+ #
37
+ # -h, --help Print help information
38
+ #
39
+ # ## Arguments
40
+ #
41
+ # [COMMAND] Command name to lookup
42
+ #
43
+ class Workers < Command
44
+
45
+ usage '[options] [DIR]'
46
+
47
+ argument :dir, required: false,
48
+ desc: 'The optional recon worker directory to list'
49
+
50
+ description 'Lists the available recon workers'
51
+
52
+ man_page 'ronin-workers-list.1'
53
+
54
+ #
55
+ # Runs the `ronin-recon workers` command.
56
+ #
57
+ # @param [String, nil] dir
58
+ # The optional recon worker directory to list.
59
+ #
60
+ def run(dir=nil)
61
+ files = if dir
62
+ dir = "#{dir}/" unless dir.end_with?('/')
63
+
64
+ Ronin::Recon.list_files.select do |file|
65
+ file.start_with?(dir)
66
+ end
67
+ else
68
+ Ronin::Recon.list_files
69
+ end
70
+
71
+ files.each do |file|
72
+ puts " #{file}"
73
+ end
74
+ end
75
+
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon 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-recon 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-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'console'
22
+
23
+ module Ronin
24
+ module Recon
25
+ class CLI
26
+ #
27
+ # Adds a `-D,--debug` option to the command that enables debugging output.
28
+ #
29
+ module DebugOption
30
+ #
31
+ # Adds the `-D,--debug` option to the including command class.
32
+ #
33
+ # @param [Class<Command>] command
34
+ # The command class which is including {DebugOption}.
35
+ #
36
+ def self.included(command)
37
+ command.option :debug, short: '-D',
38
+ desc: 'Enable debugging output' do
39
+ Console.logger.level = Console::Logger::DEBUG
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon 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-recon 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-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/recon/values'
22
+ require 'ronin/core/cli/logging'
23
+
24
+ module Ronin
25
+ module Recon
26
+ class CLI
27
+ #
28
+ # Helper methods for printing {Values Value} objects.
29
+ #
30
+ module Printing
31
+ include Core::CLI::Logging
32
+
33
+ # Mapping of {Value} classes to printable names.
34
+ VALUE_CLASS_NAMES = {
35
+ Values::Domain => 'domain',
36
+ Values::Host => 'host',
37
+ Values::IP => 'IP address',
38
+ Values::IPRange => 'IP range',
39
+ Values::Mailserver => 'mailserver',
40
+ Values::Nameserver => 'nameserver',
41
+ Values::OpenPort => 'open port',
42
+ Values::Cert => 'SSL/TLS certificate',
43
+ Values::EmailAddress => 'email addresse',
44
+ Values::URL => 'URL',
45
+ Values::Website => 'website',
46
+ Values::Wildcard => 'wildcard host name'
47
+ }
48
+
49
+ #
50
+ # Converts the value class into a printable name.
51
+ #
52
+ # @param [Class<Value>] value_class
53
+ # The value class.
54
+ #
55
+ # @return [String]
56
+ # The descriptive name for the value class.
57
+ #
58
+ # @raise [NotImplementedError]
59
+ #
60
+ def value_class_name(value_class)
61
+ VALUE_CLASS_NAMES.fetch(value_class) do
62
+ raise(NotImplementedError,"unknown value class: #{value_class.inspect}")
63
+ end
64
+ end
65
+
66
+ #
67
+ # Formats a value object into a human readable string.
68
+ #
69
+ # @param [Values::Value] value
70
+ # The value object to format.
71
+ #
72
+ # @return [String]
73
+ # The formatted value.
74
+ #
75
+ # @raise [NotImplementedError]
76
+ # The given value object was not supported.
77
+ #
78
+ def format_value(value)
79
+ case value
80
+ when Values::Domain then "domain #{value}"
81
+ when Values::Mailserver then "mailserver #{value}"
82
+ when Values::Nameserver then "nameserver #{value}"
83
+ when Values::Host then "host #{value}"
84
+ when Values::IP then "IP address #{value}"
85
+ when Values::IPRange then "IP range #{value}"
86
+ when Values::OpenPort then "open #{value.protocol.upcase} port #{value}"
87
+ when Values::Cert then "SSL/TLS certificate #{value.subject}"
88
+ when Values::URL then "URL #{value}"
89
+ when Values::Website then "website #{value}"
90
+ when Values::Wildcard then "wildcard host name #{value}"
91
+ else
92
+ raise(NotImplementedError,"value class #{value.class} not supported")
93
+ end
94
+ end
95
+
96
+ #
97
+ # Prints a newly discovered value.
98
+ #
99
+ # @param [Values::Value] value
100
+ # The value to print.
101
+ #
102
+ # @param [Value, nil] parent
103
+ # The optional parent value.
104
+ #
105
+ # @raise [NotImplementedError]
106
+ # The given value object was not supported.
107
+ #
108
+ def print_value(value,parent=nil)
109
+ if stdout.tty?
110
+ if parent
111
+ log_info "Found new #{format_value(value)} for #{format_value(parent)}"
112
+ else
113
+ log_info "Found new #{format_value(value)}"
114
+ end
115
+ else
116
+ puts value
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon 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-recon 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-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/core/cli/ruby_shell'
22
+
23
+ module Ronin
24
+ module Recon
25
+ class CLI
26
+ #
27
+ # The interactive Ruby shell for {Ronin::Recon}.
28
+ #
29
+ class RubyShell < Core::CLI::RubyShell
30
+
31
+ #
32
+ # Initializes the `ronin-recon` Ruby shell.
33
+ #
34
+ # @param [String] name
35
+ # The name of the IRB shell.
36
+ #
37
+ # @param [Object] context
38
+ # Custom context to launch IRB from within.
39
+ #
40
+ # @param [Hash{Symbol => Object}] kwargs
41
+ # Additional keyword arguments for
42
+ # `Ronin::Core::CLI::RubyShell#initialize`.
43
+ #
44
+ def initialize(name: 'ronin-recon', context: Recon, **kwargs)
45
+ super(name: name, context: context, **kwargs)
46
+ end
47
+
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon 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-recon 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-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/recon/cli/command'
22
+ require 'ronin/recon/registry'
23
+
24
+ module Ronin
25
+ module Recon
26
+ class CLI
27
+ #
28
+ # Base class for commands which load an individual worker.
29
+ #
30
+ class WorkerCommand < Command
31
+
32
+ usage '[options] {--file FILE | NAME}'
33
+
34
+ option :file, short: '-f',
35
+ value: {
36
+ type: String,
37
+ usage: 'FILE'
38
+ },
39
+ desc: 'The recon worker file to load'
40
+
41
+ argument :name, required: false,
42
+ desc: 'The recon worker to load'
43
+
44
+ # The loaded worker class.
45
+ #
46
+ # @return [Class<Worker>, nil]
47
+ attr_reader :worker_class
48
+
49
+ #
50
+ # Loads the recon worker class.
51
+ #
52
+ # @param [String, nil] name
53
+ # The optional recon worker name to load.
54
+ #
55
+ # @return [Class<Worker>]
56
+ # The loaded recon worker class.
57
+ #
58
+ def run(name=nil)
59
+ if name then load_worker(name)
60
+ elsif options[:file] then load_worker_from(options[:file])
61
+ else
62
+ print_error("must specify --file or a NAME")
63
+ exit(-1)
64
+ end
65
+ end
66
+
67
+ #
68
+ # Loads the recon worker class and sets {#worker_class}.
69
+ #
70
+ # @param [String] id
71
+ # The recon worker name to load.
72
+ #
73
+ def load_worker(id)
74
+ @worker_class = Recon.load_class(id)
75
+ rescue Recon::ClassNotFound => error
76
+ print_error(error.message)
77
+ exit(1)
78
+ rescue => error
79
+ print_exception(error)
80
+ print_error("an unhandled exception occurred while loading recon worker #{id}")
81
+ exit(-1)
82
+ end
83
+
84
+ #
85
+ # Loads the recon worker class from the given file and sets
86
+ # {#worker_class}.
87
+ #
88
+ # @param [String] file
89
+ # The file to load the recon worker class from.
90
+ #
91
+ def load_worker_from(file)
92
+ @worker_class = Recon.load_class_from_file(file)
93
+ rescue Recon::ClassNotFound => error
94
+ print_error(error.message)
95
+ exit(1)
96
+ rescue => error
97
+ print_exception(error)
98
+ print_error("an unhandled exception occurred while loading recon worker from file #{file}")
99
+ exit(-1)
100
+ end
101
+
102
+ end
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-recon - A micro-framework and tool for performing reconnaissance.
4
+ #
5
+ # Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
6
+ #
7
+ # ronin-recon 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-recon 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-recon. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/recon/version'
22
+ require 'ronin/core/cli/help/banner'
23
+
24
+ require 'command_kit/commands'
25
+ require 'command_kit/commands/auto_load'
26
+ require 'command_kit/options/version'
27
+
28
+ module Ronin
29
+ module Recon
30
+ #
31
+ # The `ronin-recon` command-line interface (CLI).
32
+ #
33
+ # @api private
34
+ #
35
+ class CLI
36
+
37
+ include CommandKit::Commands
38
+ include CommandKit::Commands::AutoLoad.new(
39
+ dir: "#{__dir__}/cli/commands",
40
+ namespace: "#{self}::Commands"
41
+ )
42
+ include CommandKit::Options::Version
43
+ include Core::CLI::Help::Banner
44
+
45
+ command_name 'ronin-recon'
46
+ version Ronin::Recon::VERSION
47
+
48
+ end
49
+ end
50
+ end