diff --git a/.ssh/New Userscript.user.js b/.ssh/New Userscript.user.js new file mode 100644 index 0000000..8ab352f --- /dev/null +++ b/.ssh/New Userscript.user.js @@ -0,0 +1,594 @@ +// ==UserScript== +// @name New Userscript +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description try to take over the world! +// @author You +// @match http://*/* +// @grant none +// ==/UserScript== + + +# +# Title: CRL_Copy_v2.ps1 +# Date: 5/8/2013 +# Author: Paul Fox (MCS) +# Copyright Microsoft Corporation @2013 +# +# Description: This script monitors the remaining lifetime of a CRL, publishes a CRL to a UNC and\or NTFS location and sends notifications via SMTP and EventLog. +# There are two input arguments: +# "Monitor" - checks the "master" CRL and the CRL in CDP locations. If the NextUpdate time is within "threshold" an alert will be sent. +# "Publish" - checks the status of the master CRL and copies the Master CRL to identified CDP locations if the CRL numbers do not match +# Master CRL and CDP push location must be file system paths (UNC and\or NTFS). The script validates that push was successful by comparing the hash +# values of the Master and CDP CRLs. +# Settings are configured within the crl_config.xml file. +# This script requires the Mono.Security.X509.X509Crl libraries version 2.10.9 (http://www.mono-project.com/Main_Page). +# Load the PSCX powershell module for the get-hash commandlet (http://pscx.codeplex.com/). Make sure to follow the install instructions in the download's ReadMe.txt file. +# If ran within the task scheduler using the "Publish" method make sure the process runs as local administrator so it can read CertSvc service status +# and is given the right to "Logon as a batch job." +# +# For debug output type $debugpreference = "continue" at the powershell command prompt. +# + +param ($arg1) + +if(!$arg1 -or (($arg1 -ne "publish") -and ($arg1 -ne "monitor"))) +{ + write-host "Usage: ./crl_copy_v2.ps1 publish|monitor" + write-host "" + write-host "Example: to publish CRL to CDP locations specified in crl_config.xml" + write-host "./crl_copy_v2.ps1 publish" + write-host "" + write-host "Example: to compare the `"master`" CRL to published CRLs in the CDP locations specified in crl_config.xml" +write-host "./crl_copy_v2.ps1 monitor" +exit +} + +# +# Function: Results +# Description: Writes the $evtlog_string to the Application eventlog and sends +# SMTP message to recipients if $SMTP = [bool]$true and $EventLevel <= SMTPThreshold +# +function results([string]$evt_string, [string]$evtlog_string, [int]$level, [string]$title, [bool]$sendsmtp, [string]$from, [array]$to, [string]$SmtpServer, [string]$SMTPThreshold, [bool]$published) +{ +write-debug "******** Inside results function ********" +write-debug "SMTP = $sendsmtp" +write-debug "EventLevel: $level" +write-debug "SMTP threshold: $SMTPThreshold" +write-debug "Published Notification: $published" + +# if eventlog does not exist create it (must run script as local administrator once to create) +if(![system.diagnostics.eventlog]::sourceExists($EventSource)) +{ +$evtlog = [system.diagnostics.eventlog]::CreateEventSource($EventSource,"Application") +} + +# set eventlog object +$evtlog = new-object system.diagnostics.eventlog("application",".") +$evtlog.source = $EventSource + +# write to eventlog +$evtlog.writeEntry($evtlog_string, $level, $EventID) + +# send email if sendsmtp = TRUE and event level <= SMTPThreshold or Notify on Publish +if($sendsmtp -and (($level -le $SMTPThreshold) -or $published)) +{ +write-debug "Sending SMTP" +if($level -eq $EventHigh) +{ +$SMTPPriority = "High" +} +else +{ +$SMTPPriority = "Normal" +} +$messageParameters = @{ +Subject = $title +From = $from +To = $to +SmtpServer = $SmtpServer +Body = $evt_string | Out-String +Priority = $SMTPPriority +} +Send-mailMessage @messageParameters -BodyAsHtml +} +else +{ +write-debug "SMTP message not sent" +} + +if($tmp_outfile) +{ +foreach($file in $tmp_outfile) +{ +$debug_out = "Outputing to: " + $file +write-debug $debug_out +$evt_string | Out-File $file +} +} +else +{ +write-debug "No output files specified" +} +} # end results function + +# +# Function: retrieve +# Description: Pulls the CRL based upon method +# +function retrieve([string]$name, [string]$method, [string]$path) +{ +$debug_out = "Function: pulling CRL: " + $name + " Method: " + $method + " Path: " + $path +write-debug $debug_out + +switch($method) +{ +"file" {$retrieved_crl =[Mono.Security.X509.X509Crl]::CreateFromFile($path + $name) +} +"ldap" {$CRLNumber = 0 +$i = 0 +$found = [bool]$FALSE +$tmp = $name.split(".") +$name = $tmp[0] +$domain = "LDAP://cn=cdp,cn=public key services,cn=services,cn=configuration," + $path +$root = New-Object System.DirectoryServices.DirectoryEntry($domain) +$query = New-Object System.DirectoryServices.DirectorySearcher($root) +$strFilter = "(&(objectclass=cRLDistributionPoint)(cn=$name))" +$query.Filter = $strFilter +$query.SearchScope = "subtree" +$query.PageSize = 1000 +$results = $query.FindAll() + +$debug_out = "LDAP: found " + $results.count + " CRLs" +write-debug $debug_out +if($results.count -gt 0) +{ +# sometimes there might be multiple CRLs in the LDAP location +# find the highest CRL number and return that one +foreach($ldapcrl in $results) +{ +if($ldapcrl.Properties.certificaterevocationlist) +{ +[byte[]]$lcrl = $ldapcrl.Properties["certificaterevocationlist"][0] +[Mono.Security.X509.X509Crl]$crl = $lcrl +$CRLnumberTMP = [Mono.Security.ASN1Convert]::ToInt32($crl.Extensions["2.5.29.20"].ASN1[1].Value) +if($CRLnumberTMP -ge $CRLNumber) +{ +$CRLNumber = $CRLnumberTMP +$result_num = $i +$found = [bool]$TRUE +} +$i++ +} +} #end foreach +} # if results > 0 +else +{ +write-debug "No LDAP CRL found" +} + +if($found) +{ +[byte[]]$lcrl = $results[$result_num].Properties["certificaterevocationlist"][0] +$retrieved_crl = [Mono.Security.X509.X509Crl]$lcrl +} +else +{ +$retrieved_crl = $null +} +} +"www" {$web_client = New-Object System.Net.WebClient +$retrieved_crl = [Mono.Security.X509.X509Crl]$web_client.DownloadData($path + $name) +} +default {write-host "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " +$evtlog_string = "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $newline +$evt_string = $evt_string + "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $newline +} +} +$debug_out = "Pulled CRL CRLNumber: " + [Mono.Security.ASN1Convert]::ToInt32($retrieved_crl.Extensions["2.5.29.20"].ASN1[1].Value) + $newline +$debug_out = $debug_out + "Pulled CRL IssuerName: " + $retrieved_crl.IssuerName + $newline +$debug_out = $debug_out + "Pulled CRL ThisUpdate: " + $retrieved_crl.ThisUpdate.ToLocalTime() + $newline +$debug_out = $debug_out + "Pulled CRL NextUpdate: " + $retrieved_crl.NextUpdate.ToLocalTime() + $newline +$debug_out = $debug_out + "Pulled CRL NextCRLPublish: " + [Mono.Security.ASN1Convert]::ToDateTime($retrieved_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + $newline +write-debug $debug_out +return [Mono.Security.X509.X509Crl]$retrieved_crl +} # end of function retrieve + +# +# MAIN +# +# Variables +# +[xml]$xmlconfigfile = get-content .\crl_config.xml +$master_name = $xmlconfigfile.configuration.master_crl.name +$master_retrieval = $xmlconfigfile.configuration.master_crl.retrieval +$master_path = $xmlconfigfile.configuration.master_crl.path +$cdps = $xmlconfigfile.configuration.cdps.cdp +$SMTP = [bool]$xmlconfigfile.configuration.SMTP.send_SMTP +$SmtpServer = $xmlconfigfile.configuration.SMTP.SmtpServer +$from = $xmlconfigfile.configuration.SMTP.from +$to = ($xmlconfigfile.configuration.SMTP.to).split(",") +$published_notify = [bool]$xmlconfigfile.configuration.SMTP.published_notify +$notify_of_publish = [bool]$false +$title = $xmlconfigfile.configuration.SMTP.title +$SMTPThreshold = $xmlconfigfile.configuration.SMTP.SMTPThreshold +$EventSource = $xmlconfigfile.configuration.eventvwr.EventSource +$EventID = $xmlconfigfile.configuration.eventvwr.EventID +$EventHigh = $xmlconfigfile.configuration.eventvwr.EventHigh +$EventWarning = $xmlconfigfile.configuration.eventvwr.EventWarning +$EventInformation = $xmlconfigfile.configuration.eventvwr.EventInformation +$threshold = $xmlconfigfile.configuration.warnings.threshold +$threshold_unit = $xmlconfigfile.configuration.warnings.threshold_unit +$cluster = [bool]$xmlconfigfile.configuration.adcs.cluster +$publish_html = [bool]$xmlconfigfile.configuration.output.publish +$tmp_outfile = ($xmlconfigfile.configuration.output.outfile).split(",") +$newline = [System.Environment]::NewLine +$time = Get-Date +$EventLevel = $EventInformation + +# +# Add Mono .Net References +# If running on an x64 system make sure the path is correct +# +Add-Type -Path "C:\Program Files (x86)\Mono-2.10.9\lib\mono\2.0\Mono.Security.dll" +Import-Module -Name Pscx + +# +# Build the output string header +# +$evt_string = "" + $title + " " + $time + "" + $newline +$evt_string = $evt_string + "

" + $title + " " + $time + "

