-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Consolidate Kerberos Ticket Storage #17377
Merged
adfoster-r7
merged 8 commits into
rapid7:feature-kerberos-authentication
from
zeroSteiner:feat/lib/kerberos/loot-info
Dec 16, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5f52ebe
Consolidate the loot_info UID string
zeroSteiner 686b946
Use a new TicketStorage class
zeroSteiner b2a4bea
Breakout the ticket storage backend drivers
zeroSteiner fea259f
Switch everything to use the ticket storage
zeroSteiner 663dee9
Expose an abstract stored ticket object
zeroSteiner 830e850
Add more docs
zeroSteiner 75fc560
Handle cases where the framework module is nil
zeroSteiner 60a76da
Allow deleting tickets by ID
zeroSteiner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
require 'msf/core/exploit/remote/kerberos/ticket/storage/base' | ||
|
||
module Msf::Exploit::Remote::Kerberos::Ticket | ||
module Storage | ||
# Storage a credential cache object. | ||
# | ||
# @param [Hash] options See the options description in Base#tickets. | ||
# @option options [Msf::Module] The framework module associated with the store operation. | ||
def self.store_ccache(ccache, options = {}) | ||
driver = WriteOnly.new(framework_module: options[:framework_module]) | ||
driver.store_ccache(ccache, options) | ||
end | ||
|
||
def initialize(info = {}) | ||
super | ||
register_advanced_options( | ||
[ | ||
Msf::OptEnum.new( | ||
'KrbCacheMode', [ | ||
true, | ||
'Kerberos ticket cache storage mode', | ||
'read-write', | ||
%w[ none read-only write-only read-write ] | ||
] | ||
) | ||
] | ||
) | ||
end | ||
|
||
# Build a ticket storage object based on either the specified options or the datastore if no options are defined. | ||
# | ||
# @param [Hash] options Options used to select the ticket storage driver backend. If this option is present, it | ||
# overrides the datastore configuration. All options it contains default to true, meaning it should only be | ||
# necessary to specify the operations (e.g. read) that should be disabled. | ||
# @option options [Boolean] read Whether or not the storage mechanism should support reading | ||
# @option options [Boolean] write Whether or not the storage mechanism should support writing | ||
def kerberos_ticket_storage(options = {}) | ||
if options.present? | ||
case [options.fetch(:read, true), options.fetch(:write, true)] | ||
when [false, false] | ||
mode = 'none' | ||
when [false, true] | ||
mode = 'write-only' | ||
when [true, false] | ||
mode = 'read-only' | ||
when [true, true] | ||
mode = 'read-write' | ||
end | ||
else | ||
mode = datastore['KrbCacheMode'] | ||
end | ||
|
||
case mode | ||
when 'none' | ||
None.new(framework_module: self) | ||
when 'read-only' | ||
ReadOnly.new(framework_module: self) | ||
when 'write-only' | ||
WriteOnly.new(framework_module: self) | ||
when 'read-write' | ||
ReadWrite.new(framework_module: self) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your thoughts on defaulting to Write behavior by default? 👀
I'm thinking in terms of element of least surprise for existing workflows with tools like impacket, users might not expect the ticket re-use behavior occurring out of the box
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion about the default storage mode right here. If you're instantiating the authenticator yourself, as a module developer to do something specific, it might make sense to just be WriteOnly.
Changing it here wouldn't change the default mode for modules though.