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: status_handler.py
# -*- Mode: Python -*- VERSION_STRING = "$Id: status_handler.py,v 1.1.1.1 2006/06/26 06:36:05 chrism Exp $" # # medusa status extension # import string import time import re from cgi import escape import asyncore import http_server import medusa_gif import producers from counter import counter START_TIME = long(time.time()) class status_extension: hit_counter = counter() def __init__ (self, objects, statusdir='/status', allow_emergency_debug=0): self.objects = objects self.statusdir = statusdir self.allow_emergency_debug = allow_emergency_debug # We use /status instead of statusdir here because it's too # hard to pass statusdir to the logger, who makes the HREF # to the object dir. We don't need the security-through- # obscurity here in any case, because the id is obscurity enough self.hyper_regex = re.compile('/status/object/([0-9]+)/.*') self.hyper_objects = [] for object in objects: self.register_hyper_object (object) def __repr__ (self): return '<Status Extension (%s hits) at %x>' % ( self.hit_counter, id(self) ) def match (self, request): path, params, query, fragment = request.split_uri() # For reasons explained above, we don't use statusdir for /object return (path[:len(self.statusdir)] == self.statusdir or path[:len("/status/object/")] == '/status/object/') # Possible Targets: # /status # /status/channel_list # /status/medusa.gif # can we have 'clickable' objects? # [yes, we can use id(x) and do a linear search] # Dynamic producers: # HTTP/1.0: we must close the channel, because it's dynamic output # HTTP/1.1: we can use the chunked transfer-encoding, and leave # it open. def handle_request (self, request): [path, params, query, fragment] = request.split_uri() self.hit_counter.increment() if path == self.statusdir: # and not a subdirectory up_time = string.join (english_time (long(time.time()) - START_TIME)) request['Content-Type'] = 'text/html' request.push ( '<html>' '<title>Medusa Status Reports</title>' '<body bgcolor="#ffffff">' '<h1>Medusa Status Reports</h1>' '<b>Up:</b> %s' % up_time ) for i in range(len(self.objects)): request.push (self.objects[i].status()) request.push ('<hr>\r\n') request.push ( '<p><a href="%s/channel_list">Channel List</a>' '<hr>' '<img src="%s/medusa.gif" align=right width=%d height=%d>' '</body></html>' % ( self.statusdir, self.statusdir, medusa_gif.width, medusa_gif.height ) ) request.done() elif path == self.statusdir + '/channel_list': request['Content-Type'] = 'text/html' request.push ('<html><body>') request.push(channel_list_producer(self.statusdir)) request.push ( '<hr>' '<img src="%s/medusa.gif" align=right width=%d height=%d>' % ( self.statusdir, medusa_gif.width, medusa_gif.height ) + '</body></html>' ) request.done() elif path == self.statusdir + '/medusa.gif': request['Content-Type'] = 'image/gif' request['Content-Length'] = len(medusa_gif.data) request.push (medusa_gif.data) request.done() elif path == self.statusdir + '/close_zombies': message = ( '<h2>Closing all zombie http client connections...</h2>' '<p><a href="%s">Back to the status page</a>' % self.statusdir ) request['Content-Type'] = 'text/html' request['Content-Length'] = len (message) request.push (message) now = int (time.time()) for channel in asyncore.socket_map.keys(): if channel.__class__ == http_server.http_channel: if channel != request.channel: if (now - channel.creation_time) > channel.zombie_timeout: channel.close() request.done() # Emergency Debug Mode # If a server is running away from you, don't KILL it! # Move all the AF_INET server ports and perform an autopsy... # [disabled by default to protect the innocent] elif self.allow_emergency_debug and path == self.statusdir + '/emergency_debug': request.push ('<html>Moving All Servers...</html>') request.done() for channel in asyncore.socket_map.keys(): if channel.accepting: if type(channel.addr) is type(()): ip, port = channel.addr channel.socket.close() channel.del_channel() channel.addr = (ip, port+10000) fam, typ = channel.family_and_type channel.create_socket (fam, typ) channel.set_reuse_addr() channel.bind (channel.addr) channel.listen(5) else: m = self.hyper_regex.match (path) if m: oid = string.atoi (m.group (1)) for object in self.hyper_objects: if id (object) == oid: if hasattr (object, 'hyper_respond'): object.hyper_respond (self, path, request) else: request.error (404) return def status (self): return producers.simple_producer ( '<li>Status Extension <b>Hits</b> : %s' % self.hit_counter ) def register_hyper_object (self, object): if not object in self.hyper_objects: self.hyper_objects.append (object) import logger class logger_for_status (logger.tail_logger): def status (self): return 'Last %d log entries for: %s' % ( len (self.messages), html_repr (self) ) def hyper_respond (self, sh, path, request): request['Content-Type'] = 'text/plain' messages = self.messages[:] messages.reverse() request.push (lines_producer (messages)) request.done() class lines_producer: def __init__ (self, lines): self.lines = lines def more (self): if self.lines: chunk = self.lines[:50] self.lines = self.lines[50:] return string.join (chunk, '\r\n') + '\r\n' else: return '' class channel_list_producer (lines_producer): def __init__ (self, statusdir): channel_reprs = map ( lambda x: '<' + repr(x)[1:-1] + '>', asyncore.socket_map.values() ) channel_reprs.sort() lines_producer.__init__ ( self, ['<h1>Active Channel List</h1>', '<pre>' ] + channel_reprs + [ '</pre>', '<p><a href="%s">Status Report</a>' % statusdir ] ) def html_repr (object): so = escape (repr (object)) if hasattr (object, 'hyper_respond'): return '<a href="/status/object/%d/">%s</a>' % (id (object), so) else: return so def html_reprs (list, front='', back=''): reprs = map ( lambda x,f=front,b=back: '%s%s%s' % (f,x,b), map (lambda x: escape (html_repr(x)), list) ) reprs.sort() return reprs # for example, tera, giga, mega, kilo # p_d (n, (1024, 1024, 1024, 1024)) # smallest divider goes first - for example # minutes, hours, days # p_d (n, (60, 60, 24)) def progressive_divide (n, parts): result = [] for part in parts: n, rem = divmod (n, part) result.append (rem) result.append (n) return result # b,k,m,g,t def split_by_units (n, units, dividers, format_string): divs = progressive_divide (n, dividers) result = [] for i in range(len(units)): if divs[i]: result.append (format_string % (divs[i], units[i])) result.reverse() if not result: return [format_string % (0, units[0])] else: return result def english_bytes (n): return split_by_units ( n, ('','K','M','G','T'), (1024, 1024, 1024, 1024, 1024), '%d %sB' ) def english_time (n): return split_by_units ( n, ('secs', 'mins', 'hours', 'days', 'weeks', 'years'), ( 60, 60, 24, 7, 52), '%d %s' )
Upload File
Create Folder