Search the Community
Showing results for tags 'crl'.
-
Hey there, Probably you know about the many questions on this forum, how to disable Ctrl-Alt-Del. I searched the whole forum bot there was not only one answer that worked. But now i found a way on my own hot to prevent that. And btw I have to say that this if f*cking easy, so shame on you You can try it, it works sure on windows 7 and vista. I also included a hotkey function to exit, but it takes up to 10 seconds until you can access the ctrl alt del screen again. Please tell me if you found out a better way and tell me what is your meaning about my script. Thank you -snip- Edit: This is the hard way, and i just wanted to show how it could be done. I am confused, no one before me mentioned this script
-
I've created this script to be able to download certificate revocation lists and check when they expire for multiple CRL's for work. The tool I have created seems to work but I'm worried It will have a memory leak or keep using more and more handles until the machine it is running on locks up. The tool uses a csv file that has the name of the CRL, the download location, a reference name for it and I'm now working on a notification bit that will email either the person responsible of an on-call email if the CRL expires. One of the problems I have is that I would normally create the labels and then update them within the while statement but I can't seem to be able to figure out how to referenece back to the array at the location I want the data to be updated. I tried creating the labels and progress bars but how do I reference each variable?? Here is the code minus a few bits: #include <Constants.au3> #include <Date.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #include <INet.au3> Dim $aRecords, $Results, $Effective_date, $Expiry_Details, $Expiry_DetailsData, $CertUtilLogs, $FILE If Not _FileReadToArray("CRL_Check.csv", $aRecords) Then MsgBox(4096, "Error", " Error reading log to Array error:" & @error) Exit EndIf $mainWindow = GUICreate("CRL Endpoint Check v3.0 (UPDATES EVERY 10 MINUTES)", 700, (($aRecords[0] * 20) + 100)) Opt("TrayIconHide", 1) Opt("GUIOnEventMode", 0) ; Email Settings $s_SmtpServer = "*** REMOVED ***" $s_helo = "EHLO CRL_Endpoint_Check_v3.0" $s_first = -1 $s_FromName = "CRL Endpoint Check v3.0" $s_FromAddress = "*** REMOVED ***" Dim $as_Body[2] GUISetState() GUICtrlCreateGroup("Environment ---> EndPoint", 20, 10, 250, (($aRecords[0] * 20) + 40)) GUICtrlCreateGroup("Expiry Times Percentage", 280, 10, 280, (($aRecords[0] * 20) + 40)) GUICtrlCreateGroup("Mins before Expiry", 570, 10, 110, (($aRecords[0] * 20) + 40)) $LastUpdate = GUICtrlCreateLabel("Last Updated...", 30, (($aRecords[0] * 20) + 55), 200, 17) GUICtrlCreateLabel("Service Started: " & _NowCalc(), 30, (($aRecords[0] * 20) + 75), 200, 17) $RefreshProgress = GUICtrlCreateProgress(290, (($aRecords[0] * 20) + 70), 250, 17) $RefreshButton = GUICtrlCreateButton("Manual Refresh", 575, (($aRecords[0] * 20) + 65), 100, 25) GUICtrlSetData($RefreshButton, "Updating") GUICtrlSetState($RefreshButton, $GUI_DISABLE) $line = 40 While 1 For $x = 1 to $aRecords[0] $Endpoints = StringSplit($aRecords[$x], ",") $s_ToAddress = $Endpoints[4] If Not FileExists($Endpoints[1]) Then DirCreate($Endpoints[1]) EndIf $EndPointsLabel = GUICtrlCreateLabel($Endpoints[1] & " ---> " & $Endpoints[2], 30, $line, 220, 17) $MinsLeft = GUICtrlCreateLabel("** Updating **", 580, $line, 95, 17) $ProgressCreate = GUICtrlCreateProgress(290, $line, 250, 17) #Alternate Local $hDownload = InetGet($Endpoints[3], $Endpoints[1] & "\" & $Endpoints[2] & ".crl", 3, 1) Do Sleep(500) Until InetGetInfo($hDownload, 2) ; Check if the download is complete. Local $aData = InetGetInfo($hDownload) ; Get all information. InetClose($hDownload) ; Close the handle to release resourcs. If $aData[4] <> 0 then GUICtrlSetData($MinsLeft, "Download ERR") GUICtrlSetColor($MinsLeft, 0xff0000) ; Red GUICtrlSetData($ProgressCreate, "0") Sleep(500) $line = $line + 20 Else Sleep(500) $line = $line + 20 ;****************************************************************************** ;Interrogating the CRL with Certutil.exe and dumping to file $CertUtilLogs = FileOpen($Endpoints[1] & "\" & $Endpoints[2] & ".txt", 2) If $CertUtilLogs = -1 Then MsgBox(0, "Error", "Unable to create CRL Dump file. May be a file permission problem.") Exit EndIf local $Run = Run(@ComSpec & " /c " & "certutil.exe " & $Endpoints[1] & "\" & $Endpoints[2] & ".crl", "", @SW_HIDE, $STDOUT_CHILD) local $Certutilline Sleep(50) While 1 $Certutilline = StdoutRead($Run) If @error Then ExitLoop Sleep(200) FileWriteLine($CertUtilLogs, $Certutilline) Wend FileClose($CertUtilLogs) Sleep(50) ;****************************************************************************** ;****************************************************************************** ;Opening dumped file and processing to look for effective and expity date to calculate CRL duration $FILE = FileOpen($Endpoints[1] & "\" & $Endpoints[2] & ".txt", 0) If $FILE = -1 Then MsgBox(0, "Error", "Unable to open file so service probably isn't responding to commands.") Exit EndIf While 1 $READLINE = FileReadLine($FILE) If @error = -1 Then ExitLoop $Effective_date = StringRegExp($READLINE, ' ThisUpdate: (.*)', 2) For $I = 0 To UBound($Effective_date) - 1 $Effective_dateData = $Effective_date[1] Next $Expiry_Details = StringRegExp($READLINE, ' NextUpdate: (.*)', 2) For $I = 0 To UBound($Expiry_Details) - 1 $Expiry_DetailsData = $Expiry_Details[1] Next WEnd FileClose($FILE) ;****************************************************************************** ;****************************************************************************** ;Reformatting expiry details to suite date/time convention $date = StringSplit($Expiry_DetailsData, " ") ; Format the time If $date[3] = "PM" Then $hour = StringSplit($date[2], ":") If $hour[1] = 12 Then $hoursplit = 12 Else $hoursplit = $hour[1] + 12 If $hoursplit = 24 Then $hoursplit = 0 Else $hoursplit = $hour[1] + 12 EndIf EndIf EndIf If $date[3] = "AM" Then $hour = StringSplit($date[2], ":") $hoursplit = $hour[1] If $hoursplit = 12 Then $hoursplit = 0 Else $hoursplit = $hour[1] EndIf EndIf ;format the date $datesplit = StringSplit($date[1], "/") $FormattedDate = $datesplit[3] & "/" & $datesplit[2] & "/" & $datesplit[1] & " " & $hoursplit & ":" & $hour[2] & ":00" ;Date difference to _NowCalc() for minutes to expiry $iDateCalc = _DateDiff('n', _NowCalc(), $FormattedDate) ;****************************************************************************** ;****************************************************************************** ;Reformatting effective details to suite date/time convention $date1 = StringSplit($Effective_dateData, " ") ; Format the time If $date1[3] = "PM" Then $hour1 = StringSplit($date1[2], ":") If $hour1[1] = 12 Then $hoursplit1 = 12 Else $hoursplit1 = $hour1[1] + 12 If $hoursplit1 = 24 Then $hoursplit1 = 0 Else $hoursplit1 = $hour1[1] + 12 EndIf EndIf EndIf If $date1[3] = "AM" Then $hour1 = StringSplit($date1[2], ":") $hoursplit1 = $hour1[1] If $hoursplit1 = 12 Then $hoursplit1 = 0 Else $hoursplit1 = $hour1[1] EndIf EndIf ;format the date $datesplit1 = StringSplit($date1[1], "/") $FormattedDate1 = $datesplit1[3] & "/" & $datesplit1[2] & "/" & $datesplit1[1] & " " & $hoursplit1 & ":" & $hour1[2] & ":00" ;Date difference to _NowCalc() $iDateCalc1 = _DateDiff('n', $FormattedDate1, _NowCalc()) $iDateCalc2 = _DateDiff('n', $FormattedDate1, $FormattedDate) $ResultPercent = (($iDateCalc1 / $iDateCalc2) * 100) ;****************************************************************************** GUICtrlSetData($ProgressCreate, $ResultPercent) If $iDateCalc < "55" Then GUICtrlSetData($MinsLeft, $iDateCalc & " (Expires Soon)") GUICtrlSetColor($MinsLeft, 0xff0000) ; Red Else GUICtrlSetColor($MinsLeft, 0x000000) ; Black EndIf If $iDateCalc < 1 Then GUICtrlSetData($MinsLeft, "Expired") GUICtrlSetData($ProgressCreate, 100) $s_Subject = "CRL Endpoint Check v3.0 - CRL (" & $Endpoints[2] & ") has expired" $as_Body[0] = "CRL Endpoint Check v3.0 from " & @ComputerName & @CRLF $as_Body[1] = "Please contact the CRL privider and let them know their CRL has expired." & @CRLF & "CRL (" & $Endpoints[2] & ".crl) expired at: " & $FormattedDate & @CRLF & @CRLF & "Endpoint URL: " & $Endpoints[3] $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_helo, $s_first) Else GUICtrlSetData($MinsLeft, $iDateCalc) EndIf FileDelete($Endpoints[1] & "\" & $Endpoints[2] & ".txt") FileDelete($Endpoints[1] & "\" & $Endpoints[2] & ".crl") EndIf Next GUICtrlSetData($LastUpdate, "Last Updated: " & _NowCalc()) $line = 40 ;****************************************************************************** GUICtrlSetData($RefreshButton, "Manual Refresh") GUICtrlSetState($RefreshButton, $GUI_ENABLE) GUICtrlSetData($RefreshProgress, 0) $Timer = TimerInit() $ProgressStep = "" $TimerValue = 600000; 10 minute approx While 1 $msg = GUIGetMsg() Select Case $msg = $RefreshButton GUICtrlSetData($RefreshButton, "Updating") GUICtrlSetState($RefreshButton, $GUI_DISABLE) GUICtrlSetData($RefreshProgress, 0) $Timer = TimerInit() ExitLoop Case $msg = $GUI_EVENT_CLOSE; Or $msg = $BUTTON2 GUIDelete() FileClose($FILE) FileClose($CertUtilLogs) Exit EndSelect GUICtrlSetData($RefreshProgress, (TimerDiff($Timer) / $TimerValue * 100)) If TimerDiff($Timer) > $TimerValue Then GUICtrlSetData($RefreshProgress, 100) $Timer = TimerInit() GUICtrlSetData($RefreshButton, "Updating") GUICtrlSetState($RefreshButton, $GUI_DISABLE) ExitLoop EndIf WEnd WEnd The input file looks like this Production,testcrl1,http://testsite1/latest.crl,testcrl1_latest.crl,test1@website.com Production,testcrl2,http://testsite2/latest.crl,testcrl2_latest.crl,test2@website.com The first tab is the environment. the second is a lable for the CRL, the third is the CRL download address and the last is the email address to email to. Attached is a screenshot of what it looks like after the initial CRL processing then waiting. If someone has a better way (as I'm sure there is) of doing this then please let me know. I have commented some of it but not all so sorry if it becomes confusing. Cheers Justin