Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace App\Site; use App\Entity\Site as SiteEntity; use App\System\CommandExec..
Decoded Output download
<?php
namespace App\Site;
use App\Entity\Site as SiteEntity;
use App\System\CommandExecutor;
use App\System\Command\CreateUserCommand;
use App\System\Command\CreateDirectoryCommand;
use App\System\Command\ServiceReloadCommand;
use App\System\Command\ChownCommand;
use App\System\Command\FindChmodCommand;
use App\System\Command\WriteFileCommand;
use App\Site\Nginx\Vhost\PhpTemplate;
use App\Site\Nginx\Vhost\StaticTemplate;
use App\Site\Nginx\Vhost\NodejsTemplate;
use App\Site\Nginx\Vhost\PythonTemplate;
use App\Site\Nginx\Vhost\ReverseProxyTemplate;
abstract class Creator
{
public const NGINX_VHOST_DIRECTORY = "/etc/nginx/sites-enabled/";
public const NGINX_SSL_CERTIFICATES_DIRECTORY = "/etc/nginx/ssl-certificates/";
public const LOGROTATE_DIRECTORY = "/etc/logrotate.d/";
protected Site $site;
protected CommandExecutor $commandExecutor;
public function __construct(Site $site)
{
$this->site = $site;
$this->commandExecutor = new CommandExecutor();
}
public function createUser(): void
{
goto ed826;
c8ee9:
$createUserCommand->setShell("/bin/bash");
goto a764d;
F9ac3:
$createUserCommand->setPassword($siteUserPassword);
goto c8ee9;
ecab0:
$this->commandExecutor->execute($createUserCommand);
goto Baeac;
C8820:
$siteUserPassword = $this->site->getUserPassword();
goto D4de9;
a09a7:
$createUserCommand = new CreateUserCommand();
goto a0484;
a764d:
$createUserCommand->setSkeletonDirectory($skeletonDirectory);
goto Dd131;
fe006:
$skeletonDirectory = realpath(
dirname(__FILE__) .
"/../../resources/etc/skel/site-user/"
);
goto a09a7;
ed826:
$siteUser = $this->site->getUser();
goto C8820;
a0484:
$createUserCommand->setUserName($siteUser);
goto F9ac3;
Dd131:
$createUserCommand->setHomeDirectory($homeDirectory);
goto A06e9;
D4de9:
$homeDirectory = sprintf("/home/%s", $siteUser);
goto fe006;
A06e9:
$createUserCommand->createHomeDirectory(true);
goto ecab0;
Baeac:
}
public function createRootDirectory()
{
goto ebf9e;
ebf9e:
$rootDirectory = $this->getRootDirectory();
goto aa262;
a1151:
$createRootDirectoryCommand->setDirectory($rootDirectory);
goto D5bc7;
aa262:
$createRootDirectoryCommand = new CreateDirectoryCommand();
goto a1151;
D5bc7:
$this->commandExecutor->execute($createRootDirectoryCommand);
goto a5981;
a5981:
}
public function createNginxVhost(): void
{
goto fe9c1;
B4845:
$vhostTemplate->removeEmptyPlaceholders();
goto fdd3b;
Afd55:
f4b1f:
goto ac8ad;
Fe51e:
$vhostTemplate->build();
goto B4845;
Be2a3:
switch ($this->site->getType()) {
case SiteEntity::TYPE_PHP:
$vhostTemplate = new PhpTemplate($this->site);
goto f4b1f;
case SiteEntity::TYPE_NODEJS:
$vhostTemplate = new NodejsTemplate($this->site);
goto f4b1f;
case SiteEntity::TYPE_STATIC:
$vhostTemplate = new StaticTemplate($this->site);
goto f4b1f;
case SiteEntity::TYPE_PYTHON:
$vhostTemplate = new PythonTemplate($this->site);
goto f4b1f;
case SiteEntity::TYPE_REVERSE_PROXY:
$vhostTemplate = new ReverseProxyTemplate($this->site);
goto f4b1f;
}
goto cdd99;
fdd3b:
$vhostContent = $vhostTemplate->getContent();
goto F5ea6;
cfaf5:
$this->commandExecutor->execute($writeVhostFileCommand);
goto efb4a;
C6e3f:
$writeVhostFileCommand->setFile($vhostFile);
goto F8405;
eab91:
$vhostFile = sprintf(
"%s/%s.conf",
rtrim(self::NGINX_VHOST_DIRECTORY, "/"),
$domainName
);
goto Fe51e;
fe9c1:
$domainName = $this->site->getDomainName();
goto d6efe;
F5ea6:
$writeVhostFileCommand = new WriteFileCommand();
goto C6e3f;
F8405:
$writeVhostFileCommand->setContent($vhostContent);
goto cfaf5;
ac8ad:
$vhostTemplate->setContent($vhostFileContent);
goto eab91;
d6efe:
$vhostFileContent = $this->site->getVhostTemplate();
goto Be2a3;
cdd99:
a3dd5:
goto Afd55;
efb4a:
}
public function createLogrotateFile()
{
goto c145d;
c0e54:
$this->commandExecutor->execute($writeLogrotateFileCommand);
goto acf28;
D6194:
$writeLogrotateFileCommand->setContent($logrotateFileContent);
goto c0e54;
D2e46:
$logrotateTemplateFile = realpath(
dirname(__FILE__) .
"/../../resources/etc/logrotate/template"
);
goto D4391;
c145d:
$siteUser = $this->site->getUser();
goto D2e46;
D259e:
$logrotateFileContent = str_replace(
[
"{{user}}",
"{{group}}",
],
[$siteUser, $siteUser],
$logrotateTemplate
);
goto Af7ff;
Af7ff:
$writeLogrotateFileCommand = new WriteFileCommand();
goto b325b;
D4391:
$logrotateTemplate = file_get_contents($logrotateTemplateFile);
goto B4791;
b325b:
$writeLogrotateFileCommand->setFile($logrotateFile);
goto D6194;
B4791:
$logrotateFile = sprintf(
"%s/%s",
rtrim(self::LOGROTATE_DIRECTORY, "/"),
$siteUser
);
goto D259e;
acf28:
}
public function resetPermissions(): void
{
goto f0e44;
de5a6:
$chownCommand->setFile($homeDirectory);
goto E5c33;
c8f72:
$homeDirectoryChmodCommand->setDirectoryChmod(770);
goto e909a;
A0c80:
$userSshDirectoryChmodCommand->setFileChmod(600);
goto C8cf5;
cfad3:
$chownCommand->setUser($siteUser);
goto C6de9;
a0c03:
$userSshDirectoryChmodCommand->setDirectoryChmod(700);
goto A0c80;
e909a:
$homeDirectoryChmodCommand->setFileChmod(770);
goto B02a8;
a37f9:
$userSshDirectoryChmodCommand = new FindChmodCommand();
goto A2733;
E5c33:
$chownCommand->setRecursive(true);
goto cfad3;
C6de9:
$chownCommand->setGroup($siteUser);
goto d35bc;
d35bc:
$homeDirectoryChmodCommand = new FindChmodCommand();
goto de38f;
de38f:
$homeDirectoryChmodCommand->setFile($homeDirectory);
goto c8f72;
dfcc3:
$homeDirectory = sprintf("/home/%s", $siteUser);
goto Af9a5;
B02a8:
$userSshDirectory = sprintf(
"/home/%s/.ssh",
$siteUser
);
goto a37f9;
f0e44:
$siteUser = $this->site->getUser();
goto dfcc3;
Ff59c:
$this->commandExecutor->execute($homeDirectoryChmodCommand, 90);
goto C3257;
C8cf5:
$this->commandExecutor->execute($chownCommand, 90);
goto Ff59c;
Af9a5:
$chownCommand = new ChownCommand();
goto de5a6;
C3257:
$this->commandExecutor->execute($userSshDirectoryChmodCommand, 90);
goto E7d72;
A2733:
$userSshDirectoryChmodCommand->setFile($userSshDirectory);
goto a0c03;
E7d72:
}
public function reloadNginxService(): void
{
$this->reloadService("nginx");
}
protected function getRootDirectory(): string
{
goto e9d29;
e9f15:
$rootDirectory = $this->site->getRootDirectory();
goto eea54;
e9d29:
$siteUser = $this->site->getUser();
goto e9f15;
C45a2:
return $rootDirectory;
goto F3a5d;
eea54:
$rootDirectory = sprintf(
"/home/%s/htdocs/%s",
$siteUser,
$rootDirectory
);
goto C45a2;
F3a5d:
}
public function createPrivateKeyAndCertificate(): void
{
goto c434f;
d8a99:
$writePrivateKeyFileCommand->setFile($privateKeyFile);
goto D385e;
D30f0:
$this->commandExecutor->execute($writePrivateKeyFileCommand);
goto Ae918;
Ae918:
$this->commandExecutor->execute($writeCertificateFileCommand);
goto b135d;
D385e:
$writePrivateKeyFileCommand->setContent($certificate->getPrivateKey());
goto e35e5;
ad01c:
$privateKeyFile = sprintf(
"%s/%s.key",
rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "/"),
$domainName
);
goto Ccc7e;
c434f:
$domainName = $this->site->getDomainName();
goto dea83;
dea83:
$certificate = $this->site->getCertificate();
goto ad01c;
Ccc7e:
$certificateFile = sprintf(
"%s/%s.crt",
rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "/"),
$domainName
);
goto Ed352;
e35e5:
$writeCertificateFileCommand = new WriteFileCommand();
goto e9b19;
Ed352:
$writePrivateKeyFileCommand = new WriteFileCommand();
goto d8a99;
Ccd61:
$writeCertificateFileCommand->setContent(
$certificate->getCertificate()
);
goto D30f0;
e9b19:
$writeCertificateFileCommand->setFile($certificateFile);
goto Ccd61;
b135d:
}
public function reloadService($serviceName)
{
goto cc049;
Abe38:
Badaf:
goto D67e1;
F8585:
$this->commandExecutor->execute($reloadServiceCommand);
goto Abe38;
cc049:
if (!("dev" != $_ENV["APP_ENV"])) {
goto Badaf;
}
goto E2ff3;
cc71e:
$reloadServiceCommand->setServiceName($serviceName);
goto F8585;
E2ff3:
$reloadServiceCommand = new ServiceReloadCommand();
goto cc71e;
D67e1:
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace App\Site;
use App\Entity\Site as SiteEntity;
use App\System\CommandExecutor;
use App\System\Command\CreateUserCommand;
use App\System\Command\CreateDirectoryCommand;
use App\System\Command\ServiceReloadCommand;
use App\System\Command\ChownCommand;
use App\System\Command\FindChmodCommand;
use App\System\Command\WriteFileCommand;
use App\Site\Nginx\Vhost\PhpTemplate;
use App\Site\Nginx\Vhost\StaticTemplate;
use App\Site\Nginx\Vhost\NodejsTemplate;
use App\Site\Nginx\Vhost\PythonTemplate;
use App\Site\Nginx\Vhost\ReverseProxyTemplate;
abstract class Creator
{
public const NGINX_VHOST_DIRECTORY = "\57\145\x74\x63\57\x6e\x67\x69\156\170\57\x73\151\164\145\163\55\145\x6e\141\x62\x6c\145\144\57";
public const NGINX_SSL_CERTIFICATES_DIRECTORY = "\57\x65\x74\x63\x2f\x6e\x67\151\156\170\57\x73\163\x6c\x2d\x63\x65\162\x74\151\146\151\x63\141\x74\145\163\x2f";
public const LOGROTATE_DIRECTORY = "\x2f\x65\x74\x63\x2f\x6c\157\x67\162\157\164\141\164\x65\x2e\144\x2f";
protected Site $site;
protected CommandExecutor $commandExecutor;
public function __construct(Site $site)
{
$this->site = $site;
$this->commandExecutor = new CommandExecutor();
}
public function createUser(): void
{
goto ed826;
c8ee9:
$createUserCommand->setShell("\x2f\x62\151\156\x2f\x62\x61\163\150");
goto a764d;
F9ac3:
$createUserCommand->setPassword($siteUserPassword);
goto c8ee9;
ecab0:
$this->commandExecutor->execute($createUserCommand);
goto Baeac;
C8820:
$siteUserPassword = $this->site->getUserPassword();
goto D4de9;
a09a7:
$createUserCommand = new CreateUserCommand();
goto a0484;
a764d:
$createUserCommand->setSkeletonDirectory($skeletonDirectory);
goto Dd131;
fe006:
$skeletonDirectory = realpath(
dirname(__FILE__) .
"\x2f\x2e\x2e\x2f\x2e\x2e\x2f\x72\x65\163\157\165\x72\143\145\163\x2f\145\x74\x63\x2f\x73\x6b\x65\x6c\57\163\x69\x74\145\x2d\x75\x73\145\162\57"
);
goto a09a7;
ed826:
$siteUser = $this->site->getUser();
goto C8820;
a0484:
$createUserCommand->setUserName($siteUser);
goto F9ac3;
Dd131:
$createUserCommand->setHomeDirectory($homeDirectory);
goto A06e9;
D4de9:
$homeDirectory = sprintf("\x2f\x68\x6f\155\145\57\45\x73", $siteUser);
goto fe006;
A06e9:
$createUserCommand->createHomeDirectory(true);
goto ecab0;
Baeac:
}
public function createRootDirectory()
{
goto ebf9e;
ebf9e:
$rootDirectory = $this->getRootDirectory();
goto aa262;
a1151:
$createRootDirectoryCommand->setDirectory($rootDirectory);
goto D5bc7;
aa262:
$createRootDirectoryCommand = new CreateDirectoryCommand();
goto a1151;
D5bc7:
$this->commandExecutor->execute($createRootDirectoryCommand);
goto a5981;
a5981:
}
public function createNginxVhost(): void
{
goto fe9c1;
B4845:
$vhostTemplate->removeEmptyPlaceholders();
goto fdd3b;
Afd55:
f4b1f:
goto ac8ad;
Fe51e:
$vhostTemplate->build();
goto B4845;
Be2a3:
switch ($this->site->getType()) {
case SiteEntity::TYPE_PHP:
$vhostTemplate = new PhpTemplate($this->site);
goto f4b1f;
case SiteEntity::TYPE_NODEJS:
$vhostTemplate = new NodejsTemplate($this->site);
goto f4b1f;
case SiteEntity::TYPE_STATIC:
$vhostTemplate = new StaticTemplate($this->site);
goto f4b1f;
case SiteEntity::TYPE_PYTHON:
$vhostTemplate = new PythonTemplate($this->site);
goto f4b1f;
case SiteEntity::TYPE_REVERSE_PROXY:
$vhostTemplate = new ReverseProxyTemplate($this->site);
goto f4b1f;
}
goto cdd99;
fdd3b:
$vhostContent = $vhostTemplate->getContent();
goto F5ea6;
cfaf5:
$this->commandExecutor->execute($writeVhostFileCommand);
goto efb4a;
C6e3f:
$writeVhostFileCommand->setFile($vhostFile);
goto F8405;
eab91:
$vhostFile = sprintf(
"\x25\x73\x2f\x25\163\x2e\x63\x6f\x6e\x66",
rtrim(self::NGINX_VHOST_DIRECTORY, "\57"),
$domainName
);
goto Fe51e;
fe9c1:
$domainName = $this->site->getDomainName();
goto d6efe;
F5ea6:
$writeVhostFileCommand = new WriteFileCommand();
goto C6e3f;
F8405:
$writeVhostFileCommand->setContent($vhostContent);
goto cfaf5;
ac8ad:
$vhostTemplate->setContent($vhostFileContent);
goto eab91;
d6efe:
$vhostFileContent = $this->site->getVhostTemplate();
goto Be2a3;
cdd99:
a3dd5:
goto Afd55;
efb4a:
}
public function createLogrotateFile()
{
goto c145d;
c0e54:
$this->commandExecutor->execute($writeLogrotateFileCommand);
goto acf28;
D6194:
$writeLogrotateFileCommand->setContent($logrotateFileContent);
goto c0e54;
D2e46:
$logrotateTemplateFile = realpath(
dirname(__FILE__) .
"\57\x2e\56\x2f\56\x2e\57\x72\145\163\x6f\165\x72\x63\145\163\57\145\x74\x63\57\x6c\x6f\x67\162\157\164\141\x74\145\57\164\x65\155\160\154\x61\x74\x65"
);
goto D4391;
c145d:
$siteUser = $this->site->getUser();
goto D2e46;
D259e:
$logrotateFileContent = str_replace(
[
"\x7b\x7b\165\163\x65\x72\x7d\175",
"\x7b\173\x67\162\157\x75\160\175\x7d",
],
[$siteUser, $siteUser],
$logrotateTemplate
);
goto Af7ff;
Af7ff:
$writeLogrotateFileCommand = new WriteFileCommand();
goto b325b;
D4391:
$logrotateTemplate = file_get_contents($logrotateTemplateFile);
goto B4791;
b325b:
$writeLogrotateFileCommand->setFile($logrotateFile);
goto D6194;
B4791:
$logrotateFile = sprintf(
"\x25\x73\57\x25\x73",
rtrim(self::LOGROTATE_DIRECTORY, "\57"),
$siteUser
);
goto D259e;
acf28:
}
public function resetPermissions(): void
{
goto f0e44;
de5a6:
$chownCommand->setFile($homeDirectory);
goto E5c33;
c8f72:
$homeDirectoryChmodCommand->setDirectoryChmod(770);
goto e909a;
A0c80:
$userSshDirectoryChmodCommand->setFileChmod(600);
goto C8cf5;
cfad3:
$chownCommand->setUser($siteUser);
goto C6de9;
a0c03:
$userSshDirectoryChmodCommand->setDirectoryChmod(700);
goto A0c80;
e909a:
$homeDirectoryChmodCommand->setFileChmod(770);
goto B02a8;
a37f9:
$userSshDirectoryChmodCommand = new FindChmodCommand();
goto A2733;
E5c33:
$chownCommand->setRecursive(true);
goto cfad3;
C6de9:
$chownCommand->setGroup($siteUser);
goto d35bc;
d35bc:
$homeDirectoryChmodCommand = new FindChmodCommand();
goto de38f;
de38f:
$homeDirectoryChmodCommand->setFile($homeDirectory);
goto c8f72;
dfcc3:
$homeDirectory = sprintf("\57\x68\157\155\x65\x2f\45\x73", $siteUser);
goto Af9a5;
B02a8:
$userSshDirectory = sprintf(
"\x2f\150\157\x6d\145\x2f\x25\163\x2f\56\x73\x73\150",
$siteUser
);
goto a37f9;
f0e44:
$siteUser = $this->site->getUser();
goto dfcc3;
Ff59c:
$this->commandExecutor->execute($homeDirectoryChmodCommand, 90);
goto C3257;
C8cf5:
$this->commandExecutor->execute($chownCommand, 90);
goto Ff59c;
Af9a5:
$chownCommand = new ChownCommand();
goto de5a6;
C3257:
$this->commandExecutor->execute($userSshDirectoryChmodCommand, 90);
goto E7d72;
A2733:
$userSshDirectoryChmodCommand->setFile($userSshDirectory);
goto a0c03;
E7d72:
}
public function reloadNginxService(): void
{
$this->reloadService("\x6e\x67\x69\156\170");
}
protected function getRootDirectory(): string
{
goto e9d29;
e9f15:
$rootDirectory = $this->site->getRootDirectory();
goto eea54;
e9d29:
$siteUser = $this->site->getUser();
goto e9f15;
C45a2:
return $rootDirectory;
goto F3a5d;
eea54:
$rootDirectory = sprintf(
"\x2f\150\157\x6d\145\57\45\163\57\x68\x74\144\x6f\x63\x73\57\x25\x73",
$siteUser,
$rootDirectory
);
goto C45a2;
F3a5d:
}
public function createPrivateKeyAndCertificate(): void
{
goto c434f;
d8a99:
$writePrivateKeyFileCommand->setFile($privateKeyFile);
goto D385e;
D30f0:
$this->commandExecutor->execute($writePrivateKeyFileCommand);
goto Ae918;
Ae918:
$this->commandExecutor->execute($writeCertificateFileCommand);
goto b135d;
D385e:
$writePrivateKeyFileCommand->setContent($certificate->getPrivateKey());
goto e35e5;
ad01c:
$privateKeyFile = sprintf(
"\x25\x73\57\45\163\56\x6b\x65\x79",
rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "\57"),
$domainName
);
goto Ccc7e;
c434f:
$domainName = $this->site->getDomainName();
goto dea83;
dea83:
$certificate = $this->site->getCertificate();
goto ad01c;
Ccc7e:
$certificateFile = sprintf(
"\45\163\x2f\x25\x73\56\x63\162\164",
rtrim(self::NGINX_SSL_CERTIFICATES_DIRECTORY, "\x2f"),
$domainName
);
goto Ed352;
e35e5:
$writeCertificateFileCommand = new WriteFileCommand();
goto e9b19;
Ed352:
$writePrivateKeyFileCommand = new WriteFileCommand();
goto d8a99;
Ccd61:
$writeCertificateFileCommand->setContent(
$certificate->getCertificate()
);
goto D30f0;
e9b19:
$writeCertificateFileCommand->setFile($certificateFile);
goto Ccd61;
b135d:
}
public function reloadService($serviceName)
{
goto cc049;
Abe38:
Badaf:
goto D67e1;
F8585:
$this->commandExecutor->execute($reloadServiceCommand);
goto Abe38;
cc049:
if (!("\x64\145\x76" != $_ENV["\101\x50\x50\137\x45\116\x56"])) {
goto Badaf;
}
goto E2ff3;
cc71e:
$reloadServiceCommand->setServiceName($serviceName);
goto F8585;
E2ff3:
$reloadServiceCommand = new ServiceReloadCommand();
goto cc71e;
D67e1:
}
}
Function Calls
None |
Stats
MD5 | 6218e0e05c3763a9bec9b95aeb31b2e5 |
Eval Count | 0 |
Decode Time | 56 ms |