-
Notifications
You must be signed in to change notification settings - Fork 12
/
fallback_task.go
69 lines (60 loc) · 2.18 KB
/
fallback_task.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
57
58
59
60
61
62
63
64
65
66
67
68
69
package dissectls
import (
"github.com/rs/zerolog/log"
"github.com/tumi8/goscanner/scanner/misc"
"github.com/tumi8/goscanner/scanner/results"
"github.com/tumi8/goscanner/tls"
)
type FallbackTask struct {
scan bool
done bool
}
func (c *FallbackTask) SetCHValues(preset *tls.ClientHelloPreset, model *results.ServerModel, scanDoneRate float64, playSafe bool, chsLeft int) {
c.scan = false
var maxSupport uint16
if model.VersionTLS13 != nil && *model.VersionTLS13 == "True" {
maxSupport = tls.VersionTLS13
} else if model.VersionTLS12 != nil && *model.VersionTLS12 == "True" {
maxSupport = tls.VersionTLS12
} else if model.VersionTLS11 != nil && *model.VersionTLS11 == "True" {
maxSupport = tls.VersionTLS11
} else if model.VersionTLS10 != nil && *model.VersionTLS10 == "True" {
maxSupport = tls.VersionTLS10
}
if preset.Version == tls.VersionTLS12 && maxSupport == tls.VersionTLS13 && preset.SupportedVersions == nil {
c.scan = true
} else if preset.Version == tls.VersionTLS11 && preset.Version < maxSupport {
c.scan = true
} else if preset.Version == tls.VersionTLS10 && preset.Version < maxSupport {
c.scan = true
}
if c.scan {
preset.Ciphers = append(preset.Ciphers, tls.TLS_FALLBACK_SCSV)
}
}
func (c *FallbackTask) Done(model *results.ServerModel) bool {
return c.done
}
func (c *FallbackTask) ResolveError(*results.ServerModel) (learnedSomething bool) { return }
func (c *FallbackTask) MergeData(state tls.ConnectionState, model *results.ServerModel, preset *tls.ClientHelloPreset, err error) (errorCouldBeMe bool, learnedSomething bool) {
if c.scan {
for _, a := range state.RecvAlerts {
if a == 86 {
errorCouldBeMe = true
c.done = true
if model.InappropriateFallbackSupport != nil {
log.Error().Bool("Support", *model.InappropriateFallbackSupport).Msg("Contradicting Fallback Support")
}
learnedSomething = model.InappropriateFallbackSupport == nil
model.InappropriateFallbackSupport = misc.NewTrue()
return
}
}
if state.ServerHello != nil {
learnedSomething = model.InappropriateFallbackSupport == nil
model.InappropriateFallbackSupport = misc.NewFalse()
}
}
return
}
func (c *FallbackTask) PostProcess(*results.ServerModel) {}