arp_scan 0.0.3 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 21449e6fd38960eb78e357a1db2e75022ec3a0cd
4
- data.tar.gz: 2b23e39343027d0366e1caa578f68c31722f8542
2
+ SHA256:
3
+ metadata.gz: 768a6997ecf0acffce32b3d52a16994e892b8f6fd93ec887613aebd478a6a86b
4
+ data.tar.gz: d8c053296aae885d75e79b70a71d4e7264fdc3f5cf61c84d65b3019b89e56262
5
5
  SHA512:
6
- metadata.gz: 819fbd9535f90d617d3bbe3448aea31e50fe155cafb44e25fd8c03d2b6332e14b5b42a6a5e35a9fbca3a112938eb181e07c3777fd1e02097d47b9bafc74ef10f
7
- data.tar.gz: cc4ad8109f6426074b01f1dddd5b5affb7bc9439658517594331b731b091534aacba601b7cd4164e2361d83cbb0278a19648788c437178445700b7efe3129f95
6
+ metadata.gz: 62d6e68337f32a52808e63dae880d09191b3b353c4338e4b05ee4349ed23572c594badb21af97a1336bba20dbad6b1d5aec23889acc16de63aa3e9e1ce8abbed
7
+ data.tar.gz: af52cd4506b2a847041e296fbf9d2483a0fb23a2c5e520b45168850ef986105736be7e0512832a88b39390c218a7eb5df5e10d233566af9107f9a8c1b745ebf6
data/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
5
+ group :test do
6
+ gem 'rspec'
7
+ gem 'rspec-support', '~>3.0.0'
8
+ end
9
+
3
10
  # Specify your gem's dependencies in arp_scan.gemspec
4
- 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,5 +1,8 @@
1
1
  # ARPScan
2
2
 
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
+
3
6
  Very simple wrapper for using and parsing output from `arp-scan`.
4
7
 
5
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/
@@ -24,8 +27,8 @@ should probably go with the `/etc/sudoers` method.
24
27
 
25
28
  ## Notes
26
29
 
27
- This code is untested and will hopefully be refactored soon.
28
-
30
+ There are some tests now, but output containing host names instead of IP
31
+ addresses will not be properly parsed. This might be fixed soon.
29
32
 
30
33
  ## Installation
31
34
 
@@ -70,6 +73,7 @@ report.reply_count => 2
70
73
  report.scan_rate => 169.99 # hosts/sec
71
74
  report.scan_time => 1.586 # seconds
72
75
  report.version => "1.8.1" # arp-scan version
76
+ report.arguments => "--localnet"
73
77
  ```
74
78
 
75
79
  Each `ScanReport` also holds zero or more `Host` objects representing founds
data/arp_scan.gemspec CHANGED
@@ -1,23 +1,22 @@
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 = ""
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
+ spec.require_paths = ['lib']
20
21
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
22
  end
data/lib/arp_scan.rb CHANGED
@@ -1,13 +1,19 @@
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
6
2
 
7
- module ARPScan
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'
8
8
 
9
- end
9
+ # This module just acts as a namespace for the gem.
10
+ #
11
+ module ARPScan; end
10
12
 
13
+ # The main interface for the gem. This method accepts arp-scan arguments in the
14
+ # form of a single string. Currently only IP addresses (no hostnames) are
15
+ # supported.
16
+ #
11
17
  def ARPScan(argument_string = nil)
12
18
  ARPScan::ARPScanner.scan argument_string
13
19
  end
@@ -1,29 +1,37 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './scan_result_processor'
2
4
 
3
5
  module ARPScan
6
+ # This module manages finding the arp-scan binary and running the scan. It
7
+ # delegates the parsing of the scan results to the ScanResultProcessor module.
8
+ #
4
9
  module ARPScanner
5
-
6
10
  # I got this method from: http://stackoverflow.com/questions/2108727
7
11
  # Cross-platform way of finding an executable in the $PATH.
8
12
  #
9
13
  # which('ruby') #=> /usr/bin/ruby
14
+ #
10
15
  def self.which(cmd)
11
16
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
12
17
  ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
13
- exts.each { |ext|
18
+ exts.each do |ext|
14
19
  exe = File.join(path, "#{cmd}#{ext}")
15
20
  return exe if File.executable?(exe) && !File.directory?(exe)
16
- }
21
+ end
17
22
  end
18
- return nil
23
+ raise 'arp-scan binary not found, make sure it is installed'
19
24
  end
20
25
 
26
+ # This method runs the actual scan by passing the arguments to the arp-scan
27
+ # binary. The results are passed to the ScanResultProcessor and a ScanReport
28
+ # is returned.
29
+ #
21
30
  def self.scan(argument_string = nil)
22
31
  result_string = `#{which 'arp-scan'} #{argument_string}`
