Class: Msf::Exploit::Remote::LDAP::EntryCache::LDAPEntryCache
- Inherits:
-
LruRedux::Cache
- Object
- LruRedux::Cache
- Msf::Exploit::Remote::LDAP::EntryCache::LDAPEntryCache
- Defined in:
- lib/msf/core/exploit/remote/ldap/entry_cache.rb
Constant Summary collapse
- MissingEntry =
Object.new.freeze
Instance Method Summary collapse
- #<<(entry) ⇒ Object
- #get_by_dn(dn) ⇒ Object
- #get_by_samaccountname(samaccountname) ⇒ Object
- #get_by_sid(sid) ⇒ Object
-
#initialize(max_size: 1000) ⇒ LDAPEntryCache
constructor
A new instance of LDAPEntryCache.
- #mark_missing_by_dn(dn) ⇒ Object
- #mark_missing_by_samaccountname(samaccountname) ⇒ Object
- #mark_missing_by_sid(sid) ⇒ Object
- #missing_entry?(entry) ⇒ Boolean
Constructor Details
#initialize(max_size: 1000) ⇒ LDAPEntryCache
Returns a new instance of LDAPEntryCache.
14 15 16 17 18 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 14 def initialize(max_size: 1000) super(max_size) @missing_samaccountname = LruRedux::Cache.new(max_size) @missing_sid = LruRedux::Cache.new(max_size) end |
Instance Method Details
#<<(entry) ⇒ Object
20 21 22 23 24 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 20 def <<(entry) raise TypeError unless entry.is_a? Net::LDAP::Entry self[entry.dn] = entry end |
#get_by_dn(dn) ⇒ Object
26 27 28 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 26 def get_by_dn(dn) self[dn] end |
#get_by_samaccountname(samaccountname) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 30 def get_by_samaccountname(samaccountname) entry = @data.values.reverse_each.find { _1.is_a?(Net::LDAP::Entry) && _1[:sAMAccountName]&.first == samaccountname } @data[entry.dn] = entry if entry # update it as recently used return entry if entry MissingEntry if @missing_samaccountname[samaccountname] end |
#get_by_sid(sid) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 38 def get_by_sid(sid) sid = Rex::Proto::MsDtyp::MsDtypSid.new(sid) entry = @data.values.reverse_each.find { _1.is_a?(Net::LDAP::Entry) && _1[:objectSid]&.first == sid.to_binary_s } @data[entry.dn] = entry if entry # update it as recently used return entry if entry MissingEntry if @missing_sid[sid.to_s] end |
#mark_missing_by_dn(dn) ⇒ Object
48 49 50 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 48 def mark_missing_by_dn(dn) self[dn] = MissingEntry end |
#mark_missing_by_samaccountname(samaccountname) ⇒ Object
52 53 54 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 52 def mark_missing_by_samaccountname(samaccountname) @missing_samaccountname[samaccountname] = true end |
#mark_missing_by_sid(sid) ⇒ Object
56 57 58 59 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 56 def mark_missing_by_sid(sid) sid = Rex::Proto::MsDtyp::MsDtypSid.new(sid) @missing_sid[sid.to_s] = true end |
#missing_entry?(entry) ⇒ Boolean
61 62 63 |
# File 'lib/msf/core/exploit/remote/ldap/entry_cache.rb', line 61 def missing_entry?(entry) entry.equal?(MissingEntry) end |