@@ -49,7 +49,7 @@ You can also make some operation on threads (suspend/resume/wait/get(or set) con
4949>> > windows.current_process.bitness
505032
5151>> > windows.current_process.token.integrity
52- SECURITY_MANDATORY_MEDIUM_RID(0x2000L )
52+ SECURITY_MANDATORY_MEDIUM_RID(0x 2000 )
5353>> > proc = [p for p in windows.system.processes if p.name == " notepad.exe" ][0 ]
5454>> > proc
5555< WinProcess " notepad.exe" pid 16520 at 0x 544e410>
@@ -89,7 +89,7 @@ Information about the Windows computer running the script are available through
8989>> > windows.system.computer_name
9090' DESKTOP-VKUGISR'
9191>> > windows.system.product_type
92- VER_NT_WORKSTATION(0x1L )
92+ VER_NT_WORKSTATION(0x 1 )
9393>> > windows.system.version
9494(10 , 0 )
9595>> > windows.system.version_name
@@ -105,7 +105,7 @@ VER_NT_WORKSTATION(0x1L)
105105>> > windows.system.logicaldrives[0 ]
106106< LogicalDrive " C:\" (DRIVE_FIXED)>
107107>> > windows.system.services[23 ]
108- < ServiceA " Appinfo" SERVICE_RUNNING(0x4L )>
108+ < ServiceA " Appinfo" SERVICE_RUNNING(0x 4 )>
109109
110110```
111111
@@ -187,6 +187,39 @@ a simple x86/x64 assembler.
187187' \x81\xff\x00\x00\x00\x00 u\x06\xc7\xc0\x01\x00\x00\x00\xc3 '
188188```
189189
190+ ### Token / Security Descriptor
191+
192+ Objects easing access to some information about `` Token `` and `` SecurityDescriptor `` are also available.
193+
194+ ``` python
195+ >> > import windows.security
196+ >> > import windows.generated_def as gdef
197+ >> > tok = windows.current_process.token
198+ >> > tok
199+ < Token TokenId= 0x 6a2b4550 Type= TokenPrimary(0x 1 )>
200+ >> > tok.username
201+ u ' hakril'
202+ >> > tok.type
203+ tagTOKEN_TYPE.TokenPrimary(0x 1 )
204+ >> > tok.integrity
205+ SECURITY_MANDATORY_MEDIUM_RID(0x 2000 )
206+ >> > tok.duplicate(type = gdef.TokenImpersonation, impersonation_level = gdef.SecurityIdentification)
207+ < Token TokenId= 0x 6a3532ce Type= TokenImpersonation(0x 2 ) ImpersonationLevel= SecurityIdentification(0x 1 )>
208+
209+ # Security Descriptor
210+ >> > sd = windows.security.SecurityDescriptor.from_filename(" c:\windows\system32\kernel32.dll" )
211+ >> > sd
212+ < SecurityDescriptor object at 0x 054E3DF0>
213+ >> > windows.utils.lookup_sid(sd.owner)
214+ (u ' NT SERVICE' , u ' TrustedInstaller' )
215+ >> > sd.dacl
216+ < Acl count= 6 >
217+ >> > list (sd.dacl)
218+ [< AccessAllowedACE mask=2032127 > , < AccessAllowedACE mask=1179817 > , < AccessAllowedACE mask=1179817 > , < AccessAllowedACE mask=1179817 > , < AccessAllowedACE mask=1179817 > , < AccessAllowedACE mask=1179817 > ]
219+ >> > sd.dacl[1 ].sid
220+ < PSID " S-1-5-32-544" >
221+ ```
222+
190223### Wintrust
191224
192225To easily script some signature check script, PythonForWindows implements some wrapper functions around `` wintrust.dll ``
@@ -202,7 +235,7 @@ SignatureData(signed=True,
202235 catalog = u ' C:\\ Windows\\ system32\\ CatRoot\\ {F750E6C3-38EE-11D1-85E5-00C04FC295EE}\\ Package_35_for_KB3128650~31bf3856ad364e35~amd64~~6.3.1.2.cat' ,
203236 catalogsigned = True , additionalinfo = 0L )
204237>> > windows.wintrust.full_signature_information(r " C:\W indows\s ystem32\p ython27. dll" )
205- SignatureData(signed = False , catalog = None , catalogsigned = False , additionalinfo = TRUST_E_NOSIGNATURE(0x800b0100L ))
238+ SignatureData(signed = False , catalog = None , catalogsigned = False , additionalinfo = TRUST_E_NOSIGNATURE(0x 800b0100 ))
206239```
207240
208241### WMI
@@ -234,7 +267,7 @@ The project also contains some wrapping classes around `_winreg` for simpler use
234267>> > cuuser_software
235268< PyHKey " HKEY_CURRENT_USER\Software" >
236269>> > cuuser_software.sam
237- KEY_READ(0x20019L )
270+ KEY_READ(0x 20019 )
238271# Explore subkeys
239272>> > cuuser_software.subkeys[:3 ]
240273[< PyHKey " HKEY_CURRENT_USER\Software\7 -Zip" > , < PyHKey " HKEY_CURRENT_USER\Software\AppDataLow" > , < PyHKey " HKEY_CURRENT_USER\Software\Audacity" > ]
@@ -408,9 +441,9 @@ calc.execute(x86.assemble("int3; mov [0x42424242], EAX; ret"))
408441d.loop()
409442
410443# # Ouput ##
411- Got exception EXCEPTION_BREAKPOINT(0x80000003L ) at 0x 77e13c7d
412- Got exception EXCEPTION_BREAKPOINT(0x80000003L ) at 0x 230000
413- Got exception EXCEPTION_ACCESS_VIOLATION(0xc0000005L ) at 0x 230001
444+ Got exception EXCEPTION_BREAKPOINT(0x 80000003 ) at 0x 77e13c7d
445+ Got exception EXCEPTION_BREAKPOINT(0x 80000003 ) at 0x 230000
446+ Got exception EXCEPTION_ACCESS_VIOLATION(0x c0000005 ) at 0x 230001
414447Access Violation: kill target process
415448```
416449
@@ -469,10 +502,10 @@ print("Done!")
469502
470503Code addr = 0x 6a0002
471504GOT AN HXBP at 0x 6a0002
472- EXCEPTION !!!! Got a EXCEPTION_SINGLE_STEP(0x80000004L ) at 0x 6a0003
473- EXCEPTION !!!! Got a EXCEPTION_SINGLE_STEP(0x80000004L ) at 0x 6a0004
474- EXCEPTION !!!! Got a EXCEPTION_SINGLE_STEP(0x80000004L ) at 0x 6a0005
475- EXCEPTION !!!! Got a EXCEPTION_SINGLE_STEP(0x80000004L ) at 0x 770c7c04
505+ EXCEPTION !!!! Got a EXCEPTION_SINGLE_STEP(0x 80000004 ) at 0x 6a0003
506+ EXCEPTION !!!! Got a EXCEPTION_SINGLE_STEP(0x 80000004 ) at 0x 6a0004
507+ EXCEPTION !!!! Got a EXCEPTION_SINGLE_STEP(0x 80000004 ) at 0x 6a0005
508+ EXCEPTION !!!! Got a EXCEPTION_SINGLE_STEP(0x 80000004 ) at 0x 770c7c04
476509Done!
477510
478511```
0 commit comments