浏览代码

Binaries for new version

new-scoring
aeris 1年前
父节点
当前提交
d60d325e04
共有 7 个文件被更改,包括 73 次插入14 次删除
  1. 4
    0
      bin/bundle
  2. 4
    1
      bin/check_https.rb
  3. 5
    1
      bin/check_smtp.rb
  4. 4
    1
      bin/check_xmpp.rb
  5. 1
    0
      bin/test
  6. 38
    0
      bin/test.rb
  7. 17
    11
      bin/tls_server.rb

+ 4
- 0
bin/bundle 查看文件

@@ -0,0 +1,4 @@
1
+#!/bin/bash
2
+: ${RBENV_ROOT:=$HOME/.rbenv}
3
+DIR="$(readlink -m "$(dirname "$0")")"
4
+LD_LIBRARY_PATH="${DIR}/../lib" "${RBENV_ROOT}/shims/bundle" $*

+ 4
- 1
bin/check_https.rb 查看文件

@@ -3,4 +3,7 @@ $:.unshift File.expand_path File.join File.dirname(__FILE__), '../lib'
3 3
 require 'rubygems'
4 4
 require 'bundler/setup'
5 5
 require 'cryptcheck'
6
-::CryptCheck::Tls::Https::Host.new ARGV[0], ARGV.fetch(1, 443)
6
+
7
+args, port = ARGV
8
+args = [args, port] if port
9
+hosts = ::CryptCheck::Tls::Https.analyze *args

+ 5
- 1
bin/check_smtp.rb 查看文件

@@ -3,4 +3,8 @@ $:.unshift File.expand_path File.join File.dirname(__FILE__), '../lib'
3 3
 require 'rubygems'
4 4
 require 'bundler/setup'
5 5
 require 'cryptcheck'
6
-::CryptCheck::Tls::Smtp.analyze_domain ARGV[0]
6
+
7
+args, port = ARGV
8
+args = [args, port] if port
9
+hosts = ::CryptCheck::Tls::Smtp.analyze *args
10
+ap hosts

+ 4
- 1
bin/check_xmpp.rb 查看文件

@@ -3,4 +3,7 @@ $:.unshift File.expand_path File.join File.dirname(__FILE__), '../lib'
3 3
 require 'rubygems'
4 4
 require 'bundler/setup'
5 5
 require 'cryptcheck'
6
-::CryptCheck::Tls::Xmpp.analyze_domain ARGV[0], type: ARGV.fetch(1, :s2s).to_sym
6
+
7
+args, type = ARGV
8
+args = [args, type] if type
9
+::CryptCheck::Tls::Xmpp.analyze *args

+ 1
- 0
bin/test 查看文件

@@ -0,0 +1 @@
1
+runner

+ 38
- 0
bin/test.rb 查看文件

@@ -0,0 +1,38 @@
1
+#!/usr/bin/env ruby
2
+$:.unshift File.expand_path File.join File.dirname(__FILE__), '../lib'
3
+require 'rubygems'
4
+require 'bundler/setup'
5
+Bundler.require :default, :development
6
+require 'cryptcheck'
7
+
8
+class CryptCheck::Tls::Cert
9
+	def valid?(*_)
10
+		true
11
+	end
12
+
13
+	def trusted?
14
+		:trusted
15
+	end
16
+end
17
+
18
+# obj = Class.new do
19
+# 	include ::CryptCheck::State
20
+#
21
+# 	def available_checks
22
+# 		[[:foo, %i(critical warning good best), -> (_) { :best }]]
23
+# 	end
24
+# end.new
25
+# ap obj.states
26
+# ap obj.status
27
+
28
+# cipher = ::CryptCheck::Tls::Cipher[::CryptCheck::Tls::Method[:TLSv1_2]].first
29
+# ap cipher.states
30
+# ap cipher.status
31
+# ap cipher.name
32
+# puts cipher.to_s
33
+
34
+# key = OpenSSL::PKey.read File.read 'spec/resources/rsa-1024.pem'
35
+# ap key.states
36
+# ap key.status
37
+
38
+host = CryptCheck::Tls::Https::Host.new 'localhost', 443

+ 17
- 11
bin/tls_server.rb 查看文件

@@ -68,7 +68,7 @@ def certificate(key)
68 68
 end
69 69
 
70 70
 key = OpenSSL::PKey::RSA.new File.read 'config/rsa-2048.pem'
71
-#key = OpenSSL::PKey::EC.new('secp521r1').generate_key
71
+# key = OpenSSL::PKey::EC.new('prime256v1').generate_key
72 72
 cert = certificate key
73 73
 
74 74
 CryptCheck::Logger.info 'Starting server'
@@ -78,13 +78,13 @@ context = OpenSSL::SSL::SSLContext.new
78 78
 #context         = OpenSSL::SSL::SSLContext.new :TLSv1_1
79 79
 context.cert    = cert
80 80
 context.key     = key
81
-context.ciphers = ARGV[0] || 'ECDHE+AESGCM'
81
+context.ciphers = ARGV[0] || 'EECDH+AESGCM'
82 82
 
83
-dh                      = OpenSSL::PKey::DH.new File.read 'config/dh-4096.pem'
84
-context.tmp_dh_callback = proc { dh }
83
+#dh                      = OpenSSL::PKey::DH.new File.read 'config/dh-4096.pem'
84
+#context.tmp_dh_callback = proc { dh }
85 85
 #context.ecdh_curves = CryptCheck::Tls::Server::SUPPORTED_CURVES.join ':'
86 86
 #context.ecdh_curves = 'secp384r1:secp521r1:sect571r1'
87
-context.ecdh_curves     = 'secp384r1'
87
+#context.ecdh_curves     = 'prime256v1'
88 88
 #ecdh = OpenSSL::PKey::EC.new('secp384r1').generate_key
89 89
 #context.tmp_ecdh_callback = proc { ecdh }
90 90
 
@@ -92,6 +92,9 @@ host, port = '::', 5000
92 92
 tcp_server              = TCPServer.new host, port
93 93
 tls_server              = OpenSSL::SSL::SSLServer.new tcp_server, context
94 94
 ::CryptCheck::Logger.info "Server started on #{host}:#{port}"
95
+# ::CryptCheck::Logger.info "Supported ciphers:"
96
+# context.ciphers.each { |c| ::CryptCheck::Logger.info c.first }
97
+
95 98
 
96 99
 loop do
97 100
 	begin
@@ -101,15 +104,18 @@ loop do
101 104
 
102 105
 		dh = connection.tmp_key
103 106
 		cipher = connection.cipher
104
-		cipher = CryptCheck::Tls::Cipher.new method, cipher, dh
107
+		cipher = CryptCheck::Tls::Cipher.new method, cipher.first
105 108
 		states = cipher.states
106
-		text   = %i(critical error warning good perfect best).collect do |s|
107
-			states[s].collect { |t| t.to_s.colorize s }.join ' '
108
-		end.reject &:empty?
109
-		text   = text.join ' '
109
+		# p states
110
+		# text   = %i(critical error warning good perfect best).collect do |s|
111
+		# 	states[s].collect { |t| t.to_s.colorize s }.join ' '
112
+		# end.reject &:empty?
113
+		# text = []
114
+		# text   = text.join ' '
115
+		# text = ''
110 116
 
111 117
 		dh     = dh ? " (#{'PFS'.colorize :good} : #{CryptCheck::Tls.key_to_s dh})" : ''
112
-		CryptCheck::Logger.info { "#{CryptCheck::Tls.colorize method} / #{cipher.colorize}#{dh} [#{text}]" }
118
+		CryptCheck::Logger.info { "#{cipher}#{dh}" }
113 119
 
114 120
 		data       = connection.gets
115 121
 		if data

正在加载...
取消
保存