将perl脚本转换为c# [英] convert a perl script to c#
问题描述
我不会将此脚本转换为c#,任何专业编码人员都可以帮助我!
#从警报文件中获取攻击者的IP地址
sub get_alert_ip {
打开(ALERT,alert.ids)或死于无法打开或读取警报文件;
while(< alert>)
{
next if(/ ^ \s * $ /); #skip空行
next if(/ ^#/); #skip评论专栏
if(/\.*\s(\\+\.\d+\\\+ \\\++)\。* / )#抓住IP地址
{
$ alertip = $ 1;
打印警报IP地址是$ alertip \ n; < br $>
}
}
关闭(ALERT);
#检查你是否得到它!
if($ ip eq){print无法从警报中获取IP地址
fi le!\ n;}}
$ alertip;
}
#########
#将新IP地址与我已经拥有的IP地址进行比较
抓取
sub compare_ip {
my($ compareip)= @_;
open(COMPARE, attackers.old)或死无法读取忽略文件,
$!\ n;
while(< compare>){
chop;
next if(/ ^ \s * $ /); #skip空行
next if(/ ^#/); #skip评论专栏
if(/(.*)/)
{
}
}
$ alertip = $ 1;
if($ alertipeq$ compareip)
{
print有人老还在攻击\ n;
}
其他
{#向IPSEC滤波器子功能发送新IP地址
& ip fi lter($ compareip);
$ tag = 1;
}
next;
关闭(比较);
if($ tag eq 1)
{
system(echo $ compareip>> ; attackers.old);
}
}
i wont to convert this script to c# ,any Professional coder can help me !
#Grab the attacker's IP address from the alert file
sub get_alert_ip{
open (ALERT, "alert.ids") or die "Cannot open or read alert file";
while (<alert>)
{
next if (/^\s*$/); #skip blank lines
next if (/^#/); # skip comment lines
if (/\.*\s(\d+\.\d+\.\d+\.\d+)\.*/) #Grab the IP Address
{
$alertip=$1;
print "Alert IP address is $alertip \n";
}
}
close (ALERT);
#Check to see if you got it!
if ($ip eq ""){ print "Could not get the IP address out of the alert
file! \n";}
$alertip;
}
#########
#Compares the new IP address to the IP address I have already
captured
sub compare_ip{
my ($compareip) = @_;
open (COMPARE, "attackers.old") or die "Cannot read the ignore file,
$!\n";
while (<compare>) {
chop;
next if (/^\s*$/); #skip blank lines
next if (/^#/); # skip comment lines
if (/(.*)/)
{
}
}
$alertip=$1;
if ("$alertip" eq "$compareip")
{
print "Somebody old is still attacking \n";
}
else
{ #Send the new IP address to the IPSEC filter subfunction
&ipfilter($compareip);
$tag=1;
}
next;
close (COMPARE);
if ($tag eq 1)
{
system ("echo $compareip >> attackers.old");
}
}
推荐答案
/ ); #skip空行
next if(/ ^#/); #skip评论专栏
if(/\.*\s(\\+\.\d+\\\+ \\\++)\。* / )#Grab the IP Address
{
/); #skip blank lines
next if (/^#/); # skip comment lines
if (/\.*\s(\d+\.\d+\.\d+\.\d+)\.*/) #Grab the IP Address
{
alertip =
alertip=
1;
打印警报IP地址
1;
print "Alert IP address is
这篇关于将perl脚本转换为c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!