Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

This output is given from : sflowtool -4 -p 3601  | /scripts/DoSTargets

Posted on 2013-12-21
2
Medium Priority
?
414 Views
Last Modified: 2013-12-22
I have 2 databases
1. ip.whitelist have only one column with ip name
2. ip.Block have 3 columns ip,reason,zaman

i have a sample output on flow as given below

sflowtool -4 -p 3601  | /scripts/DoSTargets


1387652837 178.20.228.47 15 mbps
1387652837 178.20.228.47 1792 pps
1387652837 185.9.156.35 11 mbps
1387652837 185.9.159.233 1536 pps
1387652838 185.9.156.35 11 mbps
1387652839 178.20.228.47 26 mbps
1387652839 178.20.228.47 2560 pps
1387652839 85.100.207.114 8 mbps
1387652840 178.20.228.47 27 mbps
1387652840 178.20.228.47 3072 pps
1387652840 185.9.159.233 12 mbps
1387652840 185.9.159.233 2304 pps
1387652841 178.20.228.47 20 mbps
1387652841 178.20.228.47 2048 pps
1387652841 89.253.155.97 8 mbps
1387652842 178.20.228.47 20 mbps
1387652842 178.20.228.47 1792 pps
1387652843 178.20.228.47 15 mbps
1387652843 178.20.228.47 1792 pps

Open in new window




i want sth. like this.

sflowtool -4 -p 3601  | /scripts/DoSTargets  | perl DDOSrecorder.pl

and if the traffic is bigger then 100mbps or 25000 pps it will check the ip.whitelist
and if it is not in white listed table it will only add the ip address to the ip.block table
reason column will only include the Xmbps or Xpps  to understand the blocking
0
Comment
Question by:3XLcom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 2000 total points
ID: 39735081
my %X=(
mbps => 100,
pps => 25000,
);
open W,"<ip.whitelist" or die "<ip.whitelist $!";
chomp,++$w{$_} while <W>;
close W;
open STDOUT,">>ip.block" or die ">>ip.block $!";
while( <> ){
  my @F=split;
  print "$F[1,2,3]\n" if !$w{$F[1]} && $F[2]>$X{$F[3]};
}
0
 

Author Closing Comment

by:3XLcom
ID: 39735095
thnx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question