rubywpa 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rubywpa.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Claudio Poli
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,32 @@
1
+ = Ruby WPA
2
+
3
+ Some WPA password detection with Ruby.
4
+
5
+ == Installation
6
+
7
+ gem install rubywpa
8
+
9
+ == Disclaimer
10
+
11
+ Test if your own WiFi network is subsceptible to standard WPA passwords.
12
+ I decline any responsibility for any other use.
13
+
14
+ == Why?
15
+
16
+ Because ISPs started shipping WiFi-enabled modem/routes to their customers with standard passwords.
17
+ Those passwords in some cases are directly linked to the broadcasting SSID, allowing for an attacked to use
18
+ your network without authorization.
19
+ This tool helps you find out if you are currently vulnerable or not. If the password match, please do
20
+ what's in your power to change your WiFi password, either asking your ISP or do it by yourself.
21
+
22
+ == Why Ruby?
23
+
24
+ Because it's my favourite language and it's fun.
25
+ I agree that a C library would be more portable, but it is easy enough to do it by yourself if you need to.
26
+
27
+ == TODO
28
+
29
+ - more supported ISPs
30
+ - better detection through regex
31
+ - proper code structure
32
+ - proper error raising/handling
@@ -0,0 +1,42 @@
1
+ require 'digest/md5'
2
+ require 'rubywpa/networks/alice'
3
+ require 'rubywpa/networks/fastweb'
4
+
5
+ module Rubywpa
6
+ class WiFi
7
+ attr_accessor :ssid
8
+
9
+ # Create a new rubywpa instance and set the SSID.
10
+ #
11
+ # wifi = Rubywpa::WiFi.new({
12
+ # :ssid => "MY_SSID",
13
+ # :mac => "My_mac_address" # required for some networks
14
+ # })
15
+ # wifi.password
16
+ #
17
+ def initialize(options = {}, &block)
18
+ @ssid = options[:ssid]
19
+ @mac = options[:mac]
20
+ @country_code = options[:country_code]
21
+
22
+ yield self if block_given?
23
+ end
24
+
25
+ def password
26
+ case
27
+ when fastweb? then Fastweb.compute(ssid)
28
+ when alice? then Alice.compute(ssid)
29
+ else
30
+ 'Network not supported!'
31
+ end
32
+ end
33
+
34
+ def fastweb?
35
+ !!(ssid =~ /^FASTWEB/i)
36
+ end
37
+
38
+ def alice?
39
+ !!(ssid =~ /^Alice/i)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,4 @@
1
+ class Alice
2
+ def self.compute(options = {})
3
+ end
4
+ end
@@ -0,0 +1,35 @@
1
+ class Fastweb
2
+ def self.compute(ssid)
3
+ begin
4
+ seq_20 = "\x22\x33\x11\x34\x02\x81\xFA\x22\x11\x41\x68\x11\x12\x01\x05\x22\x71\x42\x10\x66";
5
+ serial_number_bytes = ssid.split('-')[2].scan(/[a-f0-9]{2}/i)
6
+ str = ''
7
+ (0..5).each{ |idx| str << serial_number_bytes[idx].hex.chr }
8
+ str << seq_20
9
+
10
+ # MD5
11
+ str_long = ''
12
+ Digest::MD5.hexdigest(str).scan(/[a-f0-9]{2}/i).each{ |byte| str_long << byte.hex.to_s(2).rjust(8, '0') }
13
+
14
+ # HEX
15
+ hex_5 = []
16
+ i = 0
17
+ while i < 25
18
+ n = str_long[i, 5].to_i(2)
19
+ if n > 0x0a
20
+ hex_5 << (n + 0x57)
21
+ else
22
+ hex_5 << n
23
+ end
24
+ i += 5
25
+ end
26
+
27
+ # WPA
28
+ wpa = ''
29
+ hex_5.each{ |hex| wpa << sprintf("%02x", hex) }
30
+ wpa
31
+ rescue Exception => e
32
+ "Fastweb parser raised: SSID not supported yet"
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module Rubywpa
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "rubywpa/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "rubywpa"
7
+ s.version = Rubywpa::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Claudio Poli"]
10
+ s.email = ["masterkain@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Find out if your WiFi is subsceptible to standard passwords}
13
+ s.description = %q{SSID-to-WPA verifier for supported networks}
14
+
15
+ s.rubyforge_project = "rubywpa"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
File without changes
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubywpa
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Claudio Poli
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-25 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: SSID-to-WPA verifier for supported networks
23
+ email:
24
+ - masterkain@gmail.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - MIT-LICENSE
35
+ - Rakefile
36
+ - Readme.rdoc
37
+ - lib/rubywpa.rb
38
+ - lib/rubywpa/networks/alice.rb
39
+ - lib/rubywpa/networks/fastweb.rb
40
+ - lib/rubywpa/version.rb
41
+ - rubywpa.gemspec
42
+ - test/rubywpa_test.rb
43
+ has_rdoc: true
44
+ homepage: ""
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options: []
49
+
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ hash: 3
67
+ segments:
68
+ - 0
69
+ version: "0"
70
+ requirements: []
71
+
72
+ rubyforge_project: rubywpa
73
+ rubygems_version: 1.6.0
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: Find out if your WiFi is subsceptible to standard passwords
77
+ test_files:
78
+ - test/rubywpa_test.rb