Changeset 86555 in vbox for trunk/src/VBox/ValidationKit/tests/autostart
- Timestamp:
- Oct 13, 2020 10:30:53 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 140875
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py
r86540 r86555 1227 1227 if fRc: 1228 1228 sSecPolicyEditor = """ 1229 ' SetLogonAsAServiceRight.vbs 1230 ' Sample VBScript to set or grant Logon As A Service Right. 1231 ' Author: http://www.morgantechspace.com/ 1232 ' ------------------------------------------------------'1233 1234 Dim strUserName,ConfigFileName,OrgStr,RepStr,inputFile,strInputFile,outputFile,obj 1235 s trUserName = "%s"1236 Dim oShell 1237 Set oShell = CreateObject ("WScript.Shell") 1238 oShell.Run "secedit /export /cfg config.inf", 0, true 1239 oShell.Run "secedit /import /cfg config.inf /db database.sdb", 0, true 1240 1241 ConfigFileName = "config.inf" 1242 OrgStr = "SeServiceLogonRight =" 1243 RepStr = "SeServiceLogonRight = " & strUserName & "," 1244 Set inputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile("config.inf", 1,1,-1) 1245 s trInputFile = inputFile.ReadAll1246 inputFile.Close 1247 Set inputFile = Nothing 1248 1249 Set outputFile = CreateObject("Scripting.FileSystemObject").OpenTextFile("config.inf",2,1,-1) 1250 outputFile.Write (Replace(strInputFile,OrgStr,RepStr)) 1251 outputFile.Close 1252 Set outputFile = Nothing 1253 1254 oShell.Run "secedit /configure /db database.sdb /cfg config.inf",0,true1255 set oShell= Nothing 1256 1257 Set obj = CreateObject("Scripting.FileSystemObject") 1258 obj.DeleteFile("config.inf") 1259 obj.DeleteFile("database.sdb") 1260 1261 WScript.Echo "Logon As A Service Right granted to user '"& strUserName &"'" 1229 $oUser = New-Object System.Security.Principal.NTAccount("%s") 1230 $oSID = $oUser.Translate([System.Security.Principal.SecurityIdentifier]) 1231 $sExportFile = '.\cfg.inf' 1232 $sSecDb = '.\secedt.sdb' 1233 $sSecDb1 = '.\secedt.jfm' 1234 $sImportFile = '.\newcfg.inf' 1235 secedit /export /cfg $sExportFile 1236 $sCurrServiceLogonRight = Get-Content -Path $sExportFile | 1237 Where-Object -FilterScript {$PSItem -match 'SeServiceLogonRight'} 1238 $asFileContent = @' 1239 [Unicode] 1240 Unicode=yes 1241 [System Access] 1242 [Event Audit] 1243 [Registry Values] 1244 [Version] 1245 signature="$CHICAGO$" 1246 Revision=1 1247 [Profile Description] 1248 Description=GrantLogOnAsAService security template 1249 [Privilege Rights] 1250 {0}*{1} 1251 '@ -f $( 1252 if($sCurrServiceLogonRight){"$sCurrServiceLogonRight,"} 1253 else{'SeServiceLogonRight = '} 1254 ), $oSid.Value 1255 Set-Content -Path $sImportFile -Value $asFileContent 1256 secedit /import /db $sSecDb /cfg $sImportFile 1257 secedit /configure /db $sSecDb 1258 Remove-Item -Path $sExportFile 1259 Remove-Item -Path $sSecDb 1260 Remove-Item -Path $sImportFile 1261 Remove-Item -Path $sSecDb1 1262 1262 """ % (sUser,); 1263 fRc = self.uploadString(oGuestSession, sSecPolicyEditor, 'C:\\Temp\\adjustsec. vbs');1264 if not fRc: 1265 reporter.error('Upload the adjustsec. vbsfailed');1263 fRc = self.uploadString(oGuestSession, sSecPolicyEditor, 'C:\\Temp\\adjustsec.ps1'); 1264 if not fRc: 1265 reporter.error('Upload the adjustsec.ps1 failed'); 1266 1266 if fRc: 1267 1267 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 1268 1268 'Setting the "Logon as service" policy to the user %s' % sUser, 1269 30 * 1000, 'C:\\Windows\\System32\\cscript.exe', 1270 ['cscript.exe', 'C:\\Temp\\adjustsec.vbs', '//Nologo'], False, True); 1269 60 * 1000, 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe', 1270 ['powershell.exe', '-file', 'C:\\Temp\\adjustsec.ps1', '-ExecutionPolicy', 1271 'Bypass' ], False, True); 1271 1272 if not fRc: 1272 1273 reporter.error('Setting the "Logon as service" policy to the user %s failed' % sUser); 1273 1274 try: 1274 oGuestSession.fsObjRemove('C:\\Temp\\adjustsec. vbs');1275 oGuestSession.fsObjRemove('C:\\Temp\\adjustsec.ps1'); 1275 1276 except: 1276 1277 fRc = reporter.errorXcpt('Removing policy script failed');
Note:
See TracChangeset
for help on using the changeset viewer.