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

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"); %>