dissect.util 3.23__cp314-cp314t-macosx_11_0_arm64.whl → 3.24.dev1__cp314-cp314t-macosx_11_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dissect.util might be problematic. Click here for more details.

Binary file
dissect/util/sid.py CHANGED
@@ -48,3 +48,34 @@ def read_sid(fh: BinaryIO | bytes, endian: str = "<", swap_last: bool = False) -
48
48
  ]
49
49
  sid_elements.extend(map(str, sub_authorities))
50
50
  return "-".join(sid_elements)
51
+
52
+
53
+ def write_sid(sid: str, endian: str = "<", swap_last: bool = False) -> bytes:
54
+ """Write a Windows SID string to bytes.
55
+
56
+ Args:
57
+ sid: SID in the form ``S-Revision-Authority-SubAuth1-...``.
58
+ endian: Optional endianness for reading the sub authorities.
59
+ swap_last: Optional flag for swapping the endianess of the _last_ sub authority entry.
60
+ """
61
+ if not sid:
62
+ return b""
63
+
64
+ parts = sid.split("-")
65
+ if len(parts) < 3 or parts[0].upper() != "S":
66
+ raise ValueError("Invalid SID string format: insufficient parts")
67
+
68
+ revision = int(parts[1]).to_bytes(1, "little")
69
+ authority = int(parts[2]).to_bytes(6, "big")
70
+ sub_authorities = [int(x) for x in parts[3:]]
71
+
72
+ header = revision + len(sub_authorities).to_bytes(1, "little") + authority
73
+
74
+ if not sub_authorities:
75
+ return header
76
+
77
+ sub_bytes = bytearray(struct.pack(f"{endian}{len(sub_authorities)}I", *sub_authorities))
78
+ if swap_last:
79
+ sub_bytes[-4:] = sub_bytes[-4:][::-1]
80
+
81
+ return header + bytes(sub_bytes)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dissect.util
3
- Version: 3.23
3
+ Version: 3.24.dev1
4
4
  Summary: A Dissect module implementing various utility functions for the other Dissect modules
5
5
  Author-email: Dissect Team <dissect@fox-it.com>
6
6
  License-Expression: Apache-2.0
@@ -6,8 +6,8 @@ dissect/util/stream.py,sha256=M7H2Fg6tQtqhaVVaAkOpve7cbHdzW_g4tGOt6cZx_EA,23113
6
6
  dissect/util/ts.py,sha256=YqVjHFREnNhwTnR3ap7zv6MOUybo-U74LrhBLA2BpCc,8203
7
7
  dissect/util/cpio.py,sha256=epeCGfqeCglP1VVFjKvupzuSvI1DPjZdkgbGAo1R8-8,7576
8
8
  dissect/util/xmemoryview.py,sha256=nTNLbb2Cuzjj_BKEmveGTBT314VnV084rkteKBVxw5c,4085
9
- dissect/util/_native.cpython-314t-darwin.so,sha256=oooubntJoGesDASjehZ6XcoOveu-Qg6ugYu3wwYV6Jg,406784
10
- dissect/util/sid.py,sha256=ojvKL6vaHHKukfkvMMKqJfpC40UypVGc-ppkqPnj2Co,1558
9
+ dissect/util/_native.cpython-314t-darwin.so,sha256=BtHoPtK5VXqHSMblQwncnNQZmyvzgg2ysrEnGbx5ijw,406752
10
+ dissect/util/sid.py,sha256=ijrNQ9u1NFTOq1-Pr0m1dbS7kDOnYBq5EjzrdpD5Lss,2598
11
11
  dissect/util/exceptions.py,sha256=vkoy9zXcx8U6K4prI5Cqu1mFndizIeIihAfR6DDj44Q,75
12
12
  dissect/util/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  dissect/util/tools/dump_nskeyedarchiver.py,sha256=ZMSM4TPL8pRn685tX3SAKackgE6EFr2bExPU6Lm8jWk,1454
@@ -34,10 +34,10 @@ dissect/util/_native/hash/__init__.py,sha256=MdStvZya1AO2ct-qgL633RGcLdmJmQiXOVl
34
34
  dissect/util/_native/compression/__init__.pyi,sha256=GjdgmQQBe-vxGBD1x6g3pzoqbFiYesD7vz3BcK1NGfQ,80
35
35
  dissect/util/_native/compression/lz4.pyi,sha256=AGMzCY0GwYC7NwN9KIQOyveftuG5_qEGCt1gXREZ4VM,177
36
36
  dissect/util/_native/compression/lzo.pyi,sha256=IdW_7Izgsmm213vRe-69qSeHFHCD3xwx-XMORPtQgPY,120
37
- dissect_util-3.23.dist-info/RECORD,,
38
- dissect_util-3.23.dist-info/WHEEL,sha256=26nyvDx4qlf6NyRSh1NSNrXJDCQeX0hnJ7EH1bB1egM,137
39
- dissect_util-3.23.dist-info/entry_points.txt,sha256=3mwSDD1MUdj0nnTcl2qYFMeu6KYMTycUQS0rlp5CQHI,86
40
- dissect_util-3.23.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
41
- dissect_util-3.23.dist-info/METADATA,sha256=pF9UK3FlRbMcKB9RiIPDzcQIgQZEfFU13d9Uk7T0U6A,3609
42
- dissect_util-3.23.dist-info/licenses/LICENSE,sha256=PhUqiw6jAh2KbBdVRPBq_hfAvfcTBin7nZ3CK7NQbTM,11341
43
- dissect_util-3.23.dist-info/licenses/COPYRIGHT,sha256=I5uKS6nwQl9xC2xgk-8jvw0gNrpFhvZC7FDTALpj18k,313
37
+ dissect_util-3.24.dev1.dist-info/RECORD,,
38
+ dissect_util-3.24.dev1.dist-info/WHEEL,sha256=26nyvDx4qlf6NyRSh1NSNrXJDCQeX0hnJ7EH1bB1egM,137
39
+ dissect_util-3.24.dev1.dist-info/entry_points.txt,sha256=3mwSDD1MUdj0nnTcl2qYFMeu6KYMTycUQS0rlp5CQHI,86
40
+ dissect_util-3.24.dev1.dist-info/top_level.txt,sha256=Mn-CQzEYsAbkxrUI0TnplHuXnGVKzxpDw_po_sXpvv4,8
41
+ dissect_util-3.24.dev1.dist-info/METADATA,sha256=va0ZpqHWnXg_9QWn4Bu0ZeAo_ZnCudq_6a__uYmyUpo,3614
42
+ dissect_util-3.24.dev1.dist-info/licenses/LICENSE,sha256=PhUqiw6jAh2KbBdVRPBq_hfAvfcTBin7nZ3CK7NQbTM,11341
43
+ dissect_util-3.24.dev1.dist-info/licenses/COPYRIGHT,sha256=I5uKS6nwQl9xC2xgk-8jvw0gNrpFhvZC7FDTALpj18k,313