-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add certs command & use pkinit if kerberos tickets are not available …
…in cache
- Loading branch information
1 parent
4c5a365
commit c4d21eb
Showing
10 changed files
with
344 additions
and
12 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
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
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,86 @@ | ||
module Msf::Exploit::Remote::Pkcs12 | ||
|
||
class Storage | ||
include Msf::Auxiliary::Report | ||
|
||
# @!attribute [r] framework | ||
# @return [Msf::Framework] the Metasploit framework instance | ||
attr_reader :framework | ||
|
||
# @!attribute [r] framework_module | ||
# @return [Msf::Module] the Metasploit framework module that is associated with the authentication instance | ||
attr_reader :framework_module | ||
|
||
def initialize(framework: nil, framework_module: nil) | ||
@framework = framework || framework_module&.framework | ||
@framework_module = framework_module | ||
end | ||
|
||
# Get stored pkcs12 matching the options query. | ||
# | ||
# @param [Hash] options The options for matching pkcs12's. | ||
# @option options [Integer, Array<Integer>] :id The identifier of the pkcs12 (optional) | ||
# @option options [String] :realm The realm of the pkcs12 (optional) | ||
# @option options [String] :username The username of the pkcs12 (optional) | ||
# @return [Array<StoredPkcs12>] | ||
def pkcs12(options = {}, &block) | ||
stored_pkcs12_array = filter_pkcs12(options).map do |pkcs12_entry| | ||
StoredPkcs12.new(pkcs12_entry) | ||
end | ||
|
||
stored_pkcs12_array.each do |stored_pkcs12| | ||
block.call(stored_pkcs12) if block_given? | ||
end | ||
|
||
stored_pkcs12_array | ||
end | ||
|
||
# Return the raw stored pkcs12. | ||
# | ||
# @param [Hash] options See the options hash description in {#pkcs12}. | ||
# @return [Array<Metasploit::Credential::Core>] | ||
def filter_pkcs12(options) | ||
return [] unless active_db? | ||
|
||
filter = {} | ||
filter[:id] = options[:id] if options[:id].present? | ||
filter[:user] = options[:username] if options[:username].present? | ||
filter[:realm] = options[:realm] if options[:realm].present? | ||
|
||
creds = framework.db.creds( | ||
workspace: options.fetch(:workspace) { workspace }, | ||
type: 'Metasploit::Credential::Pkcs12', | ||
**filter | ||
).select do |cred| | ||
cred.private.type == 'Metasploit::Credential::Pkcs12' | ||
end | ||
|
||
creds.each do |stored_cred| | ||
block.call(stored_cred) if block_given? | ||
end | ||
end | ||
|
||
def delete_pkcs12(options = {}) | ||
if options.keys == [:ids] | ||
# skip calling #filter_pkcs12 which issues a query when the IDs are specified | ||
ids = options[:ids] | ||
else | ||
ids = filter_pkcs12(options).map(&:id) | ||
end | ||
|
||
framework.db.delete_credentials(ids: ids).map do |stored_pkcs12| | ||
StoredPkcs12.new(stored_pkcs12) | ||
end | ||
end | ||
|
||
# @return [String] The name of the workspace in which to operate. | ||
def workspace | ||
if @framework_module | ||
return @framework_module.workspace | ||
elsif @framework&.db&.active | ||
return @framework.db.workspace&.name | ||
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,38 @@ | ||
module Msf::Exploit::Remote::Pkcs12 | ||
|
||
class StoredPkcs12 | ||
def initialize(pkcs12) | ||
@pkcs12 = pkcs12 | ||
end | ||
|
||
def id | ||
@pkcs12.id | ||
end | ||
|
||
def openssl_pkcs12 | ||
private_cred.openssl_pkcs12 | ||
end | ||
|
||
def ca | ||
private_cred.ca | ||
end | ||
|
||
def adcs_template | ||
private_cred.adcs_template | ||
end | ||
|
||
def private_cred | ||
@pkcs12.private | ||
end | ||
|
||
def username | ||
@pkcs12.public.username | ||
end | ||
|
||
def realm | ||
@pkcs12.realm.value | ||
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
Oops, something went wrong.