@@ -826,10 +826,10 @@ public function scanFile($info)
826
826
$ contentDecoded = $ deobfuscator ->decode ($ contentDeobfuscated );
827
827
828
828
$ contents = [
829
- $ contentRaw , // Original content
830
- $ contentClean , // Cleaned content
831
- $ contentDeobfuscated , // Deobfuscated content
832
- $ contentDecoded , // Decoded content
829
+ ' raw ' => $ contentRaw , // Original content
830
+ ' cleaned ' => $ contentClean , // Cleaned content
831
+ ' deobfuscated ' => $ contentDeobfuscated , // Deobfuscated content
832
+ ' decoded ' => $ contentDecoded , // Decoded content
833
833
];
834
834
835
835
/**
@@ -854,11 +854,14 @@ public function scanFile($info)
854
854
'key ' => $ key ,
855
855
'level ' => $ exploit ['level ' ],
856
856
'output ' => $ matchDescription ,
857
+ 'description ' => $ exploit ['description ' ],
857
858
'line ' => $ lineNumber ,
858
859
'pattern ' => $ pattern ,
859
860
'match ' => $ lastMatch ,
860
- 'exploit ' => $ exploit ,
861
861
];
862
+ if (isset ($ exploit ['link ' ])) {
863
+ $ patternFound [$ patternFoundKey ]['link ' ] = $ exploit ['link ' ];
864
+ }
862
865
}
863
866
};
864
867
// Check exploits
@@ -878,7 +881,13 @@ public function scanFile($info)
878
881
foreach ($ functions as $ funcRaw ) {
879
882
$ lastMatch = null ;
880
883
$ func = preg_quote (trim ($ funcRaw ), '/ ' );
881
- $ checkFunction = function ($ match , $ pattern , $ level = Definitions::LVL_WARNING , $ type = '' ) use ($ contentRaw , $ funcRaw , &$ patternFound ) {
884
+ $ checkFunction = function (
885
+ $ match ,
886
+ $ pattern ,
887
+ $ level = Definitions::LVL_WARNING ,
888
+ $ descriptionPrefix = '' ,
889
+ $ type = ''
890
+ ) use ($ contentRaw , $ funcRaw , &$ patternFound ) {
882
891
$ suffix = '' ;
883
892
if (!empty ($ type )) {
884
893
$ suffix = '_ ' . $ type ;
@@ -901,9 +910,11 @@ public function scanFile($info)
901
910
'key ' => $ funcKey ,
902
911
'level ' => $ level ,
903
912
'output ' => $ matchDescription ,
913
+ 'description ' => $ descriptionPrefix . ' ` ' . $ funcRaw . '` ' ,
904
914
'line ' => $ lineNumber ,
905
915
'pattern ' => $ pattern ,
906
916
'match ' => $ lastMatch ,
917
+ 'link ' => 'https://www.php.net/ ' . $ funcRaw ,
907
918
];
908
919
}
909
920
};
@@ -914,10 +925,21 @@ public function scanFile($info)
914
925
if (in_array ($ funcRaw , self ::$ functions )) {
915
926
// Check raw functions
916
927
$ regexPattern = "/(?:^|[\s \r\n]+|[^a-zA-Z0-9_>]+)( " . $ func . "[\s \r\n]*\((?<=\().*?(?=\))\))/si " ;
917
- foreach ($ contents as $ content ) {
928
+ foreach ($ contents as $ contentType => $ content ) {
918
929
if (@preg_match_all ($ regexPattern , $ content , $ matches , PREG_OFFSET_CAPTURE )) {
919
930
foreach ($ matches [0 ] as $ match ) {
920
- $ checkFunction ($ match , $ regexPattern );
931
+ $ descriptionPrefix = 'Potentially dangerous function ' ;
932
+ $ severity = Definitions::LVL_WARNING ;
933
+ if ($ contentType === 'decoded ' ) {
934
+ $ severity = Definitions::LVL_DANGEROUS ;
935
+ $ descriptionPrefix = 'Encoded Function ' ;
936
+ }
937
+ $ checkFunction (
938
+ $ match ,
939
+ $ regexPattern ,
940
+ $ severity ,
941
+ $ descriptionPrefix
942
+ );
921
943
}
922
944
}
923
945
}
@@ -927,35 +949,28 @@ public function scanFile($info)
927
949
* Encoded functions.
928
950
*/
929
951
if (in_array ($ funcRaw , self ::$ functionsEncoded )) {
930
- $ decoders = [
952
+ $ encoders = [
931
953
'str_rot13 ' ,
932
954
'base64_decode ' ,
933
955
'strrev ' ,
934
956
];
935
- foreach ($ decoders as $ decoder ) {
957
+ foreach ($ encoders as $ encoder ) {
936
958
// Check encoded functions
937
- $ regexPatternEncoded = '/ ' . @$ decoder ($ funcRaw ) . '/s ' ;
938
- foreach ($ contents as $ content ) {
959
+ $ regexPatternEncoded = '/ ' . @$ encoder ($ funcRaw ) . '/s ' ;
960
+ foreach ($ contents as $ contentType => $ content ) {
939
961
if (@preg_match_all ($ regexPatternEncoded , $ content , $ matches , PREG_OFFSET_CAPTURE )) {
940
962
foreach ($ matches [0 ] as $ match ) {
941
- $ checkFunction ($ match , $ regexPatternEncoded , Definitions::LVL_DANGEROUS , $ decoder );
963
+ $ checkFunction (
964
+ $ match ,
965
+ $ regexPatternEncoded ,
966
+ Definitions::LVL_DANGEROUS ,
967
+ 'Encoded Function ' ,
968
+ $ encoder
969
+ );
942
970
}
943
971
}
944
972
}
945
973
}
946
-
947
- // Check hex functions
948
- $ funcHex = bin2hex ($ funcRaw );
949
- $ funcHex = chunk_split ($ funcHex , 2 , '\x ' );
950
- $ funcHex = '\x ' . substr ($ funcHex , 0 , -2 );
951
- $ regexPatternHex = '/( ' . preg_quote ($ funcHex , '/ ' ) . ')/si ' ;
952
- foreach ($ contents as $ content ) {
953
- if (@preg_match_all ($ regexPatternHex , $ content , $ matches , PREG_OFFSET_CAPTURE )) {
954
- foreach ($ matches [0 ] as $ match ) {
955
- $ checkFunction ($ match , $ regexPatternHex , Definitions::LVL_DANGEROUS , 'hex ' );
956
- }
957
- }
958
- }
959
974
}
960
975
}
961
976
@@ -981,6 +996,7 @@ public function scanFile($info)
981
996
'key ' => $ key ,
982
997
'level ' => Definitions::LVL_DANGEROUS ,
983
998
'output ' => $ matchDescription ,
999
+ 'description ' => 'Sign definition ` ' . $ key . '` ' ,
984
1000
'line ' => $ lineNumber ,
985
1001
'pattern ' => $ regexPattern ,
986
1002
'match ' => $ lastMatch ,
@@ -1006,6 +1022,7 @@ public function scanFile($info)
1006
1022
'key ' => $ key ,
1007
1023
'level ' => Definitions::LVL_DANGEROUS ,
1008
1024
'output ' => $ description ,
1025
+ 'description ' => 'LFI (Local File Inclusion), through an infected file with icon, allow remote attackers to inject and execute arbitrary commands or code on the target machine ' ,
1009
1026
'line ' => '' ,
1010
1027
'pattern ' => '' ,
1011
1028
'match ' => '' ,
0 commit comments