Skip to content

Instantly share code, notes, and snippets.

@javier
Forked from ace/jazzfonica.rb
Created June 14, 2011 11:29
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save javier/1024717 to your computer and use it in GitHub Desktop.
Save javier/1024717 to your computer and use it in GitHub Desktop.
jazzfonica
#!/usr/bin/env ruby
# jazzfonica.rb for Mac OS X
# Scans the visible networks for JAZZTEL_XXXX or WLAN_XXXX and calculates the password
# Ported from PHP example at http://kz.ath.cx/wlan/codigo.txt
# Download and execute with ruby (e.g. ruby jazzfonica.rb) from a Terminal
#ported to ubuntu from https://gist.github.com/1024587
#it will ask for sudo privileges.
#if your wlan card is not "wlan0" change the "my_wifi_card" variable
require 'digest/md5'
my_wifi_card = "wlan0"
messages = []
output = IO.popen(" sudo iwlist #{my_wifi_card} scan | egrep 'Address|ESSID' | tr '\n' ' ' " ).first
#we want to get a list of macaddress|ESSIDname. Some regexp magic to clean the output to that format
ssids = output.gsub(/\s/,'').gsub(/ESSID:"(.*?)"/, "|\\1\n").gsub(/^.+?:/,'').gsub(/(.*)\|(.*)/,"\\2|\\1").split("\n")
ssids.each do |line|
next unless line =~ /^(WLAN|JAZZTEL)_/
puts "checking #{line} ------------------"
messages << "Red: #{line.split("|")[0]}\nClave: #{Digest::MD5.hexdigest('bcgbghgg' << line.split("|")[1].split.join("\n").upcase.gsub( /:/, '')[0,8] << line.split("|")[0].split("_")[1].upcase << line.split("|")[1].split.join("\n").upcase.gsub( /:/, ''))[0,20]}\n" unless line.split("|")[0].split("_")[1].length != 4
end
puts messages.length <= 0 ? "No se han encontrado redes WLAN_XXXX o JAZZTEL_XXXX" : messages.each { |msg| msg }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment