A client contacted RIVERIT: an online store on Bitrix had stopped loading. The investigation showed that malicious code had been on the website for more than three years: throughout this time, the website was part of an attacker’s botnet, and the store’s server was used to attack third-party websites and send spam. This case study describes the findings of the investigation and the work done to restore the store.
Background
- An online store on Bitrix (Small Business edition).
- The Bitrix core had not been updated since 2023. The license had expired more than two years earlier, and security updates had been unavailable since then.
- The website returned an error when opened.
Investigation findings
Malicious code
A malicious bot was found on the website. It had made the store part of a botnet, a network of infected websites and servers that attackers control remotely.
- The bot’s main file,
inc.class.smtphec.php, was disguised as an email sending class. - The bot downloaded new versions of itself and target lists from the attackers’ server, scanned third-party websites using 50 threads, sent reports to the attackers and restarted itself via
system(). - The bot did not disrupt the store’s operation, so the infection went unnoticed.
It was not possible to determine how the website was hacked or when it was infected: the bot was already on the website when it was moved to the current server in 2023, and no server logs are available for that period.
Impact of the infection
The store’s server was used to attack third-party websites and send spam.
Why the website returned an error
- The URL rewrite rules file
urlrewrite.phphad been emptied (0 bytes): the catalog, news, promotions and brands pages did not load. .settings.phpanddbconn.phpspecified different database names and database usernames.
Work performed
Malicious code detection and removal
The website consists of about 241,000 files, of which about 70,000 are code. The modification dates of nearly all files matched the date the website was moved to the current server, so the dates could not be used to identify either the modified files or the time of infection. To find all infected files, the website was scanned by code content in an isolated environment:
- Signature search in all PHP and JS files: code execution with decoding (
eval,assert), processing of data from$_POSTand$_COOKIE, loading code from external servers, signatures of known web shells (WSO, b374k, c99, r57, IndoXploit and others), hex and base64 obfuscation, extremely long strings. 174 matches were reviewed manually, and all were false positives: standard obfuscation of licensed Bitrix code, the pdfmake and d3 libraries, YML catalog exports. - The
upload/folder and the catalog import folders: no executable files; PHP execution inupload/is disabled. - Typical injection points in Bitrix (
init.php,dbconn.php,after_connect*.php,bitrix/admin,bitrix/tools, public-facing PHP files): no malicious code. - Website templates: the only external scripts and iframes are maps and videos; no obfuscated JavaScript was found.
- Search for empty files: of the important files, only
urlrewrite.phpwas empty. - Verification scan with the standard Bitrix scanner (bitrix.xscan): 164,561 files, plus agents and event handlers in the database. 119 matches, all false positives: cache files and standard Bitrix files.
- Database (agents, event handlers and content): no malicious injections.
Based on the investigation, the bot’s files were removed from the website:
- the main file
inc.class.smtphec.php; - auxiliary files: the AngryCurl multithreaded request library (
angry.txt), included code (roll.txt), a list of User-Agent strings used to disguise requests (list.txt) and the bot’s log (pathLog.txt).
No other malicious files or injections were found.
Store recovery
The URL rewrite rules file was restored, and the database connection was configured. The website was brought back up on PHP 8.1, and PHP 8 incompatibility errors and template errors were fixed:
| Error | Fix |
|---|---|
| PHP 8 fatal error on every page | 68 methods in third-party modules declared static |
| Product page cut off at the specifications block | Handling of empty properties added to the specifications component |
| Checkout failed with a 500 error | implode() call in the cart template brought in line with PHP 8 requirements |
| H1 heading “My cart” on all pages | Page title setting disabled in the cart template |
| PHP warnings in pop-up forms | AJAX request check fixed in 5 forms |
The following were tested: the home page, 42 catalog sections, 24 product pages, the filter, search, cart, checkout, one-click purchase, personal account, registration and admin panel login. Logging of administrator logins was enabled. Previously, logins were not logged.
Database cleanup
The database size of 1.5 GB is not related to the malicious code. Bitrix agents had been disabled, so event log cleanup had not run for years, and the service tables had filled up with entries from bot attacks.
| Data | Before | After | Contents |
|---|---|---|---|
| Event log | 759,000 entries, 884 MB | 0 | Blocked attacks: 380,000 SQL injections, 281,000 open redirect attempts via /bitrix/redirect.php, 31,000 XSS attempts, 1,100 PHP injections |
| Anonymous customers | 4.84 million, 327 MB | 3,672 | Entries created by bots. Customers with an account or a cart were kept |
| CAPTCHAs | 111,000 | 0 | Expired CAPTCHA codes |
| Email events | 36,000 | 0 | Mostly spam |
Factors that increase the risk of hacking
- An outdated version of Bitrix and its modules: the most likely entry point for attackers.
- Running without Bitrix Proactive Protection and file integrity monitoring: code changes go unnoticed for years.
- Unused modules and an old template expand the attack surface, and enabled debug mode exposes internal error information.
- Backups of files and the database are not stored off the server: if the server is hacked, the backups are also at risk.
RIVERIT provides hacked website recovery: we remove malicious code, bring the website back online and eliminate the consequences of the hack. To reduce the risk of hacking, we conduct a website security audit.













