Class: Ronin::Recon::API::CrtSh
- Defined in:
- lib/ronin/recon/builtin/api/crt_sh.rb
Overview
A recon worker that queries https://crt.sh and returns host from each domains certificate
Constant Summary collapse
- HOST_NAME_REGEX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Regular expression to verify valid host names.
/\A#{Support::Text::Patterns::HOST_NAME}\z/
Instance Attribute Summary collapse
-
#client ⇒ Async::HTTP::Client
readonly
private
The HTTP client for
https://crt.sh
.
Instance Method Summary collapse
-
#initialize(**kwargs) ⇒ CrtSh
constructor
private
Initializes the
api/crt_sh
worker. -
#process(domain) {|host| ... } ⇒ Object
Returns host from each domains certificate.
Methods inherited from Worker
accepts, concurrency, intensity, outputs, register, run
Constructor Details
#initialize(**kwargs) ⇒ CrtSh
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes the api/crt_sh
worker.
65 66 67 68 69 70 71 |
# File 'lib/ronin/recon/builtin/api/crt_sh.rb', line 65 def initialize(**kwargs) super(**kwargs) @client = Async::HTTP::Client.new( Async::HTTP::Endpoint.for('https','crt.sh') ) end |
Instance Attribute Details
#client ⇒ Async::HTTP::Client (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The HTTP client for https://crt.sh
.
55 56 57 |
# File 'lib/ronin/recon/builtin/api/crt_sh.rb', line 55 def client @client end |
Instance Method Details
#process(domain) {|host| ... } ⇒ Object
Returns host from each domains certificate.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/ronin/recon/builtin/api/crt_sh.rb', line 91 def process(domain) path = "/?dNSName=#{domain}&exclude=expired&output=json" response = @client.get(path) certs = JSON.parse(response.read, symbolize_names: true) hostnames = Set.new certs.each do |cert| common_name = cert[:common_name] if common_name && common_name =~ HOST_NAME_REGEX && hostnames.add?(common_name) yield Host.new(common_name) end end end |