first commit
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled

This commit is contained in:
2025-09-06 16:08:15 +08:00
commit 63285f61aa
2624 changed files with 88491 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
FROM maven:3-jdk-8
LABEL maintainer="phithon <root@leavesongs.com>"
COPY ./ /usr/src/
WORKDIR /usr/src
RUN set -ex \
&& mvn compile jetty:help
EXPOSE 8080
CMD ["mvn", "jetty:run"]

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.vulhub</groupId>
<artifactId>s2-032</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>s2-032 Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.28</version>
</dependency>
</dependencies>
<build>
<finalName>s2-032</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
</webApp>
<httpConnector>
<port>8080</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,9 @@
package org.vulhub.action;
import com.opensymphony.xwork2.ActionSupport;
public class HelloWorldAction extends ActionSupport{
public String execute() {
return SUCCESS;
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<constant name="struts.devMode" value="false" />
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<package name="default" extends="struts-default">
<default-action-ref name="index" />
<action name="index">
<result>/index.jsp</result>
</action>
<action name="hello" class="org.vulhub.action.HelloWorldAction" method="execute">
<result name="success">/hello.jsp</result>
</action>
</package>
</struts>

View File

@@ -0,0 +1,17 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@@ -0,0 +1,10 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
<h2>Hello page</h2>
</body>
</html>

View File

@@ -0,0 +1,5 @@
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>

View File

@@ -0,0 +1,12 @@
FROM maven:3-jdk-8
LABEL maintainer="phithon <root@leavesongs.com>"
COPY ./ /usr/src/
WORKDIR /usr/src
RUN set -ex \
&& mvn compile jetty:help
EXPOSE 8080
CMD ["mvn", "jetty:run"]

View File

@@ -0,0 +1,39 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.pwntester</groupId>
<artifactId>Struts2FileUpload</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Struts2FileUpload Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.30</version>
</dependency>
</dependencies>
<build>
<finalName>Struts2FileUpload</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.11.v20150529</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
</webApp>
<httpConnector>
<port>8080</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,55 @@
package org.pwntester.action;
import com.opensymphony.xwork2.ActionSupport;
import java.io.File;
public class FileUploadAction extends ActionSupport {
private String contentType;
private File upload;
private String fileName;
private String caption;
public String input() throws Exception {
return SUCCESS;
}
public String upload() throws Exception {
return SUCCESS;
}
public String getUploadFileName() {
return fileName;
}
public void setUploadFileName(String fileName) {
this.fileName = fileName;
}
public String getUploadContentType() {
return contentType;
}
public void setUploadContentType(String contentType) {
this.contentType = contentType;
}
public File getUpload() {
return upload;
}
public void setUpload(File upload) {
this.upload = upload;
}
public String getCaption() {
return caption;
}
public void setCaption(String caption) {
this.caption = caption;
}
}

View File

@@ -0,0 +1,3 @@
struts.messages.error.file.too.large = Uploaded File size is too large
struts.messages.error.content.type.not.allowed =File type is not allowed.
struts.messages.error.file.extension.not.allowed =File extension is not allowed.

View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="global" />
<!-- <constant name="struts.multipart.parser" value="jakarta-stream" /> -->
<!--constant name="struts.multipart.maxSize" value="1" /-->
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="doUpload" />
<action name="upload" class="org.pwntester.action.FileUploadAction" method="input">
<result>pages/upload.jsp</result>
</action>
<action name="doUpload" class="org.pwntester.action.FileUploadAction" method="upload">
<result name="input">pages/upload.jsp</result>
<result>pages/upload-success.jsp</result>
</action>
</package>
</struts>

View File

@@ -0,0 +1,17 @@
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Struts 2 Web Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@@ -0,0 +1,27 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts2 Showcase - Fileupload sample</title>
</head>
<body>
<div class="page-header">
<h1>Fileupload sample</h1>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<s:actionerror cssClass="alert alert-error"/>
<s:fielderror cssClass="alert alert-error"/>
<s:form action="doUpload" method="POST" enctype="multipart/form-data">
<s:file name="upload" label="File"/>
<s:textfield name="caption" label="Caption"/>
<s:submit cssClass="btn btn-primary"/>
</s:form>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<%@ page
language="java"
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Struts2 Showcase - Fileupload sample</title>
</head>
<body>
<div class="page-header">
<h1>Fileupload sample</h1>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<ul>
<li>ContentType: <s:property value="uploadContentType" /></li>
<li>FileName: <s:property value="uploadFileName" /></li>
<li>File: <s:property value="upload" /></li>
<li>Caption:<s:property value="caption" /></li>
</ul>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,18 @@
FROM tomcat:8.5
LABEL maintainer="phithon <root@leavesongs.com>"
ARG ST2_VERSION=2.3.32
ARG WEB_DIR=/usr/local/tomcat/webapps
RUN set -ex \
&& rm -rf ${WEB_DIR}/* \
&& chmod a+x /usr/local/tomcat/bin/*.sh \
\
&& wget http://archive.apache.org/dist/struts/${ST2_VERSION}/struts-${ST2_VERSION}-apps.zip -O /tmp/struts-${ST2_VERSION}-apps.zip \
&& unzip /tmp/struts-${ST2_VERSION}-apps.zip -d /tmp/ \
&& mv /tmp/struts-${ST2_VERSION}/apps/struts2-showcase.war ${WEB_DIR}/ROOT.war \
&& rm -rf /tmp/struts* \
&& sed -i 's/securerandom\.source=file:\/dev\/random/securerandom.source=file:\/dev\/.\/urandom/g' $JAVA_HOME/lib/security/java.security
EXPOSE 8080

View File

@@ -0,0 +1,19 @@
FROM tomcat:8.5
LABEL maintainer="phithon <root@leavesongs.com>"
ARG ST2_VERSION=2.3.34
ARG WEB_DIR=/usr/local/tomcat/webapps
RUN set -ex \
&& rm -rf ${WEB_DIR}/* \
&& chmod a+x /usr/local/tomcat/bin/*.sh \
&& mkdir ${WEB_DIR}/ROOT/ \
\
&& wget http://archive.apache.org/dist/struts/${ST2_VERSION}/struts-${ST2_VERSION}-apps.zip -O /tmp/struts-${ST2_VERSION}-apps.zip \
&& unzip /tmp/struts-${ST2_VERSION}-apps.zip -d /tmp/ \
&& unzip /tmp/struts-${ST2_VERSION}/apps/struts2-showcase.war -d ${WEB_DIR}/ROOT/ \
&& rm -rf /tmp/struts* \
&& sed -i 's/securerandom\.source=file:\/dev\/random/securerandom.source=file:\/dev\/.\/urandom/g' $JAVA_HOME/lib/security/java.security
EXPOSE 8080

View File

@@ -0,0 +1,18 @@
FROM tomcat:8.5
LABEL maintainer="phithon <root@leavesongs.com>"
ARG ST2_VERSION=2.5.12
ARG WEB_DIR=/usr/local/tomcat/webapps
RUN set -ex \
&& rm -rf ${WEB_DIR}/* \
&& chmod a+x /usr/local/tomcat/bin/*.sh \
\
&& wget http://archive.apache.org/dist/struts/${ST2_VERSION}/struts-${ST2_VERSION}-apps.zip -O /tmp/struts-${ST2_VERSION}-apps.zip \
&& unzip /tmp/struts-${ST2_VERSION}-apps.zip -d /tmp/ \
&& mv /tmp/struts-${ST2_VERSION}/apps/struts2-rest-showcase.war ${WEB_DIR}/ROOT.war \
&& rm -rf /tmp/struts* \
&& sed -i 's/securerandom\.source=file:\/dev\/random/securerandom.source=file:\/dev\/.\/urandom/g' $JAVA_HOME/lib/security/java.security
EXPOSE 8080

View File

@@ -0,0 +1,12 @@
FROM maven:3-jdk-8
LABEL maintainer="litch1<litch1chk@gmail.com>"
COPY ./ /usr/src/
WORKDIR /usr/src
RUN set -ex \
&& mvn compile jetty:help
EXPOSE 8080
CMD ["mvn", "jetty:run"]

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.pwntester</groupId>
<artifactId>s2-059</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.16</version>
</dependency>
</dependencies>
<build>
<finalName>s2-059</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.31.v20200723</version>
<configuration>
<supportedPackagings>jar</supportedPackagings>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
</webApp>
<httpConnector>
<port>8080</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,21 @@
package org.pwntester.action;
import com.opensymphony.xwork2.ActionSupport;
public class IndexAction extends ActionSupport {
private String id;
public String changeId(){
return SUCCESS;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="false"/>
<!--<constant name="struts.custom.i18n.resources" value="global"/>-->
<!-- <constant name="struts.multipart.parser" value="jakarta-stream" /> -->
<!--constant name="struts.multipart.maxSize" value="1" /-->
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index"/>
<action name="index" class="org.pwntester.action.IndexAction" method="changeId">
<result>index.jsp</result>
</action>
</package>
</struts>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@@ -0,0 +1,17 @@
<%@ page
language="java"
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>S2-059 demo</title>
</head>
<body>
<s:a id="%{id}">your input id: ${id}
<br>has ben evaluated again in id attribute
</s:a>
</body>
</html>

View File

@@ -0,0 +1,12 @@
FROM maven:3-jdk-8
LABEL maintainer="phith0n <root@leavesongs.com>"
COPY ./ /usr/src/
WORKDIR /usr/src
RUN set -ex \
&& mvn compile jetty:help
EXPOSE 8080
CMD ["mvn", "jetty:run"]

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.pwntester</groupId>
<artifactId>s2-059</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.25</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
</dependencies>
<build>
<finalName>s2-059</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.4.31.v20200723</version>
<configuration>
<supportedPackagings>jar</supportedPackagings>
<scanIntervalSeconds>10</scanIntervalSeconds>
<webApp>
<contextPath>/</contextPath>
</webApp>
<httpConnector>
<port>8080</port>
</httpConnector>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,21 @@
package org.pwntester.action;
import com.opensymphony.xwork2.ActionSupport;
public class IndexAction extends ActionSupport {
private String id;
public String changeId(){
return SUCCESS;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="false"/>
<!--<constant name="struts.custom.i18n.resources" value="global"/>-->
<!-- <constant name="struts.multipart.parser" value="jakarta-stream" /> -->
<!--constant name="struts.multipart.maxSize" value="1" /-->
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index"/>
<action name="index" class="org.pwntester.action.IndexAction" method="changeId">
<result>index.jsp</result>
</action>
</package>
</struts>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

View File

@@ -0,0 +1,17 @@
<%@ page
language="java"
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>S2-059 demo</title>
</head>
<body>
<s:a id="%{id}">your input id: ${id}
<br>has ben evaluated again in id attribute
</s:a>
</body>
</html>

View File

@@ -0,0 +1,10 @@
FROM vulhub/tomcat:8.5
LABEL maintainer="phithon <root@leavesongs.com>"
RUN set -ex \
&& rm -rf /usr/local/tomcat/webapps/* \
&& chmod a+x /usr/local/tomcat/bin/*.sh
ADD https://download.vulhub.org/download/struts2/s2-053/ROOT.war /usr/local/tomcat/webapps/ROOT.war
EXPOSE 8080

1
base/struts2/s2-066/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target/

View File

@@ -0,0 +1,11 @@
FROM maven:3.9.9-eclipse-temurin-17 AS builder
COPY . /usr/src
RUN cd /usr/src && mvn clean package -DskipTests
FROM tomcat:9.0.99-jdk17-temurin
COPY --from=builder /usr/src/target/struts2-s2-066.war /usr/local/tomcat/webapps/ROOT.war
ENV CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n"

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.vulhub</groupId>
<artifactId>struts2-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>struts2-sample</name>
<description>Struts 2 Starter</description>
<properties>
<struts2.version>2.5.32</struts2.version>
<log4j2.version>2.12.1</log4j2.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
</dependencies>
<build>
<finalName>struts2-s2-066</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,97 @@
/*
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vulhub;
import com.opensymphony.xwork2.ActionSupport;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.logging.log4j.LogManager;
public class IndexAction extends ActionSupport {
private File file;
private String fileContentType;
private String fileFileName;
private String uploadedFilePath;
private String uploadedFileName;
public String execute() throws Exception {
if (file != null) {
String base = ServletActionContext.getServletContext().getRealPath("/") + "upload";
LogManager.getLogger(IndexAction.class).debug("Upload base directory: {}", base);
// Create upload directory if it doesn't exist
File dir = new File(base);
if (!dir.exists()) {
dir.mkdirs();
}
// Save the uploaded file
String fileName = getFileFileName();
File destFile = new File(dir, fileName);
FileUtils.copyFile(getFile(), destFile);
// Save the path and filename for display
uploadedFilePath = "upload/" + fileName;
uploadedFileName = getFileFileName();
return SUCCESS;
}
return INPUT;
}
// Getters and setters
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getUploadedFilePath() {
return uploadedFilePath;
}
public void setUploadedFilePath(String uploadedFilePath) {
this.uploadedFilePath = uploadedFilePath;
}
public String getUploadedFileName() {
return uploadedFileName;
}
public void setUploadedFileName(String uploadedFileName) {
this.uploadedFileName = uploadedFileName;
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="com.opensymphony.xwork2" level="info"/>
<Logger name="org.apache.struts2" level="info"/>
<Logger name="org.vulhub" level="debug"/>
<Root level="warn">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<constant name="struts.devMode" value="true"/>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<!-- Configure for file upload -->
<constant name="struts.multipart.maxSize" value="10485760"/>
<package name="myPackage" extends="struts-default">
<default-action-ref name="index" />
<action name="index" class="org.vulhub.IndexAction">
<result name="input">/WEB-INF/jsp/index.jsp</result>
<result name="success">/WEB-INF/jsp/success.jsp</result>
</action>
</package>
</struts>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>File Upload</title>
<s:head />
<style>
.form-container {
max-width: 500px;
margin: 50px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-field {
margin-bottom: 15px;
}
.submit-button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.submit-button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="form-container">
<h2>File Upload</h2>
<s:form action="index" method="post" enctype="multipart/form-data">
<div class="form-field">
<s:file label="Select a file" name="file" />
</div>
<s:submit value="Upload" cssClass="submit-button" />
</s:form>
</div>
</body>
</html>

View File

@@ -0,0 +1,68 @@
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Upload Success</title>
<style>
.result-container {
max-width: 500px;
margin: 50px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
text-align: center;
}
.file-info {
margin: 20px 0;
padding: 15px;
background-color: #f5f5f5;
border-radius: 4px;
}
.file-name {
font-size: 18px;
color: #333;
margin-bottom: 10px;
word-break: break-all;
}
.file-link {
display: inline-block;
margin-top: 10px;
color: #4CAF50;
text-decoration: none;
}
.file-link:hover {
text-decoration: underline;
}
.back-button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 4px;
display: inline-block;
margin-top: 20px;
}
.back-button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="result-container">
<h2>Upload Success!</h2>
<div class="file-info">
<div class="file-name">
File name: <s:property value="uploadedFileName" />
</div>
<a href="<s:property value="uploadedFilePath"/>" class="file-link" target="_blank">Download File</a>
</div>
<div>
<a href="index.action" class="back-button">Upload Another File</a>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="struts_blank" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts 2 - Maven Archetype - Starter</display-name>
<!-- Filters -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/upload/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>jspSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
<!-- Welcome file lists -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

View File

@@ -0,0 +1,2 @@
<% response.sendRedirect("index.action"); %>

1
base/struts2/s2-067/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
target/

View File

@@ -0,0 +1,11 @@
FROM maven:3.9.9-eclipse-temurin-17 AS builder
COPY . /usr/src
RUN cd /usr/src && mvn clean package -DskipTests
FROM tomcat:9.0.99-jdk17-temurin
COPY --from=builder /usr/src/target/struts2-s2-067.war /usr/local/tomcat/webapps/ROOT.war
ENV CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n"

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.vulhub</groupId>
<artifactId>struts2-sample</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>struts2-sample</name>
<description>Struts 2 Starter</description>
<properties>
<struts2.version>2.5.33</struts2.version>
<log4j2.version>2.12.1</log4j2.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>${struts2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.3</version>
</dependency>
</dependencies>
<build>
<finalName>struts2-s2-067</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,97 @@
/*
* Copyright 2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.vulhub;
import com.opensymphony.xwork2.ActionSupport;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import org.apache.logging.log4j.LogManager;
public class IndexAction extends ActionSupport {
private File file;
private String fileContentType;
private String fileFileName;
private String uploadedFilePath;
private String uploadedFileName;
public String execute() throws Exception {
if (file != null) {
String base = ServletActionContext.getServletContext().getRealPath("/") + "upload";
LogManager.getLogger(IndexAction.class).debug("Upload base directory: {}", base);
// Create upload directory if it doesn't exist
File dir = new File(base);
if (!dir.exists()) {
dir.mkdirs();
}
// Save the uploaded file
String fileName = getFileFileName();
File destFile = new File(dir, fileName);
FileUtils.copyFile(getFile(), destFile);
// Save the path and filename for display
uploadedFilePath = "upload/" + fileName;
uploadedFileName = getFileFileName();
return SUCCESS;
}
return INPUT;
}
// Getters and setters
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getUploadedFilePath() {
return uploadedFilePath;
}
public void setUploadedFilePath(String uploadedFilePath) {
this.uploadedFilePath = uploadedFilePath;
}
public String getUploadedFileName() {
return uploadedFileName;
}
public void setUploadedFileName(String uploadedFileName) {
this.uploadedFileName = uploadedFileName;
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="com.opensymphony.xwork2" level="info"/>
<Logger name="org.apache.struts2" level="info"/>
<Logger name="org.vulhub" level="debug"/>
<Root level="warn">
<AppenderRef ref="STDOUT"/>
</Root>
</Loggers>
</Configuration>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<constant name="struts.devMode" value="true"/>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<!-- Configure for file upload -->
<constant name="struts.multipart.maxSize" value="10485760"/>
<package name="myPackage" extends="struts-default">
<default-action-ref name="index" />
<action name="index" class="org.vulhub.IndexAction">
<result name="input">/WEB-INF/jsp/index.jsp</result>
<result name="success">/WEB-INF/jsp/success.jsp</result>
</action>
</package>
</struts>

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>File Upload</title>
<s:head />
<style>
.form-container {
max-width: 500px;
margin: 50px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
.form-field {
margin-bottom: 15px;
}
.submit-button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.submit-button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="form-container">
<h2>File Upload</h2>
<s:form action="index" method="post" enctype="multipart/form-data">
<div class="form-field">
<s:file label="Select a file" name="file" />
</div>
<s:submit value="Upload" cssClass="submit-button" />
</s:form>
</div>
</body>
</html>

View File

@@ -0,0 +1,68 @@
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@taglib prefix="s" uri="/struts-tags" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Upload Success</title>
<style>
.result-container {
max-width: 500px;
margin: 50px auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
text-align: center;
}
.file-info {
margin: 20px 0;
padding: 15px;
background-color: #f5f5f5;
border-radius: 4px;
}
.file-name {
font-size: 18px;
color: #333;
margin-bottom: 10px;
word-break: break-all;
}
.file-link {
display: inline-block;
margin-top: 10px;
color: #4CAF50;
text-decoration: none;
}
.file-link:hover {
text-decoration: underline;
}
.back-button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 4px;
display: inline-block;
margin-top: 20px;
}
.back-button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="result-container">
<h2>Upload Success!</h2>
<div class="file-info">
<div class="file-name">
File name: <s:property value="uploadedFileName" />
</div>
<a href="<s:property value="uploadedFilePath"/>" class="file-link" target="_blank">Download File</a>
</div>
<div>
<a href="index.action" class="back-button">Upload Another File</a>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="struts_blank" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Struts 2 - Maven Archetype - Starter</display-name>
<!-- Filters -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/upload/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>jspSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>5</load-on-startup>
</servlet>
<!-- Welcome file lists -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

View File

@@ -0,0 +1,2 @@
<% response.sendRedirect("index.action"); %>