Class: Presence::NMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/presence/listeners/nmapper.rb

Overview

Scanner listener that executes and prints the output from nmap for all MACs found by the scanner.

Instance Method Summary collapse

Instance Method Details

#localhost_found(ip, mac) ⇒ Object



6
7
8
9
# File 'lib/presence/listeners/nmapper.rb', line 6

def localhost_found(ip, mac)
  @local_ip = ip
  @local_mac = mac
end

#mac_found(ip, mac) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/presence/listeners/nmapper.rb', line 11

def mac_found(ip, mac)
  return if ip == @local_ip

  result = `sudo nmap -O #{ip}`
  puts '*' * 50
  puts "* IP: #{ip}"
  result.split("\n").each do |l|
    puts "    #{l}"
  end
  puts '*' * 50
end