ronin 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +14 -0
  3. data/.rubocop.yml +21 -0
  4. data/ChangeLog.md +18 -2
  5. data/Gemfile +6 -2
  6. data/Rakefile +2 -2
  7. data/bin/ronin +6 -7
  8. data/data/new/project/Gemfile.erb +9 -9
  9. data/gemspec.yml +7 -7
  10. data/lib/ronin/cli/char_set_options.rb +1 -1
  11. data/lib/ronin/cli/cipher_command.rb +3 -1
  12. data/lib/ronin/cli/command.rb +3 -0
  13. data/lib/ronin/cli/commands/asn.rb +1 -1
  14. data/lib/ronin/cli/commands/banner_grab.rb +5 -3
  15. data/lib/ronin/cli/commands/cert_dump.rb +4 -7
  16. data/lib/ronin/cli/commands/cert_gen.rb +4 -4
  17. data/lib/ronin/cli/commands/cert_grab.rb +5 -6
  18. data/lib/ronin/cli/commands/decode.rb +14 -14
  19. data/lib/ronin/cli/commands/encode.rb +14 -14
  20. data/lib/ronin/cli/commands/extract.rb +1 -1
  21. data/lib/ronin/cli/commands/grep.rb +7 -5
  22. data/lib/ronin/cli/commands/hexdump.rb +53 -22
  23. data/lib/ronin/cli/commands/hmac.rb +1 -1
  24. data/lib/ronin/cli/commands/host.rb +2 -2
  25. data/lib/ronin/cli/commands/http.rb +42 -25
  26. data/lib/ronin/cli/commands/ip.rb +2 -2
  27. data/lib/ronin/cli/commands/iprange.rb +2 -2
  28. data/lib/ronin/cli/commands/netcat.rb +32 -38
  29. data/lib/ronin/cli/commands/new/project.rb +19 -19
  30. data/lib/ronin/cli/commands/new/script.rb +12 -12
  31. data/lib/ronin/cli/commands/proxy.rb +10 -10
  32. data/lib/ronin/cli/commands/rot.rb +11 -10
  33. data/lib/ronin/cli/commands/strings.rb +1 -1
  34. data/lib/ronin/cli/commands/unhexdump.rb +1 -1
  35. data/lib/ronin/cli/dns.rb +3 -0
  36. data/lib/ronin/cli/file_processor_command.rb +3 -0
  37. data/lib/ronin/cli/host_and_port.rb +58 -0
  38. data/lib/ronin/cli/http_shell.rb +19 -16
  39. data/lib/ronin/cli/key_options.rb +3 -5
  40. data/lib/ronin/cli/method_options.rb +0 -2
  41. data/lib/ronin/cli/pattern_options.rb +5 -6
  42. data/lib/ronin/cli/printing/syntax_highlighting.rb +3 -0
  43. data/lib/ronin/cli/typo_options.rb +1 -1
  44. data/lib/ronin/cli/value_processor_command.rb +1 -1
  45. data/lib/ronin/config.rb +3 -3
  46. data/lib/ronin/version.rb +2 -2
  47. data/man/ronin-asn.1 +11 -1
  48. data/man/ronin-asn.1.md +9 -1
  49. data/man/ronin-banner-grab.1 +1 -1
  50. data/man/ronin-banner-grab.1.md +1 -1
  51. data/man/ronin-bitflip.1 +1 -1
  52. data/man/ronin-bitflip.1.md +1 -1
  53. data/man/ronin-cert-dump.1 +1 -1
  54. data/man/ronin-cert-dump.1.md +1 -1
  55. data/man/ronin-cert-gen.1 +1 -1
  56. data/man/ronin-cert-gen.1.md +1 -1
  57. data/man/ronin-cert-grab.1 +1 -1
  58. data/man/ronin-cert-grab.1.md +1 -1
  59. data/man/ronin-decode.1 +1 -1
  60. data/man/ronin-decode.1.md +1 -1
  61. data/man/ronin-decrypt.1 +1 -1
  62. data/man/ronin-decrypt.1.md +1 -1
  63. data/man/ronin-dns.1 +1 -1
  64. data/man/ronin-dns.1.md +1 -1
  65. data/man/ronin-email-addr.1 +1 -1
  66. data/man/ronin-email-addr.1.md +1 -1
  67. data/man/ronin-encode.1 +1 -1
  68. data/man/ronin-encode.1.md +1 -1
  69. data/man/ronin-encrypt.1 +1 -1
  70. data/man/ronin-encrypt.1.md +1 -1
  71. data/man/ronin-entropy.1 +1 -1
  72. data/man/ronin-entropy.1.md +1 -1
  73. data/man/ronin-escape.1 +1 -1
  74. data/man/ronin-escape.1.md +1 -1
  75. data/man/ronin-extract.1 +1 -1
  76. data/man/ronin-extract.1.md +1 -1
  77. data/man/ronin-grep.1 +1 -1
  78. data/man/ronin-grep.1.md +1 -1
  79. data/man/ronin-help.1 +1 -1
  80. data/man/ronin-help.1.md +1 -1
  81. data/man/ronin-hexdump.1 +2 -2
  82. data/man/ronin-hexdump.1.md +2 -2
  83. data/man/ronin-highlight.1 +1 -1
  84. data/man/ronin-highlight.1.md +1 -1
  85. data/man/ronin-hmac.1 +1 -1
  86. data/man/ronin-hmac.1.md +1 -1
  87. data/man/ronin-homoglyph.1 +1 -1
  88. data/man/ronin-homoglyph.1.md +1 -1
  89. data/man/ronin-host.1 +2 -2
  90. data/man/ronin-host.1.md +2 -2
  91. data/man/ronin-http.1 +1 -1
  92. data/man/ronin-http.1.md +1 -1
  93. data/man/ronin-ip.1 +1 -1
  94. data/man/ronin-ip.1.md +1 -1
  95. data/man/ronin-iprange.1 +1 -1
  96. data/man/ronin-iprange.1.md +1 -1
  97. data/man/ronin-irb.1 +1 -1
  98. data/man/ronin-irb.1.md +1 -1
  99. data/man/ronin-md5.1 +1 -1
  100. data/man/ronin-md5.1.md +1 -1
  101. data/man/ronin-netcat.1 +1 -1
  102. data/man/ronin-netcat.1.md +1 -1
  103. data/man/ronin-new-project.1 +1 -1
  104. data/man/ronin-new-project.1.md +1 -1
  105. data/man/ronin-new-script.1 +1 -1
  106. data/man/ronin-new-script.1.md +1 -1
  107. data/man/ronin-new.1 +1 -1
  108. data/man/ronin-new.1.md +1 -1
  109. data/man/ronin-proxy.1 +1 -1
  110. data/man/ronin-proxy.1.md +1 -1
  111. data/man/ronin-public-suffix-list.1 +11 -1
  112. data/man/ronin-public-suffix-list.1.md +9 -1
  113. data/man/ronin-quote.1 +1 -1
  114. data/man/ronin-quote.1.md +1 -1
  115. data/man/ronin-rot.1 +4 -3
  116. data/man/ronin-rot.1.md +4 -3
  117. data/man/ronin-sha1.1 +1 -1
  118. data/man/ronin-sha1.1.md +1 -1
  119. data/man/ronin-sha256.1 +1 -1
  120. data/man/ronin-sha256.1.md +1 -1
  121. data/man/ronin-sha512.1 +1 -1
  122. data/man/ronin-sha512.1.md +1 -1
  123. data/man/ronin-strings.1 +1 -1
  124. data/man/ronin-strings.1.md +1 -1
  125. data/man/ronin-tips.1 +1 -1
  126. data/man/ronin-tips.1.md +1 -1
  127. data/man/ronin-tld-list.1 +11 -1
  128. data/man/ronin-tld-list.1.md +9 -1
  129. data/man/ronin-typo.1 +1 -1
  130. data/man/ronin-typo.1.md +1 -1
  131. data/man/ronin-typosquat.1 +1 -1
  132. data/man/ronin-typosquat.1.md +1 -1
  133. data/man/ronin-unescape.1 +1 -1
  134. data/man/ronin-unescape.1.md +1 -1
  135. data/man/ronin-unhexdump.1 +1 -1
  136. data/man/ronin-unhexdump.1.md +1 -1
  137. data/man/ronin-unquote.1 +1 -1
  138. data/man/ronin-unquote.1.md +1 -1
  139. data/man/ronin-url.1 +1 -1
  140. data/man/ronin-url.1.md +1 -1
  141. data/man/ronin-xor.1 +1 -1
  142. data/man/ronin-xor.1.md +1 -1
  143. data/man/ronin.1 +1 -1
  144. data/man/ronin.1.md +1 -1
  145. data/ronin.gemspec +4 -3
  146. metadata +40 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b96dfac7bb76a9141b93ec0fb0de42a39b33b395ba1a0d946ad6a1be89f080f
