Click here to Skip to main content
Sign Up to vote bad
good
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:55
Edited 24 Sep '12 - 23:36

Comments
Kuthuparakkal - 25 Sep '12 - 4:59
what have you tried so far ? We can help but dont expect us to write code for you!
Zoltán Zörgő - 25 Sep '12 - 4:59
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

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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 415
1 OriginalGriff 315
2 Slacker007 240
3 Maciej Los 240
4 Aarti Meswania 210
0 Sergey Alexandrovich Kryukov 8,953
1 OriginalGriff 7,134
2 CPallini 3,758
3 Rohan Leuva 3,066
4 Maciej Los 2,528


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid