← PHP

Executar PHP!!

Lida 5537 vezes

Offline

kingless 
Membro
Mensagens 857 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

Criei um pequeno brinquedo para aqueles que estão a aprender php e não têm onde executar as funções php e para aqueles que querem simplesmente testar um codigo php ou algo assim.

Aqui vai o codigo:

Código: [Seleccione]

<?php
set_time_limit&#40;3&#41;;
header&#40;"Content-Type&#58; text/html"&#41;;
$Comando $_GET['Comando'&#93;; $executar = $_GET['executar'&#93;;
/* Por favor não apaque os creditos do criador */
?>

<title>Terminal PHP - Criado Por Kingless - blastelf@hotmail.com</title>
<style type="text/css">
body {background-color:#FFFFFF; font-family:arial,sans-serif; font-size: 13px; }
form { margin: 0px; padding: 0px; border: 0px; }
textarea {
background-color: #FFFFFF;
color : #000000;
border-style : none;
font-size : 13px;
width: 90%;
height: 200;
}
</style>
<!-- Terminal PHP - Criado Por Kingless - blastelf@hotmail.com -->
<hr color="gray">
<form action="<?__FILE__?>" method="get">
<input type="hidden" name="user_ip" value="<?=$_SERVER['REMOTE_ADDR']?>">
<textarea size="80%" name="Comando"></textarea><br/>
<input type="submit" name="executar" value="Executar!">
<hr color="gray">
<?php
$funcs = array&#40;"exec", "set_time_limit", "system","PHP_DATADIR", "PHP_SYSCONFDIR", "PHP_CONFIG_FILE_PATH", "PHP_EXTENSION_DIR", "PHP_EOL", "PATHINFO_", "mysql", '$PHP_SELF', '$_COOKIE','$_SESSION','$_FILES', '$SERVER_NAME', '$SERVER_SOFTWARE', '$DOCUMENT_ROOT', '$SERVER_ADMIN', '$SERVER_SIGNATURE', '$SERVER_SCRIPTNAME','$PHP_AUTH_USER', '$SCRIPT_FILENAME', "realpath","shell_exec", "PHP_VERSION", "PHP_OS", "fopen", "fsockopen", "file_get_contents", "file", "fwrite", "fgets", "ftp", "opendir", "fgetss", '$_GET', '$_POST', '$_ENV', '$_REQUEST', '$_SERVER', '$HTTP_', "file_put_contents", "fileowner", "mkdir", "DOCUMENT_ROOT", "readfile", "rmdir", "popen", "pathinfo", "fscanf", "fread", "flock", "disk_free_space", "fputs", "disk_total_space", "copy", "dirname", "delete", "chmod", "chown", "file_exists", "rewinddir", "readdir", "chdir", "dir", "getcwd", "scandir", "chroot", "ftp_connect", "ftp_put"&#41;;
if&#40;isset&#40;$executar&#41; AND isset&#40;$Comando&#41;&#41; &#123;
unset&#40;$executar&#41;;
$executar['strip'&#93; = stripslashes&#40;$Comando&#41;;
while&#40;list&#40;,$func&#41; = each&#40;$funcs&#41;&#41; &#123;
if&#40;strpos&#40;$executar['strip'&#93;, $func&#41;&#41; &#123;
echo&#40;"<b>Warning&#58;</b> A função <b>\"$func\"</b> foi desactivada por razões de segurança.<br /><br /><br />"&#41;;
if&#40;$executar['strip'&#93; != ""&#41; &#123;
echo&#40;"<b>[Codigo&#93;&#58;</b><br /><br />\n"&#41;;
$executar['cor'&#93; = highlight_string&#40;$executar['strip'&#93;&#41;;
$executar['cor'&#93; = explode&#40;"1", $executar['cor'&#93;&#41;;
echo&#40;$executar['cor'&#93;[0&#93;."\n"&#41;;
&#125; 
                      unset&#40;$executar&#41;;
    die&#40;0&#41;;
&#125;
       &#125; 
if&#40;preg_match&#40;"/&#40;system|exec|shell_exec|`|passthru|proc_open|proc_nice|proc_close|file_get_contents|fput|fgets|fsockopen|fopen|file|fwrite&#41;+/i", $executar['strip'&#93;&#41;&#41; &#123;
       
echo&#40;"<b>Warning&#58;</b> Esta função foi desactivada por razões de segurança.<br /><br /><br />"&#41;;
                              
unset&#40;$executar&#41;;
                      die&#40;0&#41;;
 &#125;       
       $executar['CMD'&#93; = exec&#40;"php -r '&#123;$executar['strip'&#93;&#125;'"&#41;;
           if&#40;$executar['CMD'&#93;&#41; &#123;
           echo "<b>[Codigo&#93;&#58;</b><br /><br />";
                                 $executar['cor'&#93; = highlight_string&#40;$executar['strip'&#93;&#41;;
                                  $executar['cor'&#93; = explode&#40;"1", $executar['cor'&#93;&#41;;   
                          echo "&#123;$executar['cor'&#93;[0&#93;&#125;\n<br /><br />";
                    unset&#40;$executar['cor'&#93;[0&#93;&#41;;
                print&#40;"<b>[Resultado&#93;&#58;</b><br /><br />"&#41;;
  print&#40;$executar['CMD'&#93;."\n"&#41;;
 unset&#40;$executar&#41;;
 &#125; else &#123;
       echo&#40;"O processo terminou inesperadamente, verifique o seu codigo!<br /><br /><br />"&#41;;
 if&#40;$executar['strip'&#93; != ""&#41; &#123;
echo&#40;"<b>[Codigo&#93;&#58;</b><br /><br />\n"&#41;;
$executar['cor'&#93; = highlight_string&#40;$executar['strip'&#93;&#41;;
$executar['cor'&#93; = explode&#40;"1", $executar['cor'&#93;&#41;;
echo&#40;$executar['cor'&#93;[0&#93;."\n"&#41;;
&#125;
unset&#40;$executar&#41;;
     die&#40;0&#41;;
             
&#125;   
&#125;
?>



Tenho aqui o codigo ja pronto a testar:

http://213.22.96.78/php.php

Para executar as funções php é so digitar exemplo:

echo "aeiou";

Sem <?php ou ?>

Tutorial de php: http://pt.php.net/manual/pt_BR/language.basic-syntax.php

Espero que isso seje útil !!  :wink:

PS: O codigo não funciona em windows e em certos servidores.
Offline

asturmas 
Administrador
Mensagens 19734 Gostos 50
Feedback +2

Troféus totais: 39
Trófeus: (Ver todos)
Mobile User Windows User Super Combination Combination Topic Starter 100 Poll Votes 50 Poll Votes 10 Poll Votes Poll Voter Poll Starter

Esta interesante
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Excelente mesmo...
Vai-me ser muito util para quando precisar de php na escola...
Offline

kingless 
Membro
Mensagens 857 Gostos 0
Troféus totais: 27
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Poll Starter Level 5 Level 4 Level 3 Level 2 Level 1

Código Actualizado!!  Actualize o seu código devido a falha de segurança que tinha.