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

SID in HEX format. #11

Open
msmcgillis opened this issue Oct 22, 2019 · 1 comment
Open

SID in HEX format. #11

msmcgillis opened this issue Oct 22, 2019 · 1 comment

Comments

@msmcgillis
Copy link

If you’re interested. I ran into a different form of SID value it is a hex version.

$ ad -u "Domain Users"
UID: Domain Users
SID: S-1-5-21-2385084637-1531931085-3623800711-513
S-1-5-15-8e2980dd-5b4f69cd-d7fecf87-201
GUID: a83ac89b-0e81-544a-8c6e-2cd07ef638aa
Type: group

In the above the first form is typically what I see however the second form is what I found from tools that I ran into for an EMC.

So I added support to your python SID module. Feel free to include or ignore. Supporting this additional form was useful for me.

$ diff ~/tools/ver/ad-0.0.1/bin/sid.py sid.py
11c11
< SID_HEX = 3

40,42d39
< elif sidtype == SID_HEX:
< self._sid = self.hexStrsid(data)
< return
50,53d46
< def hex(self):
< '''Return hex version of sid'''
< return self.bytehex(self._sid)
<
152,168d144
< def bytehex(cls, strsid):
< '''
< Encode a sid into hex form
< strsid - SID to encode
< '''
< tmp = cls.byte(strsid)
< ret = 'S'
< sid = []
< sid.append("%x" % cls.byteToLong(tmp[0:1]))
< sid.append("%x" % cls.byteToLong(tmp[2:2+6], False))
< for i in range(8, len(tmp), 4):
< sid.append("%x" % cls.byteToLong(tmp[i:i+4]))
< for i in sid:
< ret += '-' + str(i)
< return ret
<
< @classmethod
183,198d158
<
< @classmethod
< def hexStrsid(cls, hexsid):
< '''
< Decode a hex SID into string
< hexsid - hex encoded sid
< '''
< ret = 'S'
< fields = hexsid.split("-")
< fields = fields[1:]
< sid = []
< for i in fields:
< sid.append(int(i,16))
< for i in sid:
< ret += '-' + str(i)
< return ret

sid.py.txt

@sspreitzer
Copy link
Owner

Thanks for your work! Would you be open to open a Pull Request here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants