Issues (127)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

admin/clone.php (1 issue)

1
<?php declare(strict_types=1);
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * Wgfilemanager module for xoops
14
 *
15
 * @copyright      module for xoops
16
 * @license         GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @author         Wedega - Email:<[email protected]> - Website:<https://wedega.com>
18
 * @version        $Id: 1.0 images.php 1 Mon 2018-03-19 10:04:51Z XOOPS Project (www.xoops.org) $
19
 */
20
21
use Xmf\Request;
22
23
require __DIR__ . '/header.php';
24
// It recovered the value of argument op in URL$
25
$op = Request::getString('op', 'list');
26
27
$templateMain = 'wgfilemanager_admin_clone.tpl';
28
29
switch ($op) {
30
    case 'list':
31
    default:
32
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('clone.php'));
33
        require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
34
        $form  = new \XoopsThemeForm(\sprintf(\_AM_WGFILEMANAGER_CLONE_TITLE, $helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true);
35
        $clone = new \XoopsFormText(\_AM_WGFILEMANAGER_CLONE_NAME, 'clone', 20, 20, '');
36
        $clone->setDescription(\_AM_WGFILEMANAGER_CLONE_NAME_DSC);
37
        $form->addElement($clone, true);
38
        $form->addElement(new \XoopsFormHidden('op', 'submit'));
39
        $form->addElement(new \XoopsFormButton('', '', \_SUBMIT, 'submit'));
40
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
41
42
        break;
43
    case 'submit':
44
        // Security Check
45
        if (!$GLOBALS['xoopsSecurity']->check()) {
46
            \redirect_header('clone.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
47
        }
48
        $clone = Request::getString('clone', '', 'POST');
49
        //check if name is valid
50
        if (empty($clone) || \preg_match('/[^a-zA-Z0-9\_\-]/', $clone)) {
51
            \redirect_header('clone.php', 3, \sprintf(\_AM_WGFILEMANAGER_CLONE_INVALIDNAME, $clone));
52
        }
53
54
        // Check wether the cloned module exists or not
55
        $dirClone = $GLOBALS['xoops']->path('modules/' . $clone);
56
        if ($clone && \is_dir($dirClone)) {
57
            \redirect_header('clone.php', 3, \sprintf(\_AM_WGFILEMANAGER_CLONE_EXISTS, $clone));
58
        }
59
60
        $patterns = [
61
            \mb_strtolower(\WGFILEMANAGER_DIRNAME)           => \mb_strtolower($clone),
62
            \mb_strtoupper(\WGFILEMANAGER_DIRNAME)           => \mb_strtoupper($clone),
63
            \ucfirst(\mb_strtolower(\WGFILEMANAGER_DIRNAME)) => \ucfirst(\mb_strtolower($clone)),
64
        ];
65
66
        $patKeys   = \array_keys($patterns);
67
        $patValues = \array_values($patterns);
68
        cloneFileFolder(\WGFILEMANAGER_PATH);
69
        $logocreated = createLogo(\mb_strtolower($clone));
70
71
        //change module name in modinfo.php
72
        // file, read it
73
        $content = \file_get_contents($dirClone . '/language/english/modinfo.php');
74
        $content = \str_replace('Wgfilemanager', \mb_strtolower($clone), $content);
75
        file_put_contents($dirClone . '/language/english/modinfo.php', $content);
76
77
        $msg = '';
78
        if (\is_dir($GLOBALS['xoops']->path('modules/' . \mb_strtolower($clone)))) {
79
            $msg .= \sprintf(\_AM_WGFILEMANAGER_CLONE_CONGRAT, "<a href='" . \XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin&op=installlist'>" . \ucfirst(\mb_strtolower($clone)) . '</a>') . "<br>\n";
80
            if (!$logocreated) {
81
                $msg .= \_AM_WGFILEMANAGER_CLONE_IMAGEFAIL;
82
            }
83
        } else {
84
            $msg .= \_AM_WGFILEMANAGER_CLONE_FAIL;
85
        }
86
        $GLOBALS['xoopsTpl']->assign('result', $msg);
87
        break;
88
}
89
require __DIR__ . '/footer.php';
90
91
// recursive cloning script
92
/**
93
 * @param $path
94
 */
95
function cloneFileFolder($path): void
96
{
97
    global $patKeys;
98
    global $patValues;
99
100
    //remove \XOOPS_ROOT_PATH and add after replace, otherwise there can be a bug if \XOOPS_ROOT_PATH contains same pattern
101
    $newPath = \XOOPS_ROOT_PATH . \str_replace($patKeys[0], $patValues[0], \mb_substr($path, \mb_strlen(\XOOPS_ROOT_PATH)));
102
103
    if (\is_dir($path)) {
104
        // create new dir
105
        if (!\mkdir($newPath) && !\is_dir($newPath)) {
106
            throw new \RuntimeException(\sprintf('Directory "%s" was not created', $newPath));
107
        }
108
109
        // check all files in dir, and process it
110
        $handle = \opendir($path);
111
        if ($handle) {
112
            while (false !== ($file = \readdir($handle))) {
113
                if (0 !== \mb_strpos($file, '.')) {
114
                    cloneFileFolder("$path/$file");
115
                }
116
            }
117
            \closedir($handle);
118
        }
119
    } else {
120
        $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf'];
121
        if (\in_array(\mb_strtolower(\pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions)) {
0 ignored issues
show
It seems like pathinfo($path, PATHINFO_EXTENSION) can also be of type array; however, parameter $string of mb_strtolower() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

121
        if (\in_array(\mb_strtolower(/** @scrutinizer ignore-type */ \pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions)) {
Loading history...
122
            // image
123
            \copy($path, $newPath);
124
        } else {
125
            // file, read it
126
            $content = \file_get_contents($path);
127
            $content = \str_replace($patKeys, $patValues, $content);
128
            \file_put_contents($newPath, $content);
129
        }
130
    }
131
}
132
133
/**
134
 * @param $dirname
135
 *
136
 * @return bool
137
 */
138
function createLogo($dirname)
139
{
140
    if (!\extension_loaded('gd')) {
141
        return false;
142
    }
143
    $requiredFunctions = [
144
        'imagecreatefrompng',
145
        'imagecolorallocate',
146
        'imagefilledrectangle',
147
        'imagepng',
148
        'imagedestroy',
149
        'imagefttext',
150
        'imagealphablending',
151
        'imagesavealpha',
152
    ];
153
    foreach ($requiredFunctions as $func) {
154
        if (!\function_exists($func)) {
155
            return false;
156
        }
157
    }
158
    //            unset($func);
159
160
    if (!\file_exists($imageBase = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'))
161
        || !\file_exists($font = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/VeraBd.ttf'))) {
162
        return false;
163
    }
164
165
    $imageModule = \imagecreatefrompng($imageBase);
166
    // save existing alpha channel
167
    \imagealphablending($imageModule, false);
168
    \imagesavealpha($imageModule, true);
169
170
    //Erase old text
171
    $greyColor = \imagecolorallocate($imageModule, 237, 237, 237);
172
    \imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);
173
174
    // Write text
175
    $textColor     = \imagecolorallocate($imageModule, 0, 0, 0);
176
    $spaceToBorder = (int)((80 - \mb_strlen($dirname) * 6.5) / 2);
177
    \imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($dirname), []);
178
179
    // Set transparency color
180
    //$white = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
181
    //imagefill($imageModule, 0, 0, $white);
182
    //imagecolortransparent($imageModule, $white);
183
184
    \imagepng($imageModule, $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'));
185
    \imagedestroy($imageModule);
186
187
    return true;
188
}
189