-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetsslvxsupported.go
56 lines (50 loc) · 1.67 KB
/
getsslvxsupported.go
1
2
3
4
5
6
7
8
9
10
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
package main
import (
"fmt"
"net"
)
func getSslV2Supported(ip string, port int) ([]TlsV2ServerResponse, error) {
sslV2Ciphersuites := getAllSslV2Ciphersuites()
protoSslV2 := SslProtocolFromString("0200")
clientHello := TlsV2ClientHello{Protocol: protoSslV2}
successfullServerResponses := []TlsV2ServerResponse{}
for _, ciphersuite := range sslV2Ciphersuites {
socket, err := net.Dial("tcp", fmt.Sprintf("%s:%d", ip, port))
if err != nil {
return nil, ErrorCannotConnect
}
clientHello.Ciphersuites = []Ciphersuite{ciphersuite}
clientHello.send(socket)
serverHello := TlsV2ServerResponse{}
_, err = serverHello.read(socket)
if err == nil {
successfullServerResponses = append(successfullServerResponses, serverHello)
}
socket.Close()
}
return successfullServerResponses, nil
}
func getSslV3Supported(ip string, port int) ([]TlsV3ServerResponse, error) {
sslV3Ciphersuites := getAllSslV3Ciphersuites()
v3Protos := [...]string{"0300", "0301", "0302", "0303"}
successfullServerResponses := []TlsV3ServerResponse{}
for _, stringProto := range v3Protos {
protoSslV2 := SslProtocolFromString(stringProto)
clientHello := TlsV3ClientHello{Protocol: protoSslV2}
for _, ciphersuite := range sslV3Ciphersuites {
socket, err := net.Dial("tcp", fmt.Sprintf("%s:%d", ip, port))
if err != nil {
return nil, ErrorCannotConnect
}
clientHello.Ciphersuites = []Ciphersuite{ciphersuite}
clientHello.send(socket)
serverHello := TlsV3ServerResponse{}
_, err = serverHello.read(socket)
if err == nil {
successfullServerResponses = append(successfullServerResponses, serverHello)
}
socket.Close()
}
}
return successfullServerResponses, nil
}