Amportal commands don't work, blank admin web page,

PBX is using Freepbx12 on 32 bit Ubuntu (14.04.1 LTS). Manual install. Getting blank admin gui page, amportal commands return nothing. Asterisk is running. MySQL is running. No calls going through. Rebooting server doesn’t help. Can get into asterisk CLI.

Where do I start?

Contents of freepbx.conf

$amp_conf['AMPDBUSER']  = 'asteriskuser';
$amp_conf['AMPDBPASS']  = 'ommited';
$amp_conf['AMPDBHOST']  = 'localhost';
$amp_conf['AMPDBNAME']  = 'asterisk';
$amp_conf['AMPDBENGINE'] = 'mysql';
$amp_conf['datasource'] = ''; //for sqlite3


Contents of /etc/asterisk/asterisk.conf

astetcdir => /etc/asterisk
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astagidir => /var/lib/asterisk/agi-bin
astspooldir => /var/spool/asterisk
astrundir => /var/run/asterisk
astlogdir => /var/log/asterisk

transmit_silence_during_record = yes

Contents of /usr/local/sbin/amportal were empty. I noticed there was an amportal.bak, so I made a copy and renamed it to amportal. Now when I run amportal it shows as “Please wait…”.

Contents of amportal

#!/usr/bin/env bash

ROOT_UID=0       # root uid is 0
E_NOTROOT=67     # Non-root exit error
# define freepbx config file if not alreaddy set
if [ -z "$FREEPBX_CONF" ]; then
        if [ -e "/etc/freepbx.conf" ]; then
        elif [ -e "/etc/asterisk/freepbx.conf" ]; then

# check to see if we are root
if [ "$UID" -ne "$ROOT_UID" ]
        echo "Sorry, you must be root to run this script."
        exit $E_NOTROOT

# get settings from db/config file

