Issues (52)

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/index2.php (1 issue)

Labels
1
<?php
2
/*
3
*******************************************************
4
***													***
5
*** backpack										***
6
*** Cedric MONTUY pour CHG-WEB                      ***
7
*** Original author : Yoshi Sakai					***
8
***													***
9
*******************************************************
10
*/
11
12
use Xmf\Module\Admin;
13
use Xmf\Request;
14
15
/** @var Admin $adminObject */
16
17
require_once __DIR__ . '/admin_header.php';
18
xoops_cp_header();
19
$adminObject = Admin::getInstance();
20
$adminObject->displayNavigation(basename(__FILE__));
21
22
$bp = new backpack();
23
if ($bp->err_msg) {
24
    sprintf('<span style="color: red; ">%s</span>', $bp->err_msg);
25
}
26
function mysqli_tablename($result, $i)
27
{
28
    mysqli_data_seek($result, $i);
29
    $f     = mysqli_fetch_array($result);
30
    $fetch = null !== $f ? $f[0] : null;
31
    return $fetch;
32
}
33
34
$time_start = time();
35
//$dump_buffer = null;
36
$dump_line      = 0;
37
$dump_size      = 0;
38
$download_count = 0;
39
$download_fname = [];
40
$mime_type      = '';
41
$query_res      = []; // for query result
42
43
if (isset($_POST['purgeallfiles'])) {
44
    $bp->purge_allfiles();
45
    redirect_header('./index.php', 1, _AM_PURGED_ALLFILES);
46
}
47
// Make sure we pick up variables passed via URL
48
$mode       = Request::getString('mode', '', 'GET');
49
$action     = Request::getString('action', '', 'GET');
50
$num_tables = Request::getString('num_tables', '', 'GET');
51
$checkall   = Request::getString('checkall', '', 'GET');
52
53
$tr_comp = '<tr><td class="odd"><strong>'
54
           . _AM_COMPRESSION
55
           . '</strong></td>'
56
           . '<td><input type="radio" id="gzip" name="file_compression" value="gzip" checked>'
57
           . '<label for="gz">gzip</label>&nbsp;&nbsp;'
58
           . '<input type="radio" id="zip" name="file_compression" value="zip">'
59
           . '<label for="sql">zip</label>&nbsp;&nbsp'
60
           . '<input type="radio" id="plain" name="file_compression" value="none">'
61
           . '<label for="sql">text</label>&nbsp;&nbsp</td></tr>';
62
$tr_strd = '<tr><td class="odd" style="width:30%;"><strong>' . _AM_DETAILSTOBACKUP . '</strong></td>' . '<td><input type="checkbox" name="structure" checked>&nbsp;' . _AM_TABLESTRUCTURE . '&nbsp;' . '<input type="checkbox" name="data" checked>&nbsp;' . _AM_TABLEDATA . '&nbsp;</td></tr>';
63
64
// Handle URL actions
65
switch ($mode) {
66
    case POST_SELECT_MODULE_FORM:
67
    {
68
        $select_dirname = isset($_GET['dirname']) ? filter_input(INPUT_GET, 'dirname', FILTER_SANITIZE_STRING) : 0;
69
        $mod_selections = $bp->make_module_selection($select_dirname);
70
        echo '<form method="post" action="index2.php?mode=' . POST_SELECT_TABLES_FORM . '&amp;alltables=on">';
71
        echo '<table class="outer" style="width:100%;"><tr><td class="head" colspan=2>' . _AM_MODULEBACKUP . '</td></tr>';
72
        echo '<tr><td class="odd"><strong>' . _AM_SELECTMODULE . '</strong></td><td>' . $mod_selections . '</td></tr>';
73
        echo $tr_strd;
74
        echo $tr_comp;
75
        echo '<tr><td colspan=2 style="text-align: center;"><input type="submit" value="' . _AM_BACKUP . '"></td></tr></table>';
76
        echo '</form>';
77
        //echo '</p>';
78
        echo '<br>';
79
        break;
80
    }
81
    case POST_DB_SELECT_FORM:
82
    {
83
        $select_dirname = isset($_GET['dirname']) ? filter_input(INPUT_GET, 'dirname', FILTER_SANITIZE_STRING) : 0;
84
        $mod_selections = $bp->make_module_selection($select_dirname, 1);
85
        // Get list of tables in the database and output form
86
        if ('module' == $action && $dirname) {
87
            $result     = get_module_tables($dirname);
0 ignored issues
show
The function get_module_tables was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

87
            $result     = /** @scrutinizer ignore-call */ get_module_tables($dirname);
Loading history...
88
            $num_tables = count($result);
89
            $checkall   = true;
90
        } else {
91
            $result     = $xoopsDB->queryF('SHOW TABLES FROM ' . $db_selected);
92
            $num_tables = $xoopsDB->getRowsNum($result);
93
        }
94
        echo '<table class="outer" style="width:100%">';
95
        echo '<form method="post" action="index2.php?mode=' . POST_SELECT_TABLES_FORM . '&num_tables=' . $num_tables . '">';
96
        echo '<tr><td class="head" colspan="2"><strong>' . _AM_SELECTTABLES . '</strong></td></tr>';
97
        echo '<tr><td class="main_left" colspan="2"><p>' . _AM_BACKUPNOTICE . '</p>';
98
        echo '<p><strong>' . _AM_SELECTTABLE . '</strong></p>';
99
        $checked = (!empty($checkall) ? ' checked' : '');
100
        for ($i = 0; $i < $num_tables; ++$i) {
101
            if ('module' == $action && $dirname) {
102
                $tablename = $xoopsDB->prefix($result[$i]);
103
            } else {
104
                $tablename = mysqli_tablename($result, $i);
105
            }
106
            $checkbox_string = sprintf(
107
                '<input type="checkbox" name="check_id%d" $checked>
108
				<input type="hidden" name="tablename%d" value="%s">&nbsp;%s<br>' . "\n",
109
                $i,
110
                $i,
111
                $tablename,
112
                $tablename
113
            );
114
            echo '<tr><td class="main_left" colspan="2">' . $checkbox_string . '</td></tr>';
115
        }
116
        if ('module' == $action && $dirname) {
117
            echo '<input type="hidden" name="dirname" value="' . $dirname . '>';
118
        }
119
        echo '<tr><td colspan="2">';
120
        echo '<a href="' . XOOPS_URL . '/modules/backpack/admin/index.php?mode=' . POST_DB_SELECT_FORM . '&amp;action=backup&amp;checkall=1">' . _AM_CHECKALL . '</a></td></tr>';
121
        echo $tr_strd;
122
        echo $tr_comp;
123
        echo '<tr><td colspan="2">';
124
        echo '<p><input type="submit" value="' . _AM_BACKUP . '">';
125
        echo '<input type="reset" value="' . _AM_RESET . '">';
126
        echo '</p></td></tr></form></table>';
127
        break;
128
    }
129
    case POST_SELECT_TABLES_FORM:
130
    {
131
        $bp->purge_allfiles();
132
133
        $sql_string = '';
134
        $alltables  = $backup_structure = $backup_data = 0;
135
        if (isset($_GET['alltables'])) {
136
            $alltables = ('on' == filter_input(INPUT_GET, 'alltables', FILTER_SANITIZE_STRING)) ? 1 : 0;
137
        }
138
        if (isset($_POST['alltables'])) {
139
            $alltables = ('on' == filter_input(INPUT_POST, 'alltables', FILTER_SANITIZE_STRING)) ? 1 : 0;
140
        }
141
        if (isset($_POST['structure'])) {
142
            $backup_structure = ('on' == filter_input(INPUT_POST, 'structure', FILTER_SANITIZE_STRING)) ? 1 : 0;
143
        }
144
        if (isset($_POST['data'])) {
145
            $backup_data = ('on' == filter_input(INPUT_POST, 'data', FILTER_SANITIZE_STRING)) ? 1 : 0;
146
        }
147
        $dirname = isset($_POST['dirname']) ? filter_input(INPUT_POST, 'dirname', FILTER_SANITIZE_STRING) : 0;
148
        if ($dirname) {
149
            if (0 == strcmp($dirname, 'system')) {
150
                $result = $sys_tables;
151
            } else {
152
                $result = $bp->get_module_tables($dirname);
153
            }
154
            $num_tables = count($result);
155
        } else {
156
            $result     = $xoopsDB->queryF('SHOW TABLES FROM ' . $db_selected);
157
            $num_tables = $xoopsDB->getRowsNum($result);
158
        }
159
        $j               = 0;
160
        $tablename_array = [];
161
        if (!$alltables) {
162
            for ($i = 0; $i < $num_tables; ++$i) {
163
                $check_id  = sprintf('check_id%d', $i);
164
                $tablename = sprintf('tablename%d', $i);
165
166
                if (isset($_POST[$check_id])) {
167
                    if (isset($_POST[$tablename])) {
168
                        $tablename_array[$j] = filter_input(INPUT_POST, $tablename, FILTER_SANITIZE_STRING);
169
                        ++$j;
170
                    }
171
                }
172
            }
173
        } else {
174
            for ($i = 0; $i < $num_tables; ++$i) {
175
                if ($dirname) {
176
                    $tablename_array[$i] = $xoopsDB->prefix($result[$i]);
177
                } else {
178
                    $tablename_array[$i] = mysqli_tablename($result, $i);
179
                }
180
            }
181
        }
182
        if ($dirname) {
183
            $filename = $dirname . date('YmdHis', time());
184
        } elseif ($alltables) {
185
            $filename = 'xdb' . date('YmdHis', time());
186
        } else {
187
            $filename = 'xtbl' . date('YmdHis', time());
188
        }
189
        $cfgZipType = filter_input(INPUT_POST, 'file_compression', FILTER_SANITIZE_STRING); //$_POST['file_compression'] ;
190
        $bp->backup_data($tablename_array, $backup_structure, $backup_data, $filename, $cfgZipType);
191
        $download_fname = $bp->download_fname();
192
        if (1 == $bp->download_count) {
193
            //redirect_header("./download.php?url=".$download_fname[0]['filename'], 1, _AM_READY_TO_DOWNLOAD);
194
            $url     = './download.php?url=' . $download_fname[0]['filename'];
195
            $time    = 1;
196
            $message = _AM_READY_TO_DOWNLOAD;
197
            $url     = preg_replace('/&amp;/i', '&', htmlspecialchars($url, ENT_QUOTES));
198
            echo '
199
            <html>
200
            <head>
201
            <title>' . htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES | ENT_HTML5) . '</title>
202
            <meta http-equiv="Content-Type" content="text/html; charset=' . _CHARSET . '">
203
            <meta http-equiv="Refresh" content="' . $time . '; url=' . $url . '">
204
            <style type="text/css">
205
                    body {background-color : #fcfcfc; font-size: 12px; font-family: Trebuchet MS,Verdana, Arial, Helvetica, sans-serif; margin: 0px;}
206
                    .redirect {width: 70%; margin: 110px; text-align: center; padding: 15px; border: #e0e0e0 1px solid; color: #666666; background-color: #f6f6f6;}
207
                    .redirect a:link {color: #666666; text-decoration: none; font-weight: bold;}
208
                    .redirect a:visited {color: #666666; text-decoration: none; font-weight: bold;}
209
                    .redirect a:hover {color: #999999; text-decoration: underline; font-weight: bold;}
210
            </style>
211
            </head>
212
            <body>
213
            <div align="center">
214
            <div class="redirect">
215
              <span style="font-size: 16px; font-weight: bold;">' . $message . '</span>
216
              <hr style="height: 3px; border: 3px #E18A00 solid; width: 95%;">
217
              <p>' . sprintf(_AM_IFNOTRELOAD, $url) . '</p>
218
            </div>
219
            </div>
220
            </body>
221
            </html>';
222
        } else {
223
            $form = new XoopsThemeForm(_AM_DOWNLOAD_LIST, 'download', $_SERVER['PHP_SELF']);
224
            $iMax = count($download_fname);
225
            for ($i = 0; $i < $iMax; ++$i) {
226
                $url = '<a href="download.php?url=' . $download_fname[$i]['filename'] . '" target="_blank">' . $download_fname[$i]['filename'] . '</a>';
227
                $url .= $download_fname[$i]['line'] . 'lines ' . $download_fname[$i]['size'] . 'bytes<br>';
228
                $form->addElement(new XoopsFormLabel($i, $url));
229
            }
230
            $form->addElement(new XoopsFormButton('', 'purgeallfiles', _AM_PURGE_FILES, 'submit'));
231
            $form->display();
232
        }
233
        break;
234
    }
235
236
    case DB_SELECT_FORM:
237
    {
238
        echo '<table cellspacing="0" cellpadding="3">';
239
        if ('backup' == $action) {
240
            echo '<tr><td class="title">' . _AM_TITLE_BCK . '</td></tr>';
241
            echo '<tr><td class="main_left"><p><b>' . _AM_SELECT_DATABASE . '</b>';
242
        }
243
        if ('backup' == $action) {
244
            echo '<form method="post" action="index2.php?mode=' . POST_DB_SELECT_FORM . '">';
245
        }
246
        echo '<input type="submit" value="Restore">';
247
        echo '</form></p></td></tr></table>';
248
        break;
249
    }
250
    default:
251
    {
252
        $result     = $xoopsDB->queryF('SHOW TABLES FROM ' . $db_selected);
253
        $num_tables = $xoopsDB->getRowsNum($result);
254
        echo '<form method="post" action="index2.php?mode=' . POST_SELECT_TABLES_FORM . '&amp;num_tables=' . $num_tables . '&amp;alltables=on">';
255
        echo '<table class="outer" style="width:100%;"><tr><td class="head" colspan="2">' . _AM_BACKUPTITLE . '</td></tr>';
256
        echo $tr_strd;
257
        echo $tr_comp;
258
        echo '<tr><td colspan="2" style="text-align: center;"><input type="submit" value="' . _AM_BACKUP . '"></td></tr></table></form>';
259
        echo '<br>';
260
    }
261
}
262
require __DIR__ . '/admin_footer.php';
263