Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement CertSh worker #87

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions lib/ronin/recon/builtin/net/cert_sh.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 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 'ronin/recon/worker'

require 'async/http/internet/instance'

module Ronin
module Recon
module Net
#
# A recon worker that returns host from each domains certificate
#
class CertSh < Worker

register 'net/cert_sh'

accepts Domain

summary 'Returns host from each domains certificate.'

description <<~DESC
Returns host from each domains certificate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should mention that it's querying cert.sh in the description and summary.

DESC

#
# Returns host from each domains certificate.
#
# @param [Values::Domain] domain
# The domain value to check.
#
# @yield [host]
# If the domain has certificates, then a host value will be
# yielded.
#
# @yieldparam [Values::Host] host
# The host from certificate.
#
def process(host)
Async do
internet = Async::HTTP::Internet.instance
path = "https://crt.sh/?dNSName=#{host}&exclude=expired&output=json"

response = internet.get(path)
certs = JSON.parse(response.read, symbolize_names: true)

certs.each do |cert|
if cert[:common_name]
yield Host.new(name: cert[:common_name])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Host.new() accepts a single String.

end
end
end
end
end
end
end
end