if [[ -e $FREEPBX_CONF && -w "/etc/amportal.conf" && -z "$FORCE_AMPORTAL_CONF" ]]; then        # Check if file exists.

        php -r > /dev/null 2>&1
        if [ $? -eq 0 ]; then
                echo "Please wait..."
                `php -r '
                $bootstrap_settings["freepbx_auth"] = false;
                $bootstrap_settings["skip_astman"] = true;
                $restrict_mods = true;
                if ([email protected]_once(getenv("FREEPBX_CONF") ? getenv("FREEPBX_CONF") : "/etc/freepbx.conf")) {
                foreach($amp_conf as $key => $val) {
                        $val = str_replace(array("\r", "\n", "\r\n"), ",", $val);
                        if (is_bool($val)) {
                                echo "export " . trim($key) . "=" . ($val?"TRUE":"FALSE") ."\n";
                        } else {
                                echo "export " . trim($key) . "=" . escapeshellcmd(trim($val)) ."\n";
        elif [ -e "/var/lib/asterisk/bin/gen_amp_conf.php" ]; then
                echo "Fetching FreePBX settings with gen_amp_conf.php.."
        elif [ -e "/etc/amportal.conf" ]; then # Check if file exists.
                echo "Fetching settings from amportal.conf file.."
                . /etc/amportal.conf
                echo "FreePBX settings could not be fetched and no backup config file found!";
                echo "Have you installed FreePBX?";
elif [ -e "/etc/amportal.conf" ]; then # Check if file exists.
        . /etc/amportal.conf
        echo "FreePBX config file not found!";
        echo "Have you installed FreePBX?";

if [ -x ${AMPBIN}/freepbx_engine ]; then
        ${AMPBIN}/freepbx_engine [email protected]
elif [ -x ${ASTVARLIBDIR}/bin/freepbx_engine ]; then
        ${ASTVARLIBDIR}/bin/freepbx_engine [email protected]
elif [ -x /var/lib/asterisk/bin/freepbx_engine ]; then
        /var/lib/asterisk/bin/freepbx_engine [email protected]
        echo "FATAL: can not find freepbx_engine to start Asterisk"

There is something funky going on in the var/www/ directory. It seems every file in the var/www/ directory is there but showing 0kb, like everything in them got wiped.

Look for hidden files, weird cron jobs, extra dialplan added to extensions_custom.conf, stuff like that. It sounds like your server has been compromised. Did you have the /recordings (old user interface before UCP) enabled? In the past, there were some vulnerabilities there that could allow an attacker to control your system.

The system is not open to the internet, so if it was compromised it would have to be from an internal source. Something happened after I enabled the CDR reports module.

I copied the entire www directory from a similar system and am setting permissions recursively on the folder for 0755 and owner asterisk (since amportal chown isn’t working). Hopefully this works.

The web GUI is partially back up. I can log into it but many of the menu options are greyed out (Asterisk is not running it says, even though it is). Disconnect somewhere between FreePBX and Asterisk?

is asterisk running as root

How can I tell? Sorry I’m not too familiar with Asterisk/FreePBX. Have to do everything manually as none of the amportal commands are working.

Ran amportal a ma refreshsignatures and it found framework signature invalid. Then I did a amportal a reload and results in

Please wait...

Error(s) have occured, the following is the retrieve_conf output:
exit: 255
found language dir fr for directory, not installed on system, skipping
Added to globals: OPERATOR_XTN =
Added to globals: VMX_LOOPS = 1
Added to globals: VMX_OPTS_DOVM =
Added to globals: VMX_OPTS_LOOP =
Added to globals: VMX_REPEAT = 1
Added to globals: VMX_TIMEOUT = 2
Added to globals: VM_DDTYPE = b
Added to globals: VM_GAIN = 12
Added to globals: VM_OPTS = s
Added to globals: ASTETCDIR = /etc/asterisk
Added to globals: ASTMODDIR = /usr/lib/asterisk/modules
Added to globals: ASTVARLIBDIR = /var/lib/asterisk
Added to globals: ASTAGIDIR = /var/lib/asterisk/agi-bin
Added to globals: ASTSPOOLDIR = /var/spool/asterisk
Added to globals: ASTRUNDIR = /var/run/asterisk
Added to globals: ASTLOGDIR = /var/log/asterisk
Added to globals: CWINUSEBUSY = true
Added to globals: AMPMGRUSER = admin
Added to globals: AMPMGRPASS = amp111
Added to globals: AMPDBENGINE = mysql
Added to globals: AMPDBHOST = localhost
Added to globals: AMPDBNAME = asterisk
Added to globals: AMPDBUSER = asteriskuser
Added to globals: AMPDBPASS = ommited
Added to globals: VMX_CONTEXT = from-internal
Added to globals: VMX_PRI = 1
Added to globals: VMX_TIMEDEST_CONTEXT =
Added to globals: VMX_TIMEDEST_EXT = dovm
Added to globals: VMX_TIMEDEST_PRI = 1
Added to globals: VMX_LOOPDEST_CONTEXT =
Added to globals: VMX_LOOPDEST_EXT = dovm
Added to globals: VMX_LOOPDEST_PRI = 1
Added to globals: MIXMON_DIR =
Added to globals: MIXMON_POST =
Added to globals: DIAL_OPTIONS = Ttr
Added to globals: TRUNK_OPTIONS = Tt
Added to globals: TRUNK_RING_TIMER = 300
Added to globals: MIXMON_FORMAT = wav
Added to globals: REC_POLICY = caller
Added to globals: RINGTIMER_DEFAULT = 15
Added to globals: TRANSFER_CONTEXT = from-internal-xfer
PHP Fatal error:  Uncaught exception 'Exception' with message 'Tried to remove key noload from section modules, but that section doesn't exist' in /var/www/html/admin/libraries/BMO/ConfigFile.class.php:79
Stack trace:
#0 /var/www/html/admin/libraries/BMO/ModulesConf.class.php(63): ConfigFile->removeEntry('modules', 'noload', '')
#1 /var/www/html/admin/modules/core/ ModulesConf->removenoload('')
#2 /var/www/html/admin/libraries/BMO/FileHooks.class.php(100): FreePBX\modules\Core\PJSip->writeConfig(Array)
#3 /var/www/html/admin/libraries/BMO/FileHooks.class.php(25): FileHooks->processNewHooks()
#4 /var/lib/asterisk/bin/retrieve_conf(740): FileHooks->processFileHooks(Array)
#5 {main}
  thrown in /var/www/html/admin/libraries/BMO/ConfigFile.class.php on line 79

Ended up having to replace the modules.conf in etc/asterisk as it had one line. Asterisk and FreePBX seem to be working and now I can hit “apply config”. Calls are working now too.

;          Do NOT edit this file as it is auto-generated by FreePBX.             ;
; For information on adding additional paramaters to this file, please visit the ;
; wiki page, or ask on IRC. This file was created by the new FreePBX ;
; BMO - Big Module Object. Any similarity in naming with BMO from Adventure Time ;
; is totally deliberate.                                                         ;

preload =
preload =
noload =
noload =
noload =
noload =
noload =
noload =
noload =
noload =
noload =
noload =
noload = 
noload = 
noload =
noload =
noload =
noload =
load =
load =
load =
load =