I believe there are layers of hacks going on here. Maybe the first ones were “clever” but the next several rounds just seem to be finding already-compromised PBXes and piling on their malware.
The systems I discovered to be infected were still early in the process and only had a small amount of the aforementioned crapware loaded; someone later requested my help on another system and I found it to be much more loaded up.
So my impression is the longer you let a system sit compromised and exposed, the worse it’s going to get, and the list of clean-up items is going to get longer (just give up and rebuild).
I concur, give up, rebuild but before you do anything else add a well configured ‘root-kit checker’ that includes /var/www/html/admin /var/lib/asterisk/ /home/asterisk . (the other places will likely be already in that RK checker).
Needing a stopper in an OUTPUT chain would presume acquiescence of a possible continuing compromise, but if the fix is ‘proper’. it is should not be needed
I put everything behind the firewall hw and left only openvpn open. I hope it’s enough.
I propose to create a script on github for the diagnosis and cleaning of the installations. So too we victims can have our say.
@dicko With regards to rootkit checkers are you suggesting this is something that FPBX should include in their distro or saying admins should add it manually (which, of course, if not included in the distro…)
The opposite. The firewall doesn’t care about invading rules in the OUTPUT chain. And even if it did, just enable custom rules and the check is disabled.
A quick script that is untested but should generally work
This changes all (pj)sip secrets. You will want to apply config after and regenerate any provisioning files. This does not give any form of feedback so to get the new secrets you will have to get them from the database or by going to each extension.
This does NOT touch trunks. You want to regenerate credentials with your sip provider
All devices will 401 after running this and reloading if they try to re-register with the old credentials.
THIS MAY TRIGGER FAIL2BAN!
Should go without saying but:
Use on a system that has been cleaned of the hacked code
This comes without any form of support or warranty