A userspace application that filters DHCP floods to protect a DHCP server. It uses the Netfilter userspace packet queuing API.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

perftest.pl 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my($maccnt, $pps, $src, $dest) = @ARGV;
  5. usage() if !defined $dest;
  6. if ( $maccnt !~ /^\d+$/ || $maccnt < 1 ) {
  7. print STDERR "MAC count must be a positive integer\n";
  8. exit 1;
  9. }
  10. if ( $pps !~ /^\d+$/ || $pps < 1 ) {
  11. print STDERR "packets/sec must be a positive integer\n";
  12. exit 1;
  13. }
  14. if ( $src !~ /^(\d+\.\d+\.\d+\.\d+)$/ ) {
  15. print STDERR "source IP must be a valid IPv4 address\n";
  16. exit 1;
  17. }
  18. if ( $dest !~ /^(\d+\.\d+\.\d+\.\d+)$/ ) {
  19. print STDERR "destination IP must be a valid IPv4 address\n";
  20. exit 1;
  21. }
  22. main($maccnt, $pps, $src, $dest);
  23. sub usage {
  24. print STDERR "DHCP Flood using option 82\n";
  25. print STDERR "This is only to test dhcp_protect, the DHCP packets aren't really valid\n";
  26. print STDERR "DO NOT SEND THIS TO YOUR DHCP SERVER !!!!\n";
  27. print STDERR "\n";
  28. print STDERR "Usage: $0 <MAC count> <packets/sec> <source IPv4> <destination IPv4>\n";
  29. print STDERR "Dependency: nemesis must be installed\n";
  30. print STDERR "https://ftp.troglobit.com/nemesis/\n";
  31. print STDERR "\n";
  32. exit 1;
  33. }
  34. sub main {
  35. my($maccnt, $pps, $src, $dest)=@_;
  36. my $hdr = "";
  37. $hdr .= "010106010c02385600010000000000000000000000000000c16e5f43409c28db";
  38. $hdr .= "d56c000000000000000000000000000000000000000000000000000000000000";
  39. $hdr .= "0000000000000000000000000000000000000000000000000000000000000000";
  40. $hdr .= "0000000000000000000000000000000000000000000000000000000000000000";
  41. $hdr .= "0000000000000000000000000000000000000000000000000000000000000000";
  42. $hdr .= "0000000000000000000000000000000000000000000000000000000000000000";
  43. $hdr .= "0000000000000000000000000000000000000000000000000000000000000000";
  44. $hdr .= "000000000000000000000000638253633501013707017903060f77fc390205dc";
  45. $hdr .= "3d0701409c28dbd56c33040076a7000c097370616c6569666f6e000000000000";
  46. $hdr .= "0000000000000000000000520e0104000000000206XXXXXXXXXXXXff00000000";
  47. my $int = 1/$pps;
  48. while(1) {
  49. for(my $i=0; $i<$maccnt; $i++) {
  50. my $mac = sprintf("000000%06x", $i);
  51. my $pkt = $hdr;
  52. $pkt =~ s/XXXXXXXXXXXX/$mac/;
  53. open(N,"| nemesis udp -S $src -D $dest -x 67 -y 666 -i $int -P -") || die "install nemesis!";
  54. print N pack("H*",$pkt);
  55. print N "";
  56. close(N);
  57. }
  58. }
  59. }