보안 모니터는 이벤트 규칙이 트리거될 때 이메일 알림을 보낼 수 있습니다. 각 이벤트에 대한 전자 메일 알림 내에서 사용할 수 있는 내장 변수에는 서명 ID, 경고의 소스 및 대상 등과 같은 항목이 포함되지 않습니다. 이 문서에서는 보안 모니터를 구성하여 이메일 알림 메시지에 이러한 변수(및 기타 여러 변수)를 포함시키는 데 사용할 수 있는 지침을 제공합니다.
이 문서에 대한 특정 요건이 없습니다.
이 문서는 특정 소프트웨어 및 하드웨어 버전으로 한정되지 않습니다. 그러나 환경에서 실행되는 센서 버전에 따라 적절한 Perl 스크립트를 사용해야 합니다.
문서 규칙에 대한 자세한 내용은 Cisco 기술 팁 규칙을 참조하십시오.
이 절차를 사용하여 이메일 알림을 구성합니다.
참고: 올바른 이메일 주소로 이메일을 보내려면 스크립트에서 이메일 주소를 변경해야 합니다.
이러한 스크립트 중 하나를 $BASE\CSCOpx\MDC\etc\ids\scripts directory on the VPN/VMS(Security Management Solution) 서버에 복사합니다. 이를 통해 나중에 이벤트 규칙을 정의할 때 프로세스에서 선택할 수 있습니다. 스크립트를 emailalert.pl로 저장합니다.
참고: 다른 이름을 사용하는 경우 이 단계에 정의된 이벤트 규칙에서 해당 이름을 참조해야 합니다.
버전 3.x 센서의 경우 3.x 센서 스크립트를 사용합니다.
버전 4.x 센서의 경우 4.x 센서 스크립트를 사용합니다.
버전 5.x 센서의 경우 5.x 센서 스크립트를 사용합니다.
센서 버전을 조합한 경우, 모든 버전이 동일한 버전 레벨에 있도록 업그레이드할 것을 권장합니다. 이는 이러한 스크립트 중 하나만 한 번에 실행할 수 있기 때문입니다.
스크립트에는 각 부분과 필요한 입력을 설명하는 주석이 포함되어 있습니다. 특히, $EmailRcpt 변수(파일 맨 위 근처)를 알림을 받을 사람의 전자 메일 주소로 수정합니다.
보안 모니터 내에서 이벤트 규칙을 정의하여 새 Perl 스크립트를 호출합니다. 기본 Security Monitor 페이지에서 Admin > Event Rules를 선택하고 새 이벤트를 추가합니다.
Specify the Event Filter(이벤트 필터 지정) 창에서 이메일 알림을 트리거할 필터를 추가합니다(여기 샘플의 경우 심각도가 높은 경고에 대해 전자 메일이 전송됩니다).
Choose the Action(작업 선택) 창에서 스크립트를 실행할 확인란을 선택하고 드롭다운 상자에서 스크립트 이름을 선택합니다.
인수 섹션에서 여기에 표시된 대로 "${Query}"을 입력합니다.
참고: 이는 큰따옴표를 포함하여 여기에 있는 그대로 입력해야 합니다. 대소문자를 구분합니다.
이벤트 필터에 정의된 대로 경고(이 예에서는 높은 심각도 경고)가 수신되면 emailalert.pl이라는 스크립트가 ${Query} 인수와 함께 호출됩니다. 여기에는 경고에 대한 추가 정보가 포함됩니다. 스크립트는 모든 개별 필드를 구문 분석하고 "blat"라는 프로그램을 사용하여 최종 사용자에게 이메일을 보냅니다.
Blat는 배치 파일 또는 Perl 스크립트에서 이메일을 보내는 데 Windows 시스템에서 사용되는 프리웨어 전자 메일 프로그램입니다. VMS 설치의 일부로 $BASE\CSCOpx\bin directory에 포함되어 있습니다. 경로 설정을 확인하려면 VMS 서버에서 명령 프롬프트 창을 열고 blat를 입력합니다.
파일을 찾을 수 없음 오류가 나타나면 blat.exe 파일을 winnt\system32 디렉터리에 복사하거나 찾아서 해당 파일이 있는 디렉터리에서 엽니다. 이를 설치하려면 다음을 실행하십시오.
blat -install
이 프로그램을 설치하면 됩니다.
다음은 컨피그레이션 절차의 1단계에서 참조되는 스크립트입니다.
버전 3.x 센서에 이 스크립트를 사용합니다.
3.x 센서 |
---|
#!/usr/bin/perl #*********************************************************************** # # FILE NAME : emailalert.pl # # DESCRIPTION : This file is a perl script that will be executed as an # action when an IDS-MC Event Rule triggers, and will send an # email to $EmailRcpt with additional alert parameters (similar to # the functionality available with CSPM notifications) # # NOTE: this script only works with 3.x sensors, alarms from 4.0 # sensors are stored differently and cannot be represented # in a similar format. # # NOTE: check the "system" command in the script for the correct # format depending on whether you're using IDSMC/SecMon # v1.0 or v1.1, you may need the "-on" command-line option. # # NOTE : This script takes the ${Query} keyword from the # triggered rule, extracts the set of alarms that caused # the rule to trigger. It then reads the last alarm of # this set, parses the individual alarm fields, and # calls the legacy script with the same set of command # line arguments as CSPM. # # The calling sequence of this script must be of the form: # # emailalert.pl "${Query}" # # Where: # # "${Query}" - this is the query keyword dynamically # output by the rule when it triggers. # It MUST be wrapped in double quotes when specifying it in the Arguments # box on the Rule Actions panel. # # #*********************************************************************** ## ## The following are the only two variables that need changing. $TempIDSFile can be any ## filename (doesn't have to exist), just make sure the directory that you specify ## exists. Make sure to use 2 backslashes for each directory, the first backslash is ## so the Perl interpretor doesn't error on the pathname. ## ## $EmailRcpt is the person that is going to receive the email notifications. Also ## make sure you escape the @ symbol by putting a backslash in front of it, otherwise ## you'll get a Perl syntax error. ## $TempIDSFile = "c:\\temp\\idsalert.txt"; $EmailRcpt = "nobody\@cisco.com"; ## ## pull out command line arg ## $whereClause = $ARGV[0]; ## ## extract all the alarms matching search expression ## $tmpFile = "alarms.out"; ## The following line will extract alarms from 1.0 IDSMC/SecMon database, if ## using 1.1 comment out the line below and un-comment the other system line ## below it. ## V1.0 IDSMC/SecMon version system("IdsAlarms -s\"$whereClause\" -f\"$tmpFile\""); ## V1.1 IDSMC/SecMon version. ## system("IdsAlarms -on -s\"$whereClause\" -f\"$tmpFile\""); ## # open matching alarm output if (!open(ALARM_FILE, $tmpFile)) { print "Could not open ", $tmpFile, "\n"; exit -1; } # read to last line while (<ALARM_FILE>) { $line = $_; } # clean up close(ALARM_FILE); unlink($tmpFile); ## ## split last line into fields ## @fields = split(/,/, $line); $eventType = @fields[0]; $recordId = @fields[1]; $gmtTimestamp = 0; # need gmt time_t $localTimestamp = 0; # need local time_t $localDate = @fields[4]; $localTime = @fields[5]; $appId = @fields[6]; $hostId = @fields[7]; $orgId = @fields[8]; $srcDirection = @fields[9]; $destDirection = @fields[10]; $severity = @fields[11]; $sigId = @fields[12]; $subSigId = @fields[13]; $protocol = "TCP/IP"; $srcAddr = @fields[15]; $destAddr = @fields[16]; $srcPort = @fields[17]; $destPort = @fields[18]; $routerAddr = @fields[19]; $contextString = @fields[20]; ## Open temp file to write alert data into, open(OUT,">$TempIDSFile") || warn "Unable to open output file!\n"; ## Now write your email notification message. You're writing the following into ## the temporary file for the moment, but this will then be emailed. Use the format: ## ## print (OUT "Your text with any variable name from the list above \n"); ## ## Again, make sure you escape special characters with a backslash (note the : in between $sigId ## and $subSigId has a backslash in front of it) print(OUT "\n"); print(OUT "Received severity $severity alert at $localDate $localTime\n"); print(OUT "Signature ID $sigId\:$subSigId from $srcAddr to $destAddr\n"); print(OUT "$contextString"); close(OUT); ## then call "blat" to send contents of that file in the body of an email message. ## Blat is a freeware email program for WinNT/95, it comes with VMS in the ## $BASE\CSCOpx\bin directory, make sure you install it first by running: ## ## blat -install <SMTP server address> <source email address> ## ## For more help on blat, just type "blat" at the command prompt on your VMS system (make ## sure it's in your path (feel free to move the executable to c:\winnt\system32 BEFORE ## you run the install, that'll make sure your system can always find it). system ("blat \"$TempIDSFile\" -t \"$EmailRcpt\" -s \"Received IDS alert\""); |
버전 4.x 센서에 이 스크립트를 사용합니다.
4.x 센서 |
---|
#!/usr/bin/perluse Time::Local;#*********************************************************************** # # FILE NAME : emailalert.pl # # DESCRIPTION : This file is a perl script that will be executed as an # action when an IDS-MC Event Rule triggers, and will send an # email to $EmailRcpt with additional alert parameters (similar to # the functionality available with CSPM notifications) # # NOTE: this script only works with 4.x sensors. It will # not work with 3.x sensors. # # NOTES : This script takes the ${Query} keyword from the # triggered rule, extracts the set of alarms that caused # the rule to trigger. It then reads the last alarm of # this set, parses the individual alarm fields, and # calls the legacy script with the same set of command # line arguments as CSPM. # # The calling sequence of this script must be of the form: # # emailalert.pl "${Query}" # # Where: # # "${Query}" - this is the query keyword dynamically # output by the rule when it triggers. # It MUST be wrapped in double quotes # when specifying it in the Arguments # box on the Rule Actions panel. # # #*********************************************************************** ## ## The following are the only two variables that need changing. $TempIDSFile can be any ## filename (doesn't have to exist), just make sure the directory that you specify ## exists. Make sure to use 2 backslashes for each directory, the first backslash is ## so the Perl interpretor doesn't error on the pathname. ## ## $EmailRcpt is the person that is going to receive the email notifications. Also ## make sure you escape the @ symbol by putting a backslash in front of it, otherwise ## you'll get a Perl syntax error. ## $TempIDSFile = "c:\\temp\\idsalert.txt"; $EmailRcpt = "yourname\@yourcompany.com"; # subroutine to add leading 0's to any date variable that's less than 10. sub add_zero { my ($var) = @_; if ($var < 10) { $var = "0" .$var } return $var; } # subroutine to find one or more IP addresses within an XML tag (we can have multiple # victims and/or attackers in one alert now). sub find_addresses { my ($var) = @_; my @addresses = (); if (m/$var/) { $raw = $&; while ($raw =~ m/(\d{1,3}\.){3}\d{1,3}/) { push @addresses,$&; $raw = $'; } $var = join(', ',@addresses); return $var; } } # pull out command line arg $whereClause = $ARGV[0]; # extract all the alarms matching search expression $tmpFile = "alarms.out"; # Extract the XML alert/event out of the database. system("IdsAlarms -s\"$whereClause\" -f\"$tmpFile\""); # open matching alarm output if (!open(ALARM_FILE, $tmpFile)) { print "Could not open $tmpFile\n"; exit -1; } # read to last line while (<ALARM_FILE>) { chomp $_; push @logfile,$_; } # clean up close(ALARM_FILE); unlink($tmpFile); # Open temp file to write alert data into, open(OUT,">$TempIDSFile"); # split XML output into fields $oneline = join('',@logfile); $oneline =~ s/\<\/events\>//g; $oneline =~ s/\<\/evAlert\>/\<\/evAlert\>,/g; @items = split(/,/,$oneline); # If you want to see the actual database query result in the email, un-comment out the # line below (useful for troubleshooting): # print(OUT "$oneline\n"); # Loop until there's no more alerts foreach (@items) { if (m/\<hostId\>(.*)\<\/hostId\>/) { $hostid = $1; } if (m/severity="(.*?)"/) { $sev = $1; } if (m/Zone\=".*"\>(.*)\<\/time\>/) { $t = $1; if ($t =~ m/(.*)(\d{9})/) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($1); # Year is reported from 1900 onwards (eg. 2003 is 103). $year = $year + 1900; # Months start at 0 (January = 0, February = 1, etc), so add 1. $mon = $mon + 1; $mon = add_zero ($mon); $mday = add_zero ($mday); $hour = add_zero ($hour); $min = add_zero ($min); $sec = add_zero ($sec); } } if (m/sigName="(.*?)"/) { $SigName = $1; } if (m/sigId="(.*?)"/) { $SigID = $1; } if (m/subSigId="(.*?)"/) { $SubSig = $1; } $attackerstring = "\<attacker.*\<\/attacker"; if ($attackerstring = find_addresses ($attackerstring)) { } $victimstring = "\<victim.*\<\/victim"; if ($victimstring = find_addresses ($victimstring)) { } if (m/\<alertDetails\>(.*)\<\/alertDetails\>/) { $AlertDetails = $1; } @actions = (); if (m/\<actions\>(.*)\<\/actions\>/) { $rawaction = $1; while ($rawaction =~ m/\<(\w*?)\>(.*?)\</) { $rawaction = $'; if ($2 eq "true") { push @actions,$1; } } if (@actions) { $actiontaken = join(', ',@actions); } } else { $actiontaken = "None"; } ## Now write your email notification message. You're writing the following into ## the temporary file for the moment, but this will then be emailed. ## ## Again, make sure you escape special characters with a backslash (note the : between ## the SigID and the SubSig). ## ## Put your VMS servers IP address in the NSDB: line below to get a direct link ## to the signature details within the email. print(OUT "\n$hostid reported a $sev severity alert at $hour:$min:$sec on $mon/$mday/$year\n"); print(OUT "Signature: $SigName \($SigID\:$SubSig\)\n"); print(OUT "Attacker: $attackerstring ---> Victim: $victimstring\n"); print(OUT "Alert details: $AlertDetails \n"); print(OUT "Actions taken: $actiontaken \n"); print(OUT "NSDB: https\://<your VMS server IP address>/vms/nsdb/html/expsig_$SigID.html\n\n"); print(OUT "----------------------------------------------------\n"); } close(OUT); ## Now call "blat" to send contents of the file in the body of an email message. ## Blat is a freeware email program for WinNT/95, it comes with VMS in the ## $BASE\CSCOpx\bin directory, make sure you install it first by running: ## ## blat -install <SMTP server address> <source email address> ## ## For more help on blat, just type "blat" at the command prompt on your VMS system (make ## sure it's in your path (feel free to move the executable to c:\winnt\system32 BEFORE ## you run the install, that'll make sure your system can always find it). system ("blat \"$TempIDSFile\" -t \"$EmailRcpt\" -s \"Received IDS alert\""); |
버전 5.x 센서에 이 스크립트를 사용합니다.
5.x 센서 |
---|
#!/usr/bin/perl use Time::Local; #*********************************************************************** # # FILE NAME : emailalertv5.pl # # DESCRIPTION : This file is a perl script that will be executed as an # action when an IDS-MC Event Rule triggers, and will send an # email to $EmailRcpt with additional alert parameters (similar to # the functionality available with CSPM notifications) # # NOTE: this script only works with 5.x sensors. # # NOTES : This script takes the ${Query} keyword from the # triggered rule, extracts the set of alarms that caused # the rule to trigger. It then reads the last alarm of # this set, parses the individual alarm fields, and # calls the legacy script with the same set of command # line arguments as CSPM. # # The calling sequence of this script must be of the form: # # emailalert.pl "${Query}" # # Where: # # "${Query}" - this is the query keyword dynamically # output by the rule when it triggers. # It MUST be wrapped in double quotes # when specifying it in the Arguments # box on the Rule Actions panel. # # #*********************************************************************** ## ## The following are the only two variables that need changing. $TempIDSFile can be any ## filename (doesn't have to exist), just make sure the directory that you specify ## exists. Make sure to use 2 backslashes for each directory, the first backslash is ## so the Perl interpretor doesn't error on the pathname. ## ## $EmailRcpt is the person that is going to receive the email notifications. Also ## make sure you escape the @ symbol by putting a backslash in front of it, otherwise ## you'll get a Perl syntax error. ## $TempIDSFile = "c:\\temp\\idsalert.txt"; $EmailRcpt = "gfullage\@cisco.com"; # subroutine to add leading 0's to any date variable that's less than 10. sub add_zero { my ($var) = @_; if ($var < 10) { $var = "0" .$var } return $var; } # subroutine to find one or more IP addresses within an XML tag (we can have multiple # victims and/or attackers in one alert now). sub find_addresses { my ($var) = @_; my @addresses = (); if (m/$var/) { $raw = $&; while ($raw =~ m/(\d{1,3}\.){3}\d{1,3}/) { push @addresses,$&; $raw = $'; } $var = join(', ',@addresses); return $var; } } # pull out command line arg $whereClause = $ARGV[0]; # extract all the alarms matching search expression $tmpFile = "alarms.out"; # Extract the XML alert/event out of the database. system("IdsAlarms -os -s\"$whereClause\" -f\"$tmpFile\""); # open matching alarm output if (!open(ALARM_FILE, $tmpFile)) { print "Could not open $tmpFile\n"; exit -1; } # read to last line while (<ALARM_FILE>) { chomp $_; push @logfile,$_; } # clean up close(ALARM_FILE); unlink($tmpFile); # Open temp file to write alert data into, open(OUT,">$TempIDSFile"); # split XML output into fields $oneline = join('',@logfile); $oneline =~ s/\<\/sd\:events\>//g; $oneline =~ s/\<\/sd\:evIdsAlert\>/\<\/sd\:evIdsAlert\>,/g; @items = split(/,/,$oneline); # If you want to see the actual database query result in the email, un-comment out the # line below (useful for troubleshooting): # print(OUT "$oneline\n"); # Loop until there's no more alerts foreach (@items) { unless ($_ =~ /\<\/env\:Body\>/) { if (m/\<sd\:hostId\>(.*)\<\/sd\:hostId\>/) { $hostid = $1; } if (m/severity="(.*?)"/) { $sev = $1; } if (m/Zone\=".*"\>(.*)\<\/sd\:time\>/) { $t = $1; if ($t =~ m/(.*)(\d{9})/) { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($1); # Year is reported from 1900 onwards (eg. 2003 is 103). $year = $year + 1900; # Months start at 0 (January = 0, February = 1, etc), so add 1. $mon = $mon + 1; $mon = add_zero ($mon); $mday = add_zero ($mday); $hour = add_zero ($hour); $min = add_zero ($min); $sec = add_zero ($sec); } } if (m/description="(.*?)"/) { $SigName = $1; } if (m/\ id="(.*?)"/) { $SigID = $1; } if (m/\<cid\:subsigId\>(.*)\<\/cid\:subsigId\>/) { $SubSig = $1; } if (m/\<cid\:riskRatingValue\>(.*)\<\/cid\:riskRatingValue\>/) { $RR = $1; } if (m/\<cid\:interface\>(.*)\<\/cid\:interface\>/) { $Intf = $1; } $attackerstring = "\<sd\:attacker.*\<\/sd\:attacker"; if ($attackerstring = find_addresses ($attackerstring)) { } $victimstring = "\<sd\:target.*\<\/sd\:target"; if ($victimstring = find_addresses ($victimstring)) { } if (m/\<cid\:alertDetails\>(.*)\<\/cid\:alertDetails\>/) { $AlertDetails = $1; } @actions = (); if (m/\<sd\:actions\>(.*)\<\/sd\:actions\>/) { $rawaction = $1; while ($rawaction =~ m/\<\w*?:(\w*?)\>(.*?)\</) { $rawaction = $'; if ($2 eq "true") { push @actions,$1; } } if (@actions) { $actiontaken = join(', ',@actions); } } else { $actiontaken = "None"; } ## Now write your email notification message. You're writing the following into ## the temporary file for the moment, but this will then be emailed. ## ## Again, make sure you escape special characters with a backslash (note the : between ## the SigID and the SubSig). ## ## Put your VMS servers IP address in the NSDB: line below to get a direct link ## to the signature details within the email. print(OUT "\n$hostid reported a $sev severity alert at $hour:$min:$sec on $mon/$mday/$year\n"); print(OUT "Signature: $SigName \($SigID\:$SubSig\)\n"); print(OUT "Attacker: $attackerstring ---> Victim: $victimstring\n"); print(OUT "Alert details: $AlertDetails \n"); print(OUT "Risk Rating: $RR, Interface: $Intf \n"); print(OUT "Actions taken: $actiontaken \n"); print(OUT "NSDB: https\://sec-srv/vms/nsdb/html/expsig_$SigID.html\n\n"); print(OUT "----------------------------------------------------\n"); } } close(OUT); ## Now call "blat" to send contents of the file in the body of an email message. ## Blat is a freeware email program for WinNT/95, it comes with VMS in the ## $BASE\CSCOpx\bin directory, make sure you install it first by running: ## ## blat -install <SMTP server address> <source email address> ## ## For more help on blat, just type "blat" at the command prompt on your VMS system (make ## sure it's in your path (feel free to move the executable to c:\winnt\system32 BEFORE ## you run the install, that'll make sure your system can always find it). system ("blat \"$TempIDSFile\" -t \"$EmailRcpt\" -s \"Received IDS alert\""); |
현재 이 구성에 대해 사용 가능한 확인 절차가 없습니다.
컨피그레이션 문제를 해결하려면 다음 지침을 따르십시오.
명령 프롬프트에서 이 명령을 실행하여 블레이트가 제대로 작동하는지 확인합니다.
blat-t -s "Test message"
<filename>은 VMS 시스템의 모든 텍스트 파일에 대한 전체 경로입니다. 전자 메일 스크립트가 전달되는 사용자가 전자 메일 본문에 이 파일을 수신하면 해당 블랙이 작동합니다.
경고가 트리거된 후 이메일이 수신되지 않으면 명령 프롬프트 창에서 Perl 스크립트를 실행해 보십시오.
그러면 모든 Perl 또는 경로 유형 문제가 강조 표시됩니다. 이렇게 하려면 명령 프롬프트를 열고 다음을 입력합니다.
>cd Program Files/CSCOpx/MDC/etc/ids/scripts >emailalert.pl ${Query}
이 예와 유사한 Sybase 오류가 발생할 수 있습니다. 이는 보안 모니터에서 전달되는 경우와 달리 전달하는 ${Query} 매개 변수에 실제로 정보가 포함되지 않기 때문입니다.
이 오류가 표시되지 않는 한 스크립트가 올바르게 실행되고 전자 메일을 보냅니다. 전자 메일 본문 내의 모든 경고 매개 변수는 비어 있습니다. Perl 또는 경로 오류가 발생하면 전자 메일을 보내기 전에 수정해야 합니다.
개정 | 게시 날짜 | 의견 |
---|---|---|
1.0 |
12-Jul-2006 |
최초 릴리스 |