lan_scanner 0.0.1 → 0.0.2

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
2
  SHA256:
3
- metadata.gz: 3b03b665db6f858b32fd78d0fa4349ddb272493f86ee947c03ffa6540ee4f950
4
- data.tar.gz: 719c9f103d2b88365308fd5cea1a67156ba822f34e3ab82f2193d9e86a85b23c
3
+ metadata.gz: 06453e92801f03ccff92ba3b1b0155e540ca626228f3b2d61f72f8605c851bac
4
+ data.tar.gz: 9a28ca27720d9d69c3bf93cdaf0f9f6b9693bfdee5fc9e20ec2b7f78152b85ff
5
5
  SHA512:
6
- metadata.gz: ff053ab65a6ea8c93586ff9adb74cc0293bca5caf0415074e6a4ae70cb3340a717d0759836515f71e21b39be125d355859dced101d16c4295f2e31b36869167d
7
- data.tar.gz: 3bcf333729f6b09ce19daa4731c86981bb29f741c0d358e83a2f04ea73f7e434247039eb0f7027678d2320b1b8add626d94f45bc34153c22b264d37e9b2e72f0
6
+ metadata.gz: '0598fb4619c48ae76d23a19d3b9255b9f679f13f2df5f32ff1768293b2c7ebf368ea34d82fbb94c0787223d05f1edb4908dff8fbe1f4385cbab66aa958b23e66'
7
+ data.tar.gz: fef519bb6deb35fe43e99f6b8d6d68151ad5fe724ce105802810ead54ddc926d6eb592be0e0bca842732498839e01b45c6695c998790958dd0eb846f77aa8890
@@ -1,3 +1,3 @@
1
1
  module LanScanner
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
data/lib/lan_scanner.rb CHANGED
@@ -18,16 +18,34 @@ module LanScanner
18
18
  network = my_networks
19
19
  end
20
20
  network = [network] unless network.is_a? Array
21
- xml_results = []
21
+ sn_xml_results = []
22
22
  tmp_file = "#{Dir.tmpdir}/nmap_scan.xml"
23
+ # first we do an -sL scan, which also receives addresses from router/network cache,
24
+ # that are not found by -sn scan when scanning for the complete network, but are found
25
+ # with -sn scan, when scanning for this addresses explicitly
26
+ #
27
+ # so after this scan we scan for this addresses beneath the networks with -sn
28
+ sl_xml_results = []
23
29
  network.each do |n|
24
- ['-sL','-sn'].each do |nmap_type|
30
+ ['-sL'].each do |nmap_type|
25
31
  `nmap #{nmap_type} #{n} -oX "#{tmp_file}"`
26
- xml_results.push File.read tmp_file
32
+ sl_xml_results.push File.read tmp_file
27
33
  File.delete tmp_file
28
34
  end
29
35
  end
30
- _parse_nmap_xml xml_results
36
+ # here we scan for the received ip addresses from network cache
37
+ sl_ips = _parse_nmap_xml sl_xml_results
38
+ `nmap -sn #{sl_ips.map(&:remote_address).join(' ')} -oX "#{tmp_file}"`
39
+ sn_xml_results.push File.read tmp_file
40
+ # here we ping the networks (fast ping which does not detect all)
41
+ network.each do |n|
42
+ ['-sn'].each do |nmap_type|
43
+ `nmap #{nmap_type} #{n} -oX "#{tmp_file}"`
44
+ sn_xml_results.push File.read tmp_file
45
+ File.delete tmp_file
46
+ end
47
+ end
48
+ _parse_nmap_xml sn_xml_results
31
49
  end
32
50
 
33
51
  def self.my_networks
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lan_scanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthäus J. N. Beyrle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-21 00:00:00.000000000 Z
11
+ date: 2023-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-which