MCPcopy Create free account
hub / github.com/XiaoliChan/LDAPShell / LdapShell

Class LdapShell

utils/ldap_shell.py:31–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29
30
31class LdapShell(cmd.Cmd):
32 LDAP_MATCHING_RULE_IN_CHAIN = "1.2.840.113556.1.4.1941"
33
34 def __init__(self, base_DN, domain_dumper, client):
35 cmd.Cmd.__init__(self)
36 self.base_DN = base_DN
37 self.use_rawinput = True
38
39 self.prompt = '\n[%s]> '%self.base_DN
40 self.tid = None
41 self.intro = 'Type help for list of commands'
42 self.loggedIn = True
43 self.last_output = None
44 self.completion = []
45 self.client = client
46 self.domain_dumper = domain_dumper
47
48 def emptyline(self):
49 pass
50
51 def onecmd(self, s):
52 ret_val = False
53 try:
54 ret_val = cmd.Cmd.onecmd(self, s)
55 except Exception as e:
56 print(e)
57 LOG.error(e)
58 LOG.debug('Exception info', exc_info=True)
59
60 return ret_val
61
62 def create_empty_sd(self):
63 sd = ldaptypes.SR_SECURITY_DESCRIPTOR()
64 sd['Revision'] = b'\x01'
65 sd['Sbz1'] = b'\x00'
66 sd['Control'] = 32772
67 sd['OwnerSid'] = ldaptypes.LDAP_SID()
68 # BUILTIN\Administrators
69 sd['OwnerSid'].fromCanonical('S-1-5-32-544')
70 sd['GroupSid'] = b''
71 sd['Sacl'] = b''
72 acl = ldaptypes.ACL()
73 acl['AclRevision'] = 4
74 acl['Sbz1'] = 0
75 acl['Sbz2'] = 0
76 acl.aces = []
77 sd['Dacl'] = acl
78 return sd
79
80 def create_allow_ace(self, sid):
81 nace = ldaptypes.ACE()
82 nace['AceType'] = ldaptypes.ACCESS_ALLOWED_ACE.ACE_TYPE
83 nace['AceFlags'] = 0x00
84 acedata = ldaptypes.ACCESS_ALLOWED_ACE()
85 acedata['Mask'] = ldaptypes.ACCESS_MASK()
86 acedata['Mask']['Mask'] = 983551 # Full control
87 acedata['Sid'] = ldaptypes.LDAP_SID()
88 acedata['Sid'].fromCanonical(sid)

Callers 1

start_LDAPShellMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected