Home / os / win7

[webapps / 0day] - MediaCore 0.8.2 backup restore 0-day expl

Posted on 31 October 2010

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8' /><meta http-equiv='Content-Language' content='en' /><title>MediaCore 0.8.2 backup restore 0-day exploit | Inj3ct0r - exploit database : vulnerability : 0day : shellcode</title><meta name='description' content='MediaCore 0.8.2 backup restore 0-day exploit by indoushka in webapps / 0day | Inj3ct0r - exploit database : vulnerability : 0day : shellcode' /><link rel='shortcut icon' href='/favicon.ico' type='image/x-icon' /><link rel='alternate' type='application/rss+xml' title='Inj3ct0r RSS' href='/rss' /><script type='text/javascript'>var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-12725838-1"]);_gaq.push(["_trackPageview"]);(function(){var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);})();</script></head><body><pre>============================================ MediaCore 0.8.2 backup restore 0-day exploit ============================================ 1-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=0 0 _ __ __ __ 1 1 /&#039; __ /&#039;__` / \__ /&#039;__` 0 0 /\_, ___ /\_/\_ ___ ,_/ / _ ___ 1 1 /_/ /&#039; _ ` / /_/_\_&lt;_ /&#039;___ / /`&#039;__ 0 0 / / / / \__/ \_ \_ / 1 1 \_ \_ \_\_ \____/ \____\ \__\ \____/ \_ 0 0 /_//_//_/ \_ /___/ /____/ /__/ /___/ /_/ 1 1 \____/ &gt;&gt; Exploit database separated by exploit 0 0 /___/ type (local, remote, DoS, etc.) 1 1 1 0 [+] Site : Inj3ct0r.com 0 1 [+] Support e-mail : submit[at]inj3ct0r.com 1 0 0 1 ####################################### 1 0 I&#039;m indoushka member from Inj3ct0r Team 1 1 ####################################### 0 0-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-1 ######################################################################## # Vendor: http://getmediacore.com/requests # Date: 2010-09-27 # Author : indoushka # Thanks to : Dz-Ghost Team # Contact : 00213771818860 # Tested on : Back|track 4 ######################################################################## # Exploit By indoushka ------------- #!/usr/bin/env python2.5 # -*- coding: utf-8 -*- from mediacore.lib.commands import LoadAppCommand, load_app _script_name = &quot;Backup &amp; Restore Script&quot; _script_description = &quot;&quot;&quot; Use this script to backup and restore the important tables from a MediaCore deployment, and to restore the files associated with the data in those tables. &quot;&quot;&quot; DEBUG = False if __name__ == &quot;__main__&quot;: cmd = LoadAppCommand(_script_name, _script_description) cmd.parser.add_option(&#039;-d&#039;, &#039;--dump&#039;, dest=&#039;dump_to&#039;, help=&#039;Dump the selected tables to OUTPUT_FILE&#039;, metavar=&#039;OUTPUT_FILE&#039;) cmd.parser.add_option(&#039;-r&#039;, &#039;--read&#039;, dest=&#039;read_from&#039;, help=&#039;Update the database from the dump in INPUT_FILE&#039;, metavar=&#039;INPUT_FILE&#039;) cmd.parser.add_option(&#039;--debug&#039;, action=&#039;store_true&#039;, dest=&#039;debug&#039;, help=&#039;Write debug output to STDOUT.&#039;, default=False) load_app(cmd) DEBUG = cmd.options.debug # BEGIN SCRIPT &amp; SCRIPT SPECIFIC IMPORTS import os import sys import select import shutil import commands import subprocess from pylons import config from webob.exc import HTTPNotFound from mediacore.model.meta import DBSession from mediacore.model import * from mediacore.lib import helpers from mediacore.lib.thumbnails import thumb_paths database = &#039;mediacore&#039; user = &#039;root&#039; password = &#039;&#039; mysqldump_executable = &#039;mysqldump5&#039; mysql_executable = &#039;mysql5&#039; tables = [ &#039;tags&#039;, &#039;settings&#039;, &#039;podcasts&#039;, &#039;categories&#039;, &#039;media&#039;, &#039;comments&#039;, &#039;media_categories&#039;, &#039;media_files&#039;, &#039;media_tags&#039;, ] # Data directories: m_img_dir = config[&#039;image_dir&#039;] + os.sep + Media._thumb_dir p_img_dir = config[&#039;image_dir&#039;] + os.sep + Podcast._thumb_dir media_dir = config[&#039;media_dir&#039;] deleted_dir = config.get(&#039;deleted_files_dir&#039;, &#039;&#039;) if deleted_dir: m_deleted_dir = deleted_dir + os.sep + &#039;media&#039; p_deleted_dir = deleted_dir + os.sep + &#039;podcasts&#039; def poll_for_content(file_descriptor, timeout=0): ready = select.select([file_descriptor], [], [], timeout)[0] return ready and ready[0] == file_descriptor def dump_backup_file(filename): # The tables we want to save. # In an order that will let them be created without Foreign Key problems. dump_cmd = &quot;%s --user=%s --password=%s --compact %s %s&quot; % ( mysqldump_executable, user, password, database, &quot; &quot;.join(tables) ) perl_cmd = &#039;perl -p -e &quot;s:),(:),\n(:g&quot;&#039; exc_string = &quot;%s | %s&quot; % (dump_cmd, perl_cmd) if DEBUG: print &quot;Executing:&quot; print &quot; &quot; + exc_string print &quot;&quot; status, output = commands.getstatusoutput(exc_string) try: f = open(filename, &quot;w&quot;) f.write(output) f.close() output = &quot;Success writing to file: %s&quot; % filename except: output = &quot;Error writing to file: %s&quot; % filename status = 1 return status, output def restore_backup_file(filename): # Prepare the statements to lock, unlock, and drop all of the tables charset_stmt = &quot;SET character_set_client=utf8;&quot; lock_stmt = &quot;START TRANSACTION;&quot; disable_keys_stmt = &quot;SET FOREIGN_KEY_CHECKS=0;&quot; enable_keys_stmt = &quot;SET FOREIGN_KEY_CHECKS=1;&quot; commit_stmt = &quot;COMMIT;&quot; rollback_stmt = &quot;ROLLBACK;&quot; drop_stmt = &quot; &quot;.join([ &#039;DROP TABLE IF EXISTS %s;&#039; % t for t in tables ]) # Prepare the statements to create tables + keys + load data print &quot;Loading new data from %s...&quot; % filename try: f = open(filename) file_input = f.read() f.close() except Exception, e: return 1, &quot;Error reading data from %s&quot; % filename print &quot;Loaded data.&quot; # Put all the SQL in order in one big string. input = &quot; &quot;.join(( charset_stmt, lock_stmt, disable_keys_stmt, drop_stmt, file_input, enable_keys_stmt, )) # Prepare the command to execute MySQL cmd_args = [ mysql_executable, &quot;--user=%s&quot; % user, &quot;--password=%s&quot; % password, &quot;--force&quot;, # Don&#039;t quit if a syntax error is encountered database, ] print &quot;Executing:&quot; print &quot; &quot; + &quot; &quot;.join(cmd_args) # Run mysql and feed it the SQL as STDIN process = subprocess.Popen( cmd_args, stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE ) stdoutdata, stderrdata = &#039;&#039;, &#039;&#039; try: print &quot;Sending input data...&quot; if DEBUG: print &quot;Sending MySQL commands via STDIN:&quot; print &quot; &quot; + input.replace(&quot; &quot;,&quot; &quot;) print &quot;&quot; process.stdin.write(input) if poll_for_content(process.stderr, timeout=2): raise Exception(&#039;Error occurred.&#039;) print &quot;Committing changes...&quot; # Attempt to commit the changes. stdoutdata, stderrdata = process.communicate(&quot; &quot;+commit_stmt) status = 0 except Exception, e: print &quot;Sending or comitting data failed :( Rolling back any changes.&quot; # Oh no! An Error occurred. Roll back the transaction. stdoutdata, stderrdata = process.communicate(&quot; &quot;+rollback_stmt) status = 1 output = &quot;&quot; if stdoutdata: output = &quot;STDOUT: &quot; + stdoutdata.replace(&quot; &quot;, &quot; &quot;) if stderrdata: output += &quot; STDERR: &quot; + stderrdata.replace(&quot; &quot;, &quot; &quot;) return status, output def remove_unnecessary_files(): # Move all media files and thumbnail files into &#039;deleted&#039; folder. # XXX: don&#039;t run if deleted_dir is not set! if not deleted_dir: return for media in DBSession.query(Media).all(): file_paths = thumb_paths(media).values() for f in media.files: file_paths.append(f.file_path) helpers.delete_files(file_paths, &#039;media&#039;) for podcast in DBSession.query(Podcast).all(): file_paths = thumb_paths(podcast).values() helpers.delete_files(file_paths, &#039;podcasts&#039;) def restore_necessary_files(): # Restore the appropriate media files and thumbnail files # for any media currently in the database. # Use the python models to do this. if not deleted_dir: return filename_pairs = [] for media in DBSession.query(Media).all(): for thumb in thumb_paths(media).values(): filename_pairs.append(( thumb.replace(m_img_dir, m_deleted_dir), thumb )) for file in media.files: if file.file_path: filename_pairs.append(( file.file_path.replace(media_dir, m_deleted_dir), file.file_path )) for podcast in DBSession.query(Podcast).all(): for thumb in thumb_paths(podcast).values(): filename_pairs.append(( thumb.replace(p_img_dir, p_deleted_dir), thumb )) for src, dest in filename_pairs: if os.path.exists(src): if DEBUG: print &quot;Moving %s to %s&quot; % (src, dest) shutil.move(src, dest) def main(parser, options): if options.dump_to: status, output = dump_backup_file(options.dump_to) if options.read_from: remove_unnecessary_files() status, output = restore_backup_file(options.read_from) DBSession.commit() # Create a new transaction, to reload the tables for restore_necessary_files() if not options.dump_to and not options.read_from: parser.print_help() print &quot;&quot; status, output = 1, &#039;Incorrect or insufficient arguments provided. &#039; # print output and exit sys.stdout.write(output.strip()) print &quot;&quot; if status == 0: print &quot;Operation completed successfully.&quot; else: print &quot;Error occurred in operation. You can use the --debug flag for more information.&quot; print &quot;&quot; sys.exit(status) if __name__ == &#039;__main__&#039;: main(cmd.parser, cmd.options) http://127.0.0.1/MediaCore-0.8.2/MediaCore-0.8.2/batch-scripts/backup/backup_restore.py # <a href='http://inj3ct0r.com/'>Inj3ct0r.com</a> [2010-10-31]</pre></body></html>

 

TOP