You can try to install another clean system and export what you may have and once this new install ready, then use it.
To be honest, the wrong is done and we don’t know what is hacked right now. So, IMHO, no need to get some risk.
Improve you security for your system appplying good rules in the firewall. (the best is , to accept only trusted ip address, and drop the others).
Otherwise, you can compare any settings manually and swap to the new system once ready.
Also, you can use fwconsole ma downloadinstall for all module one by one, and next, take a look your dialpan, sip settings…etc (extensions_custom.conf, sip ,pjsip, manager…etc) if some hacked contexts, manager or devices are present somewhere in your system.
rkhunter is useful to check if there’s some stuff wrong in your system. You can install it even if it’s a little bit old.
Don’t forget to update your system (O.S + Freepbx) as often as possible.