Advertisement
Guest User

0verSniff.pl pruebas

a guest
Mar 24th, 2013
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.70 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4. use Net::PcapUtils;
  5. use NetPacket::Ethernet;
  6. use NetPacket::IP;
  7. use NetPacket::TCP;
  8. use Data::HexDump; #Recordar: soltar volcado en Hex para otras herramientas
  9. use Term::ANSIColor;
  10.  
  11.  
  12. unless ($ARGV[0]) { &error_param; }
  13.  
  14. my $option = $ARGV[0];
  15. if ($option eq "-h") { &help; }
  16.  
  17. #Recordar: meter filtros al gusto mediante argumentos
  18. #Recordar: optimizar la selección de opciones, y añadir las que había pensado
  19. my %filter = (
  20.     "-d" => "dst port 80",
  21.     "-s" => "src port 80",
  22.         "-b" => "port 80"
  23.  
  24. );
  25.  
  26. ETIQUETA:   #Esto es una guarrada, pero no consigo hacerlo de otra forma
  27. print "\n\n";
  28. Net::PcapUtils::loop(\&process_pkt, SNAPLEN => 1000, FILTER => $filter{$option});
  29.  
  30. #Aqui metemos la subrutina para leer los paquetes y limpiarlos
  31. sub process_pkt {
  32.     my($arg, $hdr, $pkt) = @_;
  33.  
  34.     my $eth_obj = NetPacket::Ethernet->decode($pkt);
  35.     if ($eth_obj->{type} == 0x0800) {
  36.         my $ip_obj = NetPacket::IP->decode($eth_obj->{data});
  37.         if ($ip_obj->{proto} == 6){
  38.             my $tcp_obj = NetPacket::TCP->decode($ip_obj->{data});
  39.             if ($tcp_obj->{data}){
  40.                 $tcp_obj->{data} =~ s/\r\n\r\n/\nxxxx/g;
  41.                 my @todo = split(/\r\n/,$tcp_obj->{data});
  42.                                 foreach my $line (@todo) {
  43.                     if ($line =~ "xxxx"){ goto ETIQUETA; }
  44.                     print "\n$line";
  45.         #Esto es otra guarrada, pero es que no consigo hacerlo de ninguna                   #otra manera. Y aun así a veces falla         
  46.  
  47.      }
  48.                
  49.     }
  50.    }
  51.   }
  52.  }
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59. sub error_param {
  60.     use Term::ANSIColor qw(:constants);
  61.         local $Term::ANSIColor::AUTORESET = 1;
  62.         print RED "\n[+]";
  63.         print "Necesitas añadir una opcion\nUso: perl 0verSniff.pl <opcion>\n\n";
  64.         exit;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement