#! /usr/bin/perl -w use Getopt::Long; sub usage() { die "\n\nusage: prepare_inject.pl [-w output_file_name inject_object] [-e command {arg_list} ]\n\n". "You must either indicate to write out an injected file with -w or to execute a command,". " with -e, or both.\n\n". "\t'output_file_name' is what the name of the inject_object will be when it is written out to the guest.\n\n". "\t'inject_object' is the file that will be written out to the guest. This could be a text file, program, or ". "really anything.\n\n". "\t'command' is the fully qualified path name for a file within the guest to execute, either by itself, ". "or after a specified inject_object is written out.\n\n"; } &GetOptions("w:s{2}" => \@write_opts, "e:s{,}" => \@exec_opts, "output:s" => \$out_name) or usage(); usage() unless (@exec_opts || @write_opts); $hfile = <generated.h") or die $!; print W $hfile; close(W); print "running special inject code compilation and linking...\n"; # compile with generated h file and inject_code_template.c with peter's script $compile_cmd = "perl compile-for-static-user-level-injection.pl -32 "; $compile_cmd .= "--output=$out_name " if defined($out_name); $compile_cmd .= "inject_code_template.c"; system($compile_cmd); unlink "generated.h"; print "All done.\n";