23
- ScanResultProcessor.process(result_string)
32
+ ScanResultProcessor.process(result_string, argument_string)
24
33
  end
25
34
 
26
35
  private_class_method :which
27
36
  end
28
37
  end
29
-
data/lib/arp_scan/host.rb CHANGED
@@ -1,25 +1,44 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ARPScan
4
+ # Abstracts replying hosts from the arp-scan output.
5
+ #
2
6
  class Host
3
- attr_reader :ip_addr, :mac, :oui
7
+ # The IP address of the host.
8
+ #
9
+ attr_reader :ip_addr
10
+
11
+ # The MAC address of the host.
12
+ #
13
+ attr_reader :mac
14
+
15
+ # OUI information about the host.
16
+ #
17
+ attr_reader :oui
4
18
 
19
+ # Create a new hsot. IP address, MAC address and OUI information are
20
+ # expected.
21
+ #
5
22
  def initialize(ip_addr, mac, oui)
6
23
  @ip_addr = ip_addr
7
24
  @mac = mac
8
25
  @oui = oui
9
26
  end
10
27
 
28
+ # Returns a hash representation of the Host object.
29
+ #
11
30
  def to_hash
12
- { :ip_addr => @ip_addr,
13
- :mac => @mac,
14
- :oui => @oui
15
- }
31
+ { ip_addr: @ip_addr,
32
+ mac: @mac,
33
+ oui: @oui }
16
34
  end
17
35
 
36
+ # Returns an array representation of the Host object.
37
+ #
18
38
  def to_array
19
- [ @ip_addr,
20
- @mac,
21
- @oui
22
- ]
39
+ [@ip_addr,
40
+ @mac,
41
+ @oui]
23
42
  end
24
43
  end
25
44
  end
@@ -1,8 +1,47 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ARPScan
4
+ # This class abstracts the string output from arp-scan into an Object. A
5
+ # ScanReports are usually created through the ScanResultProcessor module.
6
+ #
2
7
  class ScanReport
8
+ # Array of Host objects.
9
+ #
10
+ attr_reader :hosts
11
+
12
+ # Name of the interface used for the scan.
13
+ #
14
+ attr_reader :interface
15
+
16
+ # Information about the interface type.
17
+ #
18
+ attr_reader :datalink
19
+
20
+ # `arp-scan` version number.
21
+ #
22
+ attr_reader :version
23
+
24
+ # Size of the scan range ( # of hosts scanned ).
25
+ #
26
+ attr_reader :range_size
3
27
 
4
- attr_reader :hosts, :interface, :datalink, :version, :range_size, :scan_time, :scan_rate, :reply_count
28
+ # Duration of the scan in seconds, returns a Float.
29
+ #
30
+ attr_reader :scan_time
5
31
 
32
+ # The rate of the scan in hosts per second, returns a Float.
33
+ #
34
+ attr_reader :scan_rate
35
+
36
+ # The number of hosts that replied to the scan, returns a Fixnum
37
+ attr_reader :reply_count
38
+
39
+ # The argument string passed to ARPScan
40
+ attr_reader :arguments
41
+
42
+ # Create a new scan report, passing in every attribute. The best way to do
43
+ # this is with the ScanResultProcessor module.
44
+ #
6
45
  def initialize(hash)
7
46
  @hosts = hash[:hosts]
8
47
  @interface = hash[:interface]
@@ -12,29 +51,35 @@ module ARPScan
12
51
  @scan_time = Float(hash[:scan_time])
13
52
  @scan_rate = Float(hash[:scan_rate])
14
53
  @reply_count = Integer(hash[:reply_count])
