Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/07/2014, 08:36
Avatar de Melecio
Melecio
 
Fecha de Ingreso: julio-2011
Ubicación: Coahuila
Mensajes: 320
Antigüedad: 12 años, 10 meses
Puntos: 8
Respuesta: perl /sbin/iwlist scan 2>&1

ya lo encontre es este codigo

Código:
#!/usr/bin/perl
#
# wlanscan.pl
# version 0.1
#
# Written by Joey Kelly
# joeykelly.net
#
# copyright 2014
# GPL version 2
#
# I want to get and display a table of available APs.
# I did this on NetBSD once, let's see if I can replicate on Linux.

# NOTE: the iwlist docs say or said to not write scripts against it, presumably because the output will change in future versions.
# Yeah, like I'm going to listen...

use strict;
use warnings;

#my $wifi = shift || die "What is the wifi interface? Pass it as an argument to this script. Example: ./wlanscan.pl wlan0\n";
#chomp $wifi;


# let's bounce the interface first
#system "/sbin/ifconfig $wifi down";
#system "/sbin/ifconfig $wifi up";

my $scan = `/sbin/iwlist wlan0 scan`;



my @cell = split(/Cell/,$scan);
# lose the leading bogus entry
$_ = shift @cell;


foreach my $cell (@cell) {
  my ($mac, $channel, $essid, $encryption, $mode, $signalnumbers, $signalquality, $security) = ('','','','','','','','');

  if ( $cell =~ /Address:\ ([A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2}:[A-Z0-9]{2})/ ) {
    $mac = $1;
  }
  if ( $cell =~ /Channel:(\d+)/ ) {
    $channel = $1;
  }
  if ( $cell =~ /ESSID:"(\w+)"/ ) {
    $essid = $1;
  }
  $essid = '<hidden>' unless $essid;
  if ( $cell =~ /Encryption\ key:(\w+)/ ) {
    $encryption = $1;
  }
  if ( $cell =~ /Mode:(\w+)/ ) {
    $mode = $1;
  }
  if ( $cell =~ /Signal\ level=(-\d+\ dBm)/ ) {
    $signalnumbers = $1;
  }
  if ( $cell =~ /Quality=(\d+\/\d+)/ ) {
    $signalquality = $1;
  }
  #
  # OK, here's where it gets weird
  unless ( $cell =~ /WPA/ ) {
    $security = 'WEP';
  }
  if ( $cell =~ /IE:\ IEEE\ 802\.11i\/WPA2 Version\ 1/ ) {
    $security = 'WPA2 v1';
  }
  if ( $cell =~ /IE:\ IEEE\ 802\.11i\/WPA2 Version\ 2/ ) {
    $security = 'WPA2 v2';
  }
  if ( $cell =~ /IE:\ WPA\ Version\ 1/ ) {
    if ($security) {
      $security .= ' and WPA1';
    } else {
      $security = 'WPA1';
    }
  }
  # our fall-through
  $security = 'none' unless $encryption eq 'on';

  print "essid: $essid\n";
  print "channel: $channel\n";
  print "MAC: $mac\n";
  print "mode: $mode\n";
  print "encrypted: $encryption\n";
  print "security: $security\n";
  print "signal: $signalnumbers\n";
  print "quality: $signalquality\n";
  print "\n";
}

my $cells = @cell;
print "number of cells seen: $cells\n" if $cells;

funciona muy bien y me da todo lo que necesito, espero y les sirvan, Gracias,