Class: RushButton::DashCapture
- Inherits:
-
Object
- Object
- RushButton::DashCapture
- Includes:
- PacketFu
- Defined in:
- lib/rush_button/dash_capture.rb
Constant Summary collapse
- REFER_URL =
"https://api.macvendors.com/"
- VENDOR_NAME =
"Amazon Technologies Inc."
Instance Method Summary collapse
- #capture ⇒ Object
-
#initialize(iface) ⇒ DashCapture
constructor
A new instance of DashCapture.
Constructor Details
#initialize(iface) ⇒ DashCapture
Returns a new instance of DashCapture.
11 12 13 |
# File 'lib/rush_button/dash_capture.rb', line 11 def initialize iface @capture = Capture.new(iface: iface, filter: Protocol::ARP, promisc: true) end |
Instance Method Details
#capture ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rush_button/dash_capture.rb', line 15 def capture not_amazons = [] loop do packet = @capture.next unless packet sleep 1 next end if ARPPacket.can_parse? packet src_mac = ARPPacket.parse(packet).eth_src_readable puts "captured MAC: #{src_mac}" if $DEBUG if not_amazons.include? src_mac next end vendor_mac = (src_mac.split(":"))[0..2].join(":") puts "refer to #{REFER_URL+vendor_mac}..." if $DEBUG vendor_name = Net::HTTP.get URI.parse(REFER_URL+vendor_mac) puts "vendor name: #{vendor_name}" if $DEBUG if vendor_name == VENDOR_NAME puts "this is Amazon!" if $DEBUG return src_mac else not_amazons << src_mac end end end end |