Skip to content

Instantly share code, notes, and snippets.

@libcrack
Created September 22, 2016 14:26
Show Gist options
  • Select an option

  • Save libcrack/b55fad26c38e6a810ff682c360a3f6ac to your computer and use it in GitHub Desktop.

Select an option

Save libcrack/b55fad26c38e6a810ff682c360a3f6ac to your computer and use it in GitHub Desktop.
Parse airodump output
#!/usr/bin/env perl
# [email protected]
# Thu Dec 1 16:50:59 CET 2011
use strict;
use warnings;
# autoflush yeah
$|=1;
my $logfile = "";
# COLORS
my $reset="\e[0m";
# Regular Colors
my $red="\e[0;31m";
my $green="\e[0;32m";
my $blue="\e[0;34m";
my $purple="\e[0;35m";
# Intense Colors
my $iblack="\e[0;90m";
my $ired="\e[0;91m";
my $igreen="\e[0;92m";
my $iyellow="\e[0;93m";
my $iblue="\e[0;94m";
my $ipurple="\e[0;95m";
# Bold High Intensty
my $bired="\e[1;91m";
my $bigreen="\e[1;92m";
my $biyellow="\e[1;93m";
my $biblue="\e[1;94m";
my $bipurple="\e[1;95m";
#my $ap_regexp = '(.+),(.+),(.+),(.+),(.+),(.+),(.*),(.*),(.+),(.+),(.+),(.+),(.+),(.+),(.*)';
my $ap_regexp = '(.+),(.+),(.+),(.+),(.+),(.+),(.*),(.*),(.+),\s*(\d+)\s*,(.+),(.+),(.+),(.+),(.*)';
my $u_st_regexp = '(.+),(.+),(.+),(.+),(.+),.+not associated.+,(.*)';
my $st_regexp = '(.+),(.+),(.+),(.+),(.+),(.+),(.*)';
# ==============================================================================================
if(!$ARGV[0]){
print "\n\tUsage: $0 <logfile>\n\n";
exit 1;
}
$logfile = $ARGV[0];
# ==============================================================================================
open(LINES,"<:encoding(UTF-8)",$logfile) || die "can't open $logfile: $!";
while (<LINES>) {
my $linea = $_;
chomp($linea);
# Puntos de acceso
#BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power, # beacons, # IV, LAN IP, ID-length, ESSID, Key
if ($linea =~ /$ap_regexp/) {
my $ap_mac = $1;
my $ap_fseen = $2;
my $ap_lseen = $3;
my $ap_channel = $4;
my $ap_speed = $5;
my $ap_privacy = $6;
my $ap_cipher = $7;
my $ap_auth = $8;
my $ap_power = $9;
my $ap_beacons = $10;
my $ap_ivs = $11;
my $ap_ip = $12;
my $ap_id_len = $13;
my $ap_essid = $14;
my $ap_key = $15;
print "[$bired Detectado AP $reset] $ap_mac essid $ap_essid channel $ap_channel\n";
# clientes NO asociados
#Station MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs
} elsif ($linea =~ /$u_st_regexp/) {
my $st_mac = $1;
my $st_fseen = $2;
my $st_lseen = $3;
my $st_pwr = $4;
my $st_nr_pkts = $5;
my $st_bssid = 'not associated';
my $st_probed_bssid = $6;
print "[$biblue Detectado cliente no asociado $reset] $st_mac \n";
# clientes asociados
#Station MAC, First time seen, Last time seen, Power, # packets, BSSID, Probed ESSIDs
} elsif ($linea =~ /$st_regexp/) {
my $st_mac = $1;
my $st_fseen = $2;
my $st_lseen = $3;
my $st_pwr = $4;
my $st_nr_pkts = $5;
my $st_bssid = $6;
my $st_probed_bssid = $7;
if ($st_bssid =~ /\w\w:\w\w:\w\w:\w\w:\w\w:\w\w/) {
print "[$bigreen Detectado cliente $reset] $st_mac asociado con $st_bssid\n";
}
}
}
close LINES;
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment