Hackfut Security File Manager
Current Path:
/usr/lib/python2.6/site-packages/supervisor/medusa
usr
/
lib
/
python2.6
/
site-packages
/
supervisor
/
medusa
/
📁
..
📄
__init__.py
(128 B)
📄
__init__.pyc
(277 B)
📄
__init__.pyo
(277 B)
📄
auth_handler.py
(4.63 KB)
📄
auth_handler.pyc
(4.41 KB)
📄
auth_handler.pyo
(4.41 KB)
📄
chat_server.py
(4.43 KB)
📄
chat_server.pyc
(6.28 KB)
📄
chat_server.pyo
(6.28 KB)
📄
counter.py
(1.41 KB)
📄
counter.pyc
(1.99 KB)
📄
counter.pyo
(1.99 KB)
📄
default_handler.py
(6.18 KB)
📄
default_handler.pyc
(4.92 KB)
📄
default_handler.pyo
(4.92 KB)
📄
event_loop.py
(2.91 KB)
📄
event_loop.pyc
(3.43 KB)
📄
event_loop.pyo
(3.43 KB)
📄
filesys.py
(10.94 KB)
📄
filesys.pyc
(13.28 KB)
📄
filesys.pyo
(13.28 KB)
📄
ftp_server.py
(39.6 KB)
📄
ftp_server.pyc
(33.91 KB)
📄
ftp_server.pyo
(33.91 KB)
📄
http_date.py
(3.33 KB)
📄
http_date.pyc
(3.39 KB)
📄
http_date.pyo
(3.39 KB)
📄
http_server.py
(24.63 KB)
📄
http_server.pyc
(20.96 KB)
📄
http_server.pyo
(20.96 KB)
📄
logger.py
(7.81 KB)
📄
logger.pyc
(10.73 KB)
📄
logger.pyo
(10.73 KB)
📄
m_syslog.py
(7.18 KB)
📄
m_syslog.pyc
(3.91 KB)
📄
m_syslog.pyo
(3.91 KB)
📄
medusa_gif.py
(2.71 KB)
📄
medusa_gif.pyc
(1.13 KB)
📄
medusa_gif.pyo
(1.13 KB)
📄
monitor.py
(10.79 KB)
📄
monitor.pyc
(12 KB)
📄
monitor.pyo
(12 KB)
📄
monitor_client.py
(3.2 KB)
📄
monitor_client.pyc
(5.26 KB)
📄
monitor_client.pyo
(5.26 KB)
📄
monitor_client_win32.py
(1.3 KB)
📄
monitor_client_win32.pyc
(2.04 KB)
📄
monitor_client_win32.pyo
(2.04 KB)
📄
producers.py
(9.22 KB)
📄
producers.pyc
(11.36 KB)
📄
producers.pyo
(11.36 KB)
📄
put_handler.py
(3.25 KB)
📄
put_handler.pyc
(3.43 KB)
📄
put_handler.pyo
(3.43 KB)
📄
redirecting_handler.py
(1.37 KB)
📄
redirecting_handler.pyc
(2.11 KB)
📄
redirecting_handler.pyo
(2.11 KB)
📄
resolver.py
(15.19 KB)
📄
resolver.pyc
(12.11 KB)
📄
resolver.pyo
(12.11 KB)
📄
rpc_client.py
(9.45 KB)
📄
rpc_client.pyc
(10.1 KB)
📄
rpc_client.pyo
(10.1 KB)
📄
rpc_server.py
(9.72 KB)
📄
rpc_server.pyc
(9.31 KB)
📄
rpc_server.pyo
(9.31 KB)
📄
script_handler.py
(6.4 KB)
📄
script_handler.pyc
(6.5 KB)
📄
script_handler.pyo
(6.5 KB)
📄
setup.py
(496 B)
📄
setup.pyc
(729 B)
📄
setup.pyo
(729 B)
📄
status_handler.py
(9.13 KB)
📄
status_handler.pyc
(9.45 KB)
📄
status_handler.pyo
(9.45 KB)
📄
unix_user_handler.py
(2.26 KB)
📄
unix_user_handler.pyc
(2.31 KB)
📄
unix_user_handler.pyo
(2.31 KB)
📄
virtual_handler.py
(1.68 KB)
📄
virtual_handler.pyc
(3.09 KB)
📄
virtual_handler.pyo
(3.09 KB)
📄
xmlrpc_handler.py
(2.88 KB)
📄
xmlrpc_handler.pyc
(3.7 KB)
📄
xmlrpc_handler.pyo
(3.7 KB)
Editing: script_handler.py
# -*- Mode: Python -*- # This is a simple python server-side script handler. # A note about performance: This is really only suited for 'fast' # scripts: The script should generate its output quickly, since the # whole web server will stall otherwise. This doesn't mean you have # to write 'fast code' or anything, it simply means that you shouldn't # call any long-running code, [like say something that opens up an # internet connection, or a database query that will hold up the # server]. If you need this sort of feature, you can support it using # the asynchronous I/O 'api' that the rest of medusa is built on. [or # you could probably use threads] # Put your script into your web docs directory (like a cgi-bin # script), make sure it has the correct extension [see the overridable # script_handler.extension member below]. # # There's lots of things that can be done to tweak the restricted # execution model. Also, of course you could just use 'execfile' # instead (this is now the default, see class variable # script_handler.restricted) import rexec import re import string import StringIO import sys import counter import default_handler import producers unquote = default_handler.unquote class script_handler: extension = 'mpy' restricted = 0 script_regex = re.compile ( r'.*/([^/]+\.%s)' % extension, re.IGNORECASE ) def __init__ (self, filesystem): self.filesystem = filesystem self.hits = counter.counter() self.exceptions = counter.counter() def match (self, request): [path, params, query, fragment] = request.split_uri() m = self.script_regex.match (path) return (m and (m.end() == len(path))) def handle_request (self, request): [path, params, query, fragment] = request.split_uri() while path and path[0] == '/': path = path[1:] if '%' in path: path = unquote (path) if not self.filesystem.isfile (path): request.error (404) return else: self.hits.increment() request.script_filename = self.filesystem.translate (path) if request.command in ('PUT', 'POST'): # look for a Content-Length header. cl = request.get_header ('content-length') length = int(cl) if not cl: request.error (411) else: collector (self, length, request) else: self.continue_request ( request, StringIO.StringIO() # empty stdin ) def continue_request (self, request, stdin): temp_files = stdin, StringIO.StringIO(), StringIO.StringIO() old_files = sys.stdin, sys.stdout, sys.stderr if self.restricted: r = rexec.RExec() try: sys.request = request sys.stdin, sys.stdout, sys.stderr = temp_files try: if self.restricted: r.s_execfile (request.script_filename) else: execfile (request.script_filename) request.reply_code = 200 except: request.reply_code = 500 self.exceptions.increment() finally: sys.stdin, sys.stdout, sys.stderr = old_files del sys.request i,o,e = temp_files if request.reply_code != 200: s = e.getvalue() else: s = o.getvalue() request['Content-Length'] = len(s) request.push (s) request.done() def status (self): return producers.simple_producer ( '<li>Server-Side Script Handler' + '<ul>' + ' <li><b>Hits:</b> %s' % self.hits + ' <li><b>Exceptions:</b> %s' % self.exceptions + '</ul>' ) class persistent_script_handler: def __init__ (self): self.modules = {} self.hits = counter.counter() self.exceptions = counter.counter() def add_module (self, name, module): self.modules[name] = module def del_module (self, name): del self.modules[name] def match (self, request): [path, params, query, fragment] = request.split_uri() parts = string.split (path, '/') if (len(parts)>1) and self.modules.has_key (parts[1]): module = self.modules[parts[1]] request.module = module return 1 else: return 0 def handle_request (self, request): if request.command in ('PUT', 'POST'): # look for a Content-Length header. cl = request.get_header ('content-length') length = int(cl) if not cl: request.error (411) else: collector (self, length, request) else: self.continue_request (request, StringIO.StringIO()) def continue_request (self, request, input_data): temp_files = input_data, StringIO.StringIO(), StringIO.StringIO() old_files = sys.stdin, sys.stdout, sys.stderr try: sys.stdin, sys.stdout, sys.stderr = temp_files # provide a default request['Content-Type'] = 'text/html' try: request.module.main (request) request.reply_code = 200 except: request.reply_code = 500 self.exceptions.increment() finally: sys.stdin, sys.stdout, sys.stderr = old_files i,o,e = temp_files if request.reply_code != 200: s = e.getvalue() else: s = o.getvalue() request['Content-Length'] = len(s) request.push (s) request.done() class collector: def __init__ (self, handler, length, request): self.handler = handler self.request = request self.request.collector = self self.request.channel.set_terminator (length) self.buffer = StringIO.StringIO() def collect_incoming_data (self, data): self.buffer.write (data) def found_terminator (self): self.buffer.seek(0) self.request.collector = None self.request.channel.set_terminator ('\r\n\r\n') self.handler.continue_request ( self.request, self.buffer )
Upload File
Create Folder