Class: Yawast::Scanner::SslLabs

Inherits:
Object
  • Object
show all
Defined in:
lib/scanner/ssl_labs.rb

Class Method Summary collapse

Class Method Details

.cipher_suite_secure?(suite) ⇒ Boolean

Returns:

  • (Boolean)


1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
# File 'lib/scanner/ssl_labs.rb', line 1089

def self.cipher_suite_secure?(suite)
  secure = true

  # check for weak DH
  secure = false if !suite['kxStrength'].nil? && suite['kxStrength'] < 2048
  # check for RC4
  secure = false if suite['name'].include? 'RC4'
  # check for weak suites
  secure = false if suite['cipherStrength'] < 112

  secure
end

.get_cert_info(ep, body) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/scanner/ssl_labs.rb', line 103

def self.get_cert_info (ep, body)
  # get the ChainCert info for the server cert - needed for extra details
  cert = nil
  ossl_cert = nil
  body['certs'].each do |c|
    if c['id'] == ep['details']['certChains'][0]['certIds'][0]
      cert = c
      ossl_cert = OpenSSL::X509::Certificate.new cert['raw']
    end
  end

  puts "\tCertificate Information:"
  unless cert['issues'].zero?
    Yawast::Utilities.puts_vuln "\t\tCertificate Has Issues - Not Valid"

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: no chain of trust" if cert['issues'] & 1 != 0

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: certificate not yet valid" if cert['issues'] & (1 << 1) != 0

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: certificate expired" if cert['issues'] & (1 << 2) != 0

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: hostname mismatch" if cert['issues'] & (1 << 3) != 0

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: revoked" if cert['issues'] & (1 << 4) != 0

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: bad common name" if cert['issues'] & (1 << 5) != 0

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: self-signed" if cert['issues'] & (1 << 6) != 0

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: blacklisted" if cert['issues'] & (1 << 7) != 0

    Yawast::Utilities.puts_vuln "\t\tCertificate Issue: insecure signature" if cert['issues'] & (1 << 8) != 0
  end

  Yawast::Utilities.puts_info "\t\tSubject: #{cert['subject']}"
  Yawast::Utilities.puts_info "\t\tCommon Names: #{cert['commonNames'].join(' ')}"

  Yawast::Utilities.puts_info "\t\tAlternative names:"
  cert['altNames'].each do |name|
    Yawast::Utilities.puts_info "\t\t\t#{name}"
  end

  # here we divide the time by 1000 to strip the fractions of a second off.
  Yawast::Utilities.puts_info "\t\tNot Before: #{Time.at(cert['notBefore'] / 1000).utc.to_datetime}"
  Yawast::Utilities.puts_info "\t\tNot After: #{Time.at(cert['notAfter'] / 1000).utc.to_datetime}"

  if cert['keyAlg'] == 'EC'
    Yawast::Utilities.puts_info "\t\tKey: #{cert['keyAlg']} #{cert['keySize']} (RSA equivalent: #{cert['keyStrength']})"
  else
    if cert['keySize'] < 2048
      Yawast::Utilities.puts_vuln "\t\tKey: #{cert['keyAlg']} #{cert['keySize']}"
    else
      Yawast::Utilities.puts_info "\t\tKey: #{cert['keyAlg']} #{cert['keySize']}"
    end
  end

  Yawast::Utilities.puts_info "\t\tPublic Key Hash: #{Digest::SHA1.hexdigest(ossl_cert.public_key.to_s)}"

  Yawast::Utilities.puts_info "\t\tVersion: #{ossl_cert.version}"

  serial = format('%02x', ossl_cert.serial.to_i)
  serial = "0#{serial}" unless serial.length.even?
  Yawast::Utilities.puts_info "\t\tSerial: #{serial}"

  ## if the serial is exactly 16 hex digits, it may have an entropy issue.
  if serial.length == 16
    puts

    Yawast::Utilities.puts_warn "\t\tSerial number is exactly 64 bits. Serial may not comply with CA/B Forum requirements."
    Yawast::Utilities.puts_raw "\t\t\t See https://adamcaudill.com/2019/03/09/tls-64bit-ish-serial-numbers-mass-revocation/ for details."

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_serial_exactly_64_bits',
                                    {vulnerable: true, length: (serial.length / 2) * 8}

    puts
  elsif serial.length < 16
    puts

    Yawast::Utilities.puts_vuln "\t\tSerial number is less than 64 bits. Serial does not comply with CA/B Forum requirements."

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_serial_less_than_64_bits',
                                    {vulnerable: true, length: (serial.length / 2) * 8}

    puts
  else
    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_serial_exactly_64_bits',
                                    {vulnerable: false, length: (serial.length / 2) * 8}
    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_serial_less_than_64_bits',
                                    {vulnerable: false, length: (serial.length / 2) * 8}
  end

  Yawast::Utilities.puts_info "\t\tIssuer: #{cert['issuerSubject']}"

  if cert['sigAlg'].include?('SHA1') || cert['sigAlg'].include?('MD5')
    Yawast::Utilities.puts_vuln "\t\tSignature algorithm: #{cert['sigAlg']}"
    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_weak_sig_alg',
                                    {vulnerable: true, algorithm: cert['sigAlg']}
  else
    Yawast::Utilities.puts_info "\t\tSignature algorithm: #{cert['sigAlg']}"
    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_weak_sig_alg',
                                    {vulnerable: false, algorithm: cert['sigAlg']}
  end

  # TODO: figure out what the options for this value are
  if cert['validationType'] == 'E'
    Yawast::Utilities.puts_info "\t\tExtended Validation: Yes"
  elsif cert['validationType'] == 'D'
    Yawast::Utilities.puts_info "\t\tExtended Validation: No (Domain Control)"
  else
    Yawast::Utilities.puts_info "\t\tExtended Validation: No"
  end

  if cert['sct']
    # check the first bit, SCT in cert
    if ep['details']['hasSct'] & 1 != 0
      Yawast::Utilities.puts_info "\t\tCertificate Transparency: SCT in certificate"
    end

    # check second bit, SCT in stapled OSCP response
    if ep['details']['hasSct'] & (1 << 1) != 0
      Yawast::Utilities.puts_info "\t\tCertificate Transparency: SCT in the stapled OCSP response"
    end

    # check third bit, SCT in the TLS extension
    if ep['details']['hasSct'] & (1 << 2) != 0
      Yawast::Utilities.puts_info "\t\tCertificate Transparency: SCT in the TLS extension (ServerHello)"
    end
  else
    Yawast::Utilities.puts_info "\t\tCertificate Transparency: No"
  end

  Yawast::Utilities.puts_info "\t\tOCSP Must Staple: #{cert['mustStaple']}"

  if cert['revocationInfo'] & 1 != 0
    Yawast::Utilities.puts_info "\t\tRevocation information: CRL information available"
  end
  if cert['revocationInfo'] & (1 << 1) != 0
    Yawast::Utilities.puts_info "\t\tRevocation information: OCSP information available"
  end

  case cert['revocationStatus']
    when 0
      Yawast::Utilities.puts_info "\t\tRevocation status: not checked"
    when 1
      Yawast::Utilities.puts_vuln "\t\tRevocation status: certificate revoked"
    when 2
      Yawast::Utilities.puts_info "\t\tRevocation status: certificate not revoked"
    when 3
      Yawast::Utilities.puts_error "\t\tRevocation status: revocation check error"
    when 4
      Yawast::Utilities.puts_info "\t\tRevocation status: no revocation information"
    when 5
      Yawast::Utilities.puts_error "\t\tRevocation status: SSL Labs internal error"
    else
      Yawast::Utilities.puts_error "\t\tRevocation status: Unknown response #{cert['revocationStatus']}"
  end

  Yawast::Utilities.puts_info "\t\tExtensions:"
  ossl_cert.extensions.each { |ext| Yawast::Utilities.puts_info "\t\t\t#{ext}" unless ext.oid == 'subjectAltName' || ext.oid == 'ct_precert_scts' }

  # ct_precert_scts
  Yawast::Scanner::Plugins::SSL::SSL.print_precert ossl_cert

  Yawast::Scanner::Plugins::SSL::SSL.print_cert_hash ossl_cert

  puts
  Yawast::Utilities.puts_info "\t\tCertificate Chains:"
  ep['details']['certChains'].each do |chain|
    path_count = 0

    # build list of trust paths
    trust_paths = {}
    chain['trustPaths'].each do |path|
      trusts = nil
      # in practice, it seems there is only only per path, but just in case
      path['trust'].each do |trust|
        trust_line = if trust['isTrusted']
                       "#{trust['rootStore']} (trusted)"
                     else
                       "#{trust['rootStore']} (#{trust['trustErrorMessage']})"
                     end

        if trusts.nil?
          trusts = trust_line
        else
          trusts += " #{trust_line}"
        end
      end

      # build the hash and add the list of roots
      if trust_paths.has_key? path['certIds']
        trust_paths[path['certIds']] += " #{trusts}"
      else
        trust_paths[path['certIds']] = trusts
      end
    end

    # process each of the trust paths
    trust_paths.each_key do |key|
      path_count += 1
      puts "\t\t  Path #{path_count}:"
      puts "\t\t   Root Stores: #{trust_paths[key]}"

      # cert chain issues
      if chain['issues'] & (1 << 1) != 0
        Yawast::Utilities.puts_warn "\t\tCertificate Chain Issue: incomplete chain"
        Yawast::Shared::Output.log_hash 'vulnerabilities',
                                        'tls_chain_incomplete',
                                        {vulnerable: true}
      else
        Yawast::Shared::Output.log_hash 'vulnerabilities',
                                        'tls_chain_incomplete',
                                        {vulnerable: false}
      end

      if chain['issues'] & (1 << 2) != 0
        Yawast::Utilities.puts_warn "\t\tCertificate Chain Issue: chain contains unrelated/duplicate certificates"
      end

      Yawast::Utilities.puts_warn "\t\tCertificate Chain Issue: incorrect order" if chain['issues'] & (1 << 3) != 0

      Yawast::Utilities.puts_warn "\t\tCertificate Chain Issue: contains anchor" if chain['issues'] & (1 << 4) != 0

      Yawast::Utilities.puts_warn "\t\tCertificate Chain Issue: untrusted" if cert['issues'] & (1 << 5) != 0

      # setup the log entry for a symantec root - this will overwrite if one is found
      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_symantec_root',
                                      {vulnerable: false, root_hash: ''}

      key.each do |path_cert|
        body['certs'].each do |c|
          if c['id'] == path_cert
            Yawast::Utilities.puts_info "\t\t\t#{c['subject']}"
            Yawast::Utilities.puts_info "\t\t\t  Signature: #{c['sigAlg']}  Key: #{c['keyAlg']}-#{c['keySize']}"

            if Yawast::Scanner::Plugins::SSL::SSL.check_symantec_root(c['sha256Hash'])
              Yawast::Utilities.puts_vuln "\t\t\t  Untrusted Symantec Root"
              Yawast::Shared::Output.log_hash 'vulnerabilities',
                                              'tls_symantec_root',
                                              {vulnerable: true, :root_hash => c['sha256Hash']}
            end

            Yawast::Utilities.puts_info "\t\t\t  https://crt.sh/?q=#{c['sha1Hash']}"

            unless chain['certIds'].find_index(c['sha256Hash']).nil?
              Yawast::Utilities.puts_info "\t\t\t  (provided by server)"
            end

            puts
          end
        end
      end
    end
  end

  puts
end

.get_config_info(ep) ⇒ Object



368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/scanner/ssl_labs.rb', line 368

def self.get_config_info(ep)
  puts "\tConfiguration Information:"

  puts "\t\tProtocol Support:"
  # setup JSON output
  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_legacy_ssl',
                                  {vulnerable: false}
  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_tls10_enabled',
                                  {vulnerable: false}
  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_tls13_not_enabled',
                                  {vulnerable: true}

  # check protocols
  protos = {}
  tls13_enabled = false
  ep['details']['protocols'].each do |proto|
    if proto['name'] == 'SSL'
      # show a vuln for SSLvX
      Yawast::Utilities.puts_vuln "\t\t\t#{proto['name']} #{proto['version']}"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_legacy_ssl',
                                      {vulnerable: true}
    elsif proto['name'] == 'TLS' &&  proto['version'] == '1.0'
      # show a warn for TLSv1.0
      Yawast::Utilities.puts_warn "\t\t\t#{proto['name']} #{proto['version']}"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_tls10_enabled',
                                      {vulnerable: true}
    elsif proto['name'] == 'TLS' &&  proto['version'] == '1.3'
      # capture TLS 1.3 status
      tls13_enabled = true
      Yawast::Utilities.puts_info "\t\t\t#{proto['name']} #{proto['version']}"
      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_tls13_not_enabled',
                                      {vulnerable: false}
    else
      Yawast::Utilities.puts_info "\t\t\t#{proto['name']} #{proto['version']}"
    end

    protos[proto['id']] = "#{proto['name']} #{proto['version']}"
  end

  Yawast::Utilities.puts_warn "\t\t\tTLS 1.3 Is Not Enabled" unless tls13_enabled
  puts

  puts "\t\tNamed Group Support:"
  unless ep['details']['namedGroups'].nil?
    ep['details']['namedGroups']['list'].each do |group|
      Yawast::Utilities.puts_info "\t\t\t#{group['name']} #{group['bits']}"
    end
    puts
  end

  puts "\t\tCipher Suite Support:"
  # setup JSON output
  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_insecure_cipher_suites',
                                  {vulnerable: false}
  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_weak_cipher_suites',
                                  {vulnerable: false}
  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_3des_enabled',
                                  {vulnerable: false, suite: ''}
  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_rc4_enabled',
                                  {vulnerable: false, suite: ''}

  if !ep['details']['suites'].nil?
    ep['details']['suites'].each do |proto_suites|
      Yawast::Utilities.puts_info "\t\t\t#{protos[proto_suites['protocol']]}"

      proto_suites['list'].each do |suite|
        ke = get_key_exchange suite

        strength = suite['cipherStrength']
        if suite['name'].include? '3DES'
          # in this case, the effective strength is only 112 bits,
          #  which is what we want to report. So override SSL Labs
          strength = 112

          Yawast::Shared::Output.log_hash 'vulnerabilities',
                                          'tls_3des_enabled',
                                          {vulnerable: true, suite: suite['name']}
        end

        if suite['name'].include? 'RC4'
          Yawast::Shared::Output.log_hash 'vulnerabilities',
                                          'tls_rc4_enabled',
                                          {vulnerable: true, suite: suite['name']}
        end

        suite_info = if !ke.nil?
                       "#{suite['name'].ljust(50)} - #{strength}-bits - #{ke}"
                     else
                       "#{suite['name'].ljust(50)} - #{strength}-bits"
                     end

        if cipher_suite_secure? suite
          if strength >= 128
            Yawast::Utilities.puts_info "\t\t\t  #{suite_info}"
          else
            Yawast::Utilities.puts_warn "\t\t\t  #{suite_info}"

            Yawast::Shared::Output.log_hash 'vulnerabilities',
                                            'tls_weak_cipher_suites',
                                            {vulnerable: true}
          end
        else
          Yawast::Utilities.puts_vuln "\t\t\t  #{suite_info}"

          Yawast::Shared::Output.log_hash 'vulnerabilities',
                                          'tls_insecure_cipher_suites',
                                          {vulnerable: true}
        end
      end
    end
  else
    Yawast::Utilities.puts_error "\t\t\t  Information Not Available"
  end

  puts

  puts "\t\tHandshake Simulation:"
  if !ep['details']['sims']['results'].nil?
    ep['details']['sims']['results'].each do |sim|
      name = "#{sim['client']['name']} #{sim['client']['version']}"
      name += " / #{sim['client']['platform']}" unless sim['client']['platform'].nil?
      name = name.ljust(28)

      if sim['errorCode'].zero?
        protocol = protos[sim['protocolId']]

        ke = get_key_exchange sim

        suite_name = "#{sim['suiteName']} - #{ke}"

        Yawast::Utilities.puts_info "\t\t\t#{name} - #{protocol} - #{suite_name}"
      else
        Yawast::Utilities.puts_warn"\t\t\t#{name} - Simulation Failed"
      end
    end
  else
    Yawast::Utilities.puts_error "\t\t\tInformation Not Available"
  end

  puts
