yptools 1.1.0 → 1.1.1

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: 98dd6d1d9b7cc1c72d121fce68e65a6d035ebef4bab15b3fd18c0b550c2e23ec
4
- data.tar.gz: 3ddc62e82485cf62bf760a091b73d96769616e45d52de26cf98de7ca2eeb45e2
3
+ metadata.gz: c8223853ebcd90eb9fcd7f20d91a01eaac8b926ee69e2291dbfe6ee9976eaec0
4
+ data.tar.gz: 7605e3081dbb09c6d4cc654431e0341a0fb9b21c039d4134ca4c71f1512d42c5
5
5
  SHA512:
6
- metadata.gz: b3138ef32c117ca0c53f553fe0b1a95500369fcc186e1a60a569980e1efcaeae041de2c95f4324906162e8d6f780f450df3358f998261aa0f158f004ee740a58
7
- data.tar.gz: 0cc0a0b57eb2c8ee090c1f7501342948457397fbc72f91a14d9919dcd09a0a9c80d23a7b64007b026c354db6ff7e76f17d0f5f4d3fe882afce98edf1208f4a7e
6
+ metadata.gz: 7c3e46af8e5bbc9e380976f96b33e09a6a2c938d95e4bf8954fab587b3378af78d2f56b4013fa359a7b11d95317aa4e1a66c67a4148bfe3654da6013a91ac430
7
+ data.tar.gz: 01e1e766ea8dcf4a48e0862376c279847214cbeaf3aeadd511e92ece81945d50ce1ce8f29ee57266cb14d7acf42073d0094d7331e59ede4c6613c519114b6a12
@@ -3,11 +3,13 @@ class YPHelp
3
3
  def self.message
4
4
  puts %q{
5
5
 
6
+ 🤖🤖🤖 - 智能聊天、绘画(OpenAI)
6
7
  chatgpt: use [yptools chatgpt] 创建会话列表与 chatgpt 聊天,会记录上下内容(科学上网)
7
8
  [yptools chatgpt ...] 快速与 chatgpt 沟通,不会记录上下内容
8
9
 
9
10
  openai: use [yptools openaiimg ...] 根据文本描述生成图像(eg: yptools openaiimg '老虎和狮子大战' )
10
11
 
12
+ 🚀🚀🚀 - iOS开发者(IOS Developer)
11
13
  autocre: use [yptools autocre ...] 自动化工具命令
12
14
  use [yptools autocre -objc ...] 根据 json 自动创建 Objective-C 数据库操作文件 .h|.m 文件。(依赖三方库 FMDB )
13
15
  use [yptools autocre -init] 构建数据库操作文件的json模板
@@ -25,8 +27,12 @@ class YPHelp
25
27
  xpj: use [yptools xpj ...] use xcodeproj api
26
28
  use [yptools xpj check] 检查当前目录项目文件是否存在引用的问题
27
29
 
30
+ 🤡🤡🤡 - hacker
31
+ portscan: use [yptools portscan <ip地址或域名> [<端口范围>]] 扫描指定 IP 端口是否开放
32
+
33
+ 💩💩💩 - 帮助(help)
28
34
  help: use [yptools help] 查看帮助
29
-
35
+
30
36
  }
31
37
  end
32
38
 
@@ -0,0 +1,50 @@
1
+ class YPPortScan
2
+ def self.portscan(port, range)
3
+ script = %Q(
4
+ #!/bin/bash
5
+
6
+ if [ -n "#{range}" ]; then
7
+ all_port="#{range}"
8
+ else
9
+ all_port="1-65535"
10
+ fi
11
+
12
+ port_range=(${all_port//-/ })
13
+ timeout=0.02
14
+ ip_address=#{port}
15
+
16
+ port_range+=(#{range})
17
+
18
+ echo "正在扫描 ${ip_address} 的端口 ${port_range[0]} 到 ${port_range[1]}..."
19
+ echo ${port_range[1]}
20
+
21
+ open_ports=()
22
+ closed_ports=()
23
+
24
+ for ((port = ${port_range[0]}; port <= ${port_range[1]}; port++)); do
25
+ (echo >/dev/tcp/${ip_address}/${port}) >/dev/null 2>&1 &
26
+ pid=$!
27
+ (
28
+ sleep ${timeout}
29
+ kill ${pid} >/dev/null 2>&1
30
+ ) &
31
+ timer=$!
32
+ if wait ${pid} 2>/dev/null; then
33
+ echo "\\033[32m${port} 是开放的\\033[0m"
34
+ open_ports+=($port)
35
+ else
36
+ echo "\\033[31m${port} 是关闭的\\033[0m"
37
+ closed_ports+=($port)
38
+ fi
39
+ kill ${timer} >/dev/null 2>&1
40
+ done
41
+
42
+ allCount=$((${#open_ports[@]} + ${#closed_ports[@]}))
43
+
44
+ echo ${allCount} "个端口扫描完成。"
45
+ echo "共有 ${#open_ports[@]} 个端口是开放的,${#closed_ports[@]} 个端口是关闭的。"
46
+ echo "开放的端口: " "\\033[32m${open_ports[@]}\\033[0m"
47
+ )
48
+ system(script)
49
+ end
50
+ end
data/lib/yptools.rb CHANGED
@@ -11,6 +11,7 @@ require_relative 'yptools/package/yp_package'
11
11
  require_relative 'yptools/autocre/yp_autocre'
12
12
  require_relative 'yptools/autocre/yp_autoinit'
13
13
  require_relative 'yptools/chatai/yp_chatai'
14
+ require_relative 'yptools/portscan/yp_portscan'
14
15
 
15
16
  class YPTools
16
17
 
@@ -102,6 +103,13 @@ class YPTools
102
103
  yp_log_fail "'yptools xpj ..' 参数缺失"
103
104
  self.help
104
105
  end
106
+ when 'portscan'
107
+ if argvs.size > 1
108
+ self.portscan argvs
109
+ else
110
+ yp_log_fail "'yptools portscan ..' 参数缺失"
111
+ self.help
112
+ end
105
113
  else
106
114
  self.help
107
115
  end
@@ -158,6 +166,12 @@ class YPTools
158
166
  YPChatAI.openaiimg(message)
159
167
  end
160
168
 
169
+ def self.portscan(argvs)
170
+ port = argvs[1]
171
+ range = argvs[2]
172
+ YPPortScan.portscan(port,range)
173
+ end
174
+
161
175
  end
162
176
 
163
177
 
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.0
4
+ version: 1.1.1
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-10 00:00:00.000000000 Z
11
+ date: 2023-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -141,6 +141,7 @@ files:
141
141
  - lib/yptools/log/yp_log.rb
142
142
  - lib/yptools/mgc/yp_makegarbagecode.rb
143
143
  - lib/yptools/package/yp_package.rb
144
+ - lib/yptools/portscan/yp_portscan.rb
144
145
  - lib/yptools/update/yp_update.rb
145
146
  - lib/yptools/xcodeproj/yp_xcodeproj.rb
146
147
  homepage: https://github.com/HansenCCC/YPTools.git