-
-
Save javier/1024717 to your computer and use it in GitHub Desktop.
jazzfonica
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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