4
- data.tar.gz: bddecb41842c7930939cce565afc39d93881c27bff7ef51cfb9f730d2e77e020
3
+ metadata.gz: 42aeafda3468e4c0f5427a4f2323d40b96bb4aaafc042bb8380d569f5c8c5414
4
+ data.tar.gz: a150c7211fa93770dc9be47343f8f3d3391396996885263580c0185742476255
5
5
  SHA512:
6
- metadata.gz: 3c61141e197c44975416cc10c76a13962b9bc3764d1892fc60ded4785aabf960eeab2bbdfb8b1d5e0c6db523afeb3f46c9c9fcb35c15d581fbdab287e185889a
7
- data.tar.gz: 1d8f93d1f6bcef6b08cafc1527bfa81d46ab7ddb31bdab97813c4cc3b40c30674d31593a513dcf3468a7ad80134b00165f0cbf1dbb3bcf059f17a828e6dbfd20
6
+ metadata.gz: 562df97d739aedfad72706c939d40697f8ab39136a3aab69e2d67e7aa29b3ea03bf1534695f259af8060c5e09f26e6e6c51ff62c57fa8d1ad73242c0c48e9c78
7
+ data.tar.gz: '018c73e255ed3b3468d84c054d8b79095cef777443536beac09e572d1bf183ce0d3a019a8e45560013c13a0b8df202a7402d1c4d4cd41ff884a0179f932e51bb'
@@ -30,3 +30,17 @@ jobs:
30
30
  run: bundle install --jobs 4 --retry 3
