yptools 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yptools/help/yp_help.rb +2 -0
- data/lib/yptools/scanlocalips/yp_scanlocalips.rb +44 -0
- data/lib/yptools.rb +7 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8408e5e1a3c11b120fb7f35959032380a30e25363b87b24ed8db7aeed71682e3
|
4
|
+
data.tar.gz: f13a54118992f2b3629895a2cf48b82ec401c66d8eb5e351977d5f07aca1a00a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e49cce07a4d0bfafc800d8cfa3d65a1ea826732bd3f0e8710e987d99f71bc97c6c35268096a6383ef1118ad4fe1861f3305800fc6e086055d1a0ee4fc30403f
|
7
|
+
data.tar.gz: afef0a6c693d3ba8c0ed26838a5364c5d3a0b7837adbe9e3c60fab27b7f2e4f411f9c74b11dee3e96cab81003840d8d4de6b7e80f8d8cb5212bd16ac05d2e525
|
data/lib/yptools/help/yp_help.rb
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
class YPScanLocalIPs
|
4
|
+
|
5
|
+
def self.scanlocalips()
|
6
|
+
self.scan_local_ips
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.ping(ip)
|
10
|
+
IO.popen("ping -c 1 -t 1 #{ip} > /dev/null 2>&1") { |f| f.close }
|
11
|
+
if $?.exitstatus == 0
|
12
|
+
puts ip
|
13
|
+
elsif $?.exitstatus == 2
|
14
|
+
# No route to host
|
15
|
+
elsif $?.exitstatus == 68
|
16
|
+
# Name or service not known
|
17
|
+
end
|
18
|
+
rescue => e
|
19
|
+
# handle exception
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.scan_local_ips
|
23
|
+
# 获取本机IP地址前三位,例如 192.168.0
|
24
|
+
prefix = Socket.ip_address_list.find { |intf| intf.ipv4? && !intf.ipv4_loopback? }.ip_address.split('.')[0, 3].join('.') + '.'
|
25
|
+
threads = []
|
26
|
+
|
27
|
+
# 遍历所有可能的IP地址
|
28
|
+
(1..255).each do |i|
|
29
|
+
threads << Thread.new(prefix, i) do |pr, j|
|
30
|
+
# 组合出IP地址,例如 192.168.0.1
|
31
|
+
ip = "#{pr}#{j}"
|
32
|
+
# 使用ping命令测试是否能够ping通,并手动关闭文件句柄
|
33
|
+
ping(ip)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# 等待所有线程执行完毕
|
38
|
+
threads.each(&:join)
|
39
|
+
|
40
|
+
# 输出所有结果
|
41
|
+
results = threads.map(&:value).compact
|
42
|
+
results.each { |ip| puts ip + "🚀" }
|
43
|
+
end
|
44
|
+
end
|
data/lib/yptools.rb
CHANGED
@@ -12,6 +12,7 @@ require_relative 'yptools/autocre/yp_autocre'
|
|
12
12
|
require_relative 'yptools/autocre/yp_autoinit'
|
13
13
|
require_relative 'yptools/chatai/yp_chatai'
|
14
14
|
require_relative 'yptools/portscan/yp_portscan'
|
15
|
+
require_relative 'yptools/scanlocalips/yp_scanlocalips'
|
15
16
|
|
16
17
|
class YPTools
|
17
18
|
|
@@ -110,6 +111,8 @@ class YPTools
|
|
110
111
|
yp_log_fail "'yptools portscan ..' 参数缺失"
|
111
112
|
self.help
|
112
113
|
end
|
114
|
+
when 'scanlocalips'
|
115
|
+
self.scanlocalips
|
113
116
|
else
|
114
117
|
self.help
|
115
118
|
end
|
@@ -172,6 +175,10 @@ class YPTools
|
|
172
175
|
YPPortScan.portscan(port,range)
|
173
176
|
end
|
174
177
|
|
178
|
+
def self.scanlocalips()
|
179
|
+
YPScanLocalIPs.scanlocalips()
|
180
|
+
end
|
181
|
+
|
175
182
|
end
|
176
183
|
|
177
184
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yptools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chenghengsheng
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/yptools/mgc/yp_makegarbagecode.rb
|
143
143
|
- lib/yptools/package/yp_package.rb
|
144
144
|
- lib/yptools/portscan/yp_portscan.rb
|
145
|
+
- lib/yptools/scanlocalips/yp_scanlocalips.rb
|
145
146
|
- lib/yptools/update/yp_update.rb
|
146
147
|
- lib/yptools/xcodeproj/yp_xcodeproj.rb
|
147
148
|
homepage: https://github.com/HansenCCC/YPTools.git
|