@@ -33,6 +33,8 @@ use std::collections::HashMap;
33
33
#[ cfg( all( target_os = "linux" , feature = "elf" ) ) ]
34
34
use std:: collections:: HashSet ;
35
35
use std:: ffi:: OsStr ;
36
+ use std:: io:: BufRead ;
37
+ use std:: io:: BufReader ;
36
38
use std:: io:: ErrorKind ;
37
39
#[ cfg( all( feature = "color" , not( target_os = "windows" ) ) ) ]
38
40
use std:: os:: unix:: fs:: PermissionsExt ;
@@ -774,6 +776,13 @@ fn main() {
774
776
. value_name ( "FILE" )
775
777
. help ( "Target file" ) ,
776
778
)
779
+ . arg (
780
+ Arg :: new ( "listfile" )
781
+ . short ( 'L' )
782
+ . long ( "listfile" )
783
+ . value_name ( "LISTFILE" )
784
+ . help ( "Textfile with one filepath in each line" ) ,
785
+ )
777
786
. arg (
778
787
Arg :: new ( "json" )
779
788
. short ( 'j' )
@@ -842,14 +851,15 @@ fn main() {
842
851
)
843
852
. group (
844
853
ArgGroup :: new ( "operation" )
845
- . args ( [ "directory" , "file" , "pid" , "process" , "process-all" ] )
854
+ . args ( [ "directory" , "file" , "listfile" , " pid", "process" , "process-all" ] )
846
855
. required ( true ) ,
847
856
)
848
857
. get_matches ( ) ;
849
858
850
859
// required operation
851
860
let file = args. get_one :: < String > ( "file" ) ;
852
861
let directory = args. get_one :: < String > ( "directory" ) ;
862
+ let listfile = args. get_one :: < String > ( "listfile" ) ;
853
863
let procids = args. get_one :: < String > ( "pid" ) ;
854
864
let procname = args. get_one :: < String > ( "process" ) ;
855
865
let procall = args. get_flag ( "process-all" ) ;
@@ -976,5 +986,33 @@ fn main() {
976
986
process:: exit ( 1 ) ;
977
987
}
978
988
}
989
+ } else if let Some ( listfile) = listfile {
990
+ let file_path = Path :: new ( listfile) ;
991
+
992
+ if !file_path. is_file ( ) {
993
+ eprintln ! ( "Listfile {} not found" , underline!( listfile) ) ;
994
+ process:: exit ( 1 ) ;
995
+ }
996
+
997
+ let f = fs:: File :: open ( file_path) . unwrap ( ) ;
998
+ let mut reader = BufReader :: new ( f) ;
999
+ let mut line = String :: new ( ) ;
1000
+ let mut bins: Vec < Binary > = Vec :: new ( ) ;
1001
+
1002
+ while let Ok ( size) = reader. read_line ( & mut line) {
1003
+ if size == 0 {
1004
+ break ;
1005
+ }
1006
+ let binary_file_path = Path :: new ( line. trim ( ) ) ;
1007
+ if !binary_file_path. is_file ( ) {
1008
+ eprintln ! ( "File {} not found" , underline!( line. trim( ) ) ) ;
1009
+ process:: exit ( 1 ) ;
1010
+ }
1011
+ if let Ok ( mut result) = parse_single_file ( binary_file_path, libraries) {
1012
+ bins. append ( & mut result) ;
1013
+ }
1014
+ line. clear ( ) ;
1015
+ }
1016
+ print_binary_results ( & bins, & settings) ;
979
1017
}
980
1018
}
0 commit comments