31
31
  - name: Run tests
32
32
  run: bundle exec rake test
33
+
34
+ # rubocop linting
35
+ rubocop:
36
+ runs-on: ubuntu-latest
37
+ steps:
38
+ - uses: actions/checkout@v2
39
+ - name: Set up Ruby
40
+ uses: ruby/setup-ruby@v1
41
+ with:
42
+ ruby-version: 3.0
43
+ - name: Install dependencies
44
+ run: bundle install --jobs 4 --retry 3
45
+ - name: Run rubocop
46
+ run: bundle exec rubocop --parallel
data/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 3.1
5
+
6
+ inherit_gem:
7
+ rubocop-ronin: rubocop.yml
8
+
9
+ #
10
+ # ronin specific exceptions
11
+ #
12
+
13
+ # this rule does not take into account the spacing of commented out lines
14
+ Layout/ExtraSpacing:
15
+ Exclude:
16
+ - 'Gemfile'
17
+
18
+ # no need to add `frozen_string_literal: true` to new scripts/projects
19
+ Style/FrozenStringLiteralComment:
20
+ Exclude:
21
+ - 'data/new/**/*'
data/ChangeLog.md CHANGED
@@ -1,4 +1,20 @@
1
- ### 2.0.0 / 2023-XX-XX
1
+ ### 2.0.1 / 2023-03-01
2
+
3
+ * Require [ronin-support] ~> 1.0, >= 1.0.1.
4
+ * Require [ronin-core] ~> 0.1, >= 0.1.1.
5
+ * Require [ronin-web] ~> 1.0, >= 1.0.1.
6
+ * Require [ronin-payloads] ~> 0.1, >= 0.1.1.
7
+ * Require [ronin-vulns] ~> 0.1, >= 0.1.2.
8
+ * Require [ronin-exploits] ~> 1.0, >= 1.0.1.
9
+ * Added {Ronin::CLI::HostAndPort} for common `host:port` parsing logic.
10
+ * Minor bug fixes.
11
+ * Improved documentation.
12
+
13
+ #### CLI
14
+
15
+ * Ensure that the `ronin http` command works with IDN host-names.
16
+
17
+ ### 2.0.0 / 2023-02-01
2
18
 
3
19
  * Require `ruby` >= 3.0.0.
4
20
  * Require [rouge] ~> 3.0
@@ -756,7 +772,7 @@
756
772
  * Require Spidr >= 0.1.3.
757
773
  * Moved Ronin::Parameters into the parameters 0.1.0 RubyGem.
758
774
  * Added a Ronin::Hexdump module:
759
- * Provides Ronin::Hexdump.dump and Kernel#hexdump, which can hexdump any
775
+ * Provides Ronin::Hexdump.dump and Kernel#hexdump, which can hexdump any
760
776
  object that supports the #each_byte method.
761
777
  * Refactored Ronin::Chars::CharSet:
762
778
  * Now inherites the SortedSet class.
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
@@ -45,9 +47,9 @@ end
45
47
  # branch: 'main'
46
48
  # gem 'ronin-vulns', '~> 0.1', github: "ronin-rb/ronin-vulns",
47
49
  # branch: 'main'
48
- # gem 'ronin-web-server', '~> 0.1', github: "ronin-rb/ronin-web-server",
50
+ # gem 'ronin-web-server', '~> 0.1', github: "ronin-rb/ronin-web-server",
49
51
  # branch: 'main'
50
- # gem 'ronin-web-spider', '~> 0.1', github: "ronin-rb/ronin-web-spider",
52
+ # gem 'ronin-web-spider', '~> 0.1', github: "ronin-rb/ronin-web-spider",
51
53
  # branch: 'main'
52
54
  # gem 'ronin-web-user_agents', '~> 0.1', github: "ronin-rb/ronin-web-user_agents",
53
55
  # branch: 'main'
@@ -70,4 +72,6 @@ group :development do
70
72
  gem 'dead_end', require: false
71
73
  gem 'sord', require: false, platform: :mri
72
74
  gem 'stackprof', require: false, platform: :mri
75
+ gem 'rubocop', require: false, platform: :mri
76
+ gem 'rubocop-ronin', require: false, platform: :mri
73
77
  end
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
- require 'rubygems'
1
+ # frozen_string_literal: true
2
2
 
3
3
  begin
4
4
  require 'bundler'
5
5
  rescue LoadError => e
6
6
  warn e.message
7
7
  warn "Run `gem install bundler` to install Bundler"
8
- exit -1
8
+ exit(-1)
9
9
  end
10
10
 
11
11
  begin
data/bin/ronin CHANGED
@@ -1,17 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'rubygems'
4
5
 
5
6
  root = File.expand_path(File.join(File.dirname(__FILE__),'..'))
6
7
  if File.file?(File.join(root,'Gemfile.lock'))
7
8
  Dir.chdir(root) do
8
- begin
9
- require 'bundler/setup'
10
- rescue LoadError => e
11
- warn e.message
12
- warn "Run `gem install bundler` to install Bundler"
13
- exit -1
14
- end
9
+ require 'bundler/setup'
10
+ rescue LoadError => e
11
+ warn e.message
12
+ warn "Run `gem install bundler` to install Bundler"
13
+ exit(-1)
15
14
  end
16
15
  end
17
16
 
@@ -4,13 +4,13 @@ source 'https://rubygems.org'
4
4
  gem 'rake'
5
5
 
6
6
  <%- end -%>
7
- gem 'ronin-support', '~> 1.0' #, github: 'ronin-rb/ronin-support'
7
+ gem 'ronin-support', '~> 1.0' # , github: 'ronin-rb/ronin-support'
8
8
 
9
- # gem 'ronin-code-asm', '~> 0.3' #, github: 'ronin-rb/ronin-code-asm'
10
- # gem 'ronin-code-sql', '~> 1.2' #, github: 'ronin-rb/ronin-code-sql'
11
- # gem 'ronin-db', '~> 0.1' #, github: 'ronin-rb/ronin-db'
12
- # gem 'ronin-web-server', '~> 0.1' #, github: 'ronin-rb/ronin-web-server'
13
- # gem 'ronin-web-spider', '~> 0.1' #, github: 'ronin-rb/ronin-web-spider'
14
- # gem 'ronin-web-user_agents', '~> 0.1' #, github: 'ronin-rb/ronin-web-user_agents'
15
- # gem 'ronin-payloads', '~> 0.1' #, github: 'ronin-rb/ronin-payloads'
16
- # gem 'ronin-exploits', '~> 1.0' #, github: 'ronin-rb/ronin-exploits'
9
+ # gem 'ronin-code-asm', '~> 0.3' # , github: 'ronin-rb/ronin-code-asm'
10
+ # gem 'ronin-code-sql', '~> 1.2' # , github: 'ronin-rb/ronin-code-sql'
11
+ # gem 'ronin-db', '~> 0.1' # , github: 'ronin-rb/ronin-db'
12
+ # gem 'ronin-web-server', '~> 0.1' # , github: 'ronin-rb/ronin-web-server'
13
+ # gem 'ronin-web-spider', '~> 0.1' # , github: 'ronin-rb/ronin-web-spider'
14
+ # gem 'ronin-web-user_agents', '~> 0.1' # , github: 'ronin-rb/ronin-web-user_agents'
15
+ # gem 'ronin-payloads', '~> 0.1' # , github: 'ronin-rb/ronin-payloads'
16
+ # gem 'ronin-exploits', '~> 1.0' # , github: 'ronin-rb/ronin-exploits'
data/gemspec.yml CHANGED
@@ -2,7 +2,7 @@ name: ronin
2
2
  summary: A Ruby toolkit for security research and development.
3
3
  description:
4
4
  Ronin is a free and Open Source Ruby toolkit for security research and
5
- development.Ronin contains many different CLI commands and Ruby libraries for
5
+ development.Ronin contains many different CLI commands and Ruby libraries for
6
6
  a variety of security tasks, such as encoding/decoding data, filter
7
7
  IPs/hosts/URLs, querying ASNs, querying DNS, HTTP, scanning for web
8
8
  vulnerabilities, spidering websites, install 3rd party repositories of
@@ -96,17 +96,17 @@ dependencies:
96
96
  async-io: ~> 1.0
97
97
  wordlist: ~> 1.0
98
98
  # Ronin dependencies:
99
- ronin-support: ~> 1.0
100
- ronin-core: ~> 0.1
99
+ ronin-support: ~> 1.0, >= 1.0.1
100
+ ronin-core: ~> 0.1, >= 0.1.1
101
101
  ronin-repos: ~> 0.1
102
102
  ronin-db: ~> 0.1
103
103
  ronin-fuzzer: ~> 0.1
104
- ronin-web: ~> 1.0
104
+ ronin-web: ~> 1.0, >= 1.0.1
105
105
  ronin-code-asm: ~> 1.0
106
106
  ronin-code-sql: ~> 2.0
107
- ronin-payloads: ~> 0.1
108
- ronin-exploits: ~> 1.0
109
- ronin-vulns: ~> 0.1
107
+ ronin-payloads: ~> 0.1, >= 0.1.1
108
+ ronin-exploits: ~> 1.0, >= 1.0.1
109
+ ronin-vulns: ~> 0.1, >= 0.1.2
110
110
 
111
111
  development_dependencies:
112
112
  bundler: ~> 2.0
@@ -68,7 +68,7 @@ module Ronin
68
68
  command.option :include_chars, short: '-i',
69
69
  value: {
70
70
  type: String,
71
- usage: 'CHARS',
71
+ usage: 'CHARS'
72
72
  },
73
73
  desc: 'Include the additional chars to the char-set' do |string|
74
74
  @char_set += Chars::CharSet.new(*string.chars)
