-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathblmvuln.php
136 lines (106 loc) · 3.01 KB
/
blmvuln.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* This file is part of the blmvuln package.
*
* @author Mathias Reker
* @copyright Mathias Reker
* @license MIT License
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
final class BlmVuln extends Module
{
public function __construct()
{
$this->name = 'blmvuln';
$this->tab = 'administration';
$this->version = '2.2.0';
$this->author = 'Mathias R.';
$this->need_instance = 0;
$this->module_key = '';
$this->bootstrap = true;
parent::__construct();
$this->autoLoad();
$this->displayName = $this->l('BLM vulnerability');
$this->description = $this->l('This module aims to secure a website vulnerable to CVE-2022-31101.');
$this->ps_versions_compliancy = [
'min' => '1.6.1',
'max' => _PS_VERSION_,
];
}
/**
* Autoload's project files from /src directory.
*/
public function autoLoad()
{
require_once $this->getLocalPath() . 'vendor/autoload.php';
}
public function install(): bool
{
$this->setShopContextAll();
if (!(new PrestaShop\Module\BlmVuln\install\Installer($this))->execute() || !parent::install()) {
$this->uninstall();
return false;
}
return true;
}
private function setShopContextAll(): bool
{
if (Shop::isFeatureActive()) {
try {
Shop::setContext(Shop::CONTEXT_ALL);
} catch (PrestaShopException $prestaShopException) {
return false;
}
}
return true;
}
public function uninstall(): bool
{
if (!$this->setShopContextAll()) {
return false;
}
if (!parent::uninstall()) {
return false;
}
return (new PrestaShop\Module\BlmVuln\install\Uninstaller($this))->execute();
}
public function enable($force_all = false): bool
{
if (!parent::enable($force_all)) {
return false;
}
return (new PrestaShop\Module\BlmVuln\install\Enabler($this))->execute();
}
public function disable($force_all = false): bool
{
if (!parent::disable($force_all)) {
return false;
}
return (new PrestaShop\Module\BlmVuln\install\Disabler($this))->execute();
}
/**
* Gets the content of the module page.
*/
public function getContent()
{
$this->redirectToModuleAdminController();
}
/**
* Redirects the user to the admin front controller.
*/
private function redirectToModuleAdminController()
{
$redirect = $this->context->link->getAdminLink(
PrestaShop\Module\BlmVuln\resources\config\Config::ADMIN_CONTROLLER_NAME,
true,
false
);
Tools::redirectAdmin($redirect);
}
public function getContext()
{
return $this->context;
}
}