packetfu 1.1.10 → 1.1.11
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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/.gitignore +3 -0
- data/.travis.yml +8 -0
- data/CONTRIBUTING.md +47 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +1 -1
- data/README.rdoc +35 -30
- data/Rakefile +4 -4
- data/bench/octets.rb +9 -9
- data/examples/100kpackets.rb +12 -12
- data/examples/ackscan.rb +16 -16
- data/examples/arp.rb +35 -35
- data/examples/arphood.rb +36 -36
- data/examples/dissect_thinger.rb +6 -6
- data/examples/new-simple-stats.rb +23 -23
- data/examples/packetfu-shell.rb +25 -25
- data/examples/simple-sniffer.rb +9 -9
- data/examples/simple-stats.rb +23 -23
- data/examples/slammer.rb +3 -3
- data/gem-public_cert.pem +21 -0
- data/lib/packetfu.rb +149 -127
- data/lib/packetfu/capture.rb +169 -169
- data/lib/packetfu/config.rb +52 -52
- data/lib/packetfu/inject.rb +56 -56
- data/lib/packetfu/packet.rb +531 -528
- data/lib/packetfu/pcap.rb +579 -579
- data/lib/packetfu/protos/arp.rb +90 -90
- data/lib/packetfu/protos/arp/header.rb +158 -158
- data/lib/packetfu/protos/arp/mixin.rb +36 -36
- data/lib/packetfu/protos/eth.rb +44 -44
- data/lib/packetfu/protos/eth/header.rb +243 -243
- data/lib/packetfu/protos/eth/mixin.rb +3 -3
- data/lib/packetfu/protos/hsrp.rb +69 -69
- data/lib/packetfu/protos/hsrp/header.rb +107 -107
- data/lib/packetfu/protos/hsrp/mixin.rb +29 -29
- data/lib/packetfu/protos/icmp.rb +71 -71
- data/lib/packetfu/protos/icmp/header.rb +82 -82
- data/lib/packetfu/protos/icmp/mixin.rb +14 -14
- data/lib/packetfu/protos/invalid.rb +49 -49
- data/lib/packetfu/protos/ip.rb +69 -69
- data/lib/packetfu/protos/ip/header.rb +291 -291
- data/lib/packetfu/protos/ip/mixin.rb +40 -40
- data/lib/packetfu/protos/ipv6.rb +50 -50
- data/lib/packetfu/protos/ipv6/header.rb +188 -188
- data/lib/packetfu/protos/ipv6/mixin.rb +29 -29
- data/lib/packetfu/protos/tcp.rb +176 -176
- data/lib/packetfu/protos/tcp/ecn.rb +35 -35
- data/lib/packetfu/protos/tcp/flags.rb +74 -74
- data/lib/packetfu/protos/tcp/header.rb +268 -268
- data/lib/packetfu/protos/tcp/hlen.rb +32 -32
- data/lib/packetfu/protos/tcp/mixin.rb +46 -46
- data/lib/packetfu/protos/tcp/option.rb +321 -321
- data/lib/packetfu/protos/tcp/options.rb +95 -95
- data/lib/packetfu/protos/tcp/reserved.rb +35 -35
- data/lib/packetfu/protos/udp.rb +159 -123
- data/lib/packetfu/protos/udp/header.rb +91 -91
- data/lib/packetfu/protos/udp/mixin.rb +3 -3
- data/lib/packetfu/structfu.rb +280 -280
- data/lib/packetfu/utils.rb +292 -225
- data/lib/packetfu/version.rb +41 -41
- data/packetfu.gemspec +14 -3
- data/spec/arp_spec.rb +191 -0
- data/spec/eth_spec.rb +148 -0
- data/spec/icmp_spec.rb +97 -0
- data/spec/ip_spec.rb +78 -0
- data/spec/ipv6_spec.rb +81 -0
- data/spec/packet_spec.rb +61 -59
- data/spec/packet_subclasses_spec.rb +9 -10
- data/spec/packetfu_spec.rb +55 -62
- data/spec/sample3.pcap +0 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/structfu_spec.rb +270 -271
- data/spec/tcp_spec.rb +76 -77
- data/spec/udp_spec.rb +32 -0
- data/spec/utils_spec.rb +95 -0
- data/test/all_tests.rb +14 -17
- data/test/func_lldp.rb +3 -3
- data/test/ptest.rb +2 -2
- data/test/test_capture.rb +45 -45
- data/test/test_eth.rb +70 -68
- data/test/test_hsrp.rb +9 -9
- data/test/test_inject.rb +18 -18
- data/test/test_invalid.rb +16 -16
- data/test/test_octets.rb +23 -21
- data/test/test_packet.rb +156 -154
- data/test/test_pcap.rb +172 -170
- data/test/test_structfu.rb +99 -97
- data/test/test_tcp.rb +322 -320
- data/test/test_udp.rb +78 -76
- metadata +108 -44
- metadata.gz.sig +2 -0
- data/spec/ethpacket_spec.rb +0 -74
- data/test/test_arp.rb +0 -135
- data/test/test_icmp.rb +0 -62
- data/test/test_ip.rb +0 -50
- data/test/test_ip6.rb +0 -68
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 45346a86ccf70ceeb48ded267817e9395bb796d8
|
|
4
|
+
data.tar.gz: 92a9e7485b2d2089b9f4e4d0ee5ccdd00bea34a0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 013e4765cf60749f3d12431446e7b8b82a63889cb60abbb5d6d2abc69b6dbc2812ffd768fd0ad5341b73d729ee3ae1a8620f6aa521c9579dc17be197767100a2
|
|
7
|
+
data.tar.gz: 7a0e1442c308792c79a00065852b13e91be050a68b981b02bc78f12db9d12955eb00b6f56be576228cbf4a8719f51e55e3f424916b7939b1ddb1f5eb47737351
|
checksums.yaml.gz.sig
ADDED
|
Binary file
|
data.tar.gz.sig
ADDED
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Contributing to PacketFu
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing to PacketFu.
|
|
4
|
+
|
|
5
|
+
If you could follow the following guidelines, you will make it much easier for
|
|
6
|
+
us to give feedback, help you find whatever problem you have and fix it.
|
|
7
|
+
|
|
8
|
+
## Issues
|
|
9
|
+
|
|
10
|
+
If you have questions of any kind, or are unsure of how something works, please
|
|
11
|
+
[create an issue](https://github.com/packetfu/packetfu/issues/new).
|
|
12
|
+
|
|
13
|
+
Please try to answer the following questions in your issue:
|
|
14
|
+
|
|
15
|
+
- What did you do?
|
|
16
|
+
- What did you expect to happen?
|
|
17
|
+
- What happened instead?
|
|
18
|
+
|
|
19
|
+
If you have identified a bug, it would be very helpful if you could include a
|
|
20
|
+
way to replicate the bug. Ideally a failing test would be perfect, but even a
|
|
21
|
+
simple script demonstrating the error would suffice.
|
|
22
|
+
|
|
23
|
+
Feature requests are great and if submitted they will be considered for
|
|
24
|
+
inclusion, but sending a pull request is much more awesome.
|
|
25
|
+
|
|
26
|
+
## Pull Requests
|
|
27
|
+
|
|
28
|
+
If you want your pull requests to be accepted, please follow the following guidelines:
|
|
29
|
+
|
|
30
|
+
- [**Add tests!**](http://rspec.info/) Your patch won't be accepted (or will be delayed) if it doesn't have tests.
|
|
31
|
+
|
|
32
|
+
- [**Document any change in behaviour**](http://yardoc.org/) Make sure the README and any other
|
|
33
|
+
relevant documentation are kept up-to-date.
|
|
34
|
+
|
|
35
|
+
- [**Create topic branches**](https://github.com/dchelimsky/rspec/wiki/Topic-Branches) Don't ask us to pull from your master branch.
|
|
36
|
+
|
|
37
|
+
- [**One pull request per feature**](https://help.github.com/articles/using-pull-requests) If you want to do more than one thing, send
|
|
38
|
+
multiple pull requests.
|
|
39
|
+
|
|
40
|
+
- [**Send coherent history**](http://stackoverflow.com/questions/6934752/git-combining-multiple-commits-before-pushing) Make sure each individual commit in your pull
|
|
41
|
+
request is meaningful. If you had to make multiple intermediate commits while
|
|
42
|
+
developing, please squash them before sending them to us.
|
|
43
|
+
|
|
44
|
+
- [**Follow coding conventions**](https://github.com/styleguide/ruby) The standard Ruby stuff, two spaces indent,
|
|
45
|
+
don't omit parens unless you have a good reason.
|
|
46
|
+
|
|
47
|
+
Thank you so much for contributing!
|
data/Gemfile
ADDED
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
|
@@ -1,59 +1,64 @@
|
|
|
1
1
|
= PacketFu
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
{<img src="https://travis-ci.org/packetfu/packetfu.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/packetfu/packetfu]
|
|
4
|
+
{<img src="https://codeclimate.com/github/packetfu/packetfu.png" />}[https://codeclimate.com/github/packetfu/packetfu]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
A library for reading and writing packets to an interface or to a
|
|
7
|
+
libpcap-formatted file.
|
|
8
|
+
|
|
9
|
+
It is maintained at https://github.com/packetfu/packetfu .
|
|
6
10
|
|
|
7
11
|
== Documentation
|
|
8
12
|
|
|
9
|
-
PacketFu is
|
|
13
|
+
PacketFu is yard-compatible (as well as sdoc/rdoc, if you prefer). You
|
|
14
|
+
can generate local documentation easily with either `yard doc .` or
|
|
15
|
+
`sdoc`, and view doc/index.html with your favored browser. Once that's
|
|
16
|
+
done, navigate at the top, and read up on how to create a Packet or
|
|
17
|
+
Capture from an interface with show_live or whatever.
|
|
10
18
|
|
|
11
19
|
== Requirements
|
|
12
20
|
|
|
13
|
-
PcapRub:
|
|
21
|
+
PcapRub:
|
|
14
22
|
|
|
15
23
|
$ rvm gem install pcaprub
|
|
16
24
|
|
|
17
|
-
Marshall Beddoe's PcapRub is required only for packet reading and
|
|
25
|
+
Marshall Beddoe's PcapRub is required only for packet reading and
|
|
26
|
+
writing from a network interfaces (which is a pretty big only). PcapRub
|
|
27
|
+
itself relies on libpcap 0.9.8 or later for packet injection. PcapRub
|
|
28
|
+
also requires root privileges to access the interface directly.
|
|
18
29
|
|
|
19
30
|
=== Platforms
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
echo Testing with $i
|
|
26
|
-
echo $i >> /tmp/tests.txt; echo +++++++++++++++++++++++ >> /tmp/tests.txt
|
|
27
|
-
rvmsudo ./all_tests.rb >> /tmp/tests.txt; rspec . >> /tmp/tests.txt
|
|
28
|
-
done
|
|
29
|
-
|
|
30
|
-
==== Problem Platforms
|
|
31
|
-
|
|
32
|
-
* 1.8.6-p420 -- Has problems with pcaprub and capture/inject. Technically, these are pcaprub problems and not PacketFu problems, but PacketFu should at least fail better at them.
|
|
32
|
+
Given the security issues with older Rubies and the long-past [EOL for
|
|
33
|
+
1.8.x](http://www.ruby-lang.org/en/news/2011/10/06/plans-for-1-8-7/),
|
|
34
|
+
PacketFu is rather stuck on very recent versions of 1.9.3 (as of this
|
|
35
|
+
moment, the version to trust is 1.9.3-p484).
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
==== 1.8.x
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
EOL, no longer supported in any sense. PacketFu may or may not work.
|
|
37
40
|
|
|
41
|
+
==== 1.9.x
|
|
38
42
|
|
|
43
|
+
1.9.3-p484.
|
|
39
44
|
|
|
40
|
-
====
|
|
41
|
-
|
|
42
|
-
* 1.9.1-p378
|
|
43
|
-
* 1.8.7-p334
|
|
44
|
-
* 1.9.2-p180 (suggested version)
|
|
45
|
-
* 1.9.3-head
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
==== 2.x
|
|
48
46
|
|
|
47
|
+
Not yet vetted. I don't believe there's anything exciting in these
|
|
48
|
+
platforms, but there has been no attempt yet to perform formal testing.
|
|
49
|
+
I know, I'm behind the times.
|
|
49
50
|
|
|
50
51
|
== Examples
|
|
51
52
|
|
|
52
|
-
PacketFu ships with dozens and dozens of tests, built on Test::Unit.
|
|
53
|
+
PacketFu ships with dozens and dozens of tests, built on Test::Unit.
|
|
54
|
+
These should give good pointers on how you're expected to use it. See
|
|
55
|
+
the /tests directory. Furthermore, PacketFu also ships with
|
|
56
|
+
packetfu-shell.rb, which should be run via IRB (as root, if you intend
|
|
57
|
+
to use your interfaces).
|
|
53
58
|
|
|
54
59
|
== Author
|
|
55
60
|
|
|
56
|
-
PacketFu is maintained primarily by Tod Beardsley todb@
|
|
61
|
+
PacketFu is maintained primarily by Tod Beardsley todb@packetfu.com and
|
|
62
|
+
Jonathan Claudius claudijd@yahoo.com, with help from Open Source Land.
|
|
57
63
|
|
|
58
64
|
See LICENSE for licensing details.
|
|
59
|
-
|
data/Rakefile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
begin
|
|
3
|
-
|
|
3
|
+
require 'rspec/core/rake_task'
|
|
4
4
|
rescue LoadError
|
|
5
|
-
|
|
5
|
+
$stderr.puts "rspec not available, so can't set up spec tasks."
|
|
6
6
|
else
|
|
7
|
-
|
|
7
|
+
RSpec::Core::RakeTask.new
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
task :default => :spec
|
|
10
10
|
end
|
|
11
11
|
|
data/bench/octets.rb
CHANGED
|
@@ -8,15 +8,15 @@ IPV4_STR = "1.2.3.4"
|
|
|
8
8
|
|
|
9
9
|
iters = 50_000
|
|
10
10
|
Benchmark.bm do |bm|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
bm.report("Octets.new.read(...) ") {iters.times {PacketFu::Octets.new.read(IPV4_RAW)}}
|
|
12
|
+
bm.report("Octets.new.read_quad(...) ") {iters.times {PacketFu::Octets.new.read_quad(IPV4_STR)}}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
octets = PacketFu::Octets.new
|
|
15
|
+
bm.report("octets#read(...) ") {iters.times {octets.read(IPV4_RAW)}}
|
|
16
|
+
bm.report("octets#read_quad(...) ") {iters.times {octets.read_quad(IPV4_STR)}}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
octets.read(IPV4_RAW)
|
|
19
|
+
bm.report("octets#to_x() ") {iters.times {octets.to_x}}
|
|
20
|
+
bm.report("octets#to_i() ") {iters.times {octets.to_i}}
|
|
21
|
+
bm.report("octets#to_s() ") {iters.times {octets.to_s}}
|
|
22
22
|
end
|
data/examples/100kpackets.rb
CHANGED
|
@@ -14,18 +14,18 @@ start_time = Time.now.utc
|
|
|
14
14
|
count = 0
|
|
15
15
|
|
|
16
16
|
100.times do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
@pcaps = []
|
|
18
|
+
1000.times do
|
|
19
|
+
u = UDPPacket.new
|
|
20
|
+
u.ip_src = [rand(2**32-1)].pack("N")
|
|
21
|
+
u.ip_dst = [rand(2**32-1)].pack("N")
|
|
22
|
+
u.recalc
|
|
23
|
+
@pcaps << u
|
|
24
|
+
end
|
|
25
|
+
pfile = PcapFile.new
|
|
26
|
+
res = pfile.array_to_file(:filename => "/tmp/out.pcap", :array => @pcaps, :append => true)
|
|
27
|
+
count += res.last
|
|
28
|
+
puts "Wrote #{count} packets in #{Time.now.utc - start_time} seconds"
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
read_bytes_start = Time.now.utc
|
data/examples/ackscan.rb
CHANGED
|
@@ -10,25 +10,25 @@ require 'packetfu'
|
|
|
10
10
|
#cap = Capture.new(:iface=>'wlan0') # or whatever your interface is
|
|
11
11
|
# Run this on the third
|
|
12
12
|
def do_scan
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
puts "Generating packets..."
|
|
14
|
+
pkt_array = gen_packets.sort_by {rand}
|
|
15
|
+
puts "Dumping them on the wire..."
|
|
16
|
+
inj = PacketFu::Inject.new(:iface => ARGV[0])
|
|
17
|
+
inj.array_to_wire(:array=>pkt_array)
|
|
18
|
+
puts "Done!"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def gen_packets
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
config = PacketFu::Utils.whoami?(:iface=>ARGV[0])
|
|
23
|
+
pkt = PacketFu::TCPPacket.new(:config=>config, :flavor=>"Windows")
|
|
24
|
+
pkt.payload ="all I wanna do is ACK ACK ACK and a RST and take your money"
|
|
25
|
+
pkt.ip_daddr="209.85.165.0" # One of Google's networks
|
|
26
|
+
pkt.tcp_flags.ack=1
|
|
27
|
+
pkt.tcp_dst=81
|
|
28
|
+
pkt_array = []
|
|
29
|
+
256.times do |i|
|
|
30
|
+
pkt.ip_dst.o4=i
|
|
31
|
+
pkt.tcp_src = rand(5000 - 1025) + 1025
|
|
32
32
|
pkt.recalc
|
|
33
33
|
pkt_array << pkt.to_s
|
|
34
34
|
end
|
data/examples/arp.rb
CHANGED
|
@@ -9,11 +9,11 @@ require './examples' # For path setting slight-of-hand
|
|
|
9
9
|
require 'packetfu'
|
|
10
10
|
|
|
11
11
|
def usage
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if ARGV[0].nil?
|
|
13
|
+
raise ArgumentError, "You need an IP address to start with."
|
|
14
|
+
elsif !Process.euid.zero?
|
|
15
|
+
raise SecurityError, "You need to be root to run this."
|
|
16
|
+
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
usage unless target_ip = ARGV[0] # Need a target IP.
|
|
@@ -24,36 +24,36 @@ $packetfu_default = PacketFu::Config.new(PacketFu::Utils.whoami?).config
|
|
|
24
24
|
|
|
25
25
|
def arp(target_ip)
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
27
|
+
arp_pkt = PacketFu::ARPPacket.new(:flavor => "Windows")
|
|
28
|
+
arp_pkt.eth_saddr = arp_pkt.arp_saddr_mac = $packetfu_default[:eth_saddr]
|
|
29
|
+
arp_pkt.eth_daddr = "ff:ff:ff:ff:ff:ff"
|
|
30
|
+
arp_pkt.arp_daddr_mac = "00:00:00:00:00:00"
|
|
31
|
+
|
|
32
|
+
arp_pkt.arp_saddr_ip = $packetfu_default[:ip_saddr]
|
|
33
|
+
arp_pkt.arp_daddr_ip = target_ip
|
|
34
|
+
|
|
35
|
+
# Stick the Capture object in its own thread.
|
|
36
|
+
|
|
37
|
+
cap_thread = Thread.new do
|
|
38
|
+
cap = PacketFu::Capture.new(:start => true,
|
|
39
|
+
:filter => "arp src #{target_ip} and ether dst #{arp_pkt.eth_saddr}")
|
|
40
|
+
arp_pkt.to_w # Shorthand for sending single packets to the default interface.
|
|
41
|
+
target_mac = nil
|
|
42
|
+
while target_mac.nil?
|
|
43
|
+
if cap.save > 0
|
|
44
|
+
arp_response = PacketFu::Packet.parse(cap.array[0])
|
|
45
|
+
target_mac = arp_response.arp_saddr_mac if arp_response.arp_saddr_ip = target_ip
|
|
46
|
+
end
|
|
47
|
+
sleep 0.1 # Check for a response ten times per second.
|
|
48
|
+
end
|
|
49
|
+
puts "#{target_ip} is-at #{target_mac}"
|
|
50
|
+
# That's all we need.
|
|
51
|
+
exit 0
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Timeout for cap_thread
|
|
55
|
+
sleep 3; puts "Oh noes! Couldn't get an arp out of #{target_ip}. Maybe it's not here."
|
|
56
|
+
exit 1
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
arp(target_ip)
|
data/examples/arphood.rb
CHANGED
|
@@ -11,20 +11,20 @@ require 'open-uri'
|
|
|
11
11
|
$oui_prefixes = {}
|
|
12
12
|
$arp_results = []
|
|
13
13
|
def build_oui_list
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
if ARGV[2].nil?
|
|
15
|
+
puts "Fetching the oui.txt from IEEE, it'll be a second. Avoid this with #{$0} [iface] [network] <filename>."
|
|
16
|
+
oui_file = open("http://standards.ieee.org/regauth/oui/oui.txt")
|
|
17
|
+
else
|
|
18
|
+
oui_file = File.open(ARGV[2], "rb")
|
|
19
|
+
end
|
|
20
|
+
oui_file.each do |oui_line|
|
|
21
|
+
maybe_oui = oui_line.scan(/^[0-9a-f]{2}\-[0-9a-f]{2}\-[0-9a-f]{2}/i)[0]
|
|
22
|
+
unless maybe_oui.nil?
|
|
23
|
+
oui_value = maybe_oui
|
|
24
|
+
oui_vendor = oui_line.split(/\(hex\)\s*/n)[1] || "PRIVATE"
|
|
25
|
+
$oui_prefixes[oui_value] = oui_vendor.chomp
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
build_oui_list
|
|
@@ -32,30 +32,30 @@ build_oui_list
|
|
|
32
32
|
$root_ok = true if Process.euid.zero?
|
|
33
33
|
|
|
34
34
|
def arp_everyone
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
my_net = PacketFu::Config.new(PacketFu::Utils.whoami?(:iface =>(ARGV[0] || 'wlan0')))
|
|
36
|
+
threads = []
|
|
37
|
+
network = ARGV[1] || "192.168.2"
|
|
38
|
+
print "Arping around..."
|
|
39
|
+
253.times do |i|
|
|
40
|
+
threads[i] = Thread.new do
|
|
41
|
+
this_host = network + ".#{i+1}"
|
|
42
|
+
print "."
|
|
43
|
+
colon_mac = PacketFu::Utils.arp(this_host,my_net.config)
|
|
44
|
+
unless colon_mac.nil?
|
|
45
|
+
hyphen_mac = colon_mac.tr(':','-').upcase[0,8]
|
|
46
|
+
else
|
|
47
|
+
hyphen_mac = colon_mac = "NOTHERE"
|
|
48
|
+
end
|
|
49
|
+
$arp_results << "%s : %s / %s" % [this_host,colon_mac,$oui_prefixes[hyphen_mac]]
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
threads.each {|thr| thr.join}
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
if $root_ok
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
arp_everyone
|
|
57
|
+
puts "\n"
|
|
58
|
+
sleep 3
|
|
59
|
+
$arp_results.sort.each {|a| puts a unless a =~ /NOTHERE/}
|
|
60
60
|
end
|
|
61
61
|
|