@@ -24,6 +24,9 @@ require 'ronin/support/crypto/cipher'
24
24
  module Ronin
25
25
  class CLI
26
26
  module Commands
27
+ #
28
+ # Base class for all commands which use ciphers.
29
+ #
27
30
  class CipherCommand < FileProcessorCommand
28
31
 
29
32
  include KeyOptions
@@ -142,7 +145,6 @@ module Ronin
142
145
  cipher.stream(input, block_size: @block_size, output: stdout)
143
146
  end
144
147
 
145
-
146
148
  end
147
149
  end
148
150
  end
@@ -21,6 +21,9 @@ require 'ronin/root'
21
21
 
22
22
  module Ronin
23
23
  class CLI
24
+ #
25
+ # Base class for all `ronin` sub-commands.
26
+ #
24
27
  class Command < Core::CLI::Command
25
28
 
26
29
  man_dir File.join(ROOT,'man')
@@ -151,7 +151,7 @@ module Ronin
151
151
  print_asn_record(record)
152
152
  else
153
153
  print_error "could not find a record for the IP: #{options[:ip]}"
154
- exit -1
154
+ exit(-1)
155
155
  end
156
156
  else
157
157
  print_asn_records(search_asn_records)
@@ -17,6 +17,7 @@
17
17
  #
18
18
 
19
19
  require 'ronin/cli/value_processor_command'
20
+ require 'ronin/cli/host_and_port'
20
21
 
21
22
  require 'ronin/support/network/tcp'
22
23
 
@@ -42,6 +43,8 @@ module Ronin
42
43
  #
43
44
  class BannerGrab < ValueProcessorCommand
44
45
 
46
+ include HostAndPort
47
+
45
48
  usage '[options] {HOST:PORT} ...'
46
49
 
47
50
  option :with_host_port, desc: 'Print the service with the banner'
@@ -62,8 +65,7 @@ module Ronin
62
65
  # The `HOST:PORT` service pair.
63
66
  #
64
67
  def process_value(service)
65
- host, port = service.split(':',2)
66
- port = port.to_i
68
+ host, port = host_and_port(service)
67
69
 
68
70
  begin
69
71
  banner = Support::Network::TCP.banner(host,port)
@@ -73,7 +75,7 @@ module Ronin
73
75
  else
74
76
  puts banner
75
77
  end
76
- rescue => error
78
+ rescue StandardError => error
77
79
  print_error("#{service}: #{error.message}")
78
80
  end
79
81
  end
@@ -17,6 +17,7 @@
17
17
  #
18
18
 
19
19
  require 'ronin/cli/value_processor_command'
20
+ require 'ronin/cli/host_and_port'
20
21
  require 'ronin/support/crypto/cert'
21
22
  require 'ronin/support/network/ssl/mixin'
22
23
 
@@ -62,6 +63,7 @@ module Ronin
62
63
  include CommandKit::Printing::Indent
63
64
  include CommandKit::Printing::Fields
64
65
  include CommandKit::Printing::Lists
66
+ include HostAndPort
65
67
 
66
68
  usage '[options] {HOST:PORT | URL | FILE} ...'
67
69
 
@@ -100,14 +102,11 @@ module Ronin
100
102
  def process_value(value)
101
103
  case value
102
104
  when /\A[^:]+:\d+\z/
103
- host, port = value.split(':',2)
104
- port = port.to_i
105
+ host, port = host_and_port(value)
105
106
 
106
107
  print_cert(ssl_cert(host,port))
107
108
  when /\Ahttps:/
108
- uri = URI.parse(value)
109
- host = uri.host
110
- port = uri.port
109
+ host, port = host_and_port_from_url(value)
111
110
 
112
111
  print_cert(ssl_cert(host,port))
113
112
  else
@@ -180,8 +179,6 @@ module Ronin
180
179
 
181
180
  puts
182
181
 
183
- fields = {}
184
-
185
182
  if options[:extensions]
186
183
  puts "Extensions:"
187
184
  indent do
@@ -103,8 +103,8 @@ module Ronin
103
103
 
104
104
  option :subject_alt_name, short: '-A',