end

.get_key_exchange(suite) ⇒ Object



1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
# File 'lib/scanner/ssl_labs.rb', line 1102

def self.get_key_exchange(suite)
  ke = nil
  unless suite['kxType'].nil?
    ke = if !suite['namedGroupBits'].nil?
           "#{suite['kxType']}-#{suite['namedGroupBits']} / #{suite['namedGroupName']} (#{suite['kxStrength']} equivalent)"
         else
           "#{suite['kxType']}-#{suite['kxStrength']}"
         end
  end

  ke
end

.get_proto_info(ep) ⇒ Object



522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
# File 'lib/scanner/ssl_labs.rb', line 522

def self.get_proto_info(ep)
  puts "\t\tProtocol & Vulnerability Information:"

  if ep['details']['drownVulnerable']
    Yawast::Utilities.puts_vuln "\t\t\tDROWN: Vulnerable"

    ep['details']['drownHosts'].each do |dh|
      Yawast::Utilities.puts_vuln "\t\t\t\t#{dh['ip']}:#{dh['port']} - #{dh['status']}"
      puts "\t\t\t\thttps://test.drownattack.com/?site=#{dh['ip']}"
    end

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_drown',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tDROWN: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_drown',
                                    {vulnerable: false}
  end

  unless ep['details']['zeroRTTEnabled'].nil?
    case ep['details']['zeroRTTEnabled']
      when -2
        Yawast::Utilities.puts_error "\t\t\tTLS 1.3 0-RTT Support: Test Failed"
      when -1
        Yawast::Utilities.puts_info "\t\t\tTLS 1.3 0-RTT Support: Test Not Performed"
      when 0
        Yawast::Utilities.puts_info "\t\t\tTLS 1.3 0-RTT Support: No"
      when 1
        Yawast::Utilities.puts_warn "\t\t\tTLS 1.3 0-RTT Support: Yes"
      else
        Yawast::Utilities.puts_error "\t\t\tTLS 1.3 0-RTT Support: Unknown Response #{ep['details']['zeroRTTEnabled']}"
    end
  end

  unless ep['details']['renegSupport'].nil?
    if ep['details']['renegSupport'] & 1 != 0
      Yawast::Utilities.puts_vuln "\t\t\tSecure Renegotiation: insecure client-initiated renegotiation supported"
    end
    if ep['details']['renegSupport'] & (1 << 1) != 0
      Yawast::Utilities.puts_info "\t\t\tSecure Renegotiation: secure renegotiation supported"
    end
    if ep['details']['renegSupport'] & (1 << 2) != 0
      Yawast::Utilities.puts_info "\t\t\tSecure Renegotiation: secure client-initiated renegotiation supported"
    end
    if ep['details']['renegSupport'] & (1 << 3) != 0
      Yawast::Utilities.puts_info "\t\t\tSecure Renegotiation: server requires secure renegotiation support"
    end
  end

  if ep['details']['poodle']
    Yawast::Utilities.puts_vuln "\t\t\tPOODLE (SSL): Vulnerable"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_poodle_ssl',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tPOODLE (SSL): No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_poodle_ssl',
                                    {vulnerable: false}
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_zombie_poodle',
                                  {vulnerable: false, exploitable: false}
  case ep['details']['zombiePoodle']
    when -1
      Yawast::Utilities.puts_error "\t\t\tZombie POODLE: Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tZombie POODLE: Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tZombie POODLE: No"
    when 2
      Yawast::Utilities.puts_warn "\t\t\tZombie POODLE: Vulnerable - Not Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_zombie_poodle',
                                      {vulnerable: true, exploitable: false}
    when 3
      Yawast::Utilities.puts_vuln "\t\t\tZombie POODLE: Vulnerable - Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_zombie_poodle',
                                      {vulnerable: true, exploitable: true}
    when nil
      # do nothing, this means they aren't sending the result
    else
      Yawast::Utilities.puts_error "\t\t\tZombie POODLE: Unknown Response #{ep['details']['zombiePoodle']}"
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_goldendoodle',
                                  {vulnerable: false, exploitable: false}
  case ep['details']['goldenDoodle']
    when -1
      Yawast::Utilities.puts_error "\t\t\tGOLDENDOODLE: Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tGOLDENDOODLE: Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tGOLDENDOODLE: No"
    when 4
      Yawast::Utilities.puts_warn "\t\t\tGOLDENDOODLE: Vulnerable - Not Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_goldendoodle',
                                      {vulnerable: true, exploitable: false}
    when 5
      Yawast::Utilities.puts_vuln "\t\t\tGOLDENDOODLE: Vulnerable - Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_goldendoodle',
                                      {vulnerable: true, exploitable: true}
    when nil
      # do nothing, this means they aren't sending the result
    else
      Yawast::Utilities.puts_error "\t\t\tGOLDENDOODLE: Unknown Response #{ep['details']['goldenDoodle']}"
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_openssl_cve_2019_1559',
                                  {vulnerable: false, exploitable: false}
  case ep['details']['zeroLengthPaddingOracle']
    when -1
      Yawast::Utilities.puts_error "\t\t\tOpenSSL 0-Length Padding Oracle (CVE-2019-1559): Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tOpenSSL 0-Length Padding Oracle (CVE-2019-1559): Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tOpenSSL 0-Length Padding Oracle (CVE-2019-1559): No"
    when 6
      Yawast::Utilities.puts_warn "\t\t\tOpenSSL 0-Length Padding Oracle (CVE-2019-1559): Vulnerable - Not Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_openssl_cve_2019_1559',
                                      {vulnerable: true, exploitable: false}
    when 7
      Yawast::Utilities.puts_vuln "\t\t\tOpenSSL 0-Length Padding Oracle (CVE-2019-1559): Vulnerable - Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_openssl_cve_2019_1559',
                                      {vulnerable: true, exploitable: true}
    when nil
      # do nothing, this means they aren't sending the result
    else
      Yawast::Utilities.puts_error "\t\t\tOpenSSL 0-Length Padding Oracle (CVE-2019-1559): Unknown Response #{ep['details']['zeroLengthPaddingOracle']}"
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_goldendoodle',
                                  {vulnerable: false, exploitable: false}
  case ep['details']['sleepingPoodle']
    when -1
      Yawast::Utilities.puts_error "\t\t\tSleeping POODLE: Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tSleeping POODLE: Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tSleeping POODLE: No"
    when 10
      Yawast::Utilities.puts_warn "\t\t\tSleeping POODLE: Vulnerable - Not Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_sleeping_poodle',
                                      {vulnerable: true, exploitable: false}
    when 11
      Yawast::Utilities.puts_vuln "\t\t\tSleeping POODLE: Vulnerable - Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_sleeping_poodle',
                                      {vulnerable: true, exploitable: true}
    when nil
      # do nothing, this means they aren't sending the result
    else
      Yawast::Utilities.puts_error "\t\t\tSleeping POODLE: Unknown Response #{ep['details']['sleepingPoodle']}"
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_poodle',
                                  {vulnerable: false}
  case ep['details']['poodleTls']
    when -3
      Yawast::Utilities.puts_info "\t\t\tPOODLE (TLS): Inconclusive (Timeout)"
    when -2
      Yawast::Utilities.puts_info "\t\t\tPOODLE (TLS): TLS Not Supported"
    when -1
      Yawast::Utilities.puts_error "\t\t\tPOODLE (TLS): Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tPOODLE (TLS): Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tPOODLE (TLS): No"
    when 2
      Yawast::Utilities.puts_vuln "\t\t\tPOODLE (TLS): Vulnerable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_poodle',
                                      {vulnerable: true}
    when nil
    # do nothing, this means they aren't sending the result
    else
      Yawast::Utilities.puts_error "\t\t\tPOODLE (TLS): Unknown Response #{ep['details']['poodleTls']}"
  end

  if ep['details']['fallbackScsv']
    Yawast::Utilities.puts_info "\t\t\tDowngrade Prevention: Yes"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_missing_fallback_scsv',
                                    {vulnerable: false}
  else
    Yawast::Utilities.puts_warn "\t\t\tDowngrade Prevention: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_missing_fallback_scsv',
                                    {vulnerable: true}
  end

  if ep['details']['compressionMethods'] & 1 != 0
    Yawast::Utilities.puts_warn "\t\t\tCompression: DEFLATE"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_compression_enabled',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tCompression: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_compression_enabled',
                                    {vulnerable: false}
  end

  if ep['details']['heartbeat']
    Yawast::Utilities.puts_warn "\t\t\tHeartbeat: Enabled"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_heartbeat_enabled',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tHeartbeat: Disabled"
    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_heartbeat_enabled',
                                    {vulnerable: false}
  end

  if ep['details']['heartbleed']
    Yawast::Utilities.puts_vuln "\t\t\tHeartbleed: Vulnerable"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_heartblead',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tHeartbleed: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_heartblead',
                                    {vulnerable: false}
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_ticketbleed',
                                  {vulnerable: false}
  case ep['details']['ticketbleed']
    when -1
      Yawast::Utilities.puts_error "\t\t\tTicketbleed (CVE-2016-9244): Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tTicketbleed (CVE-2016-9244): Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tTicketbleed (CVE-2016-9244): No"
    when 2
      Yawast::Utilities.puts_vuln "\t\t\tTicketbleed (CVE-2016-9244): Vulnerable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_ticketbleed',
                                      {vulnerable: true}
    else
      Yawast::Utilities.puts_error "\t\t\tTicketbleed (CVE-2016-9244): Unknown Response #{ep['details']['ticketbleed']}"
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_openssl_ccs_cve20140224',
                                  {vulnerable: false, exploitable: false}
  case ep['details']['openSslCcs']
    when -1
      Yawast::Utilities.puts_error "\t\t\tOpenSSL CCS (CVE-2014-0224): Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tOpenSSL CCS (CVE-2014-0224): Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tOpenSSL CCS (CVE-2014-0224): No"
    when 2
      Yawast::Utilities.puts_vuln "\t\t\tOpenSSL CCS (CVE-2014-0224): Vulnerable - Not Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_openssl_ccs_cve20140224',
                                      {vulnerable: true, exploitable: false}
    when 3
      Yawast::Utilities.puts_vuln "\t\t\tOpenSSL CCS (CVE-2014-0224): Vulnerable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_openssl_ccs_cve20140224',
                                      {vulnerable: true, exploitable: true}
    else
      Yawast::Utilities.puts_error "\t\t\tOpenSSL CCS (CVE-2014-0224): Unknown Response #{ep['details']['openSslCcs']}"
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_openssl_lunckyminus20',
                                  {vulnerable: false}

  case ep['details']['openSSLLuckyMinus20']
    when -1
      Yawast::Utilities.puts_error "\t\t\tOpenSSL Padding Oracle (CVE-2016-2107): Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tOpenSSL Padding Oracle (CVE-2016-2107): Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tOpenSSL Padding Oracle (CVE-2016-2107): No"
    when 2
      Yawast::Utilities.puts_vuln "\t\t\tOpenSSL Padding Oracle (CVE-2016-2107): Vulnerable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_openssl_lunckyminus20',
                                      {vulnerable: true}
    else
      Yawast::Utilities.puts_error "\t\t\tOpenSSL Padding Oracle (CVE-2016-2107): Unknown Response #{ep['details']['openSSLLuckyMinus20']}"
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_robot',
                                  {vulnerable: false, exploitable: false}
  case ep['details']['bleichenbacher']
    when -1
      Yawast::Utilities.puts_error "\t\t\tROBOT: Test Failed"
    when 0
      Yawast::Utilities.puts_error "\t\t\tROBOT: Test Failed (Unknown)"
    when 1
      Yawast::Utilities.puts_info "\t\t\tROBOT: No"
    when 2
      Yawast::Utilities.puts_warn "\t\t\tROBOT: Not Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_robot',
                                      {vulnerable: true, exploitable: false}
    when 3
      Yawast::Utilities.puts_vuln "\t\t\tROBOT: Exploitable"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_robot',
                                      {vulnerable: true, exploitable: true}
    when nil
      # if it's null, we don't care
    else
      Yawast::Utilities.puts_error "\t\t\tROBOT: Unknown Response #{ep['details']['bleichenbacher']}"
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_missing_forward_secrecy',
                                  {vulnerable: false}

  if ep['details']['forwardSecrecy'] & (1 << 2) != 0
    Yawast::Utilities.puts_info "\t\t\tForward Secrecy: Yes (all simulated clients)"
  elsif ep['details']['forwardSecrecy'] & (1 << 1) != 0
    Yawast::Utilities.puts_info "\t\t\tForward Secrecy: Yes (modern clients)"
  elsif ep['details']['forwardSecrecy'] & 1 != 0
    Yawast::Utilities.puts_warn "\t\t\tForward Secrecy: Yes (limited support)"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_missing_forward_secrecy',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_vuln "\t\t\tForward Secrecy: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_missing_forward_secrecy',
                                    {vulnerable: true}
  end

  if ep['details']['supportsAead']
    Yawast::Utilities.puts_info "\t\t\tAEAD Cipher Suites Supported: Yes"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_aead_support_missing',
                                    {vulnerable: false}
  else
    Yawast::Utilities.puts_warn "\t\t\tAEAD Cipher Suites Supported: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_aead_support_missing',
                                    {vulnerable: true}
  end

  if ep['details']['supportsCBC']
    Yawast::Utilities.puts_warn "\t\t\tCBC Cipher Suites Supported: Yes"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_cbc_support',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tCBC Cipher Suites Supported: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_cbc_support',
                                    {vulnerable: false}
  end

  Yawast::Utilities.puts_info "\t\t\tALPN: #{ep['details']['alpnProtocols']}"

  Yawast::Utilities.puts_info "\t\t\tNPN: #{ep['details']['npnProtocols']}"

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_session_resumption',
                                  {vulnerable: false}

  case ep['details']['sessionResumption']
    when 0
      Yawast::Utilities.puts_info "\t\t\tSession Resumption: Not Enabled / Empty Tickets"
    when 1
      Yawast::Utilities.puts_info "\t\t\tSession Resumption: Enabled / No Resumption"
    when 2
      Yawast::Utilities.puts_warn "\t\t\tSession Resumption: Enabled"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_session_resumption',
                                      {vulnerable: true}
    else
      Yawast::Utilities.puts_error "\t\t\tSession Resumption: Unknown Response #{ep['details']['sessionResumption']}"
  end

  if ep['details']['ocspStapling']
    Yawast::Utilities.puts_info "\t\t\tOCSP Stapling: Yes"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_ocsp_stapling_missing',
                                    {vulnerable: false}
  else
    Yawast::Utilities.puts_warn "\t\t\tOCSP Stapling: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_ocsp_stapling_missing',
                                    {vulnerable: true}
  end

  if ep['details']['miscIntolerance'].positive?
    if ep['details']['miscIntolerance'] & 1 != 0
      Yawast::Utilities.puts_warn "\t\t\tTLS Extension Intolerance: Yes"
    end

    if ep['details']['miscIntolerance'] & (1 << 1) != 0
      Yawast::Utilities.puts_warn "\t\t\tLong Handshake Intolerance: Yes"
    end

    if ep['details']['miscIntolerance'] & (1 << 2) != 0
      Yawast::Utilities.puts_warn "\t\t\tLong Handshake Intolerance: Workaround Success"
    end
  end

  if ep['details']['protocolIntolerance'].positive?
    if ep['details']['protocolIntolerance'] & 1 != 0
      Yawast::Utilities.puts_warn "\t\t\tProtocol Intolerance: TLS 1.0"
    end

    if ep['details']['protocolIntolerance'] & (1 << 1) != 0
      Yawast::Utilities.puts_warn "\t\t\tProtocol Intolerance: TLS 1.1"
    end

    if ep['details']['protocolIntolerance'] & (1 << 2) != 0
      Yawast::Utilities.puts_warn "\t\t\tProtocol Intolerance: TLS 1.2"
    end

    if ep['details']['protocolIntolerance'] & (1 << 3) != 0
      Yawast::Utilities.puts_warn "\t\t\tProtocol Intolerance: TLS 1.3"
    end

    if ep['details']['protocolIntolerance'] & (1 << 4) != 0
      Yawast::Utilities.puts_warn "\t\t\tProtocol Intolerance: TLS 1.152"
    end

    if ep['details']['protocolIntolerance'] & (1 << 5) != 0
      Yawast::Utilities.puts_warn "\t\t\tProtocol Intolerance: TLS 2.152"
    end
  else
    Yawast::Utilities.puts_info "\t\t\tProtocol Intolerance: No"
  end

  if ep['details']['freak']
    Yawast::Utilities.puts_vuln "\t\t\tFREAK: Vulnerable (512-bit key exchange supported)"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_freak',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tFREAK: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_freak',
                                    {vulnerable: false}
  end

  if ep['details']['logjam']
    Yawast::Utilities.puts_vuln "\t\t\tLogjam: Vulnerable (DH key exchange with keys smaller than 1024 bits)"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_logjam',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tLogjam: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_logjam',
                                    {vulnerable: false}
  end

  Yawast::Shared::Output.log_hash 'vulnerabilities',
                                  'tls_dh_known_primes',
                                  {vulnerable: false, weak: false}

  case ep['details']['dhUsesKnownPrimes']
    when 0
      Yawast::Utilities.puts_info "\t\t\tUses common DH primes: No"
    when 1
      Yawast::Utilities.puts_warn "\t\t\tUses common DH primes: Yes (not weak)"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_dh_known_primes',
                                      {vulnerable: true, weak: false}
    when 2
      Yawast::Utilities.puts_vuln "\t\t\tUses common DH primes: Yes (weak)"

      Yawast::Shared::Output.log_hash 'vulnerabilities',
                                      'tls_dh_known_primes',
                                      {vulnerable: true, weak: true}
    else
      unless ep['details']['dhUsesKnownPrimes'].nil?
        Yawast::Utilities.puts_error "\t\t\tUses common DH primes: Unknown Response #{ep['details']['dhUsesKnownPrimes']}"
      end
  end

  if ep['details']['dhYsReuse']
    Yawast::Utilities.puts_vuln "\t\t\tDH public server param (Ys) reuse: Yes"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_dh_public_server_param_reuse',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tDH public server param (Ys) reuse: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_dh_public_server_param_reuse',
                                    {vulnerable: false}
  end

  if ep['details']['ecdhParameterReuse']
    Yawast::Utilities.puts_vuln "\t\t\tECDH Public Server Param Reuse: Yes"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_ecdh_public_server_param_reuse',
                                    {vulnerable: true}
  else
    Yawast::Utilities.puts_info "\t\t\tECDH Public Server Param Reuse: No"

    Yawast::Shared::Output.log_hash 'vulnerabilities',
                                    'tls_ecdh_public_server_param_reuse',
                                    {vulnerable: false}
  end

  puts
