rangescan 0.2.0 → 0.3.0

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: 4144b13853677049e63de5a4214bffd4140923b9627aa165793bd08a5fd3664f
4
- data.tar.gz: 5e9a1489605be94188c2a4310013062451630b12764db065af20081c1bc2d2af
3
+ metadata.gz: 643ca26936dec4a00aabc6551e9cea7c87cecfda46d5055c26f1c3e3c967893b
4
+ data.tar.gz: 6f034dcd1e4d5c59b36baec5ea6e4911aba47d88cd462d92a33898194b871839
5
5
  SHA512:
6
- metadata.gz: e82b98bb97b2742ca54bcfd47cecde7a4bee65d7fefe841f7b76cc6dfec7832c397e8d2e422afc5f64a2533ff453bb3cf83c6ad1cbeb98948845ab5710eb84e6
7
- data.tar.gz: 5e6e6173d6a858749fce649d25fd658a91a0d2941238f2ca730e07511e147e48440d713e07247c4a40c3299765760b403596b4122ac259a52d5e3847bfbfb4c2
6
+ metadata.gz: e2ce5509d388bc2d8026a8d9534339c5428bb974751d4e48ca73964d517a6de38665b8fb070247ee28cab5203b3bbad495890b6576bee1a89bb0008437130a1b
7
+ data.tar.gz: '098beb8cbee3e0f21302a2cffbaa83f9bdae11b9d80270517e7c92210bb8bf0db8050e337f180ba31a128e2cb4d858405f6e0ea0e4604905c54790abfcb27bef'
@@ -5,4 +5,5 @@ $LOAD_PATH.unshift("#{__dir__}/../lib")
5
5
 
6
6
  require "rangescan"
7
7
 
8
- RangeScan::CLI.start
8
+ ARGV.unshift(RangeScan::CLI.default_task) unless RangeScan::CLI.all_tasks.key?(ARGV[0])
9
+ RangeScan::CLI.start(ARGV)
@@ -13,6 +13,7 @@ module RangeScan
13
13
  method_option :user_agent, type: :string, desc: "User Agent"
14
14
  method_option :verify_ssl, type: :boolean, desc: "Whether to verify SSL or not"
15
15
  method_option :max_concurrency, type: :numeric, desc: "Concurrency limit for HTTP requests to scan"
16
+ method_option :headers, type: :hash, default: {}, desc: "Custom headers"
16
17
  def scan(ip_with_subnet_mask, regexp = ".")
17
18
  symbolized_options = symbolize_hash_keys(options)
18
19
  range = Range.new(ip_with_subnet_mask)
@@ -26,10 +27,18 @@ module RangeScan
26
27
  puts JSON.pretty_generate(filtered)
27
28
  end
28
29
 
30
+ default_command :scan
31
+
29
32
  no_commands do
30
33
  def symbolize_hash_keys(hash)
31
34
  hash.map { |k, v| [k.to_sym, v] }.to_h
32
35
  end
33
36
  end
37
+
38
+ class << self
39
+ def exit_on_failure?
40
+ true
41
+ end
42
+ end
34
43
  end
35
44
  end
@@ -11,6 +11,7 @@ require "rangescan/monkey_patch"
11
11
  module RangeScan
12
12
  class Scanner
13
13
  attr_reader :context
14
+ attr_reader :headers
14
15
  attr_reader :host
15
16
  attr_reader :max_concurrency
16
17
  attr_reader :port
@@ -21,19 +22,28 @@ module RangeScan
21
22
  attr_reader :user_agent
22
23
  attr_reader :verify_ssl
23
24
 
24
- def initialize(host: nil, port: nil, scheme: "http", verify_ssl: true, timeout: 5, user_agent: nil, max_concurrency: nil)
25
+ def initialize(
26
+ headers: {},
27
+ host: nil,
28
+ max_concurrency: nil,
29
+ port: nil,
30
+ scheme: "http",
31
+ timeout: 5,
32
+ user_agent: nil,
33
+ verify_ssl: true
34
+ )
35
+ @headers = headers
25
36
  @host = host
26
37
  @port = port || (scheme == "http" ? 80 : 443)
27
- @timeout = timeout
28
38
  @scheme = scheme
39
+ @timeout = timeout
29
40
  @user_agent = user_agent
30
-
31
41
  @verify_ssl = verify_ssl
32
42
 
33
43
  @ssl_context = OpenSSL::SSL::SSLContext.new
34
44
  @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE unless verify_ssl
35
45
 
36
- @max_concurrency = max_concurrency || Etc.nprocessors * 2
46
+ @max_concurrency = max_concurrency || Etc.nprocessors * 8
37
47
  end
38
48
 
39
49
  def url_for(ipv4)
@@ -78,7 +88,7 @@ module RangeScan
78
88
  private
79
89
 
80
90
  def default_request_headers
81
- @default_request_headers ||= { "host" => host, "user-agent" => user_agent }.compact
91
+ @default_request_headers ||= headers.merge({ "host" => host, "user-agent" => user_agent }.compact)
82
92
  end
83
93
 
84
94
  def ssl_options
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RangeScan
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rangescan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-26 00:00:00.000000000 Z
11
+ date: 2020-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler