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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;

my $self = {};
bless($self, $class);

# Run initialisation code
$self->_init(@_);

return $self;
}
  Permalink  
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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 883
1 OriginalGriff 410
2 CPallini 275
3 George Jonsson 166
4 ChauhanAjay 150
0 OriginalGriff 5,450
1 CPallini 4,500
2 Sergey Alexandrovich Kryukov 4,482
3 George Jonsson 3,057
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 2 Sep 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100