Skip to content

Instantly share code, notes, and snippets.

@bc0d3
Last active June 22, 2021 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bc0d3/6d55866a78f66569383241406e18794f to your computer and use it in GitHub Desktop.
Save bc0d3/6d55866a78f66569383241406e18794f to your computer and use it in GitHub Desktop.
CVE-2021-31769

CVE-2021-31769

Step by Step

First we install our trial version by downloading it from the following site

https://smart.myq-solution.com/

1_0001

once the file is downloaded, we install it in a virtual machine with windows 10, in the case of having a windows server it also works.

We prepare our environment with an administrator user and a user without privileges.

admin
user:*admin
password:admin

user
user:bc0d3
pin:2590

once we start session with the administrator user we will go to the functionality of "task scheduler" found in the menu on the left "Settings"

1_0002

Then we click on the "task scheduler" functionality

1_0003

We select some functionality that has the function of reading or listing files.

1_0004

once it is clicked, a window will appear showing the directories and files of the system.

1_0005

Being with an administrator user, these functions should only be available for this user, that is, the administrator, but if we see the HTTP requests in bursuite and make the same request with a user without privileges we can see the same directories.

Administrator user request

Demonstration that the administrator's cookies

1_0006

http request from listing directory with an administrator cookie.

1_0007

We will proceed to the next test where we use a cookie from an unprivileged user and we will also have the same result.

Non-privileged user request

Demonstration that the cookies of a user without privileges.

1_0008

Http request to list directories with a common user cookie

1_0009

This shows we have privileges to list system files, the MyQ-printserver software runs as NT AUTHORITY \ SYSTEM when installed, this means we have privileges to list system files and directories.

How can we use this to access an administrator account and run commands on the server?

It must be taken into consideration that the myQ system uses apache and php other languages, this means that when using PHP, the sessions are saved in the php directory located in the following path:

C:\Program Files\MyQ\PHP\Sessions

when installing the software we will realize it is saved in that path.

1_0010

now we only have to make a request to the aforementioned route and go through all the sessions to validate which session will be of an administrator user, take that session and add it to the browser to escalate privileges, take access and then execute commands on the server.

PoC

For this we create a python script that performs this action lists the sessions and their corresponding user. First we will take the active session of a user without privileges, usually it is delivered for printing.

1_0011

we will use our script:

1_0012

We take the session that it gives us and then we proceed to enter it into the browser to escalate privileges.

1_0013

1_0014

We will have access as administration, an escalation of privileges.

RCE

For this it is easier once inside the administrator panel we do the following:

  • Go to Task Scheduler settings
  • Create a new task with external commands
  • Add any name, Repeat every 10 minutes, File to run is C:\Windows\System32\calc.exe
  • Add the following parameters & echo ^<?php system($_GET['cmd']);?^> > C:\Program^ Files\MyQ\PhpApps\PrintServer\public\bc0d3.php'
  • Save and then select the task and run it
  • Go to the following URL https://IP:8090/bc0d3.php?cmd=whoami -- :D @bc0d3

reference images

1_0015

1_0016

@OneCodeCZ
Copy link

OneCodeCZ commented Jun 22, 2021

Only MyQ administrator is able to add External Commands in the scheduler. It was assumed that MyQ administrator is also the OS administrator which often is the case. However, this issue is fixed in MyQ Print Server 8.2 patch 3. Thank you for reporting.

@bc0d3
Copy link
Author

bc0d3 commented Jun 22, 2021

Only MyQ administrator is able to add External Commands in the scheduler. It was assumed that MyQ a

The solution to these vulnerabilities was resolved in the versions , myQ central server 8.2 and myq print server 8.2 (patch 3)

External commands are no longer available and the function of listing files is limited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment