Very simple wrapper for using and parsing output from arp-scan.
You will need to make sure arp-scan is installed. See the arp-scan homepage at http://www.nta-monitor.com/tools/arp-scan/
arp-scan generally requires root privs to run. I use setcap to give it the
raw socket privs it needs so normal users can run it without sudo:
sudo setcap cap_net_raw+ep /usr/bin/arp-scanThere are some tests now, but output containing host names instead of IP addresses will not be properly parsed. This might be fixed soon.
Add this line to your application's Gemfile:
From GitHub:
gem 'arp_scan', :git => 'git://github.com/mikerodrigues/arp_scan.git'From RubyGems:
gem 'arp_scan'And then execute:
$ bundle
Or install it yourself as:
$ gem install arp_scan
No argument parsing is done by the gem, it takes the same arguments as
arp-scan and just passes them to the binary. The result is returned as a
ScanReport object which makes it easy to iterate through hosts as well as see
metainfo about the scan itself.
Scanning is easy:
require 'arp_scan'
report = ARPScan('--localnet')
report.datalink => "EN10MB (Ethernet)"
report.interface => "eth0"
report.range_size => 256
report.reply_count => 2
report.scan_rate => 169.99 # hosts/sec
report.scan_time => 1.586 # seconds
report.version => "1.8.1" # arp-scan version
report.arguments => "--localnet"Each ScanReport also holds zero or more Host objects representing founds
hosts:
first_host = report.hosts.first
first_host.ip_addr => '10.0.0.1'
first_host.mac => '00:11:22:33:44:55'
first_host.oui => "NIC Manufacturer"cd arp_scan/spec
rspec .- Fork it ( https://github.com/mikerodrigues/arp_scan/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request