arpscanner 0.1.1 → 0.4.0

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: 464d5197c3bfefab75016f1f18e1cedc155065e3
4
- data.tar.gz: 2735858a32289cc1f9a8f4166ceab024c1024025
2
+ SHA256:
3
+ metadata.gz: 48b68acf51dd79503e0d3db993c24eaa086b48014d953d0e14f3f0a9c905dff9
4
+ data.tar.gz: 78a39058f68d2b92bb1d57ed76c02d7a9ea4edfffb3ee6758c0e259fe2f14434
5
5
  SHA512:
6
- metadata.gz: ee1e1b667a134036e2b2843413c9ab4bc88e8cf1d9fee82d6ec208fe2e310dd0acd6efe4ab94012ea181a070c6ac3b333f9a38b8a8c019371e2ab49004f4c794
7
- data.tar.gz: 89aa111870ad54100732392d28c747cc594857b7347ee0147b7201fd3a3192d3a00a50cdd4639fafb08a82fbdfd2b708062c4e7956fc9f03bbcccc454c693404
6
+ metadata.gz: 3c6865c71ad712163949fd2e32d348db89d0ccde01f4760ffae6e5bc4200c5f357a25bb200844f56e1f0cb6e250f1e682dde8046d397e8db87baf8188e6d5115
7
+ data.tar.gz: 5b6bd8004c5d133edea82813e2e60cd88c06967e5571afde520e73b3992ceb9502f5363b93da1742a52fe3e90beaebdb18c7b9a1dd0d0386193702c0ba9841ef
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,32 +2,69 @@
2
2
 
3
3
  # file: arpscanner.rb
4
4
 
5
+ require 'resolv' # resolv is a built-in Ruby library
5
6
  require 'dynarex'
7
+ require 'mactovendor'
8
+
6
9
 
7
10
  class ArpScanner
8
-
9
- def initialize()
11
+ using ColouredText
12
+
13
+ # options:
14
+ # nic: e.g. eth0, enp2s0f0
15
+ #
16
+ def initialize(nic: `ip addr`[/(?<=global )\w+/], vendors: {},
17
+ nameserver: nil)
10
18
 
11
19
  package = 'arp-scan'
20
+ @vendors, @nameserver = vendors, nameserver
12
21
 
13
22
  found = `dpkg --get-selections | grep #{package}`
14
23
 
15
24
  if found.empty? then
16
- raise 'ArpScanner: arp-scanner package not found'
25
+ raise 'ArpScanner: arp-scan package not found'.error
17
26
  end
18
27
 
19
- @arpscan_cmd = "sudo #{package} --interface=eth0 --localnet"
28
+ @arpscan_cmd = "sudo #{package} --interface=#{nic} --localnet"
20
29
 
21
30
  end
22
31
 
23
32
  def scan()
24
33
 
25
34
  a = `#{@arpscan_cmd}`.lines
35
+
36
+ a2 = a[2..-4].map do |x|
26
37
 
27
- a2 = a[2..-3].map {|x| %i(ip mac mfr).zip(x.chomp.split("\t")).to_h}
38
+ r = %i(ip mfr mac).zip(x.chomp.split("\t").values_at(0,2,1))
39
+
40
+ if @nameserver then
41
+
42
+ begin
43
+ hostname = Resolv::DNS.new(:nameserver => [@nameserver]).getname(r[0][1]).to_s
44
+ rescue
45
+ hostname = ''
46
+ puts ($!).to_s.warning
47
+ end
48
+
49
+ r.insert(1, [:hostname, hostname])
50
+
51
+ else
52
+ %i(ip mfr mac).zip(x.chomp.split("\t")).to_h
53
+ end
54
+
55
+ h = r.to_h
56
+
57
+ if h[:mfr] == '(Unknown)' then
58
+ vendor = MacToVendor.find h[:mac]
59
+ h[:mfr] = vendor if vendor
60
+ end
61
+
62
+ h
63
+
64
+ end
28
65
 
29
66
  # Add additional vendors
30
- h = {/^b8:27:eb:/ => 'Raspberry Pi Foundation'}
67
+ h = {/^b8:27:eb:/ => 'Raspberry Pi Foundation'}.merge(@vendors)
31
68
 
32
69
  a2.map! do |x|
33
70
 
@@ -37,10 +74,9 @@ class ArpScanner
37
74
 
38
75
  end
39
76
 
40
- @dx = Dynarex.new
41
- @dx.import a2
77
+ Dynarex.new.import a2
42
78
 
43
79
  end
44
80
 
45
81
 
