8
8
* License: GNU/GPLv2
9
9
* @see LICENSE.txt
10
10
*
11
- * This file: The scanner (last modified: 2021.10.30 ).
11
+ * This file: The scanner (last modified: 2022.02.01 ).
12
12
*/
13
13
14
14
namespace phpMussel \Core ;
@@ -85,9 +85,9 @@ public function __construct(\phpMussel\Core\Loader &$Loader)
85
85
if ($ this ->CalledFrom === 'CLI ' ) {
86
86
$ Origin = 'CLI ' ;
87
87
} elseif ($ this ->Loader ->Configuration ['legal ' ]['pseudonymise_ip_addresses ' ]) {
88
- $ Origin = $ this ->Loader ->pseudonymiseIP ($ _SERVER [ $ this ->Loader -> Configuration [ ' core ' ][ ' ipaddr ' ]] );
88
+ $ Origin = $ this ->Loader ->pseudonymiseIP ($ this ->IPAddr );
89
89
} else {
90
- $ Origin = $ _SERVER [ $ this ->Loader -> Configuration [ ' core ' ][ ' ipaddr ' ]] ;
90
+ $ Origin = $ this ->IPAddr ;
91
91
}
92
92
93
93
/** Get detections. */
@@ -424,7 +424,7 @@ public function quarantine(string $In, string $Key, string $IP, string $ID): boo
424
424
}
425
425
$ k = strlen ($ Key );
426
426
$ FileSize = strlen ($ In );
427
- $ Head = "\xa1 phpMussel \x21" . $ this ->Loader ->hexSafe (hash ('md5 ' , $ In )) . pack ('l* ' , $ FileSize ) . "\1" ;
427
+ $ Head = "\xA1 phpMussel \x21" . $ this ->Loader ->hexSafe (hash ('md5 ' , $ In )) . pack ('l* ' , $ FileSize ) . "\1" ;
428
428
$ In = gzdeflate ($ In , 9 );
429
429
$ Out = '' ;
430
430
$ i = 0 ;
@@ -439,10 +439,10 @@ public function quarantine(string $In, string $Key, string $IP, string $ID): boo
439
439
}
440
440
}
441
441
$ Out =
442
- "\x2f\x3d\x3d phpMussel Quarantined File Upload \x3d\x3d\x5c \n\x7c Time \x2f Date Uploaded \x3a " .
442
+ "\x2F\x3D\x3D phpMussel Quarantined File Upload \x3D\x3D\x5C \n\x7C Time \x2F Date Uploaded \x3A " .
443
443
str_pad ($ this ->Loader ->Time , 18 , ' ' ) .
444
- "\x7c \n\x7c Uploaded From \x3a " . str_pad ($ IP , 22 , ' ' ) .
445
- " \x7c \n\x5c " . str_repeat ("\x3d " , 39 ) . "\x2f \n\n\n" . $ Head . $ Out ;
444
+ "\x7C \n\x7C Uploaded From \x3A " . str_pad ($ IP , 22 , ' ' ) .
445
+ " \x7C \n\x5C " . str_repeat ("\x3D " , 39 ) . "\x2F \n\n\n" . $ Head . $ Out ;
446
446
$ UsedMemory = $ this ->memoryUse ($ this ->Loader ->QuarantinePath );
447
447
$ UsedMemory ['Size ' ] += strlen ($ Out );
448
448
$ UsedMemory ['Count ' ]++;
@@ -688,7 +688,7 @@ private function recursor($Files = '', int $Depth = -1): void
688
688
if (is_dir ($ Files )) {
689
689
if (!is_readable ($ Files )) {
690
690
$ this ->Loader ->InstanceCache ['ScanErrors ' ]++;
691
- $ this ->Loader ->atHit ('' , -1 , preg_replace (['~[\x00-\x1f ]~ ' , '~^[ \\\/]~ ' ], '' , $ Files ), sprintf (
691
+ $ this ->Loader ->atHit ('' , -1 , preg_replace (['~[\x00-\x1F ]~ ' , '~^[ \\\/]~ ' ], '' , $ Files ), sprintf (
692
692
$ this ->Loader ->L10N ->getString ('grammar_exclamation_mark ' ),
693
693
sprintf ($ this ->Loader ->L10N ->getString ('failed_to_access ' ), $ OriginalFilename )
694
694
), -5 , $ Depth );
@@ -715,7 +715,7 @@ private function recursor($Files = '', int $Depth = -1): void
715
715
$ this ->resetHeuristics ();
716
716
717
717
/** Ensure that the original filename doesn't break lines and clean it up. */
718
- $ OriginalFilenameClean = preg_replace (['~[\x00-\x1f ]~ ' , '~^[ \\\/]~ ' ], '' , $ OriginalFilename );
718
+ $ OriginalFilenameClean = preg_replace (['~[\x00-\x1F ]~ ' , '~^[ \\\/]~ ' ], '' , $ OriginalFilename );
719
719
720
720
/** Indenting to apply for "checking" . */
721
721
$ Indent = str_pad ('→ ' , ($ Depth < 1 ? 4 : ($ Depth * 3 ) + 4 ), '─ ' , STR_PAD_LEFT );
@@ -917,7 +917,7 @@ private function recursor($Files = '', int $Depth = -1): void
917
917
$ this ->quarantine (
918
918
$ In ,
919
919
$ this ->Loader ->Configuration ['quarantine ' ]['quarantine_key ' ],
920
- $ _SERVER [ $ this ->Loader -> Configuration [ ' core ' ][ ' ipaddr ' ]] ,
920
+ $ this ->IPAddr ,
921
921
$ qfu
922
922
);
923
923
$ this ->Loader ->HashReference .= sprintf ($ this ->Loader ->L10N ->getString ('quarantined_as ' ), $ qfu ) . "\n" ;
@@ -989,7 +989,7 @@ private function recursor($Files = '', int $Depth = -1): void
989
989
$ this ->quarantine (
990
990
$ In ,
991
991
$ this ->Loader ->Configuration ['quarantine ' ]['quarantine_key ' ],
992
- $ _SERVER [ $ this ->Loader -> Configuration [ ' core ' ][ ' ipaddr ' ]] ,
992
+ $ this ->IPAddr ,
993
993
$ qfu
994
994
);
995
995
$ this ->Loader ->HashReference .= sprintf ($ this ->Loader ->L10N ->getString ('quarantined_as ' ), $ qfu );
@@ -1276,7 +1276,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
1276
1276
if (strpos ($ Switch , '= ' ) === false ) {
1277
1277
continue ;
1278
1278
}
1279
- $ Switch = explode ('= ' , preg_replace ('/[^\x20-\xff ]/ ' , '' , $ Switch ));
1279
+ $ Switch = explode ('= ' , preg_replace ('/[^\x20-\xFF ]/ ' , '' , $ Switch ));
1280
1280
if (empty ($ Switch [0 ])) {
1281
1281
continue ;
1282
1282
}
@@ -2233,7 +2233,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
2233
2233
continue ;
2234
2234
}
2235
2235
if ($ ThisConf [3 ] === 2 ) {
2236
- $ ThisSig = preg_split ('/[\x00-\x1f ]+/ ' , $ VN [1 ], -1 , PREG_SPLIT_NO_EMPTY );
2236
+ $ ThisSig = preg_split ('/[\x00-\x1F ]+/ ' , $ VN [1 ], -1 , PREG_SPLIT_NO_EMPTY );
2237
2237
$ ThisSig = ($ ThisSig === false ) ? '' : implode ('' , $ ThisSig );
2238
2238
$ VN = $ this ->getShorthand ($ VN [0 ]);
2239
2239
if (
@@ -2247,7 +2247,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
2247
2247
}
2248
2248
} elseif ($ ThisConf [3 ] === 0 || $ ThisConf [3 ] === 1 ) {
2249
2249
$ ThisSig = preg_split ((
2250
- $ ThisConf [3 ] === 0 ? '/[^\da-f>]+/i ' : '/[\x00-\x1f ]+/ '
2250
+ $ ThisConf [3 ] === 0 ? '/[^\da-f>]+/i ' : '/[\x00-\x1F ]+/ '
2251
2251
), $ VN [1 ], -1 , PREG_SPLIT_NO_EMPTY );
2252
2252
$ ThisSig = ($ ThisSig === false ? '' : implode ('' , $ ThisSig ));
2253
2253
$ ThisSigLen = strlen ($ ThisSig );
@@ -2383,7 +2383,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
2383
2383
/** Chameleon attack bypasses for Mac OS X thumbnails and screenshots. */
2384
2384
$ ThumbnailBypass = (
2385
2385
substr ($ OriginalFilename , 0 , 2 ) === '._ ' &&
2386
- !preg_match ('~[^\x00-\x1f ]~ ' , substr ($ str , 0 , 8 )) &&
2386
+ !preg_match ('~[^\x00-\x1F ]~ ' , substr ($ str , 0 , 8 )) &&
2387
2387
substr ($ str , 8 , 8 ) === 'Mac OS X '
2388
2388
);
2389
2389
@@ -2502,7 +2502,7 @@ private function dataHandler(string $str = '', int $Depth = 0, string $OriginalF
2502
2502
2503
2503
/** Control character detection. */
2504
2504
if ($ this ->Loader ->Configuration ['files ' ]['block_control_characters ' ]) {
2505
- if (preg_match ('/[\x00-\x08\x0b\x0c\x0e\x1f\x7f ]/i ' , $ str )) {
2505
+ if (preg_match ('/[\x00-\x08\x0B\x0C\x0E\x1F\x7F ]/i ' , $ str )) {
2506
2506
$ this ->Loader ->atHit ($ sha256 , $ StringLength , $ OriginalFilename , sprintf (
2507
2507
$ this ->Loader ->L10N ->getString ('grammar_exclamation_mark ' ),
2508
2508
sprintf (
@@ -2921,7 +2921,7 @@ private function archiveRecursor(string $Data, string $File = '', int $ScanDepth
2921
2921
$ Hash = hash ('sha256 ' , $ Content );
2922
2922
$ DataCRC32 = hash ('crc32b ' , $ Content );
2923
2923
$ InternalCRC = $ ArchiveObject ->EntryCRC ();
2924
- $ ThisItemRef = $ ItemRef . '→ ' . preg_replace (['~[\x00-\x1f ]~ ' , '~^[ \\\/]~ ' ], '' , $ Filename );
2924
+ $ ThisItemRef = $ ItemRef . '→ ' . preg_replace (['~[\x00-\x1F ]~ ' , '~^[ \\\/]~ ' ], '' , $ Filename );
2925
2925
2926
2926
/** Verify filesize, integrity, etc. Exit early in case of problems. */
2927
2927
if ($ Filesize !== strlen ($ Content ) || (
@@ -3279,7 +3279,7 @@ function_exists('gzinflate') &&
3279
3279
break ;
3280
3280
}
3281
3281
}
3282
- $ str = preg_replace ('/[^\x21-\x7e ]/ ' , '' , strtolower ($ this ->prescanDecode ($ str . $ ostr )));
3282
+ $ str = preg_replace ('/[^\x21-\x7E ]/ ' , '' , strtolower ($ this ->prescanDecode ($ str . $ ostr )));
3283
3283
if ($ html ) {
3284
3284
$ str = preg_replace ([
3285
3285
'@<script[^>]*?>.*?</script>@si ' ,
@@ -3319,7 +3319,7 @@ private function getShorthand(string $VN): string
3319
3319
$ this ->Loader ->InstanceCache ['ignoreme ' ] = false ;
3320
3320
3321
3321
/** Byte 0 confirms whether the signature name uses shorthand. */
3322
- if ($ VN [0 ] !== "\x1a " ) {
3322
+ if ($ VN [0 ] !== "\x1A " ) {
3323
3323
return $ VN ;
3324
3324
}
3325
3325
@@ -3817,7 +3817,7 @@ private function metaDataScan(string $ItemRef, string $Filename, string &$Data,
3817
3817
/** Determine whether the file being scanned is a macro. */
3818
3818
$ this ->Loader ->InstanceCache ['file_is_macro ' ] = (
3819
3819
strtolower (substr ($ Filename , -14 )) === 'vbaproject.bin ' ||
3820
- preg_match ('~^\xd0\xcf |\x00Attribut|\x01CompObj|\x05Document~ ' , $ Data )
3820
+ preg_match ('~^\xD0\xCF |\x00Attribut|\x01CompObj|\x05Document~ ' , $ Data )
3821
3821
);
3822
3822
3823
3823
/** Handle macro detection and blocking. */
0 commit comments