Skip to content

Commit

Permalink
Sheller 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yidas committed Jul 11, 2018
1 parent 16d47ab commit 35c5732
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions sheller.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,65 @@
* Sheller
*
* @author Nick Tsai <[email protected]>
* @version 0.1.0
* @version 0.1.1
*/

// Configuration
$username = 'user';
$password = 'pass';
// sha1 password validation while $password is empty
$hashPassword = 'da39a3ee5e6b4b0d3255cfef95601890afd80709';

/**
* Validation
*/
$authUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '';
$authPW = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '';
$errorFalg = false;
// Conditions
if (!isset($_SERVER['PHP_AUTH_USER'])) {
$errorFalg = true;
}
else if ($authUser != $username) {
$errorFalg = true;
}
else if ($password && $authPW!=$password) {
$errorFalg = true;
}
else if (!$password && sha1($authPW)!=$hashPassword) {
$errorFalg = true;
}
// Check error
if ($errorFalg) {
showLoginDialog();
die('Authorization failed');
}


// Shell route
if (isset($_GET['shell'])) {

$response = shell_exec($_GET['shell']);
}

/**
* Show login dialog
*
* @return void
*/
function showLoginDialog()
{
header('WWW-Authenticate: Basic realm="Sheller"');
header('HTTP/1.0 401 Unauthorized');
}
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<title>Sheller</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
/*!
Expand Down

0 comments on commit 35c5732

Please sign in to comment.