Script to scan wifi stations and order them by signal power
#!/usr/bin/perl
#
# root@libcrack.so
# 2010
#
sub hashValueDescendingNum {
   $lista{$b} <=> $lista{$a};
}

my $args=$#ARGV;
#print "args: $args\n";
#print "ARGV: $#ARGV\n";

if ($#ARGV == -1 || $#ARGV > 0) {
    print "\n\tUso: $0 <interface> \n\n";
    exit 1;
    }

#my $dev="ETH03";
my $dev=$ARGV[0];
my @cmd=`ifconfig $dev up && iwlist $dev scanning | egrep 'ESSID|Qua|Enc'`;
my $last_essid;
my $num=20;

my %lista = ();

#XXX
for my $i  (@cmd) { 

    my $essid;
    my $calidad;

    if ($i =~ /.*ESSID:\"(.+)\".*/){
        $essid=$1;
        $last_essid=$essid;
    }

    if ($i =~ /.*Quality=(\d+)\/\d+.*/){
        $calidad=$1;
        $lista{$last_essid} = $calidad;
        #print "essid-> $last_essid\n";
        #print "Calidad -> $calidad\n\n";
    }

}

while (($essid, $calidad) = each(%lista)) {
    if ($calidad > $num){
        print "=================================\n";
        print " ESSID: $essid\n";
        print " Calidad: $calidad\n";
        print "=================================\n";
    }

}

exit 0
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License