54
+ @arguments = hash[:arguments]
15
55
  end
16
56
 
57
+ # Returns an array representation of the ScanReport. Metadata about the
58
+ # scan, and an array of Host arrays comprise the array.
59
+ #
17
60
  def to_array
18
- self.instance_variables.map do |var|
61
+ instance_variables.map do |var|
19
62
  if var == :@hosts
20
- self.instance_variable_get(var).map {|host| host.to_array}
63
+ instance_variable_get(var).map(&:to_array)
21
64
  else
22
- self.instance_variable_get(var)
65
+ instance_variable_get(var)
23
66
  end
24
67
  end
25
68
  end
26
69
 
70
+ # Returns a hash representation of the ScanReport. Metadata about the scan,
71
+ # and array of Host hashes comprise the hash.
72
+ #
27
73
  def to_hash
28
- { :hosts => @hosts.map {|host| host.to_hash},
29
- :interface => @interface,
30
- :datalink => @datalink,
31
- :version => @version,
32
- :range_size => @range_size,
33
- :scan_time => @scan_time,
34
- :scan_rate => @scan_rate,
35
- :reply_count => @reply_count
36
- }
74
+ { hosts: @hosts.map(&: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 }
37
83
  end
38
-
39
84
  end
40
85
  end
@@ -1,23 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative './host'
2
4
  require_relative './scan_report'
3
5
 
4
6
  module ARPScan
7
+ # This module is an interface for creating ScanReport objects from arp-scan
8
+ # output.
9
+ #
5
10
  module ScanResultProcessor
11
+ # Regex to capture IP address, MAC address, and OUI information
12
+ #
13
+ HOST_ENTRY_REGEX = /(\d+.\d+.\d+.\d+)\s(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)\s(.*)/.freeze
14
+
15
+ # Regex to capture interface and datalink
16
+ #
17
+ INTERFACE_SUMMARY_REGEX = /Interface: (?<interface>.+), datalink type: (?<datalink>.*$)/.freeze
6
18
 
7
- Host_Entry_Regex = /(\d+.\d+.\d+.\d+)\s(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w)\s(.*)/
8
- Interface_Summary_Regex = /Interface: (?<interface>.+), datalink type: (?<datalink>.*$)/
9
- Scan_Summary_Regex = /Ending arp-scan (?<version>.*): (?<range_size>.*) hosts scanned in (?<scan_time>.*) seconds \((?<scan_rate>.*) hosts\/sec\). (?<reply_count>.*) responded/
19
+ # Regex to capture arp-scan version, scan range size, scan time, scan rate,
20
+ # and the number of responding hosts.
21
+ #
22
+ SCAN_SUMMARY_REGEX = %r{Ending arp-scan (?<version>.*): (?<range_size>.*) hosts scanned in (?<scan_time>.*) seconds \((?<scan_rate>.*) hosts/sec\). (?<reply_count>.*) responded}.freeze
10
23
 
11
- def self.process(string)
24
+ # This method does the actual processing of the arp-scan result string. It
25
+ # uses the Regexes to capture data then passes the results to ScanRepor.new
26
+ # to return a ScanReport object.
27
+ #
28
+ def self.process(string, arguments)
12
29
  results = {}
13
- results[:hosts] = string.scan(Host_Entry_Regex).map {|entry| Host.new(*entry)}
30
+ results[:hosts] = string.scan(HOST_ENTRY_REGEX).map { |entry| Host.new(*entry) }
14
31
  results[:interface],
15
- results[:datalink] = string.scan(Interface_Summary_Regex)[0]
32
+ results[:datalink] = string.scan(INTERFACE_SUMMARY_REGEX)[0]
16
33
  results[:version],
17
34
  results[:range_size],
18
35
  results[:scan_time],
19
36
  results[:scan_rate],
20
- results[:reply_count] = string.scan(Scan_Summary_Regex)[0]
37
+ results[:reply_count] = string.scan(SCAN_SUMMARY_REGEX)[0]
38
+ results[:arguments] = arguments
21
39
  ScanReport.new(results)
22
40
  end
23
41
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ARPScan
2
- VERSION = "0.0.3"
4
+ VERSION = '0.1.1'
3
5
  end
@@ -1,17 +1,10 @@
1
- require '../lib/arp_scan'
1
+ # frozen_string_literal: true
2
2
 
3
- RSpec.describe ARPScan do
4
- report = ARPScan('-l')
5
-
6
- it "is a method you can pass arp-scan arguments to as a string" do
7
- expect(ARPScan('-l').class).to eq(ARPScan::ScanReport)
8
- end
3
+ require_relative './spec_helper.rb'
9
4
 
10
- it "returns a nested hash of attributes" do
11
- expect(report.to_hash.class).to eq(Hash)
12
- end
13
-
14
- it "returns a nested array of attributes" do
15
- expect(report.to_array.class).to eq(Array)
5
+ RSpec.describe ARPScan do
6
+ ARPScan('-l')
7
+ it 'is a method' do
8
+ expect(ARPScan.respond_to?('__send__')).to eq(true)
16
9
  end
17
10
  end
@@ -1,10 +1,13 @@
1
- require '../lib/arp_scan'
1
+ # frozen_string_literal: true
2
2
 
3
- RSpec.describe ARPScan::ARPScanner do
3
+ require_relative './spec_helper'
4
4
 
5
- it "has a #scan method to pass arp-scan arguments to as a string" do
6
- expect(ARPScan::ARPScanner.scan('-l').class).to eq(ARPScan::ScanReport)
5
+ module ARPScan
6
+ describe ARPScanner do
7
+ describe '#scan' do
8
+ it 'accepts arp-scan arguments as a string' do
9
+ expect(ARPScanner.scan('-l').class).to eq(ScanReport)
10
+ end
11
+ end
7
12
  end
8
-
9
13
  end
10
-
data/spec/host_spec.rb CHANGED
@@ -1,19 +1,27 @@
1
- require '../lib/arp_scan'
1
+ # frozen_string_literal: true
2
2
 
3
- RSpec.describe ARPScan::Host do
3
+ require_relative './spec_helper'
4
4
 
5
- host = ARPScan::Host.new('10.0.0.1', '00:11:22:33:44:55', "NIC Manufacturer")
5
+ module ARPScan
6
+ describe Host do
7
+ host = Host.new('10.0.0.1', '00:11:22:33:44:55', 'NIC Manufacturer')
6
8
 
7
- it "contains the host's IP address" do
8
- expect(host.ip_addr).to eq('10.0.0.1')
9
- end
9
+ describe '#ip_addr' do
10
+ it "returns the host's IP address" do
11
+ expect(host.ip_addr).to eq('10.0.0.1')
12
+ end
13
+ end
10
14
 
11
- it "contains the host's MAC address" do
12
- expect(host.mac).to eq('00:11:22:33:44:55')
13
- end
15
+ describe '#mac' do
16
+ it "returns the host's MAC address" do
17
+ expect(host.mac).to eq('00:11:22:33:44:55')
18
+ end
19
+ end
14
20
 
15
- it "contians the host's OUI information" do
16
- expect(host.oui).to eq('NIC Manufacturer')
21
+ describe '#oui' do
22
+ it "returns the host's OUI information" do
23
+ expect(host.oui).to eq('NIC Manufacturer')
24
+ end
25
+ end
17
26
  end
18
-
19
27
  end
@@ -1,51 +1,76 @@
1
- require '../lib/arp_scan'
1
+ # frozen_string_literal: true
2
2
 
3
- RSpec.describe ARPScan::ScanReport do
3
+ require_relative './spec_helper'
4
4
 
5
- report_hash = {
6
- :hosts => [ARPScan::Host.new(*['10.0.0.1', '00:11:22:33:44:55', 'NIC Manufacturer'])],
7
- :interface => "eth0",
8
- :datalink => "EN10MB (Ethernet)",
9
- :version => "1.8.1",
10
- :range_size => 256,
11
- :scan_time => 1.503,
12
- :scan_rate => 170.33,
13
- :reply_count => 1
14
- }
5
+ module ARPScan
6
+ describe ScanReport do
7
+ report_hash = {
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'
17
+ }
15
18
 
16
- scan_report = ARPScan::ScanReport.new(report_hash)
19
+ scan_report = ScanReport.new(report_hash)
17
20
 
18
- it "has a list of zero or more responding hosts" do
19
- expect(scan_report.hosts.first.class).to eq(ARPScan::Host)
20
- end
21
+ describe '#hosts' do
22
+ it 'returns an Array of Host objects' do
23
+ expect(scan_report.hosts.class).to eq(Array)
24
+ expect(scan_report.hosts.first.class).to eq(Host)
25
+ end
26
+ end
21
27
 
22
- it "reports the network interface used to scan" do
23
- expect(scan_report.interface).to eq("eth0")
24
- end
28
+ describe '#interface' do
29
+ it 'returns the network interface used to scan' do
30
+ expect(scan_report.interface).to eq('eth0')
31
+ end
32
+ end
25
33
 
26
- it "reports the datalink type of the network interface used to scan" do
27
- expect(scan_report.datalink).to eq('EN10MB (Ethernet)')
28
- end
29
-
30
- it "reports the version of `arp-scan` used for the scan" do
31
- expect(scan_report.version).to eq('1.8.1')
32
- end
34
+ describe '#datalink' do
35
+ it 'returns the datalink type of the network interface used to scan' do
36
+ expect(scan_report.datalink).to eq('EN10MB (Ethernet)')
37
+ end
38
+ end
33
39
 
34
- it "reports the size of the range of scanned IPs" do
35
- expect(scan_report.range_size).to eq(256)
36
- end
40
+ describe '#version' do
41
+ it 'returns the version of `arp-scan` used for the scan' do
42
+ expect(scan_report.version).to eq('1.8.1')
43
+ end
44
+ end
37
45
 
38
- it "reports the duration of the scan in seconds" do
39
- expect(scan_report.scan_time).to eq(1.503)
40
- end
46
+ describe '#range_size' do
47
+ it 'returns the size of the range of scanned IPs' do
48
+ expect(scan_report.range_size).to eq(256)
49
+ end
50
+ end
41
51
 
42
- it "reports the scan rate in hosts per second" do
43
- expect(scan_report.scan_rate).to eq(170.33)
44
- end
52
+ describe '#scan_time' do
53
+ it 'returns the duration of the scan in seconds' do
54
+ expect(scan_report.scan_time).to eq(1.503)
55
+ end
56
+ end
45
57
 
46
- it "reports the number of hosts that responded" do
47
- expect(scan_report.reply_count).to eq(1)
48
- end
58
+ describe '#scan_rate' do
59
+ it 'returns the scan rate in hosts per second' do
60
+ expect(scan_report.scan_rate).to eq(170.33)
61
+ end
62
+ end
49
63
 
64
+ describe '#reply_count' do
65
+ it 'returns the number of hosts that responded' do
66
+ expect(scan_report.reply_count).to eq(1)
67
+ end
68
+ end
50
69
 
70
+ describe '#arguments' do
71
+ it 'returns the argument string used to scan' do
72
+ expect(scan_report.arguments).to eq('-l')
73
+ end
74
+ end
75
+ end
51
76
  end
@@ -1,44 +1,53 @@
1
- require '../lib/arp_scan'
1
+ # frozen_string_literal: true
2
2
 
3
- RSpec.describe ARPScan::ScanResultProcessor do
3
+ require_relative './spec_helper'
4
4
 
5
- report_string = File.read './test_output.txt'
6
- report = ARPScan::ScanResultProcessor.process(report_string)
7
-
8
- it "processes arp-scan output to create a ScanReport object" do
9
- expect(report.class).to eq(ARPScan::ScanReport)
10
- end
5
+ module ARPScan
6
+ describe ScanResultProcessor do
7
+ argument_string = '-l'
8
+ report_string = File.read './test_output.txt'
9
+ report = ARPScan::ScanResultProcessor.process(report_string, argument_string)
11
10
 
12
- it "builds an array of Host objects" do
13
- expect(report.hosts[0].class).to eq(ARPScan::Host)
14
- end
11
+ describe '#process' do
12
+ it 'processes arp-scan output to create a ScanReport object' do
13
+ expect(report.class).to eq(ARPScan::ScanReport)
14
+ end
15
15
 
16
- it "parses the scan interface name" do
17
- expect(report.interface).to eq("eth0")
18
- end
16
+ it 'builds an array of Host objects' do
17
+ expect(report.hosts[0].class).to eq(ARPScan::Host)
18
+ end
19
19
 
20
- it "parses the datalink type information" do
21
- expect(report.datalink).to eq("EN10MB (Ethernet)")
22
- end
20
+ it 'parses the scan interface name' do
21
+ expect(report.interface).to eq('eth0')
22
+ end
23
23
 
24
- it "parses the version of arp-scan that ran the scan" do
25
- expect(report.version).to eq('1.8.1')
26
- end
24
+ it 'parses the datalink type information' do
25
+ expect(report.datalink).to eq('EN10MB (Ethernet)')
26
+ end
27
27
 
28
- it "parses the number of hosts scanned" do
29
- expect(report.range_size).to eq(256)
30
- end
28
+ it 'parses the version of arp-scan that ran the scan' do
29
+ expect(report.version).to eq('1.8.1')
30
+ end
31
31
 
32
- it "parses the duration of the scan in seconds" do
33
- expect(report.scan_time).to eq(1.494)
34
- end
32
+ it 'parses the number of hosts scanned' do
33
+ expect(report.range_size).to eq(256)
34
+ end
35
35
 
36
- it "parses the rate of the scan in hosts per second" do
37
- expect(report.scan_rate).to eq(171.35)
38
- end
36
+ it 'parses the duration of the scan in seconds' do
37
+ expect(report.scan_time).to eq(1.494)
38
+ end
39
+
40
+ it 'parses the rate of the scan in hosts per second' do
41
+ expect(report.scan_rate).to eq(171.35)
42
+ end
39
43
 
40
- it "parses the number of hosts that responded to the scan" do
41
- expect(report.reply_count).to eq(1)
44
+ it 'parses the number of hosts that responded to the scan' do
45
+ expect(report.reply_count).to eq(1)
46
+ end
47
+
48
+ it 'includes the argument string in the report' do
49
+ expect(report.arguments).to eq('-l')
50
+ end
51
+ end
42
52
  end
43
53
  end
44
-
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require '../lib/arp_scan'
metadata CHANGED
@@ -1,44 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arp_scan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Rodrigues
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-07 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.
11
+ date: 2021-07-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Use the arp-scan utility from your ruby programs.
42
14
  email:
43
15
  - mikebrodrigues@gmail.com
44
16
  executables: []
@@ -46,6 +18,7 @@ extensions: []
46
18
  extra_rdoc_files: []
47
19
  files:
48
20
  - Gemfile
21
+ - Gemfile.lock
49
22
  - LICENSE.txt
50
23
  - README.md
51
24
  - arp_scan.gemspec
@@ -60,8 +33,9 @@ files:
60
33
  - spec/host_spec.rb
61
34
  - spec/scan_report_spec.rb
62
35
  - spec/scan_result_processor_spec.rb
36
+ - spec/spec_helper.rb
63
37
  - spec/test_output.txt
64
- homepage: ''
38
+ homepage: https://github.com/mikerodrigues/arp_scan
65
39
  licenses:
66
40
  - MIT
67
41
  metadata: {}
@@ -71,17 +45,16 @@ require_paths:
71
45
  - lib
72
46
  required_ruby_version: !ruby/object:Gem::Requirement
73
47
  requirements:
74
- - - '>='
48
+ - - ">="
75
49
  - !ruby/object:Gem::Version
76
50
  version: '0'
77
51
  required_rubygems_version: !ruby/object:Gem::Requirement
78
52
  requirements:
79
- - - '>='
53
+ - - ">="
80
54
  - !ruby/object:Gem::Version
81
55
  version: '0'
82
56
  requirements: []
83
- rubyforge_project:
84
- rubygems_version: 2.2.2
57
+ rubygems_version: 3.2.3
85
58
  signing_key:
86
59
  specification_version: 4
87
60
  summary: A ruby wrapper for the arp-scan utility.
@@ -91,4 +64,5 @@ test_files:
91
64
  - spec/host_spec.rb
92
65
  - spec/scan_report_spec.rb
93
66
  - spec/scan_result_processor_spec.rb
67
+ - spec/spec_helper.rb
94
68
  - spec/test_output.txt