Skip to content

Commit d2cecac

Browse files
authored
Add files via upload
1 parent f58371b commit d2cecac

9 files changed

+48
-12
lines changed

Build Scripts/FBConfigBuild.vbs

2.81 KB
Binary file not shown.

Build Scripts/FBManageBoot.vbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Sub SetupReboot(strLabel, strDescription)
135135
Call DebugLog("Restart Command: " & strCmd)
136136
Call SetBuildfileValue("RebootStatus", "Done")
137137

138-
strAdminPassword = GetBuildfileValue("AdminPassword")
138+
strAdminPassword = GetCredential("AdminPassword", GetBuildfileValue("AuditUser"))
139139
If strAdminPassword <> "" Then
140140
strPath = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon"
141141
Call Util_RegWrite(strPath, "1", "REG_SZ")

Build Scripts/FBManageSecurity.vbs

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Dim strBuiltinDom, strClusterName, strCmd, strCmdSQL, strDirSystemDataBackup
2525
Dim strGroupDBA, strGroupDBANonSA, strGroupMSA, strHKLM, strHKU, strIsInstallDBA, strKeyPassword, strLocalAdmin
2626
Dim strNTAuth, strOSVersion, strPath, strProfDir, strProgCacls, strProgReg
2727
Dim strServer, strSIDDistComUsers, strSSLCert, strSSLCertFile, strSSLCertThumb, strSystemDataSharedPrimary
28-
Dim strTDECert, strUser, strUserAccount, strUserDNSDomain, strWaitShort
28+
Dim strTDECert, strUser, strUserAccount, strUserDNSDomain, strWaitMed, strWaitShort
2929

3030

3131
Private Sub Class_Initialize
@@ -66,6 +66,7 @@ Private Sub Class_Initialize
6666
strTDECert = GetBuildfileValue("TDECert")
6767
strUserAccount = GetBuildfileValue("UserAccount")
6868
strUserDNSDomain = GetBuildfileValue("UserDNSDomain")
69+
strWaitMed = GetBuildfileValue("WaitMed")
6970
strWaitShort = GetBuildfileValue("WaitShort")
7071

7172
Set arrProfFolders = objFSO.GetFolder(strProfDir).SubFolders
@@ -297,7 +298,8 @@ Function GetCertAttr(strCertName, strCertAttr)
297298
Call DebugLog("GetCertAttr: " & strCertName & ", " & strCertAttr)
298299
Dim strAttrValue
299300

300-
strCmd = "(Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.FriendlyName -match '" & strCertName & "'})." & strCertAttr
301+
strCmd = "$CertName = '" & strCertName & "' ;"
302+
strCmd = strCmd & "(Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.FriendlyName -like $CertName})." & strCertAttr
301303
strAttrValue = GetPSData(strCmd)
302304

303305
Select Case True
@@ -449,6 +451,24 @@ Private Function HexStrToSIDStr(strValue)
449451
End Function
450452

451453

454+
Function GetCredential(strPassword, strAccount)
455+
Call DebugLog("GetCredential: " & strPassword)
456+
Dim strAcctName
457+
458+
GetCredential = GetBuildfileValue(strPassword)
459+
Select Case True
460+
Case LCase(GetCredential) <> "encrypted"
461+
' Nothing
462+
Case strAccount = ""
463+
' Get credential from Password file
464+
Case Else
465+
strAcctName = GetBuildfileValue(strAccount)
466+
' Get credential from Password file
467+
End Select
468+
469+
End Function
470+
471+
452472
Sub ProcessUser(strLabel, strDescription, strProcess)
453473
Call SetProcessId(strLabel, strDescription)
454474

@@ -597,7 +617,8 @@ Sub SetCertAuth(strCertThumb, strAccount)
597617
' Code based on https://stackoverflow.com/questions/40046916/how-to-grant-permission-to-user-on-certificate-private-key-using-powershell
598618
Dim strPKFile
599619

600-
strCmd = "(Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Thumbprint -match '" & strCertThumb & "'}).privatekey.cspkeycontainerinfo.uniquekeycontainername"
620+
strCmd = "$CertThumb = '" & strCertThumb & "' ;"
621+
strCmd = strCmd & "(Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Thumbprint -like $CertThumb}).privatekey.cspkeycontainerinfo.uniquekeycontainername"
601622
strPKFile = GetPSData(strCmd)
602623

603624
strPath = GetBuildfileValue("VolSys") & ":\ProgramData\Microsoft\Crypto\RSA\MachineKeys\" & strPKFile
@@ -968,16 +989,24 @@ Sub SetSSLCert()
968989
strSSLFile = FormatFolder(GetBuildfileValue("PathAddComp")) & strSSLCertFile
969990

