public function before() { $className = $this->get_real_class($this); $controllerName = strtolower($className); // Create vulnerability service. if (!isset($this->pixie->vulnService)) { $this->vulninjection = $this->pixie->vulninjection->service($controllerName); $this->pixie->setVulnService($this->vulninjection); } else { $this->vulninjection = $this->pixie->vulnService; $this->pixie->vulnService->loadAndAddChildContext($controllerName); } $this->vulninjection->getConfig()->getCurrentContext()->setRequest($this->request); // Switch vulnerability config to the controller level $this->vulninjection->goDown($controllerName); if ($this->mustCheckSessionId()) { $actionContext = $this->vulninjection->getCurrentContext()->getOrCreateChildByName($this->request->param('action')); /** @var PHPSessionIdOverflow $sessVuln */ $sessVuln = $actionContext->getVulnerability('PHPSessionIdOverflow'); $sessVuln->fixSession(); } if ($className == 'Install' && in_array($this->request->param('action'), ['index', 'login'])) { $this->installationProcess = true; } try { /** @var Connection $pdov */ $this->pixie->db->get(); } catch (\Exception $e) { $this->pixie->session->set('isInstalled', false); if (!$this->installationProcess) { $this->redirect('/install'); return; } } // Check Hackazon is installed if (!$this->installationProcess && !$this->pixie->session->get('isInstalled')) { try { /** @var Connection $pdov */ $pdov = $this->pixie->db->get(); /** @var \PDO $conn */ $conn = $pdov->conn; $res = $conn->query("SHOW TABLES"); $dbTables = $res->fetchAll(); if (count($dbTables) < 20) { throw new \Exception("Not all tables are existing"); } $this->pixie->session->set('isInstalled', true); } catch (\Exception $e) { $this->pixie->session->set('isInstalled', false); $this->redirect('/install'); return; } } }