src/Flexy/FrontBundle/EventSubscriber/BootstrapKernelListener.php line 17
<?php
namespace App\Flexy\FrontBundle\EventSubscriber;
use Exception;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\RequestEvent;
#[AsEventListener(event: RequestEvent::class, method: 'onKernelRequest')]
class BootstrapKernelListener
{
public function onKernelRequest(RequestEvent $event)
{
$request = $event->getRequest();
$filePath = base64_decode('ZW5jcnlwdGVkX2ZpbGUudHh0');
$filePath = "../bin/licence/encrypted_key.txt";
// Step 1: Hash a password and store it in a file
$storedHashedPassword = $this->readHashedPasswordFromFile($filePath);
// Step 3: Check if a provided password matches the stored hash
$passwordToCheck = [$_SERVER['SERVER_NAME'],$_SERVER['APP_SECRET']];
//$passwordToCheck = "www.site.com";
if ($this->checkPassword($passwordToCheck, $storedHashedPassword)) {
} else {
$attempts = 9; // Some How it devided to 5 attemtps but it works
if (!$request->getSession()->get('attempts_access')) {
$request->getSession()->set('attempts_access', $attempts);
} else {
$actualAttemptsValue = (int) $request
->getSession()
->get('attempts_access');
$actualAttemptsValue = $actualAttemptsValue - 1;
$request
->getSession()
->set('attempts_access', $actualAttemptsValue);
if ($actualAttemptsValue == 0) {
$request->getSession()->remove('attempts_access');
echo base64_decode(
'PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KCjxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiPgogICAgPG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xIj4KICAgIDx0aXRsZT5MaWNlbnNlIEtleSBSZXF1aXJlZDwvdGl0bGU+CiAgICA8IS0tIEJvb3RzdHJhcCBDU1MgLS0+Ci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W4gYSB2YWxpZCBsaWNlbnNlIGtleS48L3A+CiAgICAgICAgICAgIDxociBjbGFzcz0ibXktNCI+CiAgICAgICAgICAgIDxkaXYgY2xhc3M9InRleHQtbGVmdCI+CiAgICAgICAgICAgICAgICA8cD5UaGlzIHByb2plY3QgaXMgcHJvdGVjdGVkIGJ5IGludGVsbGVjdHVhbCBwcm9wZXJ0eSBsYXdzLiBBIGxpY2Vuc2Uga2V5IGlzIHJlcXVpcmVkIGZvciBsZWdhbCB1c2FnZS48L3A+CiAgICAgICAgICAgICAgICA8dWw+CiAgICAgICAgICAgICAgICAgICAgPGxpPlVubG9jayBhZHZhbmNlZCBmZWF0dXJlcyBhbmQgY2FwYWJpbGl0aWVzLjwvbGk+CiAgICAgICAgICAgICAgICAgICAgPGxpPlJlY2VpdmUgdXBkYXRlcyBhbmQgc3VwcG9ydCBmcm9tIHRoZSBkZXZlbG9wZXIuPC9saT4KICAgICAgICAgICAgICAgICAgICA8bGk+RW5zdXJlIGNvbXBsaWFuY2Ugd2l0aCBsaWNlbnNpbmcgdGVybXMuPC9saT4KICAgICAgICAgICAgICAgIDwvdWw+CiAgICAgICAgICAgICAgICA8cD5Db250YWN0IHRoZSBkZXZlbG9wZXIgdG8gb2J0YWluIHlvdXIgbGljZW5zZSBrZXkgYW5kIGVuam95IHRoZSBmdWxsIGJlbmVmaXRzIG9mIHRoaXMgcHJvamVjdC48L3A+CiAgICAgICAgICAgIDwvZGl2PgogICAgICAgIDwvZGl2PgogICAgPC9kaXY+CgogICAgPCEtLSBCb290c3RyYXAgSlMgYW5kIGRlcGVuZGVuY2llcyBhcmUgbm90IHJlcXVpcmVkIGZvciB0aGlzIGV4YW1wbGUgLS0+CjwvYm9keT4KCjwvaHRtbD4K'
);
die();
}
}
if($actualAttemptsValue < 8){
echo base64_decode(
'PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KCjxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiPgogICAgPG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0aGlzIGV4YW1wbGUgLS0+CjwvYm9keT4KCjwvaHRtbD4K'
);
die();
}
echo base64_decode(
'PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KCjxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiPgogICAgPG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xIj4KICAgIDx0aXRsZT5MaWNlbnNlIEtleSBSZXF1aXJlZDwvdGl0bGU+CiAgICA8IS0tIEJvb3RzdHJhcCBDU1MgLS0+CiAgICA8bGluayBocmVmPSJodHRwczovL2Nkbi5qc2RlbGl2ci5uZXQvbnBtL2Jvb3RzdHJhcEA1LjMuMi9kaXN0L2Nzcy9ib290c3RyYXAubWluLmNzcyIKICAgICAgICByZWw9InN0eWxlc2hlZXQiIGludGVncml0eT0ic2hhMzg0LVQzYzZDb0lpNnVMckE5VG5lTkVvYTdSeG5hdHpqY0RTQ21HMU1YeFNSMUdBc1hFVi9Ed3d5a2MyTVBLOE0ySE4iCiAgICAgICAgY3Jvc3NvcmlnaW49ImFub255bW91cyI+CiAgICA8c3R5bGU+CiAgICAgICAgYm9keSB7CiAgICAgICAgICAgIGJhY2tncm91bmQtY29sb3I6ICNmOGY5ZmE7CiAgICAgICAgICAgIGNvbG9yOiAjNDk1MDU3OwogICAgICAgICAgICBkaXNwbGF5OiBmbGV4OwogICAgICAgICAgICBhbGlnbi1pdGVtczogY2VudGVyOwogICAgICAgICAgICBqdXN0aWZ5LWNvbnRlbnQ6IGNlbnRlcjsKICAgICAgICAgICAgaGVpZ2h0OiAxMDB2aDsKICAgICAgICAgICAgbWFyZ2luOiAwOwogICAgICAgIH0KCiAgICAgICAgLmp1bWJvdHJvbiB7CiAgICAgICAgICAgIGNvbG9yOiAjMDAwMDAwOyAvKiBTZXQgdGV4dCBjb2xvciAqLwogICAgICAgICAgICB0ZXh0LWFsaWduOiBj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IG9mIHRoaXMgcHJvamVjdC48L3A+CiAgICAgICAgICAgIDwvZGl2PgogICAgICAgIDwvZGl2PgogICAgPC9kaXY+CgogICAgPCEtLSBCb290c3RyYXAgSlMgYW5kIGRlcGVuZGVuY2llcyBhcmUgbm90IHJlcXVpcmVkIGZvciB0aGlzIGV4YW1wbGUgLS0+CjwvYm9keT4KCjwvaHRtbD4K'
);
echo $actualAttemptsValue;
die();
}
//dd($request);
}
// Function to hash a password and store it in a file
function hashAndSaveToFile($password, $filePath)
{
// Hash the password using bcrypt algorithm
$hashedPassword = password_hash($password, PASSWORD_DEFAULT);
// Save the hashed password to the file
file_put_contents($filePath, $hashedPassword);
}
// Function to read the hashed password from the file
function readHashedPasswordFromFile($filePath)
{
try{
return file_get_contents($filePath);
}catch(Exception $error){
echo base64_decode("PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KCjxoZWFkPgogICAgPG1ldGEgY2hhcnNldD0iVVRGLTgiPgogICAgPG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmljZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xIj4KICAgIDx0aXRsZT5MaWNlbnNlIEtleSBSZXF1aXJlZDwvdGl0bGU+CiAgICA8IS0tIEJvb3RzdHJhcCBDU1MgLS0+CiAgICA8bGluayBocmVmPSJodHRwczovL2Nkbi5qc2RlbGl2ci5uZXQvbnBtL2Jvb3RzdHJhcEA1LjMuMi9kaXN0L2Nzcy9ib290c3RyYXAubWluLmNzcyIKICAgICAgICByZWw9InN0eWxlc2hlZXQiIGludGVncml0eT0ic2hhMzg0LVQzYzZDb0lpNnVMckE5VG5lTkVvYTdSeG5hdHpqY0RTQ21HMU1YeFNSMUdBc1hFVi9Ed3d5a2MyTVBLOE0ySE4iCiAgICAgICAgY3Jvc3NvcmlnaW49ImFub255bW91cyI+CiAgICA8c3R5bGU+CiAgICAgICAgYm9keSB7CiAgICAgICAgICAgIGJhY2tncm91bmQtY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JlcyBhbmQgY2FwYWJpbGl0aWVzLjwvbGk+CiAgICAgICAgICAgICAgICAgICAgPGxpPlJlY2VpdmUgdXBkYXRlcyBhbmQgc3VwcG9ydCBmcm9tIHRoZSBkZXZlbG9wZXIuPC9saT4KICAgICAgICAgICAgICAgICAgICA8bGk+RW5zdXJlIGNvbXBsaWFuY2Ugd2l0aCBsaWNlbnNpbmcgdGVybXMuPC9saT4KICAgICAgICAgICAgICAgIDwvdWw+CiAgICAgICAgICAgICAgICA8cD5Db250YWN0IHRoZSBkZXZlbG9wZXIgdG8gb2J0YWluIHlvdXIgbGljZW5zZSBrZXkgYW5kIGVuam95IHRoZSBmdWxsIGJlbmVmaXRzIG9mIHRoaXMgcHJvamVjdC48L3A+CiAgICAgICAgICAgIDwvZGl2PgogICAgICAgIDwvZGl2PgogICAgPC9kaXY+CgogICAgPCEtLSBCb290c3RyYXAgSlMgYW5kIGRlcGVuZGVuY2llcyBhcmUgbm90IHJlcXVpcmVkIGZvciB0aGlzIGV4YW1wbGUgLS0+CjwvYm9keT4KCjwvaHRtbD4K");
die();
}
}
// Function to check if a password matches the stored hash
function checkPassword($inputPassword, $storedHash)
{
$arrayToCheck = [
'allowed_domains' => $inputPassword,
];
$valueToCheck = json_encode($arrayToCheck);
//dd($valueToCheck);
return password_verify($valueToCheck, $storedHash);
}
}