end

.info(uri, tdes_session_count) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/scanner/ssl_labs.rb', line 11

def self.info(uri, tdes_session_count)
  puts 'Beginning SSL Labs scan (this could take a minute or two)'

  begin
    endpoint = URI::DEFAULT_PARSER.parse 'https://api.ssllabs.com'

    info_body = Yawast::Scanner::Plugins::SSL::SSLLabs::Info.call_info endpoint

    Yawast::Scanner::Plugins::SSL::SSLLabs::Info.extract_msg(info_body).each do |msg|
      puts "[SSL Labs] #{msg}"
    end

    Yawast::Scanner::Plugins::SSL::SSLLabs::Analyze.scan endpoint, uri.host, true

    status = ''
    error_count = 0
    until status == 'READY' || status == 'ERROR' || status == 'DNS'
      # poll for updates every 5 seconds
      # don't want to poll faster, to avoid excess load / errors
      sleep(5)

      begin
        data_body = Yawast::Scanner::Plugins::SSL::SSLLabs::Analyze.scan endpoint, uri.host, false
        status = Yawast::Scanner::Plugins::SSL::SSLLabs::Analyze.extract_status data_body
      rescue # rubocop:disable Style/RescueStandardError
        # if we find ourselves here, we want to try a couple more times before we give up for good
        error_count += 1

        if error_count > 3
          raise
        end
      end

      print '.'
    end
    puts
    puts
    puts "\tSSL Labs: https://www.ssllabs.com/ssltest/analyze.html?d=#{uri.host}&hideResults=on"
    puts

    json = nil
    begin
      json = JSON.parse data_body
    rescue => e # rubocop:disable Style/RescueStandardError
      raise Exception, "Invalid response from SSL Labs: '#{e.message}'"
    end

    process_results uri, json, tdes_session_count
  rescue => e # rubocop:disable Style/RescueStandardError
    puts
    Yawast::Utilities.puts_error "SSL Labs Error: #{e.message}"
  end
