Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File upload #113

Closed
unam4 opened this issue Nov 22, 2023 · 1 comment
Closed

File upload #113

unam4 opened this issue Nov 22, 2023 · 1 comment

Comments

@unam4
Copy link

unam4 commented Nov 22, 2023

0x01 File upload

Interface:/adminPage/main/upload

com/cym/controller/adminPage/MainController.java#upload

	@Mapping("/adminPage/main/upload")
	public JsonResult upload(Context context, UploadedFile file) {
		try {
			File temp = new File(FileUtil.getTmpDir() + "/" + file.getName());
			file.transferTo(temp);

			return renderSuccess(temp.getPath().replace("\\", "/"));
		} catch (IllegalStateException | IOException e) {
			logger.error(e.getMessage(), e);
		}

		return renderError();
	}

You can see that file.getName () is not filtered, causing the.. /.. / directory to traverse to the ssh directory, there is no restriction on the suffix name, and you can write the public key to get shell.
Then replace the path "/".

Reappearance

ssh-keygen -t rsa -f id_rsa

upload.

image

You can see the successful upload
image

Success

@cym1102
Copy link
Owner

cym1102 commented Nov 22, 2023

ok, I will fix this

@cym1102 cym1102 closed this as completed Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants