regex not working, please help
Posted: 07 Feb 2014, 03:31
Hi,
I wrote a small regex to help me identify ip addresses trying to access my system (hackers) and block them.
For some reason it's not working but the regex was tested and it returned matching results. I'm not sure what I'm missing please help.
Here's the regex I wrote:
# Added for Freeswitch
if (($lgfile eq $config{CUSTOM1_LOG}) and ($line =~ /^.*?\[WARNING\] sofia_reg.c:(.*?) SIP auth failure \(REGISTER\) on sofia profile '(.*?)' for \[(.*?)\] from ip (\d+\.\d+\.\d+\.\d+){
return ("SIP auth failure on interface" $1 for user $2",$3,"freeswitch","5","5060","600");
}
if (($lgfile eq $config{CUSTOM2_LOG}) and ($line =~ /^.*?\[WARNING\] sofia_reg.c:(.*?) SIP auth failure \(REGISTER\) on sofia profile '(.*?)' for \[(.*?)\] from ip (\d+\.\d+\.\d+\.\d+){
return ("SIP auth failure on interface $1 for user $2",$3,"freeswitch","5","5060","600");
}
if (($lgfile eq $config{CUSTOM1_LOG}) and ($line =~ /^.*?\[WARNING\] sofia_reg.c:(.*?) Can't find user \[(.*?)\] from (\d+\.\d+\.\d+\.\d+) {
return ("Cant find user on interface" ,$1, "freeswitch","1","5060","10");
}
# End Freeswitch firewall regex
I wrote a small regex to help me identify ip addresses trying to access my system (hackers) and block them.
For some reason it's not working but the regex was tested and it returned matching results. I'm not sure what I'm missing please help.
Here's the regex I wrote:
# Added for Freeswitch
if (($lgfile eq $config{CUSTOM1_LOG}) and ($line =~ /^.*?\[WARNING\] sofia_reg.c:(.*?) SIP auth failure \(REGISTER\) on sofia profile '(.*?)' for \[(.*?)\] from ip (\d+\.\d+\.\d+\.\d+){
return ("SIP auth failure on interface" $1 for user $2",$3,"freeswitch","5","5060","600");
}
if (($lgfile eq $config{CUSTOM2_LOG}) and ($line =~ /^.*?\[WARNING\] sofia_reg.c:(.*?) SIP auth failure \(REGISTER\) on sofia profile '(.*?)' for \[(.*?)\] from ip (\d+\.\d+\.\d+\.\d+){
return ("SIP auth failure on interface $1 for user $2",$3,"freeswitch","5","5060","600");
}
if (($lgfile eq $config{CUSTOM1_LOG}) and ($line =~ /^.*?\[WARNING\] sofia_reg.c:(.*?) Can't find user \[(.*?)\] from (\d+\.\d+\.\d+\.\d+) {
return ("Cant find user on interface" ,$1, "freeswitch","1","5060","10");
}
# End Freeswitch firewall regex