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/download.php (5 issues)

Labels
Severity
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
/** @var Admin $adminObject */
14
15
ini_set('memory_limit', '20M');
16
17
require_once __DIR__ . '/admin_header.php';
18
xoops_cp_header();
19
$adminObject = Admin::getInstance();
20
$adminObject->displayNavigation(basename(__FILE__));
21
22
require dirname(__DIR__) . '/include/ext2mime.php';        // Load the decode array of extension to MIME
23
24
$fpathname   = htmlspecialchars(rawurldecode($_GET['url']), ENT_QUOTES);
25
$dl_filename = $fpathname;
26
if (defined('XOOPS_VAR_PATH')) {
27
    $backup_dir = XOOPS_VAR_PATH . '/caches/';
28
} else {
29
    $backup_dir = XOOPS_ROOT_PATH . '/cache/';
30
}
31
$fpathname = $backup_dir . $fpathname;
32
ob_clean();
33
if (!file_exists($fpathname)) {
34
    if (file_exists($fpathname . '.log')) {
35
        echo '<strong>Already downloaded by </strong>';
36
        $fp = fopen($fpathname . '.log', 'r');
37
        while (!feof($fp)) {
0 ignored issues
show
It seems like $fp can also be of type false; however, parameter $handle of feof() does only seem to accept resource, 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

37
        while (!feof(/** @scrutinizer ignore-type */ $fp)) {
Loading history...
38
            $line = fgets($fp);
0 ignored issues
show
It seems like $fp can also be of type false; however, parameter $handle of fgets() does only seem to accept resource, 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

38
            $line = fgets(/** @scrutinizer ignore-type */ $fp);
Loading history...
39
            echo $line . '<br>';
40
        }
41
        fclose($fp);
0 ignored issues
show
It seems like $fp can also be of type false; however, parameter $handle of fclose() does only seem to accept resource, 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

41
        fclose(/** @scrutinizer ignore-type */ $fp);
Loading history...
42
        exit();
43
    }
44
    print('Error - ' . $fpathname . ' does not exist.');
45
    return;
46
}
47
$browser = $version = 0;
48
UsrBrowserAgent($browser, $version);
49
ignore_user_abort();
50
51
$fnamedotpos = strrpos($dl_filename, '.');
52
$fext        = substr($dl_filename, $fnamedotpos + 1);
53
$ctype       = $ext2mime[$fext] ?? 'application/octet-stream-dummy';
54
if ('gz' == $fext) {
55
    $content_encoding = 'x-gzip';
56
}
57
//echo $fext.$ctype; exit();
58
if ('IE' == $browser && (ini_get('zlib.output_compression'))) {
59
    ini_set('zlib.output_compression', 'Off');
60
}
61
//if (!empty($content_encoding)) {
62
//    header('Content-Encoding: ' . $content_encoding);
63
//}
64
header('Content-Transfer-Encoding: binary');
65
header('Content-Length: ' . filesize($fpathname));
66
header('Content-type: ' . $ctype);
67
header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
68
header('Last-Modified: ' . date('D M j G:i:s T Y'));
69
header('Content-Disposition: attachment; filename="' . $dl_filename . '"');
70
//header("Content-Disposition: inline; filename=" . $dl_filename);
71
header('x-extension: ' . $ctype);
72
73
if ('IE' == $browser) {
74
    header('Pragma: public');
75
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
76
} else {
77
    header('Pragma: no-cache');
78
}
79
80
$fp = fopen($fpathname, 'r');
81
while (!feof($fp)) {
82
    $buffer = fread($fp, 1024 * 6); //speed-limit 64kb/s
0 ignored issues
show
It seems like $fp can also be of type false; however, parameter $handle of fread() does only seem to accept resource, 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

82
    $buffer = fread(/** @scrutinizer ignore-type */ $fp, 1024 * 6); //speed-limit 64kb/s
Loading history...
83
    print $buffer;
84
    flush();
85
    ob_flush();
86
    usleep(10000);
87
}
88
fclose($fp);
89
//
90
// Save download log
91
//
92
if ($xoopsUser) {
93
    $uname = $xoopsUser->getVar('uname');
94
} else {
95
    $uname = 'Anonymous';
96
}
97
$str     = $uname . ',' . date('Y-m-d H:i:s', time());
98
$postlog = $fpathname . '.log';
99
$fp      = fopen($postlog, 'a');
100
fwrite($fp, $str . "\n");
0 ignored issues
show
It seems like $fp can also be of type false; however, parameter $handle of fwrite() does only seem to accept resource, 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

100
fwrite(/** @scrutinizer ignore-type */ $fp, $str . "\n");
Loading history...
101
fclose($fp);
102
unlink($fpathname);
103
//xoops_cp_footer();
104
//
105
// Check User Browser
106
// @TODO - add check for Microsoft Edge browser
107
//
108
function UsrBrowserAgent(&$browser, &$version)
109
{
110
    if (preg_match('@Opera(/| )([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'], $log_version)) {
111
        $version = $log_version[2];
112
        $browser = 'OPERA';
113
    } elseif (preg_match('@MSIE ([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'], $log_version)) {
114
        $version = $log_version[1];
115
        $browser = 'IE';
116
    } elseif (preg_match('@OmniWeb/([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'], $log_version)) {
117
        $version = $log_version[1];
118
        $browser = 'OMNIWEB';
119
    } elseif (preg_match('@(Konqueror/)(.*)(;)@', $_SERVER['HTTP_USER_AGENT'], $log_version)) {
120
        $version = $log_version[2];
121
        $browser = 'KONQUEROR';
122
    } elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'], $log_version)
123
              && preg_match('@Safari/([0-9]*)@', $_SERVER['HTTP_USER_AGENT'], $log_version2)) {
124
        $version = $log_version[1] . '.' . $log_version2[1];
125
        $browser = 'SAFARI';
126
    } elseif (preg_match('@Mozilla/([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'], $log_version)) {
127
        $version = $log_version[1];
128
        $browser = 'MOZILLA';
129
    } else {
130
        $version = 0;
131
        $browser = 'OTHER';
132
    }
133
    return $browser;
134
}
135