46
- end
82
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arpscanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE3MDQyNDA5MzA0MloXDTE4MDQyNDA5MzA0MlowSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAN+QLE6Yi4Jch6ppEryYSM+k3fSq28g+YIoMO6GwTBEOg2z/FOWS4ycQF5Zg
19
- RrZGCWlegCnvkvgCwo6BsH7WeU0zNUg63QWjS1BPPKpPSWkUmG3Yo3SQMynL7gAO
20
- NaacqrnW9DPgKoSHwtHPSk8tribyDAuZHATNWtO4GiKXWMl+8tyWvM3QlcyJtUER
21
- FP0W5eXGXtjdUVk1+7WSWVJRKR8jySRTTAjH4bbTxBf837HzjMtgLKCfyW8L4Asn
22
- drJ/JhG3SkcwSdv6Ak0i2fT9+3UaHUtC2M6O+xHtbyDhFzt3zShWDa3mgcnwRgSe
23
- wm1j2Ndn6FK7XtRRgpOZv5QPj70CAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
- DwQEAwIEsDAdBgNVHQ4EFgQU6gvSWNYHJnNpLXV+IZy6iXV9nDswJgYDVR0RBB8w
25
- HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
- c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAtK/D1dXv
27
- J/IA8H8dyRSrYKcUII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ZOadm4yOxJ7LkGcwb0MsECKzFDRR
24
+ Y/EuIEv5rh9sk5Va5wFG5leyUZYmZvGSnpyvRm/XuGDh2vLiAk0xvSOyejMCAwEA
25
+ AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUAPeiepJa
26
+ +c0wMMdqidykpGLmRHAwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
27
+ c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
28
+ BgkqhkiG9w0BAQsFAAOCAYEADBzb0y9myCatops5l7QFHUp7jzLiBTBz6o4GwWky
29
+ dGe8tTfuDHQOk+m9WvLKtTZ2XCychu3yTruFXrHFB8b23SndrYgwvvb2mDNQT6bo
30
+ ltUZrkFYHHgjYUDbLw1ToeTGh882VD2G1d3cooLoN378MMUrM7IV8YisS7vtoRmu
31
+ tVZhYvwP06fS0eedDEVhx5Azi3OLTb5+hORvsnksvL1PlFqrVNO/lOGva2WM4Yt0
32
+ CpaA6lVJl3ypb/15vLrOGthmWlSFuSt4at+OZB5KxtSMclxDz9fq+c3M32uOsTXE
33
+ 07u4GCEVyvcFLBaNf6/ZF3ke24rHm6CMp/mCnFjYdRW3qIBgo0dc6gD+K1JYZThD
34
+ iV+jNLjfVhVAUXJX/n4d1qclFgFcNKQT93vklLApz7QZFzEho0MQcyV7Iq9VxOKw
35
+ cOLTxTEGHP0PrD7OYVyXjy1/2XJC9E3Ca9wr7MWld01vUdMbC0TZaqTGM+7+dejp
36
+ bCPG9KW8LldPMB4NjEePBmN1
33
37
  -----END CERTIFICATE-----
34
- date: 2017-05-10 00:00:00.000000000 Z
38
+ date: 2020-08-22 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: dynarex
@@ -39,20 +43,40 @@ dependencies:
39
43
  requirements:
40
44
  - - "~>"
41
45
  - !ruby/object:Gem::Version
42
- version: '1.7'
46
+ version: '1.8'
43
47
  - - ">="
44
48
  - !ruby/object:Gem::Version
45
- version: 1.7.21
49
+ version: 1.8.27
46
50
  type: :runtime
47
51
  prerelease: false
48
52
  version_requirements: !ruby/object:Gem::Requirement
49
53
  requirements:
50
54
  - - "~>"
51
55
  - !ruby/object:Gem::Version
52
- version: '1.7'
56
+ version: '1.8'
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 1.7.21
59
+ version: 1.8.27
60
+ - !ruby/object:Gem::Dependency
61
+ name: mactovendor
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.1.0
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.1'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.1.0
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.1'
56
80
  description:
57
81
  email: james@jamesrobertson.eu
58
82
  executables: []
@@ -79,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
103
  - !ruby/object:Gem::Version
80
104
  version: '0'
81
105
  requirements: []
82
- rubyforge_project:
83
- rubygems_version: 2.6.8
106
+ rubygems_version: 3.0.3
84
107
  signing_key:
85
108
  specification_version: 4
86
109
  summary: A wrapper for the package arp-scan. It can detect if a found MAC address
metadata.gz.sig CHANGED
Binary file