lan_scanner 0.0.1 → 0.0.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 +4 -4
- data/lib/lan_scanner/version.rb +1 -1
- data/lib/lan_scanner.rb +22 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06453e92801f03ccff92ba3b1b0155e540ca626228f3b2d61f72f8605c851bac
|
4
|
+
data.tar.gz: 9a28ca27720d9d69c3bf93cdaf0f9f6b9693bfdee5fc9e20ec2b7f78152b85ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0598fb4619c48ae76d23a19d3b9255b9f679f13f2df5f32ff1768293b2c7ebf368ea34d82fbb94c0787223d05f1edb4908dff8fbe1f4385cbab66aa958b23e66'
|
7
|
+
data.tar.gz: fef519bb6deb35fe43e99f6b8d6d68151ad5fe724ce105802810ead54ddc926d6eb592be0e0bca842732498839e01b45c6695c998790958dd0eb846f77aa8890
|
data/lib/lan_scanner/version.rb
CHANGED
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
|
-
|
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'
|
30
|
+
['-sL'].each do |nmap_type|
|
25
31
|
`nmap #{nmap_type} #{n} -oX "#{tmp_file}"`
|
26
|
-
|
32
|
+
sl_xml_results.push File.read tmp_file
|
27
33
|
File.delete tmp_file
|
28
34
|
end
|
29
35
|
end
|
30
|
-
|
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.
|
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-
|
11
|
+
date: 2023-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tty-which
|