970991
Select Case True
971-
Case GetBuildfileValue("SetSSLSelfCert") = "YES"
972-
strCmd = "POWERSHELL New-SelfSignedCertificate -DNSName '*." & strUserDNSDomain & "' -FriendlyName '" & strSSLCert & "' -CertStoreLocation 'cert:\LocalMachine\My' -NotBefore '2001-01-01T00:00:00' -NotAfter '2999-12-31T23:59:59' "
992+
Case GetBuildfileValue("SSLSelfCert") = "YES"
993+
strCmd = "POWERSHELL $UserDNSDomain = '*." & strUserDNSDomain & "' ;"
994+
strCmd = strCmd & "$SSLCert = '" & strSSLCert & "' ;"
995+
strCmd = strCmd & "New-SelfSignedCertificate -DNSName $UserDNSDomain -FriendlyName $SSLCert -CertStoreLocation 'cert:\LocalMachine\My' -NotBefore '2001-01-01T00:00:00' -NotAfter '2999-12-31T23:59:59' "
973996
Call Util_RunExec(strCmd, "", "", -1) ' Attributes: RSA, 2048 bit; Defaults: Client Authentication, Server Authentication; Usable for: Digital Signature, Key Encipherment
974997
Case CheckFile(strSSLFile) = True
975-
strCmd = "POWERSHELL $Cert = Import-PfxCertificate -FilePath '" & strSSLFile & "' -Password '" & strSSLCertPassword & "' -CertStoreLocation 'cert:\LocalMachine\My' | $Cert.FriendlyName = '" & strSSLCert & "' "
998+
strCmd = "$Password = '" & strSSLCertPassword & "' ;$SSLFile = '" & strSSLFile & "' ;"
999+
strCmd = strCmd & "(Import-PfxCertificate -FilePath $SSLFile -Password (ConvertTo-SecureString -String $Password -AsPlainText -Force) -CertStoreLocation 'cert:\LocalMachine\My').Thumbprint;"
1000+
strSSLCertThumb = GetPSData(strCmd)
1001+
strCmd = "POWERSHELL $SSLCertThumb = '" & LCase(strSSLCertThumb) & "' ;$SSLCert = '" & strSSLCert & "' ;"
1002+
strCmd = strCmd & "$Cert = (Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object {$_.Thumbprint -like $SSLCertThumb}) ;$Cert.FriendlyName = $SSLCert ;"
9761003
Call Util_RunExec(strCmd, "", "", -1)
1004+
' Call SetBuildMessage(strMsgError, "/SSLCertFile: processing is not yet supported in SQL FineBuild")
9771005
Case Else
9781006
Call SetBuildMessage(strMsgError, "Unable to find /SSLCertFile:" & strSSLCertFile)
9791007
End Select
9801008

1009+
WScript.Sleep strWaitMed
9811010
strSSLCertThumb = GetCertAttr(strSSLCert, "Thumbprint")
9821011
Call SetBuildfileValue("SSLCertThumb", strSSLCertThumb)
9831012

@@ -1004,9 +1033,10 @@ End Sub
10041033
Sub SetWinRMSSL()
10051034
Call DebugLog("SetWinRMSSL:")
10061035

1007-
strCmd = "POWERSHELL Set-WSManInstance -ResourceURI winrm/config/Listener "
1036+
strCmd = "POWERSHELL $SSLCertThumb = '" & strSSLCertThumb & "' ;"
1037+
strCmd = strCmd & "Set-WSManInstance -ResourceURI winrm/config/Listener "
10081038
strCmd = strCmd & "-SelectorSet @{Address='*';Transport='HTTPS'} "
1009-
strCmd = strCmd & "-ValueSet @{CertificateThumbprint='" & strSSLCertThumb & "'} "
1039+
strCmd = strCmd & "-ValueSet @{CertificateThumbprint=$SSLCertThumb} "
10101040
Call Util_RunExec(strCmd, "", "", -1)
10111041

10121042
End Sub
@@ -1047,6 +1077,10 @@ Function GetOUAttr(strOUPath, strUserDNSDomain, strOUAttr)
10471077
GetOUAttr = FBManageSecurity.GetOUAttr(strOUPath, strUserDNSDomain, strOUAttr)
10481078
End Function
10491079

1080+
Function GetCredential(strPassword, strAccount)
1081+
GetCredential = FBManageSecurity.GetCredential(strPassword, strAccount)
1082+
End Function
1083+
10501084
Sub ProcessUser(strLabel, strDescription, strProcess)
10511085
Call FBManageSecurity.ProcessUser(strLabel, strDescription, strProcess)
10521086
End Sub
674 Bytes
Binary file not shown.
1.41 KB
Binary file not shown.
-152 Bytes
Binary file not shown.
-108 Bytes
Binary file not shown.
-124 Bytes
Binary file not shown.

Build Scripts/Get-ADSPNAudit.vbs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
Option Explicit
1818
On Error Goto 0
1919

20-
Dim objCommand, objConnection, objNetwork, objRecordSet, objRootDSE
21-
Dim strDomainDN
20+
Dim objCommand, objConnection, objNetwork, objRecordSet, objRootDSE, objShell
21+
Dim strDomainDN, strUserDNSDomain
2222

2323
Call Init()
2424
Call Process()
@@ -44,7 +44,9 @@ Sub Init()
4444
objCommand.CommandText = "SELECT ADsPath FROM 'LDAP://" & strDomainDN & "'"
4545
Set objRecordSet = objCommand.Execute
4646

47-
wscript.echo "-- SPN Audit Report --"
47+
Set objShell = WScript.CreateObject ("Wscript.Shell")
48+
strUserDNSDomain = objShell.ExpandEnvironmentStrings("%UserDNSDomain%")
49+
Wscript.Echo "-- SPN Audit Report for " & strUserDNSDomain & " at " & Time() & " on " & Date() &" --"
4850

4951
End Sub
5052

0 commit comments

Comments
 (0)