arpscanner 0.1.0 → 0.3.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: 60a6fd991e59e363f27de94070f6203351d2e79b
4
- data.tar.gz: 17b8bfe1a8b756e6df4f0c0ab98d1a6e8bb3431f
2
+ SHA256:
3
+ metadata.gz: 79412d2b6cbd20c5aed889a22213156630d39bea4b69cba50810382ac7fd8e1a
4
+ data.tar.gz: 0f770e3e16c96f0a34454a21be2e7a50bca2867a40d609dd231a81c876169542
5
5
  SHA512:
6
- metadata.gz: 54dbd28b0c6ab8204925d8856143ed5a8094d25b922a5ffd1e9dc1e0769bee79d82f806238e2a4385adf59ce6e3220781994b103b8b36c111f13ffcb269979af
7
- data.tar.gz: ab7f18c930b879581abe9d1d429ae664ae0cee8ae24b464a1c4dd7828f0d1c53472745fda0873cceb40b5ac3d4eb133e08ae3802580e071c3af0369ce178a888
6
+ metadata.gz: 68d1bd4c340df4fd9463f6f13f60f14b2dd8e635d5f3f1aed665ba3aa10a4d6c589be63c725e00ea84a62b1323f4e72b141cac7c8face72e4b46c16f63e5c670
7
+ data.tar.gz: a268575887f08bccb4af0bed2fa668d4ca1d1f1a34f3a7feb5cf6a87d7192a3c209e088cd57581a98c1badd5185f198115790b3ff3ec60e7efd432d26b00226e
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,40 +2,73 @@
2
2
 
3
3
  # file: arpscanner.rb
4
4
 
5
+ require 'resolv' # resolv is a built-in Ruby library
6
+ require 'dynarex'
7
+
5
8
 
6
9
  class ArpScanner
7
-
8
- def initialize()
10
+ using ColouredText
11
+
12
+ # options:
13
+ # nic: e.g. eth0, enp2s0f0
14
+ #
15
+ def initialize(nic: `ip addr`[/(?<=global )\w+/], vendors: {},
16
+ nameserver: nil)
9
17
 
10
18
  package = 'arp-scan'
19
+ @vendors, @nameserver = vendors, nameserver
11
20
 
12
21
  found = `dpkg --get-selections | grep #{package}`
13
22
 
14
23
  if found.empty? then
15
- raise 'ArpScanner: arp-scanner package not found'
24
+ raise 'ArpScanner: arp-scan package not found'.error
16
25
  end
17
26
 
18
- @arpscan_cmd = "sudo #{package} --interface=eth0 --localnet"
27
+ @arpscan_cmd = "sudo #{package} --interface=#{nic} --localnet"
19
28
 
20
29
  end
21
30
 
22
31
  def scan()
23
32
 
24
33
  a = `#{@arpscan_cmd}`.lines
25
- a.shift 2
26
- a2 = a.map {|x| %i(ip mac mfr).zip(x.chomp.split("\t")).to_h}
34
+
35
+ a2 = a[2..-4].map do |x|
36
+
37
+ r = %i(ip mfr mac).zip(x.chomp.split("\t").values_at(0,2,1))
38
+
39
+ if @nameserver then
40
+
41
+ begin
42
+ hostname = Resolv::DNS.new(:nameserver => [@nameserver]).getname(r[0][1]).to_s
43
+ rescue
44
+ hostname = ''
45
+ puts ($!).to_s.warning
46
+ end
47
+
48
+ r.insert(1, [:hostname, hostname])
49
+
50
+ else
51
+ %i(ip mfr mac).zip(x.chomp.split("\t")).to_h
52
+ end
53
+
54
+ r.to_h
55
+
56
+ end
27
57
 
28
58
  # Add additional vendors
29
- h = {/^b8:27:eb:/ => 'Raspberry Pi Foundation'}
59
+ h = {/^b8:27:eb:/ => 'Raspberry Pi Foundation'}.merge(@vendors)
30
60
 
31
- a2.map do |x|
61
+ a2.map! do |x|
32
62
 
33
63
  _, vendor = h.detect {|mac, mfr| x[:mac] =~ mac }
34
64
  x[:mfr] = vendor if vendor
35
65
  x
36
66
 
37
67
  end
68
+
69
+ Dynarex.new.import a2
38
70
 
39
71
  end
72
+
40
73
 
41
74
  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.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,29 +10,53 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----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LiAk0xvSOyejMCAwEA
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-04-24 00:00:00.000000000 Z
35
- dependencies: []
38
+ date: 2020-08-22 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: dynarex
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.8'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 1.8.27
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.8'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.8.27
36
60
  description:
37
61
  email: james@jamesrobertson.eu
38
62
  executables: []
@@ -59,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
83
  - !ruby/object:Gem::Version
60
84
  version: '0'
61
85
  requirements: []
62
- rubyforge_project:
63
- rubygems_version: 2.6.8
86
+ rubygems_version: 3.0.3
64
87
  signing_key:
65
88
  specification_version: 4
66
89
  summary: A wrapper for the package arp-scan. It can detect if a found MAC address
metadata.gz.sig CHANGED
Binary file