Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Hacking cPanel With ~/.contactemail - Resetting Passwords

This tutorial is based on how one of my old servers was compromised. It took nearly 2 years to figure out how the hacker was repeatedly re-gaining access to a cPanel account. This is something that may even be patched in the newest cPanel licenses, but there are reports going all the way into 2022 and 1 report in 2023 of the hack still around. Older versions are obviously much more vulnerable.

The whole hack is centered around cPanel's method of storing contact emails for users in plaintext in a file:
Code
~/.contactemail

TLDR Version:
- update .contactemail to have any email address
- using cPanel reset password will now send the password reset link to the new email address, instead of original email on file
- because .contactemail has not always been secure, many servers are vulnerable
- any vulnerability that allows a hacker to edit files, even if the hack is 100% unrelated to cPanel, can be used to edit .contactemail for this method

Although the emails of users are tracked elsewhere as well, this file can be manipulated to take control. For example, WHCMS has a list of users with a variable in each file for CONTACTEMAIL, but when updates roll out this just replaces the value inside the individual .contactemail file, per user. However, if you change the value in .contactemail, parts of cPanel use that without doublechecking other values in the master list. What this means is that if you can write to .contactemail, you can get full control of the cPanel.

The reason this is is bad is because contactemail was not readonly / secured by default. For example, we brought on a new client that had an infected Wordpress. because the hacker was already in there, they were already targeting the email file. Any time we locked them back out, they were still able to get back in. This is because we would change password, even change the email ourselves, and also alter permissions for files on the system, and remove their PHP shells... but we didn't know about contactemail.

You see, once you have access to the system and have found the .contactemail file, you have a few options, and this is what the hacker did to us:
Spoiler (Click to View)



Again - this is much more of a hack for older versions of cPanel, but I do see some recent notes on it that suggest it's either not fully patched, can be manipulated depending on server settings, or there simply are a lot of people still using older cPanel versions. Either way, this was the worst any of my servers ever got hacked and I am happy to share this info if it helps you complete your own pentesting or to otherwise secure your server.
so fucking goooooooooooooodddddddddddddddddddd
The member who made this post was warned. In some way it violates our rules or policies.
Please familiarize yourself by reading our Help Documents.
there are any way to secure cPanel? how to disable or restrict contactemail file?
(Jan 19, 2024 05:48 PM)xanutree Wrote:  there are any way to secure cPanel? how to disable or restrict contactemail file?

Chmod, chown, protect against directory traversal code, don't let your server get infected
thank you for this useful tut hope to see more content fro myou
(Jan 20, 2024 05:20 AM)MarkGold Wrote:  thank you for this useful tut hope to see more content fro myou

Thanks Mark, I plan on releasing more tutorials over time. Glad you found this useful!


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Turtle™Jun 23, 2017 08:03 PM 124 12,546 Jun 23, 2017 08:03 PM
Last Post: Misuu
by GuestPassJun 21, 2015 06:43 PM 2 194 Jun 21, 2015 06:43 PM
Last Post: GuestPass
by ๖ۣۜTigerNet™Dec 8, 2014 10:19 AM 0 389 Dec 8, 2014 10:19 AM
Last Post: ๖ۣۜTigerNet™