kscript 1.0.1 → 1.0.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/kscript/cli.rb +0 -2
- data/lib/kscript/logger.rb +1 -1
- data/lib/kscript/plugins/kk_es_fingerprint_utils.rb +3 -2
- data/lib/kscript/plugins/kk_ffmpeg_utils.rb +4 -0
- data/lib/kscript/plugins/kk_ip_utils.rb +0 -3
- data/lib/kscript/plugins/kk_jenkins_utils.rb +3 -7
- data/lib/kscript/plugins/kk_kibana_utils.rb +3 -2
- data/lib/kscript/plugins/kk_lvm_utils.rb +2 -1
- data/lib/kscript/plugins/kk_optimize_utils.rb +0 -1
- data/lib/kscript/plugins/kk_portscan_utils.rb +54 -16
- data/lib/kscript/plugins/kk_projscan_utils.rb +0 -1
- data/lib/kscript/plugins/kk_sh_utils.rb +0 -1
- data/lib/kscript/plugins/kk_syscheck_utils.rb +4 -0
- data/lib/kscript/plugins/kk_wg_pass_utils.rb +0 -1
- data/lib/kscript/utils.rb +0 -3
- data/lib/kscript/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01ab48d4e8819e3190707f87bbc3fa8a98df3046c278a6c6a625c8eca25d4585
|
4
|
+
data.tar.gz: 15970ccc55e4900e98d0c99a6e3ebb4ebe9555891e63393ec31459c4847d5ab9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e45e15a0732f678f90db60384458c542f8d038460a801a60f986c197f975321fbf8ca88e39902f5fd2d1d8c2b39b8f4adae55522253824f8cf9a5afff947a83
|
7
|
+
data.tar.gz: 4b0f0f5c5be88b4b248ad9e5d5a8ccca3c0f9a267da5a664afe426917881f16ec173b09e3e287d44fbe9a9aa86aa74ef651c96abaae4b34e77ab1c6b40a85ed1
|
data/lib/kscript/cli.rb
CHANGED
data/lib/kscript/logger.rb
CHANGED
@@ -15,8 +15,9 @@ module Kscript
|
|
15
15
|
|
16
16
|
# Initialize with certificate path
|
17
17
|
# @param cert_path [String] path to the certificate file
|
18
|
-
def initialize(cert_path =
|
19
|
-
|
18
|
+
def initialize(cert_path = nil, *_args, **opts)
|
19
|
+
super(**opts.merge(service: 'kk_es_fingerprint'))
|
20
|
+
@cert_path = cert_path || self.class::DEFAULT_CERT_PATH
|
20
21
|
end
|
21
22
|
|
22
23
|
def run
|
@@ -6,12 +6,6 @@
|
|
6
6
|
# https://opensource.org/licenses/MIT
|
7
7
|
|
8
8
|
require 'kscript'
|
9
|
-
require 'http'
|
10
|
-
require 'base64'
|
11
|
-
require 'rexml/document'
|
12
|
-
require 'json'
|
13
|
-
require 'fileutils'
|
14
|
-
require 'kscript/base'
|
15
9
|
|
16
10
|
module Kscript
|
17
11
|
class KkJenkinsUtils < Base
|
@@ -21,7 +15,9 @@ module Kscript
|
|
21
15
|
end
|
22
16
|
end
|
23
17
|
|
24
|
-
def initialize(
|
18
|
+
def initialize(*args, **opts)
|
19
|
+
super(**opts.merge(service: 'kk_jenkins'))
|
20
|
+
jenkins_url, user, password = args
|
25
21
|
@jenkins_url = jenkins_url
|
26
22
|
@user = user
|
27
23
|
@password = password
|
@@ -6,7 +6,6 @@
|
|
6
6
|
# https://opensource.org/licenses/MIT
|
7
7
|
|
8
8
|
require 'kscript'
|
9
|
-
require 'securerandom'
|
10
9
|
|
11
10
|
module Kscript
|
12
11
|
class KkKibanaUtils < Base
|
@@ -16,7 +15,9 @@ module Kscript
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
def initialize(
|
18
|
+
def initialize(*args, **opts)
|
19
|
+
super(**opts.merge(service: 'kk_kibana'))
|
20
|
+
project_name, project_env, base_url, username, password = args
|
20
21
|
@base_url = base_url
|
21
22
|
@username = username
|
22
23
|
@password = password
|
@@ -20,7 +20,8 @@ module Kscript
|
|
20
20
|
|
21
21
|
# Initialize the LVM mounter with configuration
|
22
22
|
# @param config [Hash] configuration options
|
23
|
-
def initialize(config = {}, *_args, **
|
23
|
+
def initialize(config = {}, *_args, **opts)
|
24
|
+
super(**opts.merge(service: 'kk_lvm'))
|
24
25
|
@config = DEFAULT_CONFIG.merge(config)
|
25
26
|
end
|
26
27
|
|
@@ -6,8 +6,6 @@
|
|
6
6
|
# https://opensource.org/licenses/MIT
|
7
7
|
|
8
8
|
require 'kscript'
|
9
|
-
require 'socket'
|
10
|
-
require 'timeout'
|
11
9
|
|
12
10
|
module Kscript
|
13
11
|
class KkPortscanUtils < Base
|
@@ -17,10 +15,11 @@ module Kscript
|
|
17
15
|
# @param host [String] target host to scan
|
18
16
|
# @param ports [Array<Integer>] list of ports to scan
|
19
17
|
# @param thread_count [Integer] number of concurrent threads
|
20
|
-
def initialize(target = nil, ports = (1..1024), *_args, **opts)
|
18
|
+
def initialize(target = nil, ports = (1..1024), thread_count = 50, *_args, **opts)
|
21
19
|
super(**opts.merge(service: 'kk_port_scanner'))
|
22
20
|
@target = target
|
23
|
-
@ports =
|
21
|
+
@ports = parse_ports(ports)
|
22
|
+
@thread_count = (opts[:thread_count] || thread_count || 50).to_i
|
24
23
|
end
|
25
24
|
|
26
25
|
def run
|
@@ -31,23 +30,62 @@ module Kscript
|
|
31
30
|
|
32
31
|
# Execute port scanning using multiple threads
|
33
32
|
def scan
|
34
|
-
msg = "Scanning #{@target} ports #{@ports}"
|
33
|
+
msg = "Scanning #{@target} ports #{@ports} with concurrency=#{@thread_count}"
|
35
34
|
if human_output?
|
36
35
|
puts msg
|
37
36
|
else
|
38
37
|
logger.kinfo(msg)
|
39
38
|
end
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
queue = Queue.new
|
40
|
+
@ports.each { |port| queue << port }
|
41
|
+
threads = []
|
42
|
+
@thread_count.times do
|
43
|
+
threads << Thread.new do
|
44
|
+
until queue.empty?
|
45
|
+
port = nil
|
46
|
+
begin
|
47
|
+
port = queue.pop(true)
|
48
|
+
rescue ThreadError
|
49
|
+
break
|
50
|
+
end
|
51
|
+
begin
|
52
|
+
Socket.tcp(@target, port, connect_timeout: 0.5) do |_sock|
|
53
|
+
if human_output?
|
54
|
+
puts "Port #{port} is open"
|
55
|
+
else
|
56
|
+
logger.kinfo('Port open', port: port)
|
57
|
+
logger.kinfo("Port #{port} is open")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT, SocketError
|
61
|
+
# closed or filtered
|
62
|
+
end
|
47
63
|
end
|
48
64
|
end
|
49
|
-
|
50
|
-
|
65
|
+
end
|
66
|
+
threads.each(&:join)
|
67
|
+
end
|
68
|
+
|
69
|
+
# 支持多种端口参数格式: 22,80,443 或 1..1024
|
70
|
+
def parse_ports(ports)
|
71
|
+
return ports.to_a if ports.is_a?(Range)
|
72
|
+
|
73
|
+
if ports.is_a?(String)
|
74
|
+
if ports.include?(',')
|
75
|
+
ports.split(',').map(&:to_i)
|
76
|
+
elsif ports.include?('..')
|
77
|
+
begin
|
78
|
+
eval(ports).to_a
|
79
|
+
rescue StandardError
|
80
|
+
(1..1024).to_a
|
81
|
+
end
|
82
|
+
else
|
83
|
+
[ports.to_i]
|
84
|
+
end
|
85
|
+
elsif ports.is_a?(Array)
|
86
|
+
ports.map(&:to_i)
|
87
|
+
else
|
88
|
+
(1..1024).to_a
|
51
89
|
end
|
52
90
|
end
|
53
91
|
|
@@ -56,11 +94,11 @@ module Kscript
|
|
56
94
|
end
|
57
95
|
|
58
96
|
def self.arguments
|
59
|
-
'<target_host>'
|
97
|
+
'<target_host> [ports] [thread_count]'
|
60
98
|
end
|
61
99
|
|
62
100
|
def self.usage
|
63
|
-
"kscript portscan 192.168.1.1\nkscript portscan example.com
|
101
|
+
"kscript portscan 192.168.1.1\nkscript portscan example.com 22,80,443 100\nkscript portscan 192.168.1.1 1..1024 200"
|
64
102
|
end
|
65
103
|
|
66
104
|
def self.group
|
data/lib/kscript/utils.rb
CHANGED
data/lib/kscript/version.rb
CHANGED