elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Perl] DH Sniffer 0.3
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Perl] DH Sniffer 0.3  (Leído 1,689 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Perl] DH Sniffer 0.3
« en: 18 Enero 2014, 23:56 pm »

Un simple sniffer en perl para capturar todo lo que pasa en los metodos GET y POST

El codigo :

Código
  1. #!usr/bin/perl
  2. #DH Sniffer 0.3
  3. #(C) Doddy Hackman 2014
  4. #Credits :
  5. #Based on :
  6. #http://stackoverflow.com/questions/4777042/can-i-use-tcpdump-to-get-http-requests-response-header-and-response-body
  7. #http://www.perlmonks.org/?node_id=656590
  8. #http://stein.cshl.org/~lstein/talks/WWW6/sniffer/
  9. #http://perlenespanol.com/foro/post36051.html
  10. #Thanks to : Lincoln D. Stein , paulz and Explorer
  11.  
  12. use CGI;
  13. use threads;
  14. use URI::Escape;
  15.  
  16. $| = 1;
  17.  
  18. my $control = shift;
  19.  
  20. head();
  21.  
  22. if ( $control eq "" ) {
  23.    print "\n[+] Sintax : $0 <option>\n";
  24.    print "\n[++] Options :\n";
  25.    print "\n[+] -g : Capture method GET\n";
  26.    print "[+] -p : Capture method POST\n";
  27.    print "\n[+] Example : sudo perl $0 -pg\n";
  28.    copyright();
  29. }
  30.  
  31. print "\n";
  32.  
  33. my $hilo_get  = threads->new( \&sniffer_get );
  34. my $hilo_post = threads->new( \&sniffer_post );
  35.  
  36. $hilo_get->join;
  37. $hilo_post->join;
  38.  
  39. sub sniffer_get {
  40.  
  41.    if ( $control =~ /g/ ) {
  42.  
  43.        open( GET, "/usr/sbin/tcpdump -lnx -s 1024 dst port 80 |" );
  44.  
  45.        while (<GET>) {
  46.  
  47.            if (/^\S/) {
  48.  
  49.                while ( $contenido =~
  50.                    /(GET|POST|WWW-Authenticate|Authorization).+/g )
  51.                {
  52.                    print "\n[+] $ip = $name " . uri_unescape($&);
  53.                    savefile( "logs", "\n[+] $ip = $name " . uri_unescape($&) );
  54.                }
  55.  
  56.                undef $ip;
  57.                undef $name;
  58.                undef $contenido;
  59.  
  60.                ( $ip, $name ) =
  61.                  /IP (\d+\.\d+\.\d+\.\d+).+ > (\d+\.\d+\.\d+\.\d+)/;
  62.  
  63.            }
  64.  
  65.            s/\s+//g;
  66.            s/0x[abcdef\d]+://i;
  67.            s/([0-9a-f]{2})/chr(hex($1))/eg;
  68.            tr/\x1F-\x7E\r\n//cd;
  69.  
  70.            $contenido .= $_;
  71.  
  72.        }
  73.    }
  74. }
  75.  
  76. sub sniffer_post {
  77.  
  78.    if ( $control =~ /p/ ) {
  79.  
  80.        open( POST,
  81. "tcpdump -A -s 0 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' |"
  82.        );
  83.        while (<POST>) {
  84.  
  85.            if (/^\S/) {
  86.  
  87.                my $code = $_;
  88.  
  89.                $buscando = CGI->new($code);
  90.  
  91.                my @params = $buscando->param;
  92.  
  93.                foreach $par (@params) {
  94.  
  95.                    if ( $par =~ /\./ ) {
  96.                        next;
  97.                    }
  98.                    else {
  99.                        my $dataf = $buscando->param($par);
  100.                        print "\n[+] $par " . " : " . $dataf;
  101.                        savefile( "logs", "\n[+] $par " . " : " . $dataf );
  102.                    }
  103.                }
  104.            }
  105.        }
  106.    }
  107. }
  108.  
  109. sub savefile {
  110.    open( SAVE, ">>" . $_[0] );
  111.    print SAVE $_[1];
  112.    close SAVE;
  113. }
  114.  
  115. sub head {
  116.    print "\n-- == DH Sniffer 0.3 == --\n";
  117. }
  118.  
  119. sub copyright {
  120.    print "\n-- == (C) Doddy Hackman 2014 == --\n\n";
  121.    exit(1);
  122. }
  123.  
  124. # The End ?
  125.  

Eso es todo.


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Libros de Perl online [PERL]
Scripting
madpitbull_99 0 3,835 Último mensaje 18 Mayo 2011, 21:49 pm
por madpitbull_99
Messenger Sniffer en Perl
Scripting
brians444 1 2,190 Último mensaje 29 Mayo 2012, 02:56 am
por megabyte18a
sniffer wifi, sniffer gsm.
Hacking
soyloqbuskas 2 4,132 Último mensaje 1 Agosto 2012, 16:29 pm
por soyloqbuskas
[Perl] Creacion de un Joiner en Perl
Scripting
BigBear 0 2,788 Último mensaje 15 Marzo 2013, 16:12 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines