Przeglądaj źródła

Use official SSLLabs API to fetch user-agent support

master
Aeris 3 lat temu
rodzic
commit
9c93fbf5e2
3 zmienionych plików z 5138 dodań i 1872 usunięć
  1. 0
    33
      bin/fetch_ssllabs_useragent
  2. 19
    0
      bin/fetch_ssllabs_useragents
  3. 5119
    1839
      config/user-agents-ciphers.json

+ 0
- 33
bin/fetch_ssllabs_useragent Wyświetl plik

@@ -1,33 +0,0 @@
1
-#!/usr/bin/env ruby
2
-require 'httparty'
3
-require 'nokogiri'
4
-require 'nokogiri-pretty'
5
-require 'open-uri'
6
-
7
-uas = Nokogiri::HTML open 'https://www.ssllabs.com/ssltest/clients.html'
8
-uas = Hash[uas.css('#multiTable > tr > td:first > a').collect do |ua|
9
-	ua_url = ua.attr :href
10
-	ua = Nokogiri::HTML open "https://www.ssllabs.com/ssltest/#{ua_url}"
11
-
12
-	name = ua.at_css('h1').text.sub('User Agent Capabilities:', '').strip
13
-	puts name
14
-
15
-	reports = ua.css '.reportTable'
16
-	protocols = Hash[reports[0].css('tr').collect do |protocol|
17
-		protocol, support = protocol.css 'td'
18
-		next if protocol.attr(:class) == 'tableHead'
19
-		protocol = protocol.text.sub("\xC2\xA0 INSECURE", '').strip
20
-		support = support.text == 'Yes'
21
-		[protocol, support]
22
-	end.reject &:nil?]
23
-
24
-	ciphers = Hash[reports[1].css('tr').collect do |cipher|
25
-		cipher, size = cipher.css 'td'
26
-		next if cipher.attr(:class) == 'tableHead' or size.nil?
27
-		cipher = /(.*) \(0x(.*)\).*/.match cipher.text
28
-		cipher = ["0x#{cipher[2].upcase.rjust(2, '0')}", cipher[1]]
29
-	end.reject &:nil?]
30
-
31
-	[name, { protocols: protocols, ciphers: ciphers }]
32
-end]
33
-File.write 'config/user-agent.json', JSON.pretty_generate(uas, {indent: "\t"})

+ 19
- 0
bin/fetch_ssllabs_useragents Wyświetl plik

@@ -0,0 +1,19 @@
1
+#!/usr/bin/env ruby
2
+require 'open-uri'
3
+require 'json'
4
+
5
+PROTOCOLS = {
6
+	768 => 'SSL 3',
7
+	769 => 'TLS 1.0',
8
+	770 => 'TLS 1.1',
9
+	771 => 'TLS 1.2'
10
+}
11
+
12
+uas = JSON.load open 'https://api.dev.ssllabs.com/api/v3/getClients'
13
+uas = uas.collect do |ua|
14
+	name = [ua['name'], ua['version'], ua['platform']].compact.join ' '
15
+	protocols = ua['lowestProtocol'].upto(ua['highestProtocol']).collect { |n| PROTOCOLS[n] }
16
+	ciphers = ua['suiteIds'].zip(ua['suiteNames']).collect { |i, n| ["0x#{i.to_s(16).upcase.rjust(2, '0')}", n]}.to_h
17
+	[name, { protocols: protocols, ciphers: ciphers }]
18
+end
19
+File.write 'config/user-agents-ciphers.json', JSON.pretty_generate(uas, {indent: "\t"})

+ 5119
- 1839
config/user-agents-ciphers.json
Plik diff jest za duży
Wyświetl plik


Ładowanie…
Anuluj
Zapisz