arp_scan 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 34dd3d80cf5837da8b1fbaba13bdf550e7ce1cb7
4
- data.tar.gz: 1192b2fbba626243f283c26c86f86ae14c3d42dc
2
+ SHA256:
3
+ metadata.gz: 35970ca5fd7010c821b2a553e4852e0b3e4cbccf186aa57a1ce26ac0ad6c049c
4
+ data.tar.gz: 1c63484f637139d6de689c29e9014ecce4d222506bc837c33a4edd75802944b4
5
5
  SHA512:
6
- metadata.gz: 12f73da6dd9d7e339ca33b02d334015d736e1be0b65355450e78feffce5154df927914e7cb4d1a491b908db697723ce484693c1e1650a7e389a7b71f52eac794
7
- data.tar.gz: 4fdfbb69b73022af9ebda830a85ea58bff8a06fc876e21e439884cf53c1d0d99cd8ea36ac671fc5fa46b3dccbe02761904a78df9d2c3bf71194712be068bb5fa
6
+ metadata.gz: da55cbe303db00aca3fa6fa24818cedbf40f525b329d986a56cd5d9dfe16071a7f84e2c2a7fe74c9172e3e5debd0077a5337d51cd4942eba022289bd3bf09e21
7
+ data.tar.gz: 80c489f8604c905e732bb13fb48c7d2a3f13a8e923a28d71cb68e5d74774b1359805b160c02ea46bba5ee71ca8af16b9597674fed9b8cdd1de7231bb82223dab
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  group :test do
@@ -6,4 +8,4 @@ group :test do
6
8
  end
7
9
 
8
10
  # Specify your gem's dependencies in arp_scan.gemspec
9
- #gemspec
11
+ # gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.4.4)
5
+ rspec (3.0.0)
6
+ rspec-core (~> 3.0.0)
7
+ rspec-expectations (~> 3.0.0)
8
+ rspec-mocks (~> 3.0.0)
9
+ rspec-core (3.0.4)
10
+ rspec-support (~> 3.0.0)
11
+ rspec-expectations (3.0.4)
12
+ diff-lcs (>= 1.2.0, < 2.0)
13
+ rspec-support (~> 3.0.0)
14
+ rspec-mocks (3.0.4)
15
+ rspec-support (~> 3.0.0)
16
+ rspec-support (3.0.4)
17
+
18
+ PLATFORMS
19
+ x86_64-linux
20
+
21
+ DEPENDENCIES
22
+ rspec
23
+ rspec-support (~> 3.0.0)
24
+
25
+ BUNDLED WITH
26
+ 2.2.15
data/README.md CHANGED
@@ -1,29 +1,18 @@
1
1
  # ARPScan
2
2
 
3
- [![arp_scan API
4
- Documentation](https://www.omniref.com/ruby/gems/arp_scan.png)](https://www.omniref.com/ruby/gems/arp_scan)
3
+ [![Gem Version](https://badge.fury.io/rb/arp_scan.svg)](http://badge.fury.io/rb/arp_scan)
4
+ <a href="https://codeclimate.com/github/mikerodrigues/arp_scan"><img src="https://codeclimate.com/github/mikerodrigues/arp_scan/badges/gpa.svg" /></a>
5
5
 
6
6
  Very simple wrapper for using and parsing output from `arp-scan`.
7
7
 
8
8
  You will need to make sure `arp-scan` is installed. See the arp-scan homepage at http://www.nta-monitor.com/tools/arp-scan/
9
9
 
10
- You'll also need superuser privileges to run `arp-scan`, you have have a few
11
- options but be sure to understand what you're doing before you do it:
12
-
13
- * Edit `/etc/sudoers` to allow user to run `arp-scan` as root without a
14
- password.
15
-
16
- `user host = (root) NOPASSWD: /usr/bin/arp-scan`
17
-
18
- * Set the SUID bit on the `arp-scan` bin:
19
-
20
- `sudo chmod u+s /usr/bin/arp-scan`
21
-
22
- * Run your Ruby code as root (I wouldn't do this)
23
-
24
- I use the SUID method but if you have other people logging into your machine you
25
- should probably go with the `/etc/sudoers` method.
10
+ `arp-scan` generally requires root privs to run. I use `setcap` to give it the
11
+ raw socket privs it needs so normal users can run it without sudo:
26
12
 
13
+ ```shell
14
+ sudo setcap cap_net_raw+ep /usr/bin/arp-scan
15
+ ```
27
16
 
28
17
  ## Notes
29
18
 
@@ -86,6 +75,12 @@ first_host.mac => '00:11:22:33:44:55'
86
75
  first_host.oui => "NIC Manufacturer"
87
76
  ```
88
77
 
78
+ ## Run the Tests
79
+ ```ruby
80
+ cd arp_scan/spec
81
+ rspec .
82
+ ```
83
+
89
84
 
90
85
 
91
86
 
data/arp_scan.gemspec CHANGED
@@ -1,23 +1,21 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'arp_scan/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "arp_scan"
8
+ spec.name = 'arp_scan'
8
9
  spec.version = ARPScan::VERSION
9
- spec.authors = ["Michael Rodrigues"]
10
- spec.email = ["mikebrodrigues@gmail.com"]
11
- spec.summary = %q{A ruby wrapper for the arp-scan utility.}
12
- spec.description = %q{Easily use the arp-scan utility from within your ruby programs.}
13
- spec.homepage = "https://github.com/mikerodrigues/arp_scan"
14
- spec.license = "MIT"
10
+ spec.authors = ['Michael Rodrigues']
11
+ spec.email = ['mikebrodrigues@gmail.com']
12
+ spec.summary = 'A ruby wrapper for the arp-scan utility.'
13
+ spec.description = 'Use the arp-scan utility from your ruby programs.'
14
+ spec.homepage = 'https://github.com/mikerodrigues/arp_scan'
15
+ spec.license = 'MIT'
15
16
 
16
17
  spec.files = `git ls-files -z`.split("\x0")
17
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.require_paths = ['lib']
23
21
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './scan_result_processor'
2
4
 
3
5
  module ARPScan
@@ -5,18 +7,27 @@ module ARPScan
5
7
  # delegates the parsing of the scan results to the ScanResultProcessor module.
6
8
  #
7
9
  module ARPScanner
10
+ # get array of file extensions, relevant for Windows
11
+ def self.exts
12
+ ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
13
+ end
14
+
15
+ # get array of paths
16
+ def self.paths
17
+ ENV['PATH'].split(File::PATH_SEPARATOR)
18
+ end
19
+
8
20
  # I got this method from: http://stackoverflow.com/questions/2108727
9
21
  # Cross-platform way of finding an executable in the $PATH.
10
22
  #
11
23
  # which('ruby') #=> /usr/bin/ruby
12
24
  #
13
25
  def self.which(cmd)
14
- exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
15
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
16
- exts.each { |ext|
26
+ paths.each do |path|
27
+ exts.each do |ext|
17
28
  exe = File.join(path, "#{cmd}#{ext}")
18
29
  return exe if File.executable?(exe) && !File.directory?(exe)
19
- }
30
+ end
20
31
  end
21
32
  raise 'arp-scan binary not found, make sure it is installed'
22
33
  end
@@ -30,7 +41,6 @@ module ARPScan
30
41
  ScanResultProcessor.process(result_string, argument_string)
31
42
  end
32
43
 
33
- private_class_method :which
44
+ private_class_method :which, :exts, :paths
34
45
  end
35
46
  end
36
-
data/lib/arp_scan/host.rb CHANGED
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ARPScan
2
4
  # Abstracts replying hosts from the arp-scan output.
3
5
  #
4
6
  class Host
5
-
6
7
  # The IP address of the host.
7
8
  #
8
9
  attr_reader :ip_addr
@@ -27,19 +28,17 @@ module ARPScan
27
28
  # Returns a hash representation of the Host object.
28
29
  #
29
30
  def to_hash
30
- { :ip_addr => @ip_addr,
31
- :mac => @mac,
32
- :oui => @oui
33
- }
31
+ { ip_addr: @ip_addr,
32
+ mac: @mac,
33
+ oui: @oui }
34
34
  end
35
35
 
36
36
  # Returns an array representation of the Host object.
37
37
  #
38
38
  def to_array
39
- [ @ip_addr,
40
- @mac,
41
- @oui
42
- ]
39
+ [@ip_addr,
40
+ @mac,
41
+ @oui]
43
42
  end
44
43
  end
45
44
  end
@@ -1,10 +1,10 @@
1
- module ARPScan
1
+ # frozen_string_literal: true
2
2
 
3
+ module ARPScan
3
4
  # This class abstracts the string output from arp-scan into an Object. A
4
5
  # ScanReports are usually created through the ScanResultProcessor module.
5
6
  #
6
7
  class ScanReport
7
-
8
8
  # Array of Host objects.
9
9
  #
10
10
  attr_reader :hosts
@@ -17,6 +17,14 @@ module ARPScan
17
17
  #
18
18
  attr_reader :datalink
19
19
 
20
+ # IP address of interface
21
+ #
22
+ attr_reader :ipv4
23
+
24
+ # MAC address of the interface
25
+ #
26
+ attr_reader :mac
27
+
20
28
  # `arp-scan` version number.
21
29
  #
22
30
  attr_reader :version
@@ -46,6 +54,8 @@ module ARPScan
46
54
  @hosts = hash[:hosts]
47
55
  @interface = hash[:interface]
48
56
  @datalink = hash[:datalink]
57
+ @ipv4 = hash[:ipv4]
58
+ @mac = hash[:mac]
49
59
  @version = hash[:version]
50
60
  @range_size = Integer(hash[:range_size])
51
61
  @scan_time = Float(hash[:scan_time])
@@ -58,11 +68,11 @@ module ARPScan
58
68
  # scan, and an array of Host arrays comprise the array.
59
69
  #
60
70
  def to_array
61
- self.instance_variables.map do |var|
71
+ instance_variables.map do |var|
62
72
  if var == :@hosts
63
- self.instance_variable_get(var).map {|host| host.to_array}
73
+ instance_variable_get(var).map(&:to_array)
64
74
  else
65
- self.instance_variable_get(var)
75
+ instance_variable_get(var)
66
76
  end
67
77
  end
68
78
  end
@@ -71,17 +81,17 @@ module ARPScan
71
81
  # and array of Host hashes comprise the hash.
72
82
  #
73
83
  def to_hash
74
- { :hosts => @hosts.map {|host| host.to_hash},
75
- :interface => @interface,
76
- :datalink => @datalink,
77
- :version => @version,
78
- :range_size => @range_size,
79
- :scan_time => @scan_time,
80
- :scan_rate => @scan_rate,
81
- :reply_count => @reply_count,
82
- :arguments => @arguments
83
- }
84
+ { hosts: @hosts.map(&:to_hash),
85
+ interface: @interface,
86
+ datalink: @datalink,
87
+ ipv4: @ipv4,
88
+ mac: @mac,
89
+ version: @version,
90
+ range_size: @range_size,
91
+ scan_time: @scan_time,
92
+ scan_rate: @scan_rate,
93
+ reply_count: @reply_count,
94
+ arguments: @arguments }
84
95
  end
85
-
86
96
  end
87
97
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './host'
2
4
  require_relative './scan_report'
3
5
 
@@ -6,19 +8,26 @@ module ARPScan
6
8
  # output.
7
9
  #
8
10
  module ScanResultProcessor
9
-
10
11
  # Regex to capture IP address, MAC address, and OUI information
11
12
  #
12
- Host_Entry_Regex = /(\d+.\d+.\d+.\d+)\s(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)\s(.*)/
13
-
13
+ HOST_ENTRY_REGEX = /(\d+.\d+.\d+.\d+)\s(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)\s(.*)/
14
+
14
15
  # Regex to capture interface and datalink
15
16
  #
16
- Interface_Summary_Regex = /Interface: (?<interface>.+), datalink type: (?<datalink>.*$)/
17
+ INTERFACE_SUMMARY_REGEX = /
18
+ ^Interface:\s+(?<interface>[^,\n]+),
19
+ (?:\s*datalink)?\s*type:\s*(?<datalink>[^\n,]+?)(?=,\s*MAC:|$)
20
+ (?:,\s*MAC:\s*(?<mac>[0-9A-Fa-f]{2}(?::[0-9A-Fa-f]{2}){5}))?
21
+ (?:,\s*IPv4:\s*(?<ipv4>(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)))?
22
+ $
23
+ /x
24
+
25
+
17
26
 
18
27
  # Regex to capture arp-scan version, scan range size, scan time, scan rate,
19
28
  # and the number of responding hosts.
20
29
  #
21
- Scan_Summary_Regex = /Ending arp-scan (?<version>.*): (?<range_size>.*) hosts scanned in (?<scan_time>.*) seconds \((?<scan_rate>.*) hosts\/sec\). (?<reply_count>.*) responded/
30
+ SCAN_SUMMARY_REGEX = %r{Ending arp-scan (?<version>.*): (?<range_size>.*) hosts scanned in (?<scan_time>.*) seconds \((?<scan_rate>.*) hosts/sec\). (?<reply_count>.*) responded}
22
31
 
23
32
  # This method does the actual processing of the arp-scan result string. It
24
33
  # uses the Regexes to capture data then passes the results to ScanRepor.new
@@ -26,14 +35,16 @@ module ARPScan
26
35
  #
27
36
  def self.process(string, arguments)
28
37
  results = {}
29
- results[:hosts] = string.scan(Host_Entry_Regex).map {|entry| Host.new(*entry)}
38
+ results[:hosts] = string.scan(HOST_ENTRY_REGEX).map { |entry| Host.new(*entry) }
30
39
  results[:interface],
31
- results[:datalink] = string.scan(Interface_Summary_Regex)[0]
40
+ results[:datalink],
41
+ results[:mac],
42
+ results[:ipv4] = string.scan(INTERFACE_SUMMARY_REGEX)[0]
32
43
  results[:version],
33
- results[:range_size],
34
- results[:scan_time],
35
- results[:scan_rate],
36
- results[:reply_count] = string.scan(Scan_Summary_Regex)[0]
44
+ results[:range_size],
45
+ results[:scan_time],
46
+ results[:scan_rate],
47
+ results[:reply_count] = string.scan(SCAN_SUMMARY_REGEX)[0]
37
48
  results[:arguments] = arguments
38
49
  ScanReport.new(results)
39
50
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ARPScan
2
- VERSION = "0.1.0"
4
+ VERSION = '0.1.2'
3
5
  end
data/lib/arp_scan.rb CHANGED
@@ -1,8 +1,10 @@
1
- require_relative "./arp_scan/version"
2
- require_relative "./arp_scan/arp_scanner"
3
- require_relative "./arp_scan/scan_report"
4
- require_relative "./arp_scan/scan_result_processor"
5
- require_relative "./arp_scan/host"
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './arp_scan/version'
4
+ require_relative './arp_scan/arp_scanner'
5
+ require_relative './arp_scan/scan_report'
6
+ require_relative './arp_scan/scan_result_processor'
7
+ require_relative './arp_scan/host'
6
8
 
7
9
  # This module just acts as a namespace for the gem.
8
10
  #
@@ -1,8 +1,10 @@
1
- require_relative './spec_helper.rb'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './spec_helper'
2
4
 
3
5
  RSpec.describe ARPScan do
4
- report = ARPScan('-l')
5
- it "is a method" do
6
+ ARPScan('-l')
7
+ it 'is a method' do
6
8
  expect(ARPScan.respond_to?('__send__')).to eq(true)
7
9
  end
8
10
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './spec_helper'
2
4
 
3
5
  module ARPScan
4
6
  describe ARPScanner do
5
- describe "#scan" do
6
- it "accepts arp-scan arguments as a string" do
7
+ describe '#scan' do
8
+ it 'accepts arp-scan arguments as a string' do
7
9
  expect(ARPScanner.scan('-l').class).to eq(ScanReport)
8
10
  end
9
11
  end
data/spec/host_spec.rb CHANGED
@@ -1,27 +1,27 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './spec_helper'
2
4
 
3
5
  module ARPScan
4
6
  describe Host do
7
+ host = Host.new('10.0.0.1', '00:11:22:33:44:55', 'NIC Manufacturer')
5
8
 
6
- host = Host.new('10.0.0.1', '00:11:22:33:44:55', "NIC Manufacturer")
7
-
8
- describe "#ip_addr" do
9
+ describe '#ip_addr' do
9
10
  it "returns the host's IP address" do
10
11
  expect(host.ip_addr).to eq('10.0.0.1')
11
12
  end
12
13
  end
13
14
 
14
- describe "#mac" do
15
+ describe '#mac' do
15
16
  it "returns the host's MAC address" do
16
17
  expect(host.mac).to eq('00:11:22:33:44:55')
17
18
  end
18
19
  end
19
20
 
20
- describe "#oui" do
21
+ describe '#oui' do
21
22
  it "returns the host's OUI information" do
22
23
  expect(host.oui).to eq('NIC Manufacturer')
23
24
  end
24
25
  end
25
-
26
26
  end
27
27
  end
@@ -1,73 +1,74 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './spec_helper'
2
4
 
3
5
  module ARPScan
4
6
  describe ScanReport do
5
-
6
7
  report_hash = {
7
- :hosts => [Host.new(*['10.0.0.1', '00:11:22:33:44:55', 'NIC Manufacturer'])],
8
- :interface => "eth0",
9
- :datalink => "EN10MB (Ethernet)",
10
- :version => "1.8.1",
11
- :range_size => 256,
12
- :scan_time => 1.503,
13
- :scan_rate => 170.33,
14
- :reply_count => 1,
15
- :arguments => '-l'
8
+ hosts: [Host.new('10.0.0.1', '00:11:22:33:44:55', 'NIC Manufacturer')],
9
+ interface: 'eth0',
10
+ datalink: 'EN10MB (Ethernet)',
11
+ version: '1.8.1',
12
+ range_size: 256,
13
+ scan_time: 1.503,
14
+ scan_rate: 170.33,
15
+ reply_count: 1,
16
+ arguments: '-l'
16
17
  }
17
18
 
18
19
  scan_report = ScanReport.new(report_hash)
19
20
 
20
- describe "#hosts" do
21
- it "returns an Array of Host objects" do
21
+ describe '#hosts' do
22
+ it 'returns an Array of Host objects' do
22
23
  expect(scan_report.hosts.class).to eq(Array)
23
24
  expect(scan_report.hosts.first.class).to eq(Host)
24
25
  end
25
26
  end
26
27
 
27
- describe "#interface" do
28
- it "returns the network interface used to scan" do
29
- expect(scan_report.interface).to eq("eth0")
28
+ describe '#interface' do
29
+ it 'returns the network interface used to scan' do
30
+ expect(scan_report.interface).to eq('eth0')
30
31
  end
31
32
  end
32
33
 
33
- describe "#datalink" do
34
- it "returns the datalink type of the network interface used to scan" do
34
+ describe '#datalink' do
35
+ it 'returns the datalink type of the network interface used to scan' do
35
36
  expect(scan_report.datalink).to eq('EN10MB (Ethernet)')
36
37
  end
37
38
  end
38
39
 
39
- describe "#version" do
40
- it "returns the version of `arp-scan` used for the scan" do
40
+ describe '#version' do
41
+ it 'returns the version of `arp-scan` used for the scan' do
41
42
  expect(scan_report.version).to eq('1.8.1')
42
43
  end
43
44
  end
44
45
 
45
- describe "#range_size" do
46
- it "returns the size of the range of scanned IPs" do
46
+ describe '#range_size' do
47
+ it 'returns the size of the range of scanned IPs' do
47
48
  expect(scan_report.range_size).to eq(256)
48
49
  end
49
50
  end
50
51
 
51
- describe "#scan_time" do
52
- it "returns the duration of the scan in seconds" do
52
+ describe '#scan_time' do
53
+ it 'returns the duration of the scan in seconds' do
53
54
  expect(scan_report.scan_time).to eq(1.503)
54
55
  end
55
56
  end
56
57
 
57
- describe "#scan_rate" do
58
- it "returns the scan rate in hosts per second" do
58
+ describe '#scan_rate' do
59
+ it 'returns the scan rate in hosts per second' do
59
60
  expect(scan_report.scan_rate).to eq(170.33)
60
61
  end
61
62
  end
62
63
 
63
- describe "#reply_count" do
64
- it "returns the number of hosts that responded" do
64
+ describe '#reply_count' do
65
+ it 'returns the number of hosts that responded' do
65
66
  expect(scan_report.reply_count).to eq(1)
66
67
  end
67
68
  end
68
69
 
69
- describe "#arguments" do
70
- it "returns the argument string used to scan" do
70
+ describe '#arguments' do
71
+ it 'returns the argument string used to scan' do
71
72
  expect(scan_report.arguments).to eq('-l')
72
73
  end
73
74
  end
@@ -1,50 +1,65 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './spec_helper'
2
4
 
3
5
  module ARPScan
4
6
  describe ScanResultProcessor do
5
-
6
7
  argument_string = '-l'
7
8
  report_string = File.read './test_output.txt'
9
+ report_string_2 = File.read './test_output_2.txt'
8
10
  report = ARPScan::ScanResultProcessor.process(report_string, argument_string)
11
+ report_2 = ARPScan::ScanResultProcessor.process(report_string_2, argument_string)
9
12
 
10
- describe "#process" do
11
- it "processes arp-scan output to create a ScanReport object" do
13
+ describe '#process' do
14
+ it 'processes arp-scan output to create a ScanReport object' do
12
15
  expect(report.class).to eq(ARPScan::ScanReport)
16
+ expect(report_2.class).to eq(ARPScan::ScanReport)
13
17
  end
14
18
 
15
- it "builds an array of Host objects" do
19
+ it 'builds an array of Host objects' do
16
20
  expect(report.hosts[0].class).to eq(ARPScan::Host)
21
+ expect(report_2.hosts[0].class).to eq(ARPScan::Host)
22
+ end
23
+
24
+ it 'parses the scan interface name' do
25
+ expect(report.interface).to eq('eth0')
26
+ expect(report_2.interface).to eq('enp4s0')
27
+ end
28
+
29
+ it 'parses the datalink type information' do
30
+ expect(report.datalink).to eq('EN10MB (Ethernet)')
31
+ expect(report_2.datalink).to eq('EN10MB')
17
32
  end
18
33
 
19
- it "parses the scan interface name" do
20
- expect(report.interface).to eq("eth0")
34
+ it 'parses the ip of the scanner on newer versions of arp-scan' do
35
+ expect(report_2.ipv4).to eq('10.0.0.5')
21
36
  end
22
37
 
23
- it "parses the datalink type information" do
24
- expect(report.datalink).to eq("EN10MB (Ethernet)")
38
+ it 'parses the MAC of the scanner on newer versions of arp-scan' do
39
+ expect(report_2.mac).to eq('a1:b2:c3:d4:e5:f6')
25
40
  end
26
41
 
27
- it "parses the version of arp-scan that ran the scan" do
42
+ it 'parses the version of arp-scan that ran the scan' do
28
43
  expect(report.version).to eq('1.8.1')
29
44
  end
30
45
 
31
- it "parses the number of hosts scanned" do
46
+ it 'parses the number of hosts scanned' do
32
47
  expect(report.range_size).to eq(256)
33
48
  end
34
49
 
35
- it "parses the duration of the scan in seconds" do
50
+ it 'parses the duration of the scan in seconds' do
36
51
  expect(report.scan_time).to eq(1.494)
37
52
  end
38
53
 
39
- it "parses the rate of the scan in hosts per second" do
54
+ it 'parses the rate of the scan in hosts per second' do
40
55
  expect(report.scan_rate).to eq(171.35)
41
56
  end
42
57
 
43
- it "parses the number of hosts that responded to the scan" do
58
+ it 'parses the number of hosts that responded to the scan' do
44
59
  expect(report.reply_count).to eq(1)
45
60
  end
46
61
 
47
- it "includes the argument string in the report" do
62
+ it 'includes the argument string in the report' do
48
63
  expect(report.arguments).to eq('-l')
49
64
  end
50
65
  end
data/spec/spec_helper.rb CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require '../lib/arp_scan'
@@ -0,0 +1,9 @@
1
+ Interface: enp4s0, type: EN10MB, MAC: a1:b2:c3:d4:e5:f6, IPv4: 10.0.0.5
2
+ Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
3
+ 10.0.0.1 11:22:33:44:55:66 GL Technologies (Hong Kong) Limited
4
+ 10.0.0.100 aa:bb:cc:dd:ee:ff SHENZHEN ZHIBOTONG ELECTRONICS CO.,LTD
5
+ 10.0.0.213 1a:2b:3c:4d:e5:f6 (Unknown)
6
+
7
+ 3 packets received by filter, 0 packets dropped by kernel
8
+ Ending arp-scan 1.10.0: 256 hosts scanned in 1.965 seconds (130.28 hosts/sec). 3 responded
9
+
metadata CHANGED
@@ -1,51 +1,24 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arp_scan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Rodrigues
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2015-02-22 00:00:00.000000000 Z
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.7'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.7'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- description: Easily use the arp-scan utility from within your ruby programs.
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Use the arp-scan utility from your ruby programs.
42
13
  email:
43
14
  - mikebrodrigues@gmail.com
44
15
  executables: []
45
16
  extensions: []
46
17
  extra_rdoc_files: []
47
18
  files:
19
+ - ".gitignore"
48
20
  - Gemfile
21
+ - Gemfile.lock
49
22
  - LICENSE.txt
50
23
  - README.md
51
24
  - arp_scan.gemspec
@@ -62,11 +35,11 @@ files:
62
35
  - spec/scan_result_processor_spec.rb
63
36
  - spec/spec_helper.rb
64
37
  - spec/test_output.txt
38
+ - spec/test_output_2.txt
65
39
  homepage: https://github.com/mikerodrigues/arp_scan
66
40
  licenses:
67
41
  - MIT
68
42
  metadata: {}
69
- post_install_message:
70
43
  rdoc_options: []
71
44
  require_paths:
72
45
  - lib
@@ -81,9 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
54
  - !ruby/object:Gem::Version
82
55
  version: '0'
83
56
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.4.5
86
- signing_key:
57
+ rubygems_version: 3.7.1
87
58
  specification_version: 4
88
59
  summary: A ruby wrapper for the arp-scan utility.
89
60
  test_files:
@@ -94,3 +65,4 @@ test_files:
94
65
  - spec/scan_result_processor_spec.rb
95
66
  - spec/spec_helper.rb
96
67
  - spec/test_output.txt
68
+ - spec/test_output_2.txt