forked from LeakIX/l9plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
confluence_version.go
121 lines (114 loc) · 3.92 KB
/
confluence_version.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
package web
/*
* Thanks to https://twitter.com/HaboubiAnis for pointers on this plugin.
*/
import (
"fmt"
"github.com/LeakIX/l9format"
"github.com/PuerkitoBio/goquery"
"github.com/hashicorp/go-version"
"log"
)
type ConfluenceVersionIssue struct {
l9format.ServicePluginBase
}
func (ConfluenceVersionIssue) GetVersion() (int, int, int) {
return 0, 1, 0
}
func (ConfluenceVersionIssue) GetName() string {
return "ConfluenceVersionIssue"
}
func (ConfluenceVersionIssue) GetStage() string {
return "open"
}
var ConfluenceRequest = l9format.WebPluginRequest{Method: "GET", Path: "/login.action"}
func (plugin ConfluenceVersionIssue) GetRequests() []l9format.WebPluginRequest {
//No need to register requests, / is a default one
return []l9format.WebPluginRequest{
ConfluenceRequest,
}
}
// Test leak from response
func (plugin ConfluenceVersionIssue) Verify(request l9format.WebPluginRequest, response l9format.WebPluginResponse, event *l9format.L9Event, options map[string]string) bool {
// If we're checking a /login.action request, negative
if !ConfluenceRequest.Equal(request) {
log.Printf("skipping confluence %s", request.Path)
return false
}
// If there's no HTML in the response, negative
if response.Document == nil {
log.Println("skipping confluence")
//no html
return false
}
// Find metas
response.Document.Find("meta").Each(func(i int, selection *goquery.Selection) {
// With ajs-version-number name attrib
if attrName, hasAttr := selection.Attr("name"); hasAttr && attrName == "ajs-version-number" {
if attrValue, hasAttrValue := selection.Attr("content"); hasAttrValue {
log.Printf("Found version %s", attrValue)
confluenceVersion, err := version.NewVersion(attrValue)
if err != nil {
return
}
if len(confluenceVersion.Segments()) < 3 {
return
}
event.Service.Software.Name = "Confluence"
event.Service.Software.Version = confluenceVersion.String()
segments := confluenceVersion.Segments()
major, minor, patch := segments[0], segments[1], segments[2]
// version test, TODO didn't care optimizing the logic, make it better for next issues
if major < 6 && major > 4 {
event.Summary = fmt.Sprintf("Confluence version %s likely vulnerable to CVE-2021-26084", confluenceVersion.String())
event.AddTag("cve-2021-26084")
return
}
if major == 6 && minor < 13 {
event.Summary = fmt.Sprintf("Confluence version %s likely vulnerable to CVE-2021-26084", confluenceVersion.String())
event.AddTag("cve-2021-26084")
return
}
if major == 6 && minor == 13 {
if patch < 23 {
event.Summary = fmt.Sprintf("Confluence version %s likely vulnerable to CVE-2021-26084", confluenceVersion.String())
event.AddTag("cve-2021-26084")
}
return
}
if major == 6 && minor > 13 {
event.Summary = fmt.Sprintf("Confluence version %s likely vulnerable to CVE-2021-26084", confluenceVersion.String())
event.AddTag("cve-2021-26084")
return
}
if major == 7 && minor == 4 {
if patch < 11 {
event.Summary = fmt.Sprintf("Confluence version %s likely vulnerable to CVE-2021-26084", confluenceVersion.String())
event.AddTag("cve-2021-26084")
}
return
}
if major == 7 && minor > 4 && minor < 11 {
event.Summary = fmt.Sprintf("Confluence version %s likely vulnerable to CVE-2021-26084", confluenceVersion.String())
event.AddTag("cve-2021-26084")
return
}
if major == 7 && minor == 11 {
if patch < 6 {
event.Summary = fmt.Sprintf("Confluence version %s likely vulnerable to CVE-2021-26084", confluenceVersion.String())
event.AddTag("cve-2021-26084")
}
return
}
if major == 7 && minor == 12 {
if patch < 5 {
event.Summary = fmt.Sprintf("Confluence version %s likely vulnerable to CVE-2021-26084", confluenceVersion.String())
event.AddTag("cve-2021-26084")
}
return
}
}
}
})
return event.HasTag("cve-2021-26084")
}