" + $newline +$evt_string = $evt_string + "
" + $newline
+$evt_string = $evt_string + "CRL Name: " + $master_name + $newline
+$evt_string = $evt_string + "Method: " + $arg1  + $newline
+$evt_string = $evt_string + "Warning threshold: " + $threshold + " " + $threshold_unit + "
" + $newline + +# +# Eventlog string +# +$evtlog_string = $evtlog_string + "CRL Name: " + $master_name + $newline +$evtlog_string = $evtlog_string + "Method: " + $arg1 + $newline +$evtlog_string = $evtlog_string + "Warning threshold: " + $threshold + " " + $threshold_unit + $newline + +# +# If ran within the task scheduler, run with admin rights to read the service status +# Is certsrv running? Is it a clustered CA? +# If clustered and is not running, send an Informational message +# +$service = get-service | where-Object {$_.name -eq "certsvc"} +if (!($service.Status -eq "Running")) +{ +if($Cluster) +{ +$evt_string = $evt_string + "Active Directory Certificate Services is not running on this node of the cluster
" + $newline +$evt_string = $evt_string + "
" + $newline +$evtlog_string = $evtlog_string + "Active Directory Certificate Services is not running on this node of the cluster
" + $newline +# don't write the HTML output files, the other node will write the files +$tmp_outfile = $null +results $evt_string $evtlog_string $EventInformation $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish +write-debug "ADCS is not running. This is a clustered node. Exiting" +exit +} +else +{ +$evt_string = $evt_string + "**** IMPORTANT **** IMPORTANT **** IMPORTANT ****
" + $newline + $evt_string = $evt_string + "Certsvc status is: " + $service.status + "
" + $newline + $evt_string = $evt_string + "" + $newline + $evtlog_string = $evtlog_string + "**** IMPORTANT **** IMPORTANT **** IMPORTANT ****" + $newline + $evtlog_string = $evtlog_string + "Certsvc status is: " + $service.status + $newline + results $evt_string $evtlog_string $EventHigh $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish + write-debug "ADCS is not running and not a clustered node. Not good." + exit +} +} +else +{ + write-debug "Certsvc is running. Continue." +} + +# +# Build the output table +# +$evt_string = $evt_string + "" + $newline +$evt_string = $evt_string + "` +` +` +` + ` +` +" +if($arg1 -eq "publish") +{ + $evt_string = $evt_string + "" +} +$evt_string = $evt_string + "" + $newline + +# +# Get the master CRL +# +write-debug "Pulling master CRL" +[Mono.Security.X509.X509Crl]$master_crl = retrieve $master_name $master_retrieval $master_path +if($master_crl) +{ + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" +} +else +{ + $EventLevel = $EventHigh + $evt_string = $evt_string + "
CRL Path Number ThisUpate NextUpdate NextCRLPublish Status Published
Master " + $master_path + " " + [Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value) + " " + $master_crl.ThisUpdate.ToLocalTime() + " " + $master_crl.NextUpdate.ToLocalTime() + " " + [Mono.Security.ASN1Convert]::ToDateTime($master_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + "

" + $newline + $evt_string = $evt_string + "Unable to retrieve master crl: $master_path$master_name
" + $newline +$evt_string = $evt_string + "" + $newline +$evtlog_string = $evtlog_string + "Unable to retrieve master crl: $master_name" + $newline +results $evt_string $evtlog_string $EventLevel $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish +write-debug $evt_string +exit +} + +# +# It looks like IsCurrent method checks againt UTC time +# So reverting to compare with LocalTime +# +if($master_crl.NextUpdate.ToLocalTime() -gt $time) +{ +# determine if with in threshold warning window +$delta = new-timespan $time $master_crl.NextUpdate.ToLocalTime() +$measure = "Total"+$threshold_unit +if($delta.$measure -gt $threshold) +{ +$evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + "Master CRL is current" + $newline +} +else +{ + $evt_string = $evt_string + " " +$evtlog_string = $evtlog_string + "Master CRL is soon to expire and is below threshold level" + $newline +$EventLevel = $EventWarning +} +} +else +{ +$evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + "Master CRL has expired" + $newline + $EventLevel = $EventHigh +} +if($arg1 -eq "publish") +{ + $evt_string = $evt_string + " " +} +$evt_string = $evt_string + "" + $newline + +# +# Pull CRLs from the CDPs +# +write-debug "Pulling CDP CRLs" +foreach($cdp in $cdps) +{ + $cdp_crl = $null + [Mono.Security.X509.X509Crl]$cdp_crl = retrieve $master_name $cdp.retrieval $cdp.retrieval_path + $evt_string = $evt_string + " " + $cdp.name + " " + # if CDP is http then make an HREF + if($cdp.retrieval -eq "www") + { + if($master_name -match " ") + { + $www_crl = $master_name.replace(" ","%20") + } + else + { + $www_crl = $master_name + } + $evt_string = $evt_string + "" + $cdp.retrieval_path + $www_crl +" " + } + else + { + $evt_string = $evt_string + " " + $cdp.retrieval_path + " " + } + + if($cdp_crl) + { + $evt_string = $evt_string + " " + [Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value) + " " + $evt_string = $evt_string + " " + $cdp_crl.ThisUpdate.ToLocalTime() + " " + $evt_string = $evt_string + " " + $cdp_crl.NextUpdate.ToLocalTime() + " " + $evt_string = $evt_string + " " + [Mono.Security.ASN1Convert]::ToDateTime($cdp_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + " " + + if($cdp_crl.NextUpdate.ToLocalTime() -gt $time) + { + # determine if with in threshold warning window + $delta = new-timespan $time $cdp_crl.NextUpdate.ToLocalTime() + $measure = "Total"+$threshold_unit + if($delta.$measure -gt $threshold) + { + # if within threshold and the CRL numbers do not match set to orange + if([Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value) -ne [Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value)) + { + $evt_string = $evt_string + " " +$evtlog_string = $evtlog_string + $cdp.name + " CRL number does not match master CRL" + $newline +} +else +{ +$evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + $cdp.name + " is current" + $newline + } + } + else + { + # within the threshold window + $evt_string = $evt_string + " " +$evtlog_string = $evtlog_string + $cdp.name + " is soon to expire and is below threshold level" + $newline +if($EventLevel -gt $EventWarning){$EventLevel = $EventWarning} +} +} +else +{ +# expired +$evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + $cdp.name + " has expired" + $newline + if($EventLevel -gt $EventHigh){$EventLevel = $EventHigh} + } + } # end $cdp_crl exists + else + { + $EventLevel = $EventWarning + $evt_string = $evt_string + "Unable to retrieve crl" + $newline + $evt_string = $evt_string + " " +$evtlog_string = $evtlog_string + "Unable to retrieve crl: " + $cdp.retrieval_path + $master_name + $newline +} + + +if($arg1 -eq "publish") +{ +if($cdp.push) +{ +# push master CRL out to location if master CRL # > CDP CRL # +if([Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value) -gt [Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value)) +{ +# only file copy at this time +write-debug "Master CRL is newer, pushing out" +$source_path = $master_path + $master_Name +$source = Get-Item $source_path +$dest_path = $cdp.push_path + $master_Name +Copy-Item $source $dest_path + +# Compare the hash values of the master CRL to the copied CDP CRL +# If they do not equal alert via SMTP set event level to high +$master_hash = get-hash $source_path +write-debug $master_hash.HashString +$cdp_hash = get-hash $dest_path +write-debug $cdp_hash.HashString +if($master_hash.HashString -ne $cdp_hash.HashString) +{ +$evt_string = $evt_string + " failed " + $evtlog_string = $evtlog_string + "CRL publish to " + $cdp.name + " failed" + $newline + if($EventLevel -gt $EventHigh){$EventLevel = $EventHigh} + } + else + { + write-debug "Push succeeded" + $evt_string = $evt_string + " " + $time + " " +$evtlog_string = $evtlog_string + "CRL publish to " + $cdp.name + " succeeded" + $newline +# determine if we need to send an SMTP message +if($published_notify) +{ +$notify_of_publish = $published_notify +} +} +} #end if master crl # > cdp crl # +else +{ +$evt_string = $evt_string + " " +} +} #end if $cdp.push = TRUE +else +{ +$evt_string = $evt_string + " " +} +} #end of if arg1 = publish + + +$evt_string = $evt_string + "" + $newline +write-debug "----------------" +} #end of foreach $cdps + +# +# Close up the table +# +$evt_string = $evt_string + "
" + $newline + +# +# Send results +# +results $evt_string $evtlog_string $EventLevel $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish + + + + +CRL_Config.XML +XML + + + + +issuingca.crl +file +C:\Windows\System32\certsrv\CertEnroll\ + + + + +internal cdp1 +www +http://www.f.internal/pki/ +true +file +\\www.f.internal\pki\ + + + +internal ldap +ldap +dc=f,dc=internal + + + + + + +external cdp +www +http://pki.g.internal/pki/ + + + + + + + +true +exchange.f.internal +crlcopy@f.internal +pfox@f.internal,pierref@f.internal +true +CRL Copy Process Results +2 + + + +CRL Copy Process +5000 +1 +2 +4 + + + +5 +hours + + + + + + + +c:\windows\system32\certsrv\certenroll\CRLCopy.htm,\\www.f.internal\pki\CRLCopy.htm + + + +function # # Title: CRL_Copy_v2.ps1 # Date: 5/8/2013 # Author: Paul Fox (MCS) # Copyright Microsoft Corporation @2013 # # Description: This script monitors the remaining lifetime of a CRL, publishes a CRL to a UNC and\or NTFS location and sends notifications via SMTP and EventLog. # There are two input arguments: # "Monitor" - checks the "master" CRL and the CRL in CDP locations. If the NextUpdate time is within "threshold" an alert will be sent. # "Publish" - checks the status of the master CRL and copies the Master CRL to identified CDP locations if the CRL numbers do not match # Master CRL and CDP push location must be file system paths (UNC and\or NTFS). The script validates that push was successful by comparing the hash # values of the Master and CDP CRLs. # Settings are configured within the crl_config.xml file. # This script requires the Mono.Security.X509.X509Crl libraries version 2.10.9 (http://www.mono-project.com/Main_Page). # Load the PSCX powershell module for the get-hash commandlet (http://pscx.codeplex.com/). Make sure to follow the install instructions in the download's ReadMe.txt file. # If ran within the task scheduler using the "Publish" method make sure the process runs as local administrator so it can read CertSvc service status # and is given the right to "Logon as a batch job." # # For debug output type $debugpreference = "continue" at the powershell command prompt. # param ($arg1) if(!$arg1 -or (($arg1 -ne "publish") -and ($arg1 -ne "monitor"))) { write-host "Usage: ./crl_copy_v2.ps1 publish|monitor" write-host "" write-host "Example: to publish CRL to CDP locations specified in crl_config.xml" write-host "./crl_copy_v2.ps1 publish" write-host "" write-host "Example: to compare the `"master`" CRL to published CRLs in the CDP locations specified in crl_config.xml" write-host "./crl_copy_v2.ps1 monitor" exit } # # Function: Results # Description: Writes the $evtlog_string to the Application eventlog and sends # SMTP message to recipients if $SMTP = [bool]$true and $EventLevel <= SMTPThreshold # function results([string]$evt_string, [string]$evtlog_string, [int]$level, [string]$title, [bool]$sendsmtp, [string]$from, [array]$to, [string]$SmtpServer, [string]$SMTPThreshold, [bool]$published) { write-debug "******** Inside results function ********" write-debug "SMTP = $sendsmtp" write-debug "EventLevel: $level" write-debug "SMTP threshold: $SMTPThreshold" write-debug "Published Notification: $published" # if eventlog does not exist create it (must run script as local administrator once to create) if(![system.diagnostics.eventlog]::sourceExists($EventSource)) { $evtlog = [system.diagnostics.eventlog]::CreateEventSource($EventSource,"Application") } # set eventlog object $evtlog = new-object system.diagnostics.eventlog("application",".") $evtlog.source = $EventSource # write to eventlog $evtlog.writeEntry($evtlog_string, $level, $EventID) # send email if sendsmtp = TRUE and event level <= SMTPThreshold or Notify on Publish if($sendsmtp -and (($level -le $SMTPThreshold) -or $published)) { write-debug "Sending SMTP" if($level -eq $EventHigh) { $SMTPPriority = "High" } else { $SMTPPriority = "Normal" } $messageParameters = @{ Subject = $title From = $from To = $to SmtpServer = $SmtpServer Body = $evt_string | Out-String Priority = $SMTPPriority } Send-mailMessage @messageParameters -BodyAsHtml } else { write-debug "SMTP message not sent" } if($tmp_outfile) { foreach($file in $tmp_outfile) { $debug_out = "Outputing to: " + $file write-debug $debug_out $evt_string | Out-File $file } } else { write-debug "No output files specified" } } # end results function # # Function: retrieve # Description: Pulls the CRL based upon method # function retrieve([string]$name, [string]$method, [string]$path) { $debug_out = "Function: pulling CRL: " + $name + " Method: " + $method + " Path: " + $path write-debug $debug_out switch($method) { "file" {$retrieved_crl =[Mono.Security.X509.X509Crl]::CreateFromFile($path + $name) } "ldap" {$CRLNumber = 0 $i = 0 $found = [bool]$FALSE $tmp = $name.split(".") $name = $tmp[0] $domain = "LDAP://cn=cdp,cn=public key services,cn=services,cn=configuration," + $path $root = New-Object System.DirectoryServices.DirectoryEntry($domain) $query = New-Object System.DirectoryServices.DirectorySearcher($root) $strFilter = "(&(objectclass=cRLDistributionPoint)(cn=$name))" $query.Filter = $strFilter $query.SearchScope = "subtree" $query.PageSize = 1000 $results = $query.FindAll() $debug_out = "LDAP: found " + $results.count + " CRLs" write-debug $debug_out if($results.count -gt 0) { # sometimes there might be multiple CRLs in the LDAP location # find the highest CRL number and return that one foreach($ldapcrl in $results) { if($ldapcrl.Properties.certificaterevocationlist) { [byte[]]$lcrl = $ldapcrl.Properties["certificaterevocationlist"][0] [Mono.Security.X509.X509Crl]$crl = $lcrl $CRLnumberTMP = [Mono.Security.ASN1Convert]::ToInt32($crl.Extensions["2.5.29.20"].ASN1[1].Value) if($CRLnumberTMP -ge $CRLNumber) { $CRLNumber = $CRLnumberTMP $result_num = $i $found = [bool]$TRUE } $i++ } } #end foreach } # if results > 0 else { write-debug "No LDAP CRL found" } if($found) { [byte[]]$lcrl = $results[$result_num].Properties["certificaterevocationlist"][0] $retrieved_crl = [Mono.Security.X509.X509Crl]$lcrl } else { $retrieved_crl = $null } } "www" {$web_client = New-Object System.Net.WebClient $retrieved_crl = [Mono.Security.X509.X509Crl]$web_client.DownloadData($path + $name) } default {write-host "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " $evtlog_string = "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $newline $evt_string = $evt_string + "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $newline } } $debug_out = "Pulled CRL CRLNumber: " + [Mono.Security.ASN1Convert]::ToInt32($retrieved_crl.Extensions["2.5.29.20"].ASN1[1].Value) + $newline $debug_out = $debug_out + "Pulled CRL IssuerName: " + $retrieved_crl.IssuerName + $newline $debug_out = $debug_out + "Pulled CRL ThisUpdate: " + $retrieved_crl.ThisUpdate.ToLocalTime() + $newline $debug_out = $debug_out + "Pulled CRL NextUpdate: " + $retrieved_crl.NextUpdate.ToLocalTime() + $newline $debug_out = $debug_out + "Pulled CRL NextCRLPublish: " + [Mono.Security.ASN1Convert]::ToDateTime($retrieved_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + $newline write-debug $debug_out return [Mono.Security.X509.X509Crl]$retrieved_crl } # end of function retrieve # # MAIN # # Variables # [xml]$xmlconfigfile = get-content .\crl_config.xml $master_name = $xmlconfigfile.configuration.master_crl.name $master_retrieval = $xmlconfigfile.configuration.master_crl.retrieval $master_path = $xmlconfigfile.configuration.master_crl.path $cdps = $xmlconfigfile.configuration.cdps.cdp $SMTP = [bool]$xmlconfigfile.configuration.SMTP.send_SMTP $SmtpServer = $xmlconfigfile.configuration.SMTP.SmtpServer $from = $xmlconfigfile.configuration.SMTP.from $to = ($xmlconfigfile.configuration.SMTP.to).split(",") $published_notify = [bool]$xmlconfigfile.configuration.SMTP.published_notify $notify_of_publish = [bool]$false $title = $xmlconfigfile.configuration.SMTP.title $SMTPThreshold = $xmlconfigfile.configuration.SMTP.SMTPThreshold $EventSource = $xmlconfigfile.configuration.eventvwr.EventSource $EventID = $xmlconfigfile.configuration.eventvwr.EventID $EventHigh = $xmlconfigfile.configuration.eventvwr.EventHigh $EventWarning = $xmlconfigfile.configuration.eventvwr.EventWarning $EventInformation = $xmlconfigfile.configuration.eventvwr.EventInformation $threshold = $xmlconfigfile.configuration.warnings.threshold $threshold_unit = $xmlconfigfile.configuration.warnings.threshold_unit $cluster = [bool]$xmlconfigfile.configuration.adcs.cluster $publish_html = [bool]$xmlconfigfile.configuration.output.publish $tmp_outfile = ($xmlconfigfile.configuration.output.outfile).split(",") $newline = [System.Environment]::NewLine $time = Get-Date $EventLevel = $EventInformation # # Add Mono .Net References # If running on an x64 system make sure the path is correct # Add-Type -Path "C:\Program Files (x86)\Mono-2.10.9\lib\mono\2.0\Mono.Security.dll" Import-Module -Name Pscx # # Build the output string header # $evt_string = "" + $title + " " + $time + "" + $newline $evt_string = $evt_string + "

" + $title + " " + $time + "

" + $newline $evt_string = $evt_string + "
" + $newline $evt_string = $evt_string + "CRL Name: " + $master_name + $newline $evt_string = $evt_string + "Method: " + $arg1 + $newline $evt_string = $evt_string + "Warning threshold: " + $threshold + " " + $threshold_unit + "
" + $newline # # Eventlog string # $evtlog_string = $evtlog_string + "CRL Name: " + $master_name + $newline $evtlog_string = $evtlog_string + "Method: " + $arg1 + $newline $evtlog_string = $evtlog_string + "Warning threshold: " + $threshold + " " + $threshold_unit + $newline # # If ran within the task scheduler, run with admin rights to read the service status # Is certsrv running? Is it a clustered CA? # If clustered and is not running, send an Informational message # $service = get-service | where-Object {$_.name -eq "certsvc"} if (!($service.Status -eq "Running")) { if($Cluster) { $evt_string = $evt_string + "Active Directory Certificate Services is not running on this node of the cluster
" + $newline $evt_string = $evt_string + "
" + $newline $evtlog_string = $evtlog_string + "Active Directory Certificate Services is not running on this node of the cluster
" + $newline # don't write the HTML output files, the other node will write the files $tmp_outfile = $null results $evt_string $evtlog_string $EventInformation $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish write-debug "ADCS is not running. This is a clustered node. Exiting" exit } else { $evt_string = $evt_string + "**** IMPORTANT **** IMPORTANT **** IMPORTANT ****
" + $newline $evt_string = $evt_string + "Certsvc status is: " + $service.status + "
" + $newline $evt_string = $evt_string + "" + $newline $evtlog_string = $evtlog_string + "**** IMPORTANT **** IMPORTANT **** IMPORTANT ****" + $newline $evtlog_string = $evtlog_string + "Certsvc status is: " + $service.status + $newline results $evt_string $evtlog_string $EventHigh $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish write-debug "ADCS is not running and not a clustered node. Not good." exit } } else { write-debug "Certsvc is running. Continue." } # # Build the output table # $evt_string = $evt_string + "" + $newline $evt_string = $evt_string + "` ` ` ` ` ` " if($arg1 -eq "publish") { $evt_string = $evt_string + "" } $evt_string = $evt_string + "" + $newline # # Get the master CRL # write-debug "Pulling master CRL" [Mono.Security.X509.X509Crl]$master_crl = retrieve $master_name $master_retrieval $master_path if($master_crl) { $evt_string = $evt_string + "" $evt_string = $evt_string + "" $evt_string = $evt_string + "" $evt_string = $evt_string + "" $evt_string = $evt_string + "" $evt_string = $evt_string + "" } else { $EventLevel = $EventHigh $evt_string = $evt_string + "
CRL Path Number ThisUpate NextUpdate NextCRLPublish Status Published
Master " + $master_path + " " + [Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value) + " " + $master_crl.ThisUpdate.ToLocalTime() + " " + $master_crl.NextUpdate.ToLocalTime() + " " + [Mono.Security.ASN1Convert]::ToDateTime($master_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + "

" + $newline $evt_string = $evt_string + "Unable to retrieve master crl: $master_path$master_name
" + $newline $evt_string = $evt_string + "" + $newline $evtlog_string = $evtlog_string + "Unable to retrieve master crl: $master_name" + $newline results $evt_string $evtlog_string $EventLevel $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish write-debug $evt_string exit } # # It looks like IsCurrent method checks againt UTC time # So reverting to compare with LocalTime # if($master_crl.NextUpdate.ToLocalTime() -gt $time) { # determine if with in threshold warning window $delta = new-timespan $time $master_crl.NextUpdate.ToLocalTime() $measure = "Total"+$threshold_unit if($delta.$measure -gt $threshold) { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + "Master CRL is current" + $newline } else { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + "Master CRL is soon to expire and is below threshold level" + $newline $EventLevel = $EventWarning } } else { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + "Master CRL has expired" + $newline $EventLevel = $EventHigh } if($arg1 -eq "publish") { $evt_string = $evt_string + " " } $evt_string = $evt_string + "" + $newline # # Pull CRLs from the CDPs # write-debug "Pulling CDP CRLs" foreach($cdp in $cdps) { $cdp_crl = $null [Mono.Security.X509.X509Crl]$cdp_crl = retrieve $master_name $cdp.retrieval $cdp.retrieval_path $evt_string = $evt_string + " " + $cdp.name + " " # if CDP is http then make an HREF if($cdp.retrieval -eq "www") { if($master_name -match " ") { $www_crl = $master_name.replace(" ","%20") } else { $www_crl = $master_name } $evt_string = $evt_string + "" + $cdp.retrieval_path + $www_crl +" " } else { $evt_string = $evt_string + " " + $cdp.retrieval_path + " " } if($cdp_crl) { $evt_string = $evt_string + " " + [Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value) + " " $evt_string = $evt_string + " " + $cdp_crl.ThisUpdate.ToLocalTime() + " " $evt_string = $evt_string + " " + $cdp_crl.NextUpdate.ToLocalTime() + " " $evt_string = $evt_string + " " + [Mono.Security.ASN1Convert]::ToDateTime($cdp_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + " " if($cdp_crl.NextUpdate.ToLocalTime() -gt $time) { # determine if with in threshold warning window $delta = new-timespan $time $cdp_crl.NextUpdate.ToLocalTime() $measure = "Total"+$threshold_unit if($delta.$measure -gt $threshold) { # if within threshold and the CRL numbers do not match set to orange if([Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value) -ne [Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value)) { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + $cdp.name + " CRL number does not match master CRL" + $newline } else { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + $cdp.name + " is current" + $newline } } else { # within the threshold window $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + $cdp.name + " is soon to expire and is below threshold level" + $newline if($EventLevel -gt $EventWarning){$EventLevel = $EventWarning} } } else { # expired $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + $cdp.name + " has expired" + $newline if($EventLevel -gt $EventHigh){$EventLevel = $EventHigh} } } # end $cdp_crl exists else { $EventLevel = $EventWarning $evt_string = $evt_string + "Unable to retrieve crl" + $newline $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + "Unable to retrieve crl: " + $cdp.retrieval_path + $master_name + $newline } if($arg1 -eq "publish") { if($cdp.push) { # push master CRL out to location if master CRL # > CDP CRL # if([Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value) -gt [Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value)) { # only file copy at this time write-debug "Master CRL is newer, pushing out" $source_path = $master_path + $master_Name $source = Get-Item $source_path $dest_path = $cdp.push_path + $master_Name Copy-Item $source $dest_path # Compare the hash values of the master CRL to the copied CDP CRL # If they do not equal alert via SMTP set event level to high $master_hash = get-hash $source_path write-debug $master_hash.HashString $cdp_hash = get-hash $dest_path write-debug $cdp_hash.HashString if($master_hash.HashString -ne $cdp_hash.HashString) { $evt_string = $evt_string + " failed " $evtlog_string = $evtlog_string + "CRL publish to " + $cdp.name + " failed" + $newline if($EventLevel -gt $EventHigh){$EventLevel = $EventHigh} } else { write-debug "Push succeeded" $evt_string = $evt_string + " " + $time + " " $evtlog_string = $evtlog_string + "CRL publish to " + $cdp.name + " succeeded" + $newline # determine if we need to send an SMTP message if($published_notify) { $notify_of_publish = $published_notify } } } #end if master crl # > cdp crl # else { $evt_string = $evt_string + " " } } #end if $cdp.push = TRUE else { $evt_string = $evt_string + " " } } #end of if arg1 = publish $evt_string = $evt_string + "" + $newline write-debug "----------------" } #end of foreach $cdps # # Close up the table # $evt_string = $evt_string + "
" + $newline # # Send results # results $evt_string $evtlog_string $EventLevel $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish CRL_Config.XML XML issuingca.crl file C:\Windows\System32\certsrv\CertEnroll\ internal cdp1 www http://www.f.internal/pki/ true file \\www.f.internal\pki\ internal ldap ldap dc=f,dc=internal external cdp www http://pki.g.internal/pki/ true exchange.f.internal crlcopy@f.internal pfox@f.internal,pierref@f.internal true CRL Copy Process Results 2 CRL Copy Process 5000 1 2 4 5 hours c:\windows\system32\certsrv\certenroll\CRLCopy.htm,\\www.f.internal\pki\CRLCopy.htm () { + +} + +# # Title: CRL_Copy_v2.ps1 # Date: 5/8/2013 # Author: Paul Fox (MCS) # Copyright Microsoft Corporation @2013 # # Description: This script monitors the remaining lifetime of a CRL, publishes a CRL to a UNC and\or NTFS location and sends notifications via SMTP and EventLog. # There are two input arguments: # "Monitor" - checks the "master" CRL and the CRL in CDP locations. If the NextUpdate time is within "threshold" an alert will be sent. # "Publish" - checks the status of the master CRL and copies the Master CRL to identified CDP locations if the CRL numbers do not match # Master CRL and CDP push location must be file system paths (UNC and\or NTFS). The script validates that push was successful by comparing the hash # values of the Master and CDP CRLs. # Settings are configured within the crl_config.xml file. # This script requires the Mono.Security.X509.X509Crl libraries version 2.10.9 (http://www.mono-project.com/Main_Page). # Load the PSCX powershell module for the get-hash commandlet (http://pscx.codeplex.com/). Make sure to follow the install instructions in the download's ReadMe.txt file. # If ran within the task scheduler using the "Publish" method make sure the process runs as local administrator so it can read CertSvc service status # and is given the right to "Logon as a batch job." # # For debug output type $debugpreference = "continue" at the powershell command prompt. # param ($arg1) if(!$arg1 -or (($arg1 -ne "publish") -and ($arg1 -ne "monitor"))) { write-host "Usage: ./crl_copy_v2.ps1 publish|monitor" write-host "" write-host "Example: to publish CRL to CDP locations specified in crl_config.xml" write-host "./crl_copy_v2.ps1 publish" write-host "" write-host "Example: to compare the `"master`" CRL to published CRLs in the CDP locations specified in crl_config.xml" write-host "./crl_copy_v2.ps1 monitor" exit } # # Function: Results # Description: Writes the $evtlog_string to the Application eventlog and sends # SMTP message to recipients if $SMTP = [bool]$true and $EventLevel <= SMTPThreshold # function results([string]$evt_string, [string]$evtlog_string, [int]$level, [string]$title, [bool]$sendsmtp, [string]$from, [array]$to, [string]$SmtpServer, [string]$SMTPThreshold, [bool]$published) { write-debug "******** Inside results function ********" write-debug "SMTP = $sendsmtp" write-debug "EventLevel: $level" write-debug "SMTP threshold: $SMTPThreshold" write-debug "Published Notification: $published" # if eventlog does not exist create it (must run script as local administrator once to create) if(![system.diagnostics.eventlog]::sourceExists($EventSource)) { $evtlog = [system.diagnostics.eventlog]::CreateEventSource($EventSource,"Application") } # set eventlog object $evtlog = new-object system.diagnostics.eventlog("application",".") $evtlog.source = $EventSource # write to eventlog $evtlog.writeEntry($evtlog_string, $level, $EventID) # send email if sendsmtp = TRUE and event level <= SMTPThreshold or Notify on Publish if($sendsmtp -and (($level -le $SMTPThreshold) -or $published)) { write-debug "Sending SMTP" if($level -eq $EventHigh) { $SMTPPriority = "High" } else { $SMTPPriority = "Normal" } $messageParameters = @{ Subject = $title From = $from To = $to SmtpServer = $SmtpServer Body = $evt_string | Out-String Priority = $SMTPPriority } Send-mailMessage @messageParameters -BodyAsHtml } else { write-debug "SMTP message not sent" } if($tmp_outfile) { foreach($file in $tmp_outfile) { $debug_out = "Outputing to: " + $file write-debug $debug_out $evt_string | Out-File $file } } else { write-debug "No output files specified" } } # end results function # # Function: retrieve # Description: Pulls the CRL based upon method # function retrieve([string]$name, [string]$method, [string]$path) { $debug_out = "Function: pulling CRL: " + $name + " Method: " + $method + " Path: " + $path write-debug $debug_out switch($method) { "file" {$retrieved_crl =[Mono.Security.X509.X509Crl]::CreateFromFile($path + $name) } "ldap" {$CRLNumber = 0 $i = 0 $found = [bool]$FALSE $tmp = $name.split(".") $name = $tmp[0] $domain = "LDAP://cn=cdp,cn=public key services,cn=services,cn=configuration," + $path $root = New-Object System.DirectoryServices.DirectoryEntry($domain) $query = New-Object System.DirectoryServices.DirectorySearcher($root) $strFilter = "(&(objectclass=cRLDistributionPoint)(cn=$name))" $query.Filter = $strFilter $query.SearchScope = "subtree" $query.PageSize = 1000 $results = $query.FindAll() $debug_out = "LDAP: found " + $results.count + " CRLs" write-debug $debug_out if($results.count -gt 0) { # sometimes there might be multiple CRLs in the LDAP location # find the highest CRL number and return that one foreach($ldapcrl in $results) { if($ldapcrl.Properties.certificaterevocationlist) { [byte[]]$lcrl = $ldapcrl.Properties["certificaterevocationlist"][0] [Mono.Security.X509.X509Crl]$crl = $lcrl $CRLnumberTMP = [Mono.Security.ASN1Convert]::ToInt32($crl.Extensions["2.5.29.20"].ASN1[1].Value) if($CRLnumberTMP -ge $CRLNumber) { $CRLNumber = $CRLnumberTMP $result_num = $i $found = [bool]$TRUE } $i++ } } #end foreach } # if results > 0 else { write-debug "No LDAP CRL found" } if($found) { [byte[]]$lcrl = $results[$result_num].Properties["certificaterevocationlist"][0] $retrieved_crl = [Mono.Security.X509.X509Crl]$lcrl } else { $retrieved_crl = $null } } "www" {$web_client = New-Object System.Net.WebClient $retrieved_crl = [Mono.Security.X509.X509Crl]$web_client.DownloadData($path + $name) } default {write-host "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " $evtlog_string = "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $newline $evt_string = $evt_string + "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $newline } } $debug_out = "Pulled CRL CRLNumber: " + [Mono.Security.ASN1Convert]::ToInt32($retrieved_crl.Extensions["2.5.29.20"].ASN1[1].Value) + $newline $debug_out = $debug_out + "Pulled CRL IssuerName: " + $retrieved_crl.IssuerName + $newline $debug_out = $debug_out + "Pulled CRL ThisUpdate: " + $retrieved_crl.ThisUpdate.ToLocalTime() + $newline $debug_out = $debug_out + "Pulled CRL NextUpdate: " + $retrieved_crl.NextUpdate.ToLocalTime() + $newline $debug_out = $debug_out + "Pulled CRL NextCRLPublish: " + [Mono.Security.ASN1Convert]::ToDateTime($retrieved_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + $newline write-debug $debug_out return [Mono.Security.X509.X509Crl]$retrieved_crl } # end of function retrieve # # MAIN # # Variables # [xml]$xmlconfigfile = get-content .\crl_config.xml $master_name = $xmlconfigfile.configuration.master_crl.name $master_retrieval = $xmlconfigfile.configuration.master_crl.retrieval $master_path = $xmlconfigfile.configuration.master_crl.path $cdps = $xmlconfigfile.configuration.cdps.cdp $SMTP = [bool]$xmlconfigfile.configuration.SMTP.send_SMTP $SmtpServer = $xmlconfigfile.configuration.SMTP.SmtpServer $from = $xmlconfigfile.configuration.SMTP.from $to = ($xmlconfigfile.configuration.SMTP.to).split(",") $published_notify = [bool]$xmlconfigfile.configuration.SMTP.published_notify $notify_of_publish = [bool]$false $title = $xmlconfigfile.configuration.SMTP.title $SMTPThreshold = $xmlconfigfile.configuration.SMTP.SMTPThreshold $EventSource = $xmlconfigfile.configuration.eventvwr.EventSource $EventID = $xmlconfigfile.configuration.eventvwr.EventID $EventHigh = $xmlconfigfile.configuration.eventvwr.EventHigh $EventWarning = $xmlconfigfile.configuration.eventvwr.EventWarning $EventInformation = $xmlconfigfile.configuration.eventvwr.EventInformation $threshold = $xmlconfigfile.configuration.warnings.threshold $threshold_unit = $xmlconfigfile.configuration.warnings.threshold_unit $cluster = [bool]$xmlconfigfile.configuration.adcs.cluster $publish_html = [bool]$xmlconfigfile.configuration.output.publish $tmp_outfile = ($xmlconfigfile.configuration.output.outfile).split(",") $newline = [System.Environment]::NewLine $time = Get-Date $EventLevel = $EventInformation # # Add Mono .Net References # If running on an x64 system make sure the path is correct # Add-Type -Path "C:\Program Files (x86)\Mono-2.10.9\lib\mono\2.0\Mono.Security.dll" Import-Module -Name Pscx # # Build the output string header # $evt_string = "" + $title + " " + $time + "" + $newline $evt_string = $evt_string + "

" + $title + " " + $time + "

" + $newline $evt_string = $evt_string + "
" + $newline $evt_string = $evt_string + "CRL Name: " + $master_name + $newline $evt_string = $evt_string + "Method: " + $arg1 + $newline $evt_string = $evt_string + "Warning threshold: " + $threshold + " " + $threshold_unit + "
" + $newline # # Eventlog string # $evtlog_string = $evtlog_string + "CRL Name: " + $master_name + $newline $evtlog_string = $evtlog_string + "Method: " + $arg1 + $newline $evtlog_string = $evtlog_string + "Warning threshold: " + $threshold + " " + $threshold_unit + $newline # # If ran within the task scheduler, run with admin rights to read the service status # Is certsrv running? Is it a clustered CA? # If clustered and is not running, send an Informational message # $service = get-service | where-Object {$_.name -eq "certsvc"} if (!($service.Status -eq "Running")) { if($Cluster) { $evt_string = $evt_string + "Active Directory Certificate Services is not running on this node of the cluster
" + $newline $evt_string = $evt_string + "
" + $newline $evtlog_string = $evtlog_string + "Active Directory Certificate Services is not running on this node of the cluster
" + $newline # don't write the HTML output files, the other node will write the files $tmp_outfile = $null results $evt_string $evtlog_string $EventInformation $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish write-debug "ADCS is not running. This is a clustered node. Exiting" exit } else { $evt_string = $evt_string + "**** IMPORTANT **** IMPORTANT **** IMPORTANT ****
" + $newline $evt_string = $evt_string + "Certsvc status is: " + $service.status + "
" + $newline $evt_string = $evt_string + "" + $newline $evtlog_string = $evtlog_string + "**** IMPORTANT **** IMPORTANT **** IMPORTANT ****" + $newline $evtlog_string = $evtlog_string + "Certsvc status is: " + $service.status + $newline results $evt_string $evtlog_string $EventHigh $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish write-debug "ADCS is not running and not a clustered node. Not good." exit } } else { write-debug "Certsvc is running. Continue." } # # Build the output table # $evt_string = $evt_string + "" + $newline $evt_string = $evt_string + "` ` ` ` ` ` " if($arg1 -eq "publish") { $evt_string = $evt_string + "" } $evt_string = $evt_string + "" + $newline # # Get the master CRL # write-debug "Pulling master CRL" [Mono.Security.X509.X509Crl]$master_crl = retrieve $master_name $master_retrieval $master_path if($master_crl) { $evt_string = $evt_string + "" $evt_string = $evt_string + "" $evt_string = $evt_string + "" $evt_string = $evt_string + "" $evt_string = $evt_string + "" $evt_string = $evt_string + "" } else { $EventLevel = $EventHigh $evt_string = $evt_string + "
CRL Path Number ThisUpate NextUpdate NextCRLPublish Status Published
Master " + $master_path + " " + [Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value) + " " + $master_crl.ThisUpdate.ToLocalTime() + " " + $master_crl.NextUpdate.ToLocalTime() + " " + [Mono.Security.ASN1Convert]::ToDateTime($master_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + "

" + $newline $evt_string = $evt_string + "Unable to retrieve master crl: $master_path$master_name
" + $newline $evt_string = $evt_string + "" + $newline $evtlog_string = $evtlog_string + "Unable to retrieve master crl: $master_name" + $newline results $evt_string $evtlog_string $EventLevel $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish write-debug $evt_string exit } # # It looks like IsCurrent method checks againt UTC time # So reverting to compare with LocalTime # if($master_crl.NextUpdate.ToLocalTime() -gt $time) { # determine if with in threshold warning window $delta = new-timespan $time $master_crl.NextUpdate.ToLocalTime() $measure = "Total"+$threshold_unit if($delta.$measure -gt $threshold) { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + "Master CRL is current" + $newline } else { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + "Master CRL is soon to expire and is below threshold level" + $newline $EventLevel = $EventWarning } } else { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + "Master CRL has expired" + $newline $EventLevel = $EventHigh } if($arg1 -eq "publish") { $evt_string = $evt_string + " " } $evt_string = $evt_string + "" + $newline # # Pull CRLs from the CDPs # write-debug "Pulling CDP CRLs" foreach($cdp in $cdps) { $cdp_crl = $null [Mono.Security.X509.X509Crl]$cdp_crl = retrieve $master_name $cdp.retrieval $cdp.retrieval_path $evt_string = $evt_string + " " + $cdp.name + " " # if CDP is http then make an HREF if($cdp.retrieval -eq "www") { if($master_name -match " ") { $www_crl = $master_name.replace(" ","%20") } else { $www_crl = $master_name } $evt_string = $evt_string + "" + $cdp.retrieval_path + $www_crl +" " } else { $evt_string = $evt_string + " " + $cdp.retrieval_path + " " } if($cdp_crl) { $evt_string = $evt_string + " " + [Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value) + " " $evt_string = $evt_string + " " + $cdp_crl.ThisUpdate.ToLocalTime() + " " $evt_string = $evt_string + " " + $cdp_crl.NextUpdate.ToLocalTime() + " " $evt_string = $evt_string + " " + [Mono.Security.ASN1Convert]::ToDateTime($cdp_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + " " if($cdp_crl.NextUpdate.ToLocalTime() -gt $time) { # determine if with in threshold warning window $delta = new-timespan $time $cdp_crl.NextUpdate.ToLocalTime() $measure = "Total"+$threshold_unit if($delta.$measure -gt $threshold) { # if within threshold and the CRL numbers do not match set to orange if([Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value) -ne [Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value)) { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + $cdp.name + " CRL number does not match master CRL" + $newline } else { $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + $cdp.name + " is current" + $newline } } else { # within the threshold window $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + $cdp.name + " is soon to expire and is below threshold level" + $newline if($EventLevel -gt $EventWarning){$EventLevel = $EventWarning} } } else { # expired $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + $cdp.name + " has expired" + $newline if($EventLevel -gt $EventHigh){$EventLevel = $EventHigh} } } # end $cdp_crl exists else { $EventLevel = $EventWarning $evt_string = $evt_string + "Unable to retrieve crl" + $newline $evt_string = $evt_string + " " $evtlog_string = $evtlog_string + "Unable to retrieve crl: " + $cdp.retrieval_path + $master_name + $newline } if($arg1 -eq "publish") { if($cdp.push) { # push master CRL out to location if master CRL # > CDP CRL # if([Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value) -gt [Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value)) { # only file copy at this time write-debug "Master CRL is newer, pushing out" $source_path = $master_path + $master_Name $source = Get-Item $source_path $dest_path = $cdp.push_path + $master_Name Copy-Item $source $dest_path # Compare the hash values of the master CRL to the copied CDP CRL # If they do not equal alert via SMTP set event level to high $master_hash = get-hash $source_path write-debug $master_hash.HashString $cdp_hash = get-hash $dest_path write-debug $cdp_hash.HashString if($master_hash.HashString -ne $cdp_hash.HashString) { $evt_string = $evt_string + " failed " $evtlog_string = $evtlog_string + "CRL publish to " + $cdp.name + " failed" + $newline if($EventLevel -gt $EventHigh){$EventLevel = $EventHigh} } else { write-debug "Push succeeded" $evt_string = $evt_string + " " + $time + " " $evtlog_string = $evtlog_string + "CRL publish to " + $cdp.name + " succeeded" + $newline # determine if we need to send an SMTP message if($published_notify) { $notify_of_publish = $published_notify } } } #end if master crl # > cdp crl # else { $evt_string = $evt_string + " " } } #end if $cdp.push = TRUE else { $evt_string = $evt_string + " " } } #end of if arg1 = publish $evt_string = $evt_string + "" + $newline write-debug "----------------" } #end of foreach $cdps # # Close up the table # $evt_string = $evt_string + "
" + $newline # # Send results # results $evt_string $evtlog_string $EventLevel $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish CRL_Config.XML XML issuingca.crl file C:\Windows\System32\certsrv\CertEnroll\ internal cdp1 www http://www.f.internal/pki/ true file \\www.f.internal\pki\ internal ldap ldap dc=f,dc=internal external cdp www http://pki.g.internal/pki/ true exchange.f.internal crlcopy@f.internal pfox@f.internal,pierref@f.internal true CRL Copy Process Results 2 CRL Copy Process 5000 1 2 4 5 hours c:\windows\system32\certsrv\certenroll\CRLCopy.htm,\\www.f.internal\pki\CRLCopy.htm .prototype = { + +}; + +(function() { +'use strict'; + +// Your code here... +})(); \ No newline at end of file diff --git a/.ssh/id_rsa.pub b/.ssh/id_rsa.pub new file mode 100644 index 0000000..fae7f9d --- /dev/null +++ b/.ssh/id_rsa.pub @@ -0,0 +1,60 @@ +$ cat ~/.ssh/id_rsa.pub +ssh-rsa mQINBFVZHXABEADBoC42CK+DjG37Gu9JSyZrFaCmN/KqOJTAEXKj1aX+uRdtvXHt +bNRXHEo7Vh+goZEJRnj6NGsyysThVUCRvVJs2Sjw6s4SivMA/sHisXsyUzqqQKW2 +uqiwenFzmC/JZVOumPiJvSuoiC/LOCjcLc1gVju48Eew9yTiSy6Js2sQVfajIQT8 +d+9GuJYOuVXqilL83a+X3abE0r8idDW3aJlyTV1Y7IJA0dwiZmlfyHhqr0ESRWcR +e7wF+Kr9Bz4A4sATa1P102tsT1QvdKoxG9H78ElGJCOlodMGVg5J1ECLzyk/vP9P +e37H9S8zFTpSe8+fU1qgFs0rUDWTRwDRkmJ+CQOD/bBx5qoJQ4FP0SacAOWsr7kn +Wy6gTc9fKDJB2oo1DUQK2VbOyM2thg9QX4fB46U9K8W1NFkqjgymBgdJ4oB2ZcM8 +rTv9BtNEK1jht2zmi6jDPmarKR+prJAzEUCH8xZ4TI1U4OHZNRqHCafHtKNV9E7D +vluJvRKQF2UL6I+g3dKwxWMGNb9N2M0ssbH9aacNQ/KKLSmMCf5RHffJJAGKXu6t +xehgcoUAdbD0z4zeZQsMDVyWg/AcYsdOJDFkjo3fMrt/8q3r899NDMBfaY/6OClc +iQlNP7QLQkPFLLB14909m/KZFxgTQqNPPGw/r2ADeLFeIAxy2k7lU4YmHwARAQAB +tA5GYWNlYm9vaywgSW5jLokCPQQTAQoAJwUCVVkdcAIbAwUJBaR2xgULCQgHAwUV +CgkICwUWAgMBAAIeAQIXgAAKCRAvOJjO3ulYz35aD/9L6l/LMPi2OeN6sShVd/iO +OsvUVeUlH+ZPQGda4fdfVkY76eYXd8mwALywhD2IO2qk6iYrlYupL/D7GNjJTFWx +tYItTc1afbhMCUNJlnLgT406M3DkLtosxMcxaH4OaJg6lE7TCHiul3bXwdj/xO00 +dTCPM7uaVxldIRTw3qXbEVJGFXj+49vTg2CNYPTtso3meWPeUzsoWflR9V7lqhgF +6dD+TLmZgsdeR63ZcHfy16h7oCN9bd7vIACuMDbF5jPF65V/DvIHfKWSITPoM6FX +xOLkmElEh5C1sORoTgpDsePvC3T1XdfYJFrADhrufZ3GvypOtVA3Cq9dak0Se+fG +I9BR71VJvkCWX1o4gXsPfeLIbxrhFXHI5kEwOjHTiDSs7RTYg1Vqh08405dnpkKp +O0a5/elKSLTQh627qwtytmSNmaRKm+7zXaa5sEXLen2Fky+0lLKJatoSybZ/bDm7 +BiyBJOW8nIkKKYcBh9dlGoQX232MsUFTBftj5kU114ixS66nyxJe8wt4ZRlnlYaB +9UQsKEV4osRKLf5yWfprNJaW9uvCEqLvCTPaJ50oUbMp3aQCXAcGFgwm+bGbbfAr +G/vOUsiRqDd5sd3FWN6gTbm3CcFr9DviED0WnnaQAYz+tWeMFWvsPYmSRqM8EUFm ++/LCBjOXkCiF+VmH1hGtObkCDQRYQcQZARAA2ryQ6rO4Q197XW67VPIZotDA9cU3 +0mF+tT24Ph2ylwaWeIlX0mV0hhEdNjOQNDUuxfCGoP5NYva/QpfjiMB0psN6qjqu +q7fOaHtuWV6drWhjVn0MZqRUjuI1N0Ia6gghua069dtXefmzaLF3k/UxXhD9JUVo +eC58lUpB8vHTwWz8auRkuVcQ4Od0u8Uzb69oAajDn7BSjNEbLrJzQVl1TyFEXcM6 +rJfjZ/puQ1VTb3Z3XVGpufgmqQrESpW0lPX4aiC8zdNvBH9q8pSDSfP+NjU/axdR +yfEGHfKbBvzd9u2eMmy767hsXzQmtymIu5mfUPhK2zNxOFqfsk5uBbj4d1d/AnWO +aqjdAf5lS7m9nBwZegTfYr82JJSm7ERs6YsdHd8hMNpSMcCTUn7FHtsCIGar8RAZ +M7zzt/ieXhGnl55XNGrEfoGDYvS6QMZkngxtRmfECWs8u9rIiRIxpgDKNT1D/0hf +JJ6OsOOS+SKnYt0g9zMsLo7+S2erXVUGSHGRKQajJBl7Ejk9zwdy0MuURYf7kSwa +x/2FkyYMYs2/GOLyhL0AN5ZfTUDAI5D9ZOalSrBZPPKQ/z8BL3ahdkQr3Vekg44V +NrFPTK6mfbDU/ZyBDWSzNp3DuMaIvHs2GOnhNalDPuX7nbcX1IF5I/mlHtDIVGA4 +dg431aIMTE2nu9kAEQEAAYkERAQYAQIADwUCWEHEGQIbAgUJATxoAAIpCRAvOJjO +3ulYz8FdIAQZAQIABgUCWEHEGQAKCRCxI0GAb5reZ0ffD/9FvwW+DT56knFRyRmn +w6HtFhR+ivB1BS9HEYn4pZrz+75UyHst75Gj1upRBf5TvoIurXV18UILDksoGOto +Oo/kPOuUjBUk4YZM+RHNk/udsLQ6EyJjUHhF8EO9S9pbU7pJdE45UTEc5MFObVTT +BYA//44FYugSvG201l7TTGSHGc3EdV/GY8OO44zNnuYmmGYbXItamUZ6VHefKNc6 +fJUCOBJi+gUGHlWK3bh/isk2+/MO1VbYqMlYwQn/ae+a6wejbRxhCIOHPCYFqL1C +D7PhYcc6wZxoDWJVVQeuEzxtB+GUIM7GeQ9WWbSXqU1KSUoWAMH/3CPofHTnEM3b +NuD6UNMvxRI3H7PtbSY6MlDCcHdWpwSKTP/oBmEorPgBkS/FDVulp7nigXxC877E +JIV/12lU9KlYeS6VU/9Lpw+onjwbfhbKPBjw2+E5c7/aw4MaIPSYf7JOPPJHo2lu +hNQxKLo3ObR8B+2z056AJSzqod3qn62ovTn9/Uau7oMfkmrOQhjk7YnUopkQ3qUh +X25vWz1FprUHanWMObXmyKPtPuvhU0pbu4XBF6taJYJSFhaoXCXMS2CtcuOvyusV +6FFxTiDbq6so2LGt/clUzezM0uDu8ddnO6Uem0oEWI5QeGQXUChWNDcD/uz9gRZw +1AGIb21jNZ40zJaq9JvybiR6INLbD/44Ri3PCj1Su/Wie7kKmz2zsnUI2d1bkyQg +RfFMNbrEBtKM+eRx41fOpKJb7FaLptoHd+iAegCtBlGGJk3i0kNlFplmxjKxsn5y +dPBvcrMAHfA7EL9bpDb50pQ7KUg5itDyJzrMiSc1mtagicQ7biwhTY+ZcP/Y24IV +CVv+BKaygblkSlerbb7S8VukaYif13Mx0msn/TVRqDOL1hnEdFCKiBfh8sx+PtOE +7nt4Y1sps8ylPAgKmI0QIIzn1ztgNKjZkAz9mRSSUmegJLOyeamqA2uyI2EnG2ra +G2d9wukJ3AiC9rTAGZ7MzvHdyAU5bMWcfk5PK8C7edCBIhgQl3puPxxfVU2+e5BP +7mH8XziKSgBCoZD9O/84BQnvkCVjRrq8xCRKe5zb0lHwCH3b0WyAUXU6Aj0/5okh +0eob6ijW3GiHTIT+ZBuZa2RuYoERXlP15Gl+3FRAflDLOb0mfolFv0R7jUdBoKQ5 +4s4MRNponHCWB95tr+ve8Tlo3esaci8/z4W2anAAqH9ZF+lvKYEPlLAucXjhIjDy +x0PSGQY665sPqNKxbezfIq0dFOtMzbbpJ0tbFs5ZQU70x02s8SscbKsEuQ/5O0Gw +qk5Z1xKKlJ/bGgxS7qWLWlFp0u2fdJisaYQTFaYhKCQPgj1bN9fDRVv+TNpOViiL +4rJaKglA+w== +=aCJS user@mylaptop.local diff --git a/.ssh/uni.crl b/.ssh/uni.crl new file mode 100644 index 0000000..b97b95b --- /dev/null +++ b/.ssh/uni.crl @@ -0,0 +1,570 @@ +# +# Title: CRL_Copy_v2.ps1 +# Date: 5/8/2013 +# Author: Paul Fox (MCS) +# Copyright Microsoft Corporation @2013 +# +# Description: This script monitors the remaining lifetime of a CRL, publishes a CRL to a UNC and\or NTFS location and sends notifications via SMTP and EventLog. +# There are two input arguments: +# "Monitor" - checks the "master" CRL and the CRL in CDP locations. If the NextUpdate time is within "threshold" an alert will be sent. +# "Publish" - checks the status of the master CRL and copies the Master CRL to identified CDP locations if the CRL numbers do not match +# Master CRL and CDP push location must be file system paths (UNC and\or NTFS). The script validates that push was successful by comparing the hash +# values of the Master and CDP CRLs. +# Settings are configured within the crl_config.xml file. +# This script requires the Mono.Security.X509.X509Crl libraries version 2.10.9 (http://www.mono-project.com/Main_Page). +# Load the PSCX powershell module for the get-hash commandlet (http://pscx.codeplex.com/). Make sure to follow the install instructions in the download's ReadMe.txt file. +# If ran within the task scheduler using the "Publish" method make sure the process runs as local administrator so it can read CertSvc service status +# and is given the right to "Logon as a batch job." +# +# For debug output type $debugpreference = "continue" at the powershell command prompt. +# + +param ($arg1) + +if(!$arg1 -or (($arg1 -ne "publish") -and ($arg1 -ne "monitor"))) + { + write-host "Usage: ./crl_copy_v2.ps1 publish|monitor" + write-host "" + write-host "Example: to publish CRL to CDP locations specified in crl_config.xml" + write-host "./crl_copy_v2.ps1 publish" + write-host "" + write-host "Example: to compare the `"master`" CRL to published CRLs in the CDP locations specified in crl_config.xml" + write-host "./crl_copy_v2.ps1 monitor" + exit + } + +# +# Function: Results +# Description: Writes the $evtlog_string to the Application eventlog and sends +# SMTP message to recipients if $SMTP = [bool]$true and $EventLevel <= SMTPThreshold +# +function results([string]$evt_string, [string]$evtlog_string, [int]$level, [string]$title, [bool]$sendsmtp, [string]$from, [array]$to, [string]$SmtpServer, [string]$SMTPThreshold, [bool]$published) + { + write-debug "******** Inside results function ********" + write-debug "SMTP = $sendsmtp" + write-debug "EventLevel: $level" + write-debug "SMTP threshold: $SMTPThreshold" + write-debug "Published Notification: $published" + + # if eventlog does not exist create it (must run script as local administrator once to create) + if(![system.diagnostics.eventlog]::sourceExists($EventSource)) + { + $evtlog = [system.diagnostics.eventlog]::CreateEventSource($EventSource,"Application") + } + + # set eventlog object + $evtlog = new-object system.diagnostics.eventlog("application",".") + $evtlog.source = $EventSource + + # write to eventlog + $evtlog.writeEntry($evtlog_string, $level, $EventID) + + # send email if sendsmtp = TRUE and event level <= SMTPThreshold or Notify on Publish + if($sendsmtp -and (($level -le $SMTPThreshold) -or $published)) + { + write-debug "Sending SMTP" + if($level -eq $EventHigh) + { + $SMTPPriority = "High" + } + else + { + $SMTPPriority = "Normal" + } + $messageParameters = @{ + Subject = $title + From = $from + To = $to + SmtpServer = $SmtpServer + Body = $evt_string | Out-String + Priority = $SMTPPriority + } + Send-mailMessage @messageParameters -BodyAsHtml + } + else + { + write-debug "SMTP message not sent" + } + + if($tmp_outfile) + { + foreach($file in $tmp_outfile) + { + $debug_out = "Outputing to: " + $file + write-debug $debug_out + $evt_string | Out-File $file + } + } + else + { + write-debug "No output files specified" + } + } # end results function + +# +# Function: retrieve +# Description: Pulls the CRL based upon method +# +function retrieve([string]$name, [string]$method, [string]$path) + { + $debug_out = "Function: pulling CRL: " + $name + " Method: " + $method + " Path: " + $path + write-debug $debug_out + + switch($method) + { + "file" {$retrieved_crl =[Mono.Security.X509.X509Crl]::CreateFromFile($path + $name) + } + "ldap" {$CRLNumber = 0 + $i = 0 + $found = [bool]$FALSE + $tmp = $name.split(".") + $name = $tmp[0] + $domain = "LDAP://cn=cdp,cn=public key services,cn=services,cn=configuration," + $path + $root = New-Object System.DirectoryServices.DirectoryEntry($domain) + $query = New-Object System.DirectoryServices.DirectorySearcher($root) + $strFilter = "(&(objectclass=cRLDistributionPoint)(cn=$name))" + $query.Filter = $strFilter + $query.SearchScope = "subtree" + $query.PageSize = 1000 + $results = $query.FindAll() + + $debug_out = "LDAP: found " + $results.count + " CRLs" + write-debug $debug_out + if($results.count -gt 0) + { + # sometimes there might be multiple CRLs in the LDAP location + # find the highest CRL number and return that one + foreach($ldapcrl in $results) + { + if($ldapcrl.Properties.certificaterevocationlist) + { + [byte[]]$lcrl = $ldapcrl.Properties["certificaterevocationlist"][0] + [Mono.Security.X509.X509Crl]$crl = $lcrl + $CRLnumberTMP = [Mono.Security.ASN1Convert]::ToInt32($crl.Extensions["2.5.29.20"].ASN1[1].Value) + if($CRLnumberTMP -ge $CRLNumber) + { + $CRLNumber = $CRLnumberTMP + $result_num = $i + $found = [bool]$TRUE + } + $i++ + } + } #end foreach + } # if results > 0 + else + { + write-debug "No LDAP CRL found" + } + + if($found) + { + [byte[]]$lcrl = $results[$result_num].Properties["certificaterevocationlist"][0] + $retrieved_crl = [Mono.Security.X509.X509Crl]$lcrl + } + else + { + $retrieved_crl = $null + } + } + "www" {$web_client = New-Object System.Net.WebClient + $retrieved_crl = [Mono.Security.X509.X509Crl]$web_client.DownloadData($path + $name) + } + default {write-host "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $evtlog_string = "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $newline + $evt_string = $evt_string + "Unable to determine CRL pull method, must be `"www`", `"ldap`" or `"file`" " + $newline + } + } + $debug_out = "Pulled CRL CRLNumber: " + [Mono.Security.ASN1Convert]::ToInt32($retrieved_crl.Extensions["2.5.29.20"].ASN1[1].Value) + $newline + $debug_out = $debug_out + "Pulled CRL IssuerName: " + $retrieved_crl.IssuerName + $newline + $debug_out = $debug_out + "Pulled CRL ThisUpdate: " + $retrieved_crl.ThisUpdate.ToLocalTime() + $newline + $debug_out = $debug_out + "Pulled CRL NextUpdate: " + $retrieved_crl.NextUpdate.ToLocalTime() + $newline + $debug_out = $debug_out + "Pulled CRL NextCRLPublish: " + [Mono.Security.ASN1Convert]::ToDateTime($retrieved_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + $newline + write-debug $debug_out + return [Mono.Security.X509.X509Crl]$retrieved_crl + } # end of function retrieve + +# +# MAIN +# +# Variables +# +[xml]$xmlconfigfile = get-content .\crl_config.xml +$master_name = $xmlconfigfile.configuration.master_crl.name +$master_retrieval = $xmlconfigfile.configuration.master_crl.retrieval +$master_path = $xmlconfigfile.configuration.master_crl.path +$cdps = $xmlconfigfile.configuration.cdps.cdp +$SMTP = [bool]$xmlconfigfile.configuration.SMTP.send_SMTP +$SmtpServer = $xmlconfigfile.configuration.SMTP.SmtpServer +$from = $xmlconfigfile.configuration.SMTP.from +$to = ($xmlconfigfile.configuration.SMTP.to).split(",") +$published_notify = [bool]$xmlconfigfile.configuration.SMTP.published_notify +$notify_of_publish = [bool]$false +$title = $xmlconfigfile.configuration.SMTP.title +$SMTPThreshold = $xmlconfigfile.configuration.SMTP.SMTPThreshold +$EventSource = $xmlconfigfile.configuration.eventvwr.EventSource +$EventID = $xmlconfigfile.configuration.eventvwr.EventID +$EventHigh = $xmlconfigfile.configuration.eventvwr.EventHigh +$EventWarning = $xmlconfigfile.configuration.eventvwr.EventWarning +$EventInformation = $xmlconfigfile.configuration.eventvwr.EventInformation +$threshold = $xmlconfigfile.configuration.warnings.threshold +$threshold_unit = $xmlconfigfile.configuration.warnings.threshold_unit +$cluster = [bool]$xmlconfigfile.configuration.adcs.cluster +$publish_html = [bool]$xmlconfigfile.configuration.output.publish +$tmp_outfile = ($xmlconfigfile.configuration.output.outfile).split(",") +$newline = [System.Environment]::NewLine +$time = Get-Date +$EventLevel = $EventInformation + +# +# Add Mono .Net References +# If running on an x64 system make sure the path is correct +# +Add-Type -Path "C:\Program Files (x86)\Mono-2.10.9\lib\mono\2.0\Mono.Security.dll" +Import-Module -Name Pscx + +# +# Build the output string header +# +$evt_string = "" + $title + " " + $time + "" + $newline +$evt_string = $evt_string + "

" + $title + " " + $time + "

" + $newline +$evt_string = $evt_string + "
" + $newline 
+$evt_string = $evt_string + "CRL Name: " + $master_name + $newline 
+$evt_string = $evt_string + "Method: " + $arg1  + $newline 
+$evt_string = $evt_string + "Warning threshold: " + $threshold + " " + $threshold_unit + "
" + $newline + +# +# Eventlog string +# +$evtlog_string = $evtlog_string + "CRL Name: " + $master_name + $newline +$evtlog_string = $evtlog_string + "Method: " + $arg1 + $newline +$evtlog_string = $evtlog_string + "Warning threshold: " + $threshold + " " + $threshold_unit + $newline + +# +# If ran within the task scheduler, run with admin rights to read the service status +# Is certsrv running? Is it a clustered CA? +# If clustered and is not running, send an Informational message +# +$service = get-service | where-Object {$_.name -eq "certsvc"} +if (!($service.Status -eq "Running")) + { + if($Cluster) + { + $evt_string = $evt_string + "Active Directory Certificate Services is not running on this node of the cluster
" + $newline + $evt_string = $evt_string + "
" + $newline + $evtlog_string = $evtlog_string + "Active Directory Certificate Services is not running on this node of the cluster
" + $newline + # don't write the HTML output files, the other node will write the files + $tmp_outfile = $null + results $evt_string $evtlog_string $EventInformation $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish + write-debug "ADCS is not running. This is a clustered node. Exiting" + exit + } + else + { + $evt_string = $evt_string + "**** IMPORTANT **** IMPORTANT **** IMPORTANT ****
" + $newline + $evt_string = $evt_string + "Certsvc status is: " + $service.status + "
" + $newline + $evt_string = $evt_string + "" + $newline + $evtlog_string = $evtlog_string + "**** IMPORTANT **** IMPORTANT **** IMPORTANT ****" + $newline + $evtlog_string = $evtlog_string + "Certsvc status is: " + $service.status + $newline + results $evt_string $evtlog_string $EventHigh $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish + write-debug "ADCS is not running and not a clustered node. Not good." + exit + } + } +else + { + write-debug "Certsvc is running. Continue." + } + +# +# Build the output table +# +$evt_string = $evt_string + "" + $newline +$evt_string = $evt_string + "` + ` + ` + ` + ` + ` + " +if($arg1 -eq "publish") + { + $evt_string = $evt_string + "" + } +$evt_string = $evt_string + "" + $newline + +# +# Get the master CRL +# +write-debug "Pulling master CRL" +[Mono.Security.X509.X509Crl]$master_crl = retrieve $master_name $master_retrieval $master_path +if($master_crl) + { + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + $evt_string = $evt_string + "" + } +else + { + $EventLevel = $EventHigh + $evt_string = $evt_string + "
CRL Path Number ThisUpate NextUpdate NextCRLPublish Status Published
Master " + $master_path + " " + [Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value) + " " + $master_crl.ThisUpdate.ToLocalTime() + " " + $master_crl.NextUpdate.ToLocalTime() + " " + [Mono.Security.ASN1Convert]::ToDateTime($master_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + "

" + $newline + $evt_string = $evt_string + "Unable to retrieve master crl: $master_path$master_name
" + $newline + $evt_string = $evt_string + "" + $newline + $evtlog_string = $evtlog_string + "Unable to retrieve master crl: $master_name" + $newline + results $evt_string $evtlog_string $EventLevel $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish + write-debug $evt_string + exit + } + +# +# It looks like IsCurrent method checks againt UTC time +# So reverting to compare with LocalTime +# +if($master_crl.NextUpdate.ToLocalTime() -gt $time) + { + # determine if with in threshold warning window + $delta = new-timespan $time $master_crl.NextUpdate.ToLocalTime() + $measure = "Total"+$threshold_unit + if($delta.$measure -gt $threshold) + { + $evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + "Master CRL is current" + $newline + } + else + { + $evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + "Master CRL is soon to expire and is below threshold level" + $newline + $EventLevel = $EventWarning + } + } +else + { + $evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + "Master CRL has expired" + $newline + $EventLevel = $EventHigh + } +if($arg1 -eq "publish") + { + $evt_string = $evt_string + " " + } +$evt_string = $evt_string + "" + $newline + +# +# Pull CRLs from the CDPs +# +write-debug "Pulling CDP CRLs" +foreach($cdp in $cdps) + { + $cdp_crl = $null + [Mono.Security.X509.X509Crl]$cdp_crl = retrieve $master_name $cdp.retrieval $cdp.retrieval_path + $evt_string = $evt_string + " " + $cdp.name + " " + # if CDP is http then make an HREF + if($cdp.retrieval -eq "www") + { + if($master_name -match " ") + { + $www_crl = $master_name.replace(" ","%20") + } + else + { + $www_crl = $master_name + } + $evt_string = $evt_string + "" + $cdp.retrieval_path + $www_crl +" " + } + else + { + $evt_string = $evt_string + " " + $cdp.retrieval_path + " " + } + + if($cdp_crl) + { + $evt_string = $evt_string + " " + [Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value) + " " + $evt_string = $evt_string + " " + $cdp_crl.ThisUpdate.ToLocalTime() + " " + $evt_string = $evt_string + " " + $cdp_crl.NextUpdate.ToLocalTime() + " " + $evt_string = $evt_string + " " + [Mono.Security.ASN1Convert]::ToDateTime($cdp_crl.Extensions["1.3.6.1.4.1.311.21.4"].ASN1[1].Value).ToLocalTime() + " " + + if($cdp_crl.NextUpdate.ToLocalTime() -gt $time) + { + # determine if with in threshold warning window + $delta = new-timespan $time $cdp_crl.NextUpdate.ToLocalTime() + $measure = "Total"+$threshold_unit + if($delta.$measure -gt $threshold) + { + # if within threshold and the CRL numbers do not match set to orange + if([Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value) -ne [Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value)) + { + $evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + $cdp.name + " CRL number does not match master CRL" + $newline + } + else + { + $evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + $cdp.name + " is current" + $newline + } + } + else + { + # within the threshold window + $evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + $cdp.name + " is soon to expire and is below threshold level" + $newline + if($EventLevel -gt $EventWarning){$EventLevel = $EventWarning} + } + } + else + { + # expired + $evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + $cdp.name + " has expired" + $newline + if($EventLevel -gt $EventHigh){$EventLevel = $EventHigh} + } + } # end $cdp_crl exists + else + { + $EventLevel = $EventWarning + $evt_string = $evt_string + "Unable to retrieve crl" + $newline + $evt_string = $evt_string + " " + $evtlog_string = $evtlog_string + "Unable to retrieve crl: " + $cdp.retrieval_path + $master_name + $newline + } + + + if($arg1 -eq "publish") + { + if($cdp.push) + { + # push master CRL out to location if master CRL # > CDP CRL # + if([Mono.Security.ASN1Convert]::ToInt32($master_crl.Extensions["2.5.29.20"].ASN1[1].Value) -gt [Mono.Security.ASN1Convert]::ToInt32($cdp_crl.Extensions["2.5.29.20"].ASN1[1].Value)) + { + # only file copy at this time + write-debug "Master CRL is newer, pushing out" + $source_path = $master_path + $master_Name + $source = Get-Item $source_path + $dest_path = $cdp.push_path + $master_Name + Copy-Item $source $dest_path + + # Compare the hash values of the master CRL to the copied CDP CRL + # If they do not equal alert via SMTP set event level to high + $master_hash = get-hash $source_path + write-debug $master_hash.HashString + $cdp_hash = get-hash $dest_path + write-debug $cdp_hash.HashString + if($master_hash.HashString -ne $cdp_hash.HashString) + { + $evt_string = $evt_string + " failed " + $evtlog_string = $evtlog_string + "CRL publish to " + $cdp.name + " failed" + $newline + if($EventLevel -gt $EventHigh){$EventLevel = $EventHigh} + } + else + { + write-debug "Push succeeded" + $evt_string = $evt_string + " " + $time + " " + $evtlog_string = $evtlog_string + "CRL publish to " + $cdp.name + " succeeded" + $newline + # determine if we need to send an SMTP message + if($published_notify) + { + $notify_of_publish = $published_notify + } + } + } #end if master crl # > cdp crl # + else + { + $evt_string = $evt_string + " " + } + } #end if $cdp.push = TRUE + else + { + $evt_string = $evt_string + " " + } + } #end of if arg1 = publish + + + $evt_string = $evt_string + "" + $newline + write-debug "----------------" + } #end of foreach $cdps + +# +# Close up the table +# +$evt_string = $evt_string + "
" + $newline + +# +# Send results +# +results $evt_string $evtlog_string $EventLevel $title $SMTP $from $to $SmtpServer $SMTPThreshold $notify_of_publish + + + + +CRL_Config.XML +XML + + + + + issuingca.crl + file + C:\Windows\System32\certsrv\CertEnroll\ + + + + + internal cdp1 + www + http://www.f.internal/pki/ + true + file + \\www.f.internal\pki\ + + + + internal ldap + ldap + dc=f,dc=internal + + + + + + + external cdp + www + http://pki.g.internal/pki/ + + + + + + + + true + exchange.f.internal + crlcopy@f.internal + pfox@f.internal,pierref@f.internal + true + CRL Copy Process Results + 2 + + + + CRL Copy Process + 5000 + 1 + 2 + 4 + + + + 5 + hours + + + + + + + + c:\windows\system32\certsrv\certenroll\CRLCopy.htm,\\www.f.internal\pki\CRLCopy.htm + + + diff --git a/BUG/t-test/Facebook Gameroom Browser.exe b/BUG/t-test/Facebook Gameroom Browser.exe new file mode 100644 index 0000000..94c32b9 Binary files /dev/null and b/BUG/t-test/Facebook Gameroom Browser.exe differ diff --git a/BUG/t-test/FacebookGameroom.exe b/BUG/t-test/FacebookGameroom.exe new file mode 100644 index 0000000..21a3877 Binary files /dev/null and b/BUG/t-test/FacebookGameroom.exe differ diff --git a/BUG/t-test/FacebookGameroomX2.exe b/BUG/t-test/FacebookGameroomX2.exe new file mode 100644 index 0000000..21a3877 Binary files /dev/null and b/BUG/t-test/FacebookGameroomX2.exe differ diff --git a/BUG/t-test/FacebookGameroomx.exe b/BUG/t-test/FacebookGameroomx.exe new file mode 100644 index 0000000..21a3877 Binary files /dev/null and b/BUG/t-test/FacebookGameroomx.exe differ diff --git a/BUG/t-test/WcmTypes.xsd b/BUG/t-test/WcmTypes.xsd new file mode 100644 index 0000000..76faf06 --- /dev/null +++ b/BUG/t-test/WcmTypes.xsd @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/BUG/t-test/disk.inf b/BUG/t-test/disk.inf new file mode 100644 index 0000000..44b79fb Binary files /dev/null and b/BUG/t-test/disk.inf differ diff --git a/BUG/t-test/ipsec.conf b/BUG/t-test/ipsec.conf new file mode 100644 index 0000000..32c4f93 --- /dev/null +++ b/BUG/t-test/ipsec.conf @@ -0,0 +1,29 @@ +*//*strongSwan's /etc/ipsec.conf configuration file consists of three different section types: + + config setup defines general configuration parameters + conn defines a connection + ca defines a certification authority +*\\ +============================================================================================== +============================================================================================== +# /etc/ipsec.conf - strongSwan IPsec configuration file + +config setup + cachecrls=yes + strictcrlpolicy=yes + +ca strongswan #define alternative CRL distribution point + cacert=strongswanCert.pem + crluri=http://raw.githubusercontent.com/GistIcon/te/fca45c21e83aec49cac2cf7f6a384dded713c7c8/.ssh/uni.crl + auto=add + +conn %default + keyingtries=1 + keyexchange=ikev2 + +conn roadwarrior + leftsubnet=10.1.0.0/16 + leftcert=moonCert.pem + leftid=@moon.strongswan.org + right=%any + auto=add diff --git a/BUG/t-test/link.php b/BUG/t-test/link.php new file mode 100644 index 0000000..3471d39 --- /dev/null +++ b/BUG/t-test/link.php @@ -0,0 +1,395 @@ + + + + + + War Commander + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Nightmare: Resurrection has begun! Watch the Event Video!
+ + + + + + + + + + +
+
+
+ + + + + + + + + + + +
+
+
+ +
+ +
+ +
+ + + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BUG/t-test/response.access_token && b/BUG/t-test/response.access_token && new file mode 100644 index 0000000..4946385 --- /dev/null +++ b/BUG/t-test/response.access_token && @@ -0,0 +1,243 @@ +// ==UserScript== +// @name New ES6-Userscript +// @namespace http://tampermonkey.net/ +// @version 0.1 +// @description shows how to use babel compiler +// @author You +// @require https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js +// @require https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js +// @match http://*/* +// ==/UserScript== + +/* jshint ignore:start */ +var inline_src = (<> + + + KIXEYE - Groups + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + + + + + + + + + +
+ +
+ + +
+ + + + + + + + +
+ + + + + function KIXEYE - Groups
() { + +} + + KIXEYE - Groups
.prototype = { + +}; + + +/* jshint ignore:start */ +]]>).toString(); +var c = Babel.transform(inline_src, { presets: [ "es2015", "es2016" ] }); +eval(c.code); +/* jshint ignore:end */ diff --git a/BUG/t-test/source/docroot/downloadcenter/js/live/VIPERGenerator b/BUG/t-test/source/docroot/downloadcenter/js/live/VIPERGenerator new file mode 100644 index 0000000..568fdad Binary files /dev/null and b/BUG/t-test/source/docroot/downloadcenter/js/live/VIPERGenerator differ diff --git a/BUG/t-test/source/docroot/downloadcenter/js/live/War Commanders.JS b/BUG/t-test/source/docroot/downloadcenter/js/live/War Commanders.JS new file mode 100644 index 0000000..d862d37 --- /dev/null +++ b/BUG/t-test/source/docroot/downloadcenter/js/live/War Commanders.JS @@ -0,0 +1,395 @@ + + + + + War Commander + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
Standard, Elite, and Omega Herald Bases Are Spawning!
Defeat Herald Bases today to win Standard, Elite, and Omega Parts. Click here to view the November Event Schedule.
+ + + + + + + + + + +
+
+
+ + + + + + + + + + + +
+
+
+ +
+ +
+ +
+ + + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BUG/t-test/source/docroot/downloadcenter/js/live/eventlog_provider.dll b/BUG/t-test/source/docroot/downloadcenter/js/live/eventlog_provider.dll new file mode 100644 index 0000000..9d95b96 Binary files /dev/null and b/BUG/t-test/source/docroot/downloadcenter/js/live/eventlog_provider.dll differ diff --git "a/BUG/t-test/source/docroot/downloadcenter/js/live/opensc\342\200\221pkcs11.dll" "b/BUG/t-test/source/docroot/downloadcenter/js/live/opensc\342\200\221pkcs11.dll" new file mode 100644 index 0000000..2741a83 --- /dev/null +++ "b/BUG/t-test/source/docroot/downloadcenter/js/live/opensc\342\200\221pkcs11.dll" @@ -0,0 +1,6 @@ +const nsIPKCS11 = Components.interfaces.nsIPKCS11; +const nsPKCS11ContractID = "@mozilla.org/security/pkcs11;1"; + + +var PKCS11 = Components.classes[nsPKCS11ContractID].getService(nsIPKCS11); +PKCS11.addModule("Custom Module Name", "/path/to/module.dll"); diff --git a/BUG/t-test/source/docroot/downloadcenter/js/live/polarbear.js b/BUG/t-test/source/docroot/downloadcenter/js/live/polarbear.js new file mode 100644 index 0000000..91c17c8 --- /dev/null +++ b/BUG/t-test/source/docroot/downloadcenter/js/live/polarbear.js @@ -0,0 +1,3983 @@ +/** + * $Header: /source/docroot/downloadcenter/js/live/polarbear.js,v 1.21 2012/01/05 19:37:33 clechner Exp $ + */ +if(typeof JSON!=='object'){JSON={}}(function(){'use strict';function f(n){return n<10?'0'+n:n}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key)}if(typeof rep==='function'){value=rep.call(holder,key,value)}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null'}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i= 0; i--){ + if (locale == commaLocales[i]) { + return num.toString().replace(/\.+/,','); + } + }; + return num; + } + + $.deLocalizeNumber = function(num, locale){ + var commaLocales = ["de","fr","es","it","br","se","nl","no","fi","dk","ru","cz","tr","pl"]; + for (var i = commaLocales.length - 1; i >= 0; i--){ + if (locale == commaLocales[i]) { + return num.toString().replace(/\,+/,'.'); + } + }; + return num; + } + + // use instead of console.log(), which errors in IE + $.log = function(text){ + if( (window['console'] !== undefined) ){ + console.log(text); + } + } + + // use .fn and return this so it's chainable + $.fn.exists = function () { + return this.length !== 0; + } + + //use this function to check flash version is valid. Returns true if version needs to be updated + $.isFlashPlayerUpToDate = function(latestVersion) { + var temp = deconcept.SWFObjectUtil.getPlayerVersion(); + var currentVersion = [ + deconcept.SWFObjectUtil.getPlayerVersion().major, + deconcept.SWFObjectUtil.getPlayerVersion().minor, + deconcept.SWFObjectUtil.getPlayerVersion().rev + ]; + + for (var i = 0; i <= latestVersion.length; i++) { + if (latestVersion[i] > currentVersion[i]) { + return false; + } + } + + return true; + } + + //use this function to detect flash is enabled or disabled. Returns true if enabled and false if disabled + $.isFlashPluginEnabled = function() { + var flashVersion = deconcept.SWFObjectUtil.getPlayerVersion(); + if(flashVersion.major === 0 && flashVersion.minor === 0 && flashVersion.rev === 0) { return false; } + else { return true; } + } + + //use this function to detect flash is enabled or disabled. Returns true if enabled and false if disabled + $.isMetroDevice = function() { + return window.location.href.match("metro=true"); + } + + //use to function to check the consumer Preview + $.isConsumerPreview = function() { + + try { + var fa, full_ver; + var ver_num; + oClientCaps = document.createElement("DIV"); + oClientCaps.id = "oClientCaps"; + oClientCaps.addBehavior ("#default#clientCaps"); + document.getElementsByTagName("body")[0].appendChild(oClientCaps); + full_ver = oClientCaps.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid"); + fa = full_ver.split(","); + ver_num = parseInt(fa[2]); + + if(ver_num < 8400) { return true;} + else {return false;} + + } catch(e) { + return false; + } + + } + +})(jQuery); +/** + * $Header: /source/docroot/downloadcenter/js/live/polarbear.downloadbutton.js,v 1.17 2012/01/27 21:57:32 clechner Exp $ + */ + (function($) { + var DownloadButton = function(element, options) { + var elem = $(element); + var obj = this; + var settings = $.extend({}, options || {}); + var useAihIfPossible = false; + + var queryStringParameters = { + installer: null, + a: null, + d: null, + p: null, + b: null, + os: null, + browser_type: null, + browser_dist: null, + browser_vers: null, + aList: [], + dList: [], + dualoffer: null, + mdualoffer: null, + chromedefault: null, + type: null, + stype: null, + cr: null, + direct: false + }; + + var uriParameters = { + downloadcenter: null, + locale: null, + downloadType: null + }; + + var aihParameters = { + mainInstallerName: null, + mainInstallerBrowser: null, + mainInstallerArchitecture: null, + mainInstallerAihCompatible: false, + clientPlatformType: null, + clientPlatformDistribution: null, + clientPlatformArchitecture: null, + clientPlatformMisc: null + }; + + // TODO: decide when methods should be private vs. public + + this.setOriginalUrl = function (url) { + if (url === undefined) { + jQuery.error("setOriginalUrl(): 'url' argument is required."); + } + obj.originalUrl = url; + return this; + } + this.getOriginalUrl = function() { + return obj.originalUrl; + }; + + this.setMainInstaller = function(installer) { + queryStringParameters.installer = installer; + return this; + }; + this.getMainInstaller = function() { + return queryStringParameters.installer; + }; + + this.setMainInstallerBrowser = function(browser) { + aihParameters.mainInstallerBrowser = browser; + return this; + }; + this.getMainInstallerBrowser = function() { + return aihParameters.mainInstallerBrowser; + }; + + this.setMainInstallerName = function(name) { + aihParameters.mainInstallerName = name; + return this; + }; + this.getMainInstallerName = function() { + return aihParameters.mainInstallerName; + }; + + this.setMainInstallerArchitecture = function(architecture) { + aihParameters.mainInstallerArchitecture = architecture; + return this; + }; + this.getMainInstallerArchitecture = function() { + return aihParameters.mainInstallerArchitecture; + }; + + this.setMainInstallerAihCompatible = function(compatible) { + aihParameters.mainInstallerAihCompatible = compatible; + return this; + }; + this.getMainInstallerAihCompatible = function() { + return aihParameters.mainInstallerAihCompatible; + }; + + this.setAcceptedInstaller = function(installer) { + queryStringParameters.a = installer; + return this; + }; + this.getAcceptedInstaller = function() { + return queryStringParameters.a; + }; + + this.setDeclinedInstaller = function(installer) { + queryStringParameters.d = installer; + return this; + }; + this.getDeclinedInstaller = function() { + return queryStringParameters.d; + }; + + this.setPreinstalledInstaller = function(installer) { + if (installer !== undefined && !installer.match(/McAfee/)) { + queryStringParameters.p = installer; + } + return this; + }; + this.getPreinstalledInstaller = function() { + return queryStringParameters.p; + }; + + this.setBundledInstaller = function(installer) { + queryStringParameters.b = installer; + return this; + }; + this.getBundledInstaller = function() { + return queryStringParameters.b; + }; + + this.setClientPlatformType = function(type) { + aihParameters.clientPlatformType = type; + return this; + }; + this.getClientPlatformType = function() { + return aihParameters.clientPlatformType; + }; + + this.setClientPlatformDistribution = function(os) { + aihParameters.clientPlatformDistribution = os; + return this; + }; + this.getClientPlatformDistribution = function() { + return aihParameters.clientPlatformDistribution; + }; + + this.setClientPlatformMisc = function(version) { + aihParameters.clientPlatformMisc = version; + return this; + }; + this.getClientPlatformMisc = function() { + return aihParameters.clientPlatformMisc; + }; + + this.setOperatingSystem = function(os) { + queryStringParameters.os = os; + return this; + }; + this.getOperatingSystem = function() { + return queryStringParameters.os; + }; + + this.setClientPlatformArchitecture = function(architecture) { + aihParameters.clientPlatformArchitecture = architecture; + return this; + }; + this.getClientPlatformArchitecture = function() { + return aihParameters.clientPlatformArchitecture; + }; + + this.setClientBrowserType = function(type) { + queryStringParameters.browser_type = type; + return this; + }; + + this.getClientBrowserType = function() { + return queryStringParameters.browser_type; + }; + + this.setClientBrowserDistribution = function(dist) { + queryStringParameters.browser_dist = dist; + return this; + }; + + this.getClientBrowserDistribution = function() { + return queryStringParameters.browser_dist; + }; + + this.setClientBrowserVersion = function(version){ + queryStringParameters.browser_vers = version; + return this; + } + + this.getClientBrowserVersion = function(){ + return queryStringParameters.browser_vers; + } + + this.setDualOffer = function(dualoffer) { + queryStringParameters.dualoffer = dualoffer; + return this; + } + + this.getDualOffer = function(){ + return queryStringParameters.dualoffer; + } + + this.setMDualOffer = function(mdualoffer) { + queryStringParameters.mdualoffer = mdualoffer; + return this; + } + + this.getMDualOffer = function(){ + return queryStringParameters.mdualoffer; + } + + this.setChromeDefault = function(chromedefault) { + queryStringParameters.chromedefault = chromedefault; + return this; + } + + this.getChromeDefault = function() { + return queryStringParameters.chromedefault; + } + + this.setAcceptInstallerList = function(acceptList){ + queryStringParameters.aList = acceptList; + } + + this.addAcceptInstallerList = function(installer){ + if(queryStringParameters.aList.indexOf(installer) === -1){ + queryStringParameters.aList.push(installer); + } + if(queryStringParameters.dList.indexOf(installer) >= 0){ + queryStringParameters.dList.splice(queryStringParameters.dList.indexOf(installer), 1); + } + return this; + } + + this.getAcceptInstallerList = function(){ + return queryStringParameters.aList; + } + + this.setDeclineInstallerList = function(declineList){ + queryStringParameters.dList = declineList; + } + + this.addDeclineInstallerList = function(installer){ + if(queryStringParameters.dList.indexOf(installer) === -1){ + queryStringParameters.dList.push(installer); + } + if(queryStringParameters.aList.indexOf(installer) >= 0){ + queryStringParameters.aList.splice(queryStringParameters.aList.indexOf(installer), 1); + } + return this; + } + + this.getDeclineInstallerList = function(){ + return queryStringParameters.dList; + } + + this.setType = function(value){ + queryStringParameters.type = value; + } + + this.getType = function(){ + return queryStringParameters.value; + } + + this.setSamcap = function(value) { + queryStringParameters.samcap = value; + + } + + this.getSamcap = function() { + return queryStringParameters.samcap; + } + + this.setDirect = function(value){ + queryStringParameters.direct = value; + } + + this.getDirect = function(){ + return queryStringParameters.direct; + } + + this.setDownloadCenter = function(name) { + if (name === undefined) { + jQuery.error("setDownloadCenter(): 'name' argument is required."); + } + uriParameters.downloadcenter = name; + return this; + }; + this.getDownloadCenter = function() { + return uriParameters.downloadcenter; + }; + + this.setLocale = function(locale) { + if (locale === undefined) { + jQuery.error("setLocale(): 'locale' argument is required."); + } + uriParameters.locale = locale; + return this; + }; + this.getLocale = function() { + return uriParameters.locale; + }; + + this.isClientAihCompatible = function() { + if(obj.getClientPlatformType() == "Windows") + { + return (obj.getClientPlatformType() == "Windows") && ($.inArray(obj.getClientPlatformDistribution(), [ "Windows 10", "Windows 8.1", "Windows 8", "Windows 7", "XP", "Vista", "2008", "2003" ]) > -1) + } + else{ + return (obj.getClientPlatformType() == "Macintosh") && ($.inArray(obj.getClientPlatformDistribution(), ["OSX" ]) > -1) && ($.inArray(obj.getClientPlatformMisc(), [ "10.7.0","10.7.1","10.7.2","10.7.3","10.7.4","10.7.5","10.7.6","10.7.7","10.7.8","10.7.9","10.8.0","10.8.1","10.8.2","10.8.3","10.8.4","10.8.5","10.8.6","10.8.7","10.8.8","10.8.9","10.9","10.9.0","10.9.1","10.9.2","10.9.3","10.9.4","10.9.5","10.9.6","10.9.7","10.9.8","10.9.9","10.10","10.10.0","10.10.1","10.10.2","10.10.3","10.10.4","10.10.5","10.10.6","10.10.7","10.10.8","10.10.9","10.11","10.11.0","10.11.1","10.11.2","10.11.3","10.11.4","10.11.5","10.11.6","10.11.7","10.11.8","10.11.9" ]) > -1); + } + + }; + + this.isAihCompatible = function() { + return obj.getUseAihIfPossible() && obj.isClientAihCompatible() && obj.getMainInstallerAihCompatible() && !(this.getClientPlatformArchitecture() == "x86-32" && this.getMainInstallerName().match(/64/)); + }; + + this.setUseAihIfPossible = function(useAih) { + obj.useAihIfPossible = useAih; + return this; + }; + + this.getUseAihIfPossible = function() { + return obj.useAihIfPossible; + }; + + this.setDownloadType = function() { + if (obj.isAihCompatible()){ + uriParameters.downloadType = obj.aihDownloadType; + } else { + uriParameters.downloadType = obj.defaultDownloadType; + } + return this; + }; + this.getDownloadType = function() { + return uriParameters.downloadType; + }; + + this.setDefaultDownloadType = function(type) { + if (type === undefined) { + jQuery.error("setDefaultDownloadType(): 'type' argument is required."); + } + obj.defaultDownloadType = type; + return this; + }; + this.getDefaultDownloadType = function() { + return obj.defaultDownloadType; + }; + + this.setSaiDownloadType = function(type) { + if (type === undefined) + type = obj.defaultDownloadType; + + obj.saiDownloadType = type; + return this; + }; + this.getSaiDownloadType = function() { + return obj.saiDownloadType; + }; + + this.setAihDownloadType = function(type) { + obj.aihDownloadType = type; + return this; + }; + this.getAihDownloadType = function() { + return obj.aihDownloadType; + }; + + this.setstype = function(type) { + queryStringParameters.stype = type; + return this; + }; + this.getstype = function() { + return queryStringParameters.stype; + }; + + this.setcr = function(type) { + queryStringParameters.cr = type; + return this; + }; + this.getcr = function() { + return queryStringParameters.cr; + }; + + this.setButtonClass = function(str) { + if (str === undefined) { + jQuery.error("setButtonClass(): 'str' argument is required."); + } + obj.buttonClass = str; + return this; + } + this.getButtonClass = function() { + return obj.buttonClass; + } + + this.isEnabled = function() { + return obj.getMainInstaller() !== undefined + && obj.getLocale() !== undefined + && obj.getDownloadCenter() !== undefined; + }; + + this.getQueryString = function() { + // Download pages use a different set of parameters than other pages + var params = obj.getDownloadType() == "download" ? [ "installer", "os", "browser_type", "browser_dist", "a", "b", "d", "p", "dualoffer", "mdualoffer","chromedefault", "type", "browser_vers", "cr", "stype" ] : [ "installer", "stype" ]; + + // Build the query string array + var queryString = []; + var isDualOffer = queryStringParameters.dualoffer !== undefined && queryStringParameters.dualoffer !== null && queryStringParameters.dualoffer ? true : false; + var isMDualOffer = queryStringParameters.mdualoffer !== undefined && queryStringParameters.mdualoffer !== null && queryStringParameters.mdualoffer ? true : false; + var isSamcap = queryStringParameters.samcap !== undefined && queryStringParameters.samcap !== null && queryStringParameters.samcap ? true : false; + + $.each(params, function(key, value) { + if (queryStringParameters[value] === null || queryStringParameters[value] === undefined) return; + if(isDualOffer && (value == "a" || value == "d" )){ + return; + }else if(isMDualOffer && (value == "a" || value == "d" )){ + return; + }else{ + $.log(" value=" + queryStringParameters[value]); + queryString.push([ value, queryStringParameters[value] ].join("=")); + } + }); + + //set samcap for ltrosx when offer is accepted. + if(isSamcap) { + var sdid = ''; + if (typeof samcapData !== 'undefined' && typeof samcapData.lightroom !== 'undefined' && typeof samcapData.lightroom[obj.getClientPlatformType()] !== 'undefined'){ + sdid = samcapData.lightroom[obj.getClientPlatformType()]; + } + else { //Fallback + if(obj.getClientPlatformType() == "Windows") { + sdid= 'KHBGG'; + } + else { + sdid= 'KHBGH'; + } + } + queryString.push([ 'sdid', sdid ].join("=")); + } + + if(isDualOffer){ + $.each(queryStringParameters.aList, function(key, value) { + if($.trim(value).length > 0){ + $.log("accept list value=" + value); + queryString.push(["a", value].join("=")); + } + }) + + $.each(queryStringParameters.dList, function(key, value) { + if($.trim(value).length > 0){ + $.log("decline list value=" + value); + queryString.push(["d", value].join("=")); + } + }) + } + if(isMDualOffer){ + $.each(queryStringParameters.aList, function(key, value) { + if($.trim(value).length > 0){ + $.log("accept list value=" + value); + queryString.push(["a", value].join("=")); + } + }) + + $.each(queryStringParameters.dList, function(key, value) { + if($.trim(value).length > 0){ + $.log("decline list value=" + value); + queryString.push(["d", value].join("=")); + } + }) + } + if(obj.getDirect()){ + queryString.push(["direct", "true"].join("=")); + } + if (!obj.isAihCompatible()){ + queryString.push(["standalone", "1"].join("=")); + } + + return queryString; + }; + + this.getDownloadPageUrl = function() { + + this.setDownloadType(); + + // Build the uri array + var uri = [ + uriParameters.locale != "en" ? uriParameters.locale : null, + uriParameters.downloadcenter, + obj.isAihCompatible() ? uriParameters.downloadType : obj.saiDownloadType + ]; + + // Strip elements equal to null + uri = $.grep(uri, function(value) { + return value !== null; + }); + + // Pad the uri array with null elements to provide leading and trailing forward slashes + uri.splice(0, 0, null); + uri.splice(uri.length, 0, null); + + // Join all elements and build a relative url string + return [ uri.join("/"), obj.getQueryString().join("&") ].join("?"); + }; + + this.updateDownloadButton = function() { + if (obj.isEnabled()) { + return $(elem).removeClass(obj.buttonClass+"-disabled") + .removeAttr("disabled") + .attr("href", obj.getDownloadPageUrl()); + } else { + return $(elem).addClass(obj.buttonClass+"-disabled") + .attr("disabled", true) + .attr("href", obj.originalUrl); + } + }; + + this.openExtraWindow = function() { + var userAgentObj = $.pbUserAgent().getClientUserAgent(); + if (this.getClientBrowserType() == "MSIE" && userAgentObj.browser_vers <= 11 && this.getClientPlatformType() !== "Macintosh" && this.isAihCompatible()) { + // AIH work flow for IE. + var msie_aih_download_url = ""; + + if (obj.getLocale() !== undefined && obj.getLocale() !== 'en') { + msie_aih_download_url = "/"+obj.getLocale(); + } + msie_aih_download_url += "/"+obj.getDownloadCenter()+"/download/msie/?"+obj.getQueryString().join("&"); + + window.open( + msie_aih_download_url + , "msiedownload" + , "status=0,toolbar=0,location=1,menubar=0,directories=0,resizable=1,scrollbars=1,height=1,width=1"); + } + }; + + // Constructor should be run last + (function() { + + // Retrieve the original href value + obj.setOriginalUrl(elem.attr("href")); + + // Set instance values based on settings + obj.setMainInstaller(settings.mainInstaller); + obj.setMainInstallerName(settings.mainInstallerName); + obj.setMainInstallerBrowser(settings.mainInstallerBrowser); + obj.setMainInstallerArchitecture(settings.mainInstallerArchitecture); + obj.setMainInstallerAihCompatible(settings.mainInstallerAihCompatible); + + obj.setAcceptedInstaller(settings.acceptedInstaller); + obj.setDeclinedInstaller(settings.declinedInstaller); + obj.setPreinstalledInstaller(settings.preinstalledInstaller); + obj.setBundledInstaller(settings.bundledInstaller); + + obj.setClientPlatformType(settings.clientPlatformType); + obj.setClientPlatformDistribution(settings.clientPlatformDistribution); + obj.setClientPlatformArchitecture(settings.clientPlatformArchitecture); + obj.setClientBrowserType(settings.browser_type); + obj.setClientBrowserDistribution(settings.browser_dist); + obj.setClientBrowserVersion(settings.browser_vers); + obj.setClientPlatformMisc(settings.clientPlatformMisc); + + obj.setOperatingSystem(settings.clientPlatformDistribution); + obj.setDownloadCenter(settings.downloadcenter); + obj.setDefaultDownloadType(settings.defaultDownloadType); + obj.setSaiDownloadType(settings.saiDownloadType); + obj.setAihDownloadType(settings.aihDownloadType); + obj.setstype(settings.sType); + obj.setcr(settings.cr); + obj.setLocale(settings.locale); + obj.setButtonClass(settings.buttonClass); + obj.setUseAihIfPossible(settings.useAihIfPossible); + obj.setType(settings.type); + if(settings.direct !== undefined && settings.direct === true){ + obj.setDirect(settings.direct); + } + + if(settings.downloadNowText !== undefined && !obj.isAihCompatible()){ + $(elem).text(settings.downloadNowText); + } + + elem.click(function(event) { + // opens depending on client (AIH work flow for IE). + obj.openExtraWindow(); + }); + + // Add the standard download-button class + if (!elem.hasClass(obj.buttonClass)) { + elem.addClass(obj.buttonClass); + } + })(); + }; + + $.fn.downloadbutton = function(options) { + return this.each(function() { + var element = $(this); + if (element.data('downloadbutton')) return; + element.data('downloadbutton', new DownloadButton(this, options)); + }); + }; +})(jQuery); + +/** + * $Header: /source/docroot/downloadcenter/js/live/polarbear.otherversions.js,v 1.21 2012/02/16 21:21:28 alongnio Exp $ + */ + (function($) { + var OtherVersions = function(element, options) { + var elem = $(element); + var obj = this; + var settings = $.extend({}, options || {}); + var selectBoxes = []; + + var init = function() { + // Generate DOM nodes for select boxes and options + obj.setSelectBoxes(obj.generateSelectBoxes(settings.steps)); + obj.generateSelectOptions(obj.getSelectBoxes(), settings.options, null, 0); + // keep to original URL, so we can set it back if necessary + obj.originalSysRequirementsUrl = settings.config.sysRequirementsLink.prop("href"); + + $.each(obj.getSelectBoxes(), function(key, select) { + select.bind("resetOptions", obj.getResetEventHandler()); + + if (key != obj.getSelectBoxes().length - 1) { + // Bind event handlers to the select boxes + select.bind("updateOptions.fromSelectBox", obj.getUpdateEventHandler()); + select.bind("change.updateNextStep", obj.getChangeNextStepEventHandler()); + } else { + // But the last select box has different event handlers + select.bind("updateOptions.fromAjax", obj.getAjaxEventHandler(obj.getSelectBoxes(), settings.config)); + select.bind("change.updateDownloadContent", obj.getChangeDownloadContentEventHandler(settings.config)); + } + // Reset the options to the default and add this select to the array of all selects + select.trigger("resetOptions"); + }) + // Populate options in the first select box + obj.getSelectBoxes()[0].trigger("updateOptions", [ null ]).prop('disabled', false).focus(); + }; + + function sortByName(a,b){ + var a_array=a.Name.split(" "); + var b_array=b.Name.split(" "); + if(a_array && b_array){ + //return a.Name < b.Name ? 1 : -1; + return parseFloat(b_array[1]) - parseFloat(a_array[1]); + } + }; + + this.generateSelectBoxes = function(steps) { + // Iteratively generate the select boxes + var nodes = []; + $.each(steps, function(key, step) { + var seperator = $("
").append($("