105
105
  value: {
106
- type: /[a-z0-9:\._-]+/,
107
- usage: 'HOST|IP'
106
+ type: /[a-z0-9:\._-]+/,
107
+ usage: 'HOST|IP'
108
108
  },
109
109
  desc: 'Adds HOST or IP to subjectAltName' do |value|
110
110
  @subject_alt_names << value
@@ -277,7 +277,7 @@ module Ronin
277
277
  @not_after ||= if options[:not_after]
278
278
  Time.parse(options[:not_after])
279
279
  else
280
- not_before+Support::Crypto::Cert::ONE_YEAR
280
+ not_before + Support::Crypto::Cert::ONE_YEAR
281
281
  end
282
282
  end
283
283
 
@@ -378,7 +378,7 @@ module Ronin
378
378
  # @return [String, nil]
379
379
  #
380
380
  def subject_alt_name_ext
381
- if !@subject_alt_names.empty?
381
+ unless @subject_alt_names.empty?
382
382
  @subject_alt_names.map { |name|
383
383
  if name =~ IP_REGEXP
384
384
  "IP: #{name}"
@@ -17,6 +17,7 @@
17
17
  #
18
18
 
19
19
  require 'ronin/cli/value_processor_command'
20
+ require 'ronin/cli/host_and_port'
20
21
  require 'ronin/support/network/ssl/mixin'
21
22
 
22
23
  require 'uri'
@@ -49,6 +50,7 @@ module Ronin
49
50
  #
50
51
  class CertGrab < ValueProcessorCommand
51
52
 
53
+ include HostAndPort
52
54
  include Support::Network::SSL::Mixin
53
55
 
54
56
  usage '[options] {HOST:PORT | URL} ...'
@@ -63,7 +65,7 @@ module Ronin
63
65
  examples [
64
66
  'github.com:443',
65
67
  '93.184.216.34:443',
66
- 'https://github.com/',
68
+ 'https://github.com/'
67
69
  ]
68
70
 
69
71
  man_page 'ronin-cert-grab.1'
@@ -77,14 +79,11 @@ module Ronin
77
79
  def process_value(value)
78
80
  case value
79
81
  when /\A[^:]+:\d+\z/
80
- host, port = value.split(':',2)
81
- port = port.to_i
82
+ host, port = host_and_port(value)
82
83
 
83
84
  grab_cert(host,port)
84
85
  when /\Ahttps:/
85
- uri = URI.parse(value)
86
- host = uri.host
87
- port = uri.port
86
+ host, port = host_and_port_from_url(value)
88
87
 
89
88
  grab_cert(host,port)
90
89
  else
@@ -61,14 +61,14 @@ module Ronin
61
61
  class Decode < StringMethodsCommand
62
62
 
63
63
  option :base16, desc: 'Base16 decodes the data' do
64
- require 'ronin/support/encoding/base16'
65
- @method_calls << :base16_decode
66
- end
64
+ require 'ronin/support/encoding/base16'
65
+ @method_calls << :base16_decode
66
+ end
67
67
 
68
68
  option :base32, desc: 'Base32 decodes the data' do
69
- require 'ronin/support/encoding/base32'
70
- @method_calls << :base32_decode
71
- end
69
+ require 'ronin/support/encoding/base32'
70
+ @method_calls << :base32_decode
71
+ end
72
72
 
73
73
  option :base64, short: '-b',
74
74
  equals: true,
@@ -78,11 +78,11 @@ module Ronin
78
78
  },
79
79
  desc: 'Base64 decodes the data' do |mode=nil|
80
80
  require 'ronin/support/encoding/base64'
81
- if mode
82
- @method_calls << [:base64_decode, [mode]]
83
- else
84
- @method_calls << :base64_decode
85
- end
81
+ @method_calls << if mode
82
+ [:base64_decode, [mode]]
83
+ else
84
+ :base64_decode
85
+ end
86
86
  end
87
87
 
88
88
  option :zlib, short: '-z',
@@ -122,9 +122,9 @@ module Ronin
122
122
  end
123
123
 
124
124
  option :http, desc: 'HTTP decodes the data' do
125
- require 'ronin/support/encoding/http'
126
- @method_calls << :http_decode
127
- end
125
+ require 'ronin/support/encoding/http'
126
+ @method_calls << :http_decode
127
+ end
128
128
 
129
129
  option :js, short: '-j',
130
130
  desc: 'JavaScript decodes the data' do
@@ -61,14 +61,14 @@ module Ronin
61
61
  class Encode < StringMethodsCommand
62
62
 
63
63
  option :base16, desc: 'Base16 encodes the data' do
64
- require 'ronin/support/encoding/base16'
65
- @method_calls << :base16_encode
66
- end
64
+ require 'ronin/support/encoding/base16'
65
+ @method_calls << :base16_encode
66
+ end
67
67
 
68
68
  option :base32, desc: 'Base32 encodes the data' do
69
- require 'ronin/support/encoding/base32'
70
- @method_calls << :base32_encode
71
- end
69
+ require 'ronin/support/encoding/base32'
70
+ @method_calls << :base32_encode
71
+ end
72
72
 
73
73
  option :base64, short: '-b',
74
74
  equals: true,
@@ -78,11 +78,11 @@ module Ronin
78
78
  },
79
79
  desc: 'Base64 encodes the data' do |mode=nil|
80
80
  require 'ronin/support/encoding/base64'
81
- if mode
82
- @method_calls << [:base64_encode, [mode]]
83
- else
84
- @method_calls << :base64_encode
85
- end
81
+ @method_calls << if mode
82
+ [:base64_encode, [mode]]
83
+ else
84
+ :base64_encode
85
+ end
86
86
  end
87
87
 
88
88
  option :zlib, short: '-z',
@@ -122,9 +122,9 @@ module Ronin
122
122
  end
123
123
 
124
124
  option :http, desc: 'HTTP encodes the data' do
125
- require 'ronin/support/encoding/http'
126
- @method_calls << :http_encode
127
- end
125
+ require 'ronin/support/encoding/http'
126
+ @method_calls << :http_encode
127
+ end
128
128
 
129
129
  option :js, short: '-j',
130
130
  desc: 'JavaScript encodes the data' do
@@ -122,7 +122,7 @@ module Ronin
122
122
  def run(*files)
123
123
  unless @pattern
124
124
  print_error "must specify a pattern to search for"
125
- exit -1
125
+ exit(-1)
126
126
  end
127
127
 
128
128
  super(*files)
@@ -136,7 +136,7 @@ module Ronin
136
136
  def run(*files)
137
137
  unless @pattern
138
138
  print_error "must specify a pattern to search for"
139
- exit -1
139
+ exit(-1)
140
140
  end
141
141
 
142
142
  super(*files)
@@ -151,8 +151,8 @@ module Ronin
151
151
  def process_input(input)
152
152
  filename = filename_of(input)
153
153
 
154
- input.each_line(chomp: true).each_with_index do |line,index|
155
- match_line(line, filename: filename, line_number: index+1)
154
+ input.each_line(chomp: true).with_index do |line,index|
155
+ match_line(line, filename: filename, line_number: index + 1)
156
156
  end
157
157
  end
158
158
 
@@ -184,7 +184,9 @@ module Ronin
184
184
  #
185
185
  def match_line(line,**kwargs)
186
186
  index = 0
187
+
187
188
  printed_prefix = false
189
+ only_matching = options[:only_matching]
188
190
 
189
191
  while (match = line.match(@pattern,index))
190
192
  unless printed_prefix
@@ -195,13 +197,13 @@ module Ronin
195
197
  match_start, match_stop = match.offset(0)
196
198
 
197
199
  # print the text before the match, unless --only-matching is enabled
198
- print(line[index...match_start]) unless options[:only_matching]
200
+ print(line[index...match_start]) unless only_matching
199
201
  print_match(match)
200
202
 
201
203
  index = match_stop
202
204
  end
203
205
 
204
- unless options[:only_matching]
206
+ unless only_matching
205
207
  # print the rest of the line, if we've had at least one match
206
208
  puts(line[index..]) if index > 0
207
209
  end