@@ -326,6 +326,7 @@ private function arguments($args = null)
326
326
self ::$ argv ->addFlag ('auto-delete ' , array ('default ' => false ));
327
327
self ::$ argv ->addFlag ('auto-quarantine ' , array ('default ' => false ));
328
328
self ::$ argv ->addFlag ('auto-skip ' , array ('default ' => false ));
329
+ self ::$ argv ->addFlag ('auto-whitelist ' , array ('default ' => false ));
329
330
self ::$ argv ->addFlag ('auto-prompt ' , array ('default ' => null , 'has_value ' => true ));
330
331
self ::$ argv ->addArgument ('path ' , array ('var_args ' => true , 'default ' => '' ));
331
332
self ::$ argv ->parse ($ args );
@@ -493,27 +494,32 @@ private function arguments($args = null)
493
494
// Prompt
494
495
if (isset (self ::$ argv ['auto-clean ' ]) && self ::$ argv ['auto-clean ' ]) {
495
496
self ::$ settings ['report ' ] = false ;
496
- self ::$ prompt = '3 ' ;
497
+ self ::$ prompt = 'clean ' ;
497
498
}
498
499
499
500
if (isset (self ::$ argv ['auto-clean-line ' ]) && self ::$ argv ['auto-clean-line ' ]) {
500
501
self ::$ settings ['report ' ] = false ;
501
- self ::$ prompt = '4 ' ;
502
+ self ::$ prompt = 'clean-line ' ;
502
503
}
503
504
504
505
if (isset (self ::$ argv ['auto-delete ' ]) && self ::$ argv ['auto-delete ' ]) {
505
506
self ::$ settings ['report ' ] = false ;
506
- self ::$ prompt = '1 ' ;
507
+ self ::$ prompt = 'delete ' ;
507
508
}
508
509
509
510
if (isset (self ::$ argv ['auto-quarantine ' ]) && self ::$ argv ['auto-quarantine ' ]) {
510
511
self ::$ settings ['report ' ] = false ;
511
- self ::$ prompt = '2 ' ;
512
+ self ::$ prompt = 'quarantine ' ;
513
+ }
514
+
515
+ if (isset (self ::$ argv ['auto-whitelist ' ]) && self ::$ argv ['auto-whitelist ' ]) {
516
+ self ::$ settings ['report ' ] = false ;
517
+ self ::$ prompt = 'whitelist ' ;
512
518
}
513
519
514
520
if (isset (self ::$ argv ['auto-skip ' ]) && self ::$ argv ['auto-skip ' ]) {
515
521
self ::$ settings ['report ' ] = false ;
516
- self ::$ prompt = '- ' ;
522
+ self ::$ prompt = 'skip ' ;
517
523
}
518
524
519
525
if (isset (self ::$ argv ['auto-prompt ' ]) && !empty (self ::$ argv ['auto-prompt ' ])) {
@@ -892,15 +898,20 @@ private function scan($iterator)
892
898
$ preview = implode (Console::eol (1 ), array_slice ($ preview_lines , 0 , 1000 ));
893
899
if (!in_array ($ last_command , array ('4 ' , '5 ' , '7 ' ))) {
894
900
Console::displayLine ("$ _FILE_PATH " , 2 , 'yellow ' );
895
- Console::display (Console::title (' PREVIEW ' , '= ' ), 'white ' , 'red ' );
901
+
902
+ $ title = Console::title (' PREVIEW ' , '= ' );
903
+ Console::display ($ title , 'white ' , 'red ' );
896
904
Console::newLine (2 );
905
+
897
906
Console::code ($ preview , $ pattern_found );
898
907
if (count ($ preview_lines ) > 1000 ) {
899
908
Console::newLine (2 );
900
909
Console::display (' [ ' . (count ($ preview_lines ) - 1000 ) . ' rows more ] ' );
901
910
}
902
911
Console::newLine (2 );
903
- Console::display (Console::title ('' , '= ' ), 'white ' , 'red ' );
912
+
913
+ $ title = Console::title ('' , '= ' );
914
+ Console::display ($ title , 'white ' , 'red ' );
904
915
}
905
916
Console::newLine (2 );
906
917
Console::writeLine ('File path: ' . $ _FILE_PATH , 1 , 'yellow ' );
@@ -926,7 +937,7 @@ private function scan($iterator)
926
937
$ last_command = $ confirmation ;
927
938
unset($ preview_lines , $ preview );
928
939
929
- if (in_array ($ confirmation , array ('1 ' ))) {
940
+ if (in_array ($ confirmation , array ('1 ' , ' delete ' ))) {
930
941
// Remove file
931
942
Console::writeLine ('File path: ' . $ _FILE_PATH , 1 , 'yellow ' );
932
943
$ confirm2 = 'y ' ;
@@ -940,7 +951,7 @@ private function scan($iterator)
940
951
Console::writeLine ("File ' $ _FILE_PATH ' removed! " , 2 , 'green ' );
941
952
$ _WHILE = false ;
942
953
}
943
- } elseif (in_array ($ confirmation , array ('2 ' ))) {
954
+ } elseif (in_array ($ confirmation , array ('2 ' , ' quarantine ' ))) {
944
955
// Move to quarantine
945
956
$ quarantine = self ::$ pathQuarantine . str_replace (realpath (self ::currentDirectory ()), '' , $ _FILE_PATH );
946
957
@@ -953,7 +964,7 @@ private function scan($iterator)
953
964
self ::$ summaryQuarantine [] = $ quarantine ;
954
965
Console::writeLine ("File ' $ _FILE_PATH ' moved to quarantine! " , 2 , 'green ' );
955
966
$ _WHILE = false ;
956
- } elseif (in_array ($ confirmation , array ('3 ' )) && count ($ pattern_found ) > 0 ) {
967
+ } elseif (in_array ($ confirmation , array ('3 ' , ' clean ' )) && count ($ pattern_found ) > 0 ) {
957
968
// Remove evil code
958
969
foreach ($ pattern_found as $ pattern ) {
959
970
preg_match ('/(<\?php)(.*?)( ' . preg_quote ($ pattern ['match ' ], '/ ' ) . '[\s\r\n]*;?)/si ' , $ fc , $ match );
@@ -967,11 +978,15 @@ private function scan($iterator)
967
978
$ fc = preg_replace ('/<\?php[\s\r\n]*\?\>/si ' , '' , $ fc );
968
979
}
969
980
Console::newLine ();
970
- Console::display (Console::title (' SANITIZED ' , '= ' ), 'black ' , 'green ' );
981
+
982
+ $ title = Console::title (' SANITIZED ' , '= ' );
983
+ Console::display ($ title , 'black ' , 'green ' );
971
984
Console::newLine (2 );
972
985
Console::code ($ fc );
973
986
Console::newLine (2 );
974
- Console::display (Console::title ('' , '= ' ), 'black ' , 'green ' );
987
+
988
+ $ title = Console::title ('' , '= ' );
989
+ Console::display ($ title , 'black ' , 'green ' );
975
990
Console::newLine (2 );
976
991
Console::displayLine ('File sanitized, now you must verify if has been fixed correctly. ' , 2 , 'yellow ' );
977
992
$ confirm2 = 'y ' ;
@@ -987,7 +1002,7 @@ private function scan($iterator)
987
1002
} else {
988
1003
self ::$ summaryIgnored [] = $ _FILE_PATH ;
989
1004
}
990
- } elseif (in_array ($ confirmation , array ('4 ' )) && count ($ pattern_found ) > 0 ) {
1005
+ } elseif (in_array ($ confirmation , array ('4 ' , ' clean-line ' )) && count ($ pattern_found ) > 0 ) {
991
1006
// Remove evil line code
992
1007
$ fc_expl = explode (PHP_EOL , $ fc );
993
1008
foreach ($ pattern_found as $ pattern ) {
@@ -996,11 +1011,15 @@ private function scan($iterator)
996
1011
$ fc = implode (PHP_EOL , $ fc_expl );
997
1012
998
1013
Console::newLine ();
999
- Console::display (Console::title (' SANITIZED ' , '= ' ), 'black ' , 'green ' );
1014
+
1015
+ $ title = Console::title (' SANITIZED ' , '= ' );
1016
+ Console::display ($ title , 'black ' , 'green ' );
1000
1017
Console::newLine (2 );
1001
1018
Console::code ($ fc );
1002
1019
Console::newLine (2 );
1003
- Console::display (Console::title ('' , '= ' ), 'black ' , 'green ' );
1020
+
1021
+ $ title = Console::title ('' , '= ' );
1022
+ Console::display ($ title , 'black ' , 'green ' );
1004
1023
Console::newLine (2 );
1005
1024
Console::displayLine ('File sanitized, now you must verify if has been fixed correctly. ' , 2 , 'yellow ' );
1006
1025
$ confirm2 = 'y ' ;
@@ -1016,7 +1035,7 @@ private function scan($iterator)
1016
1035
} else {
1017
1036
self ::$ summaryIgnored [] = $ _FILE_PATH ;
1018
1037
}
1019
- } elseif (in_array ($ confirmation , array ('5 ' ))) {
1038
+ } elseif (in_array ($ confirmation , array ('5 ' , ' vim ' ))) {
1020
1039
// Edit with vim
1021
1040
$ descriptors = array (
1022
1041
array ('file ' , '/dev/tty ' , 'r ' ),
@@ -1033,7 +1052,7 @@ private function scan($iterator)
1033
1052
self ::$ summaryEdited [] = $ _FILE_PATH ;
1034
1053
Console::writeLine ("File ' $ _FILE_PATH ' edited with vim! " , 2 , 'green ' );
1035
1054
self ::$ summaryRemoved [] = $ _FILE_PATH ;
1036
- } elseif (in_array ($ confirmation , array ('6 ' ))) {
1055
+ } elseif (in_array ($ confirmation , array ('6 ' , ' nano ' ))) {
1037
1056
// Edit with nano
1038
1057
$ descriptors = array (
1039
1058
array ('file ' , '/dev/tty ' , 'r ' ),
@@ -1050,7 +1069,7 @@ private function scan($iterator)
1050
1069
self ::$ summaryEdited [] = $ _FILE_PATH ;
1051
1070
Console::writeLine ("File ' $ _FILE_PATH ' edited with nano! " , 2 , 'green ' );
1052
1071
self ::$ summaryRemoved [] = $ _FILE_PATH ;
1053
- } elseif (in_array ($ confirmation , array ('7 ' ))) {
1072
+ } elseif (in_array ($ confirmation , array ('7 ' , ' whitelist ' ))) {
1054
1073
// Add to whitelist
1055
1074
foreach ($ pattern_found as $ key => $ pattern ) {
1056
1075
//$exploit = preg_replace("/^(\S+) \[line [0-9]+\].*/si", "$1", $key);
@@ -1069,15 +1088,20 @@ private function scan($iterator)
1069
1088
} else {
1070
1089
Console::writeLine ("Exploits of file ' $ _FILE_PATH ' failed adding file to whitelist! Check write permission of ' " . self ::$ pathWhitelist . "' file! " , 2 , 'red ' );
1071
1090
}
1072
- } elseif (in_array ($ confirmation , array ('8 ' ))) {
1091
+ } elseif (in_array ($ confirmation , array ('8 ' , ' show ' ))) {
1073
1092
// Show source code
1074
1093
Console::newLine ();
1075
1094
Console::displayLine ("$ _FILE_PATH " , 2 , 'yellow ' );
1076
- Console::display (Console::title (' SOURCE ' , '= ' ), 'white ' , 'red ' );
1095
+
1096
+ $ title = Console::title (' SOURCE ' , '= ' );
1097
+ Console::display ($ title , 'white ' , 'red ' );
1077
1098
Console::newLine (2 );
1099
+
1078
1100
Console::code ($ fc , $ pattern_found );
1079
1101
Console::newLine (2 );
1080
- Console::display (Console::title ('' , '= ' ), 'white ' , 'red ' );
1102
+
1103
+ $ title = Console::title ('' , '= ' );
1104
+ Console::display ($ title , 'white ' , 'red ' );
1081
1105
Console::newLine (2 );
1082
1106
} else {
1083
1107
// None
0 commit comments