end

.process_results(uri, body, tdes_session_count) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/scanner/ssl_labs.rb', line 65

def self.process_results(uri, body, tdes_session_count)
  begin
    if !body['endpoints'].nil?
      body['endpoints'].each do |ep|
        Yawast::Utilities.puts_info "IP: #{ep['ipAddress']} - Grade: #{ep['grade']}"
        puts

        begin
          if ep['statusMessage'] == 'Ready'
            get_cert_info ep, body
            get_config_info ep
            get_proto_info ep
          else
            Yawast::Utilities.puts_error "Error getting information for IP: #{ep['ipAddress']}: #{ep['statusMessage']}"
          end
        rescue => e # rubocop:disable Style/RescueStandardError
          Yawast::Utilities.puts_error "Error getting information for IP: #{ep['ipAddress']}: #{e.message}"
        end

        Yawast::Scanner::Plugins::SSL::Sweet32.get_tdes_session_msg_count(uri) if tdes_session_count

        puts
      end
    else
      Yawast::Utilities.puts_error 'SSL Labs Error: No Endpoint Data Received.'

      # TODO: Remove this before release
      puts
      puts "DEBUG DATA (send to [email protected]): #{body}"
      puts
      puts
    end
  rescue => e # rubocop:disable Style/RescueStandardError
    puts
    Yawast::Utilities.puts_error "SSL Labs Error: #{e.message}"
  end
end