WifiScan.rb

#!/usr/bin/ruby
#Script displaying results of an airodump-ng scan
#Part of the Wifon project
#Author: Adam Menkiewicz, 2010

require 'fastercsv'
require 'curses'

chan = Array.new
id = Array.new
mac = Array.new
crypt = Array.new
line = Array.new

channel = Array.new
essid = Array.new
bssid = Array.new
enc = Array.new


@scr = Curses.init_screen
        Curses.raw
        Curses.noecho
        Curses.curs_set(0)
        @scr.keypad(true)
        @scr.refresh
i = 0;
e = 0;
k = 0;
triger = 1;
loop do


if(triger == 1)
chan.clear
id.clear
mac.clear
crypt.clear
line.clear
#/tmp/data-01.csv
FasterCSV.foreach("/tmp/data-01.txt", :quote_char => '"', :col_sep =>',', :row_sep =>:auto) {|a|

    channel[i] = a[3]
    essid[i] = a[13]
    bssid[i] = a[0]
    enc[i] = a[5]
      i =i+1

}

e = 2
while(i>0 ) do

  if(channel[e] != nil &&  essid[e] != nil && bssid[e] != nil && enc[e] != nil)
      essidstr = essid[e];
      chanstr = channel[e]
      macstr = bssid[e];
      macstr.delete! ":"


    id << essidstr.strip!;
    line << "";
    mac << macstr;
    chan << chanstr.strip!
    crypt << enc[e];
   
    e = e+1
  end
  i=i-1
 end
 triger = 0;
end
s = mac.size

if(mac[k] == nil && chan[k] == nil)
@scr.setpos(0,0);
@scr.addstr("Cant find network, wait a bit and press any key to scan...");
@scr.refresh
end
 if(mac[k] != nil)
  @scr.clear
  @scr.setpos(0,0);
  @scr.addstr(id[k]);
  @scr.setpos(1,0);
  @scr.addstr(line[k]);
  @scr.setpos(2,0);
  @scr.addstr(mac[k]);
  @scr.setpos(3,0);
  @scr.addstr(chan[k]);
  @scr.setpos(3,4);
  @scr.addstr(crypt[k]);
  @scr.refresh
 end

key = @scr.getch

if (key == Curses::KEY_DOWN ) then
    k=k+1
      if (k>s-1)
      k = k-1
     end
end
if (key == Curses::KEY_UP ) then
      k=k-1
      if (k<0)
        k = k+1
      end
  end
 if ( key == Curses::KEY_CANCEL)
   @scr.clear
   @scr.refresh

    Curses.stdscr.clear
        Curses.stdscr.setpos(0, 0)
        Curses.refresh
        Curses.close_screen
    :exit
    exec "echo quiting"

  end
   if ( key == Curses::KEY_ENTER)
   triger = 1;
  end
@scr.refresh
end

Comments