Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Perl
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 ()
{
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 () {
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");
}
}
Posted 24-Sep-12 22:55pm
Edited 24-Sep-12 23:36pm
v2
Comments
Kuthuparakkal at 25-Sep-12 4:59am
   
what have you tried so far ? We can help but dont expect us to write code for you!
Zoltán Zörgő at 25-Sep-12 4:59am
   
It would be better to write the specification implemented by this code - and rewrite it from scratch in c#. "Converting" has no meaning is this sense.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Perl is a write once and don't dare to touch again scripting language. Even at it's best it can be hard to understand.
 
what you can do is extract the notion of what the perl script is doing and implement it as best you can in c#.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid