fingerprinter 0.1.5 → 0.1.7

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: 8f6821303bf8854c4b159cc1038bfb08af71d170b07a24e19376f49f88bba6ee
4
- data.tar.gz: edd7faad955013acf5c94e897e4994e340baafc493c3f2c1bfccdb2bf7558f7c
3
+ metadata.gz: bc97915b45277081abb4d06cbd9463bc82b214be082bec3aaa0af5655f28026d
4
+ data.tar.gz: 782347d3a249269a1c543f1c94230e88b9183b2bf3a310b10c7df4a9ee73f3f7
5
5
  SHA512:
6
- metadata.gz: 711d27cdd3329f07e6e24daa9400e36a8e8f62c6467870c0dc0309ed75bd1aa9713aaede490b9c882e91e1e69d8b9ccb0c20077f6e42a00353b03db685483078
7
- data.tar.gz: 49b065930036587200a211e12337e67bd6a61643e0101c9e2ddb860bc5454542ce74fb33557a4ac830dfa27159410ea2317eee8f751ed49848265a8bc4834bb0
6
+ metadata.gz: fe3aef3a9410d4a932e8b12b3f57a51c0d4286ebe006b5f6d53146231e0537b9874f35237c51c88ce324d54382d0a0de8bd48db3de9c0b826c4728f3aa23946d
7
+ data.tar.gz: 04e0164fe28d9ada0ad3d2095bc12b1bfa66d2447ed2ef8748b747391403acd6f3bd130bce371105fb8dd28be0a22c2ae974e68d5de5eb49fb7be95c663d68a5
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ServiceNow Detection
4
+ class ServiceNow < Fingerprinter::Technologies
5
+ HEADERS_REGEX = {
6
+ 'server' => /ServiceNow/,
7
+ 'set-cookie' => /glide_user/
8
+ }.freeze
9
+
10
+ BODY_CONTENT_REGEX = [
11
+ /About ServiceNow/
12
+ ].freeze
13
+
14
+ def self.run(data)
15
+ return unless response_headers_check(data[:response], HEADERS_REGEX) ||
16
+ title_detection(data[:doc], 'ServiceNow') ||
17
+ whole_body_check(data[:response], BODY_CONTENT_REGEX)
18
+
19
+ 'ServiceNow'
20
+ end
21
+ end
data/lib/fingerprinter.rb CHANGED
@@ -8,6 +8,11 @@ module Fingerprinter
8
8
  Dir[File.join(__dir__, 'fingerprinter', 'core/*.rb')].sort.each { |file| require file }
9
9
  Dir[File.join(__dir__, 'fingerprinter', 'utilities/*.rb')].sort.each { |file| require file }
10
10
 
11
+ EXCLUSIONS = %w[pass.diod.orange.com].freeze
12
+ WILDCARDS = [
13
+ ['Application is not available', 'The application is currently not serving requests at this endpoint']
14
+ ].freeze
15
+
11
16
  def self.http_client
12
17
  @http_client ||= HttpClient.new
13
18
  end
@@ -32,10 +37,13 @@ module Fingerprinter
32
37
 
33
38
  def run(urls)
34
39
  urls.each do |url|
40
+ next if EXCLUSIONS.any? { |exclusion| url.match?(exclusion) }
41
+
35
42
  response = get_response(url)
36
43
  next unless response
44
+ next if wildcard?(response)
37
45
 
38
- url = Utilities::Urls.up_to_port(response.effective_url)
46
+ url = effective_url(response, url)
39
47
 
40
48
  responses = response.redirections
41
49
  responses << response
@@ -55,6 +63,13 @@ module Fingerprinter
55
63
 
56
64
  private
57
65
 
66
+ def wildcard?(response)
67
+ response_body = response.body
68
+ WILDCARDS.any? do |patterns|
69
+ patterns.all? { |pattern| response_body&.include?(pattern) }
70
+ end
71
+ end
72
+
58
73
  def get_response(url)
59
74
  response = nil
60
75
  3.times do
@@ -67,19 +82,31 @@ module Fingerprinter
67
82
  if stream_error?(response)
68
83
  return
69
84
  elsif timeout_without_scheme?(url, response)
70
- url = "https://#{url}"
85
+ url = normalize_url(url)
71
86
  return get_response(url)
72
87
  end
73
88
  return if response&.code == 0
74
- return response if same_scope?(url, response)
89
+ return response if response.redirections.empty? || same_scope?(url, response)
75
90
 
76
91
  response.redirections.first
77
92
  end
78
93
 
94
+ def effective_url(response, url)
95
+ effective_url = Utilities::Urls.up_to_port(response.effective_url)
96
+ effective_url.nil? ? normalize_url(url) : effective_url
97
+ end
98
+
99
+ def normalize_url(url)
100
+ url.start_with?('http') ? url : "https://#{url}"
101
+ end
102
+
79
103
  def same_scope?(url, response)
80
- url = "https://#{url}" unless url.start_with?('http')
104
+ url = normalize_url(url)
105
+
106
+ base_host = Utilities::Urls.uri_parse(url)&.host
107
+ response_host = Utilities::Urls.uri_parse(response&.effective_url)&.host
81
108
 
82
- Utilities::Urls.uri_parse(url)&.host == Utilities::Urls.uri_parse(response&.effective_url)&.host
109
+ base_host == response_host || 'www.' + base_host == response_host
83
110
  end
84
111
 
85
112
  def stream_error?(response)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fingerprinter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua MARTINELLE
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-11 00:00:00.000000000 Z
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -68,6 +68,7 @@ files:
68
68
  - lib/fingerprinter/technologies/softwares/apache_ofbiz.rb
69
69
  - lib/fingerprinter/technologies/softwares/f5_next_central_manager.rb
70
70
  - lib/fingerprinter/technologies/softwares/nexus_repository.rb
71
+ - lib/fingerprinter/technologies/softwares/servicenow.rb
71
72
  - lib/fingerprinter/technologies/softwares/tinyproxy.rb
72
73
  - lib/fingerprinter/utilities/kb.rb
73
74
  - lib/fingerprinter/utilities/parser.rb