tcpflow.cpp (tcpflow-1.5.0) | : | tcpflow.cpp (tcpflow-1.6.1) | ||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
#include <cap-ng.h> | #include <cap-ng.h> | |||
#endif | #endif | |||
/* droproot is from tcpdump. | /* droproot is from tcpdump. | |||
* See https://github.com/the-tcpdump-group/tcpdump/blob/master/tcpdump.c#L611 | * See https://github.com/the-tcpdump-group/tcpdump/blob/master/tcpdump.c#L611 | |||
*/ | */ | |||
const char *program_name = 0; | const char *program_name = 0; | |||
const char *tcpflow_droproot_username = 0; | const char *tcpflow_droproot_username = 0; | |||
const char *tcpflow_chroot_dir = 0; | const char *tcpflow_chroot_dir = 0; | |||
int packet_buffer_timeout = 10; | ||||
scanner_info::scanner_config be_config; // system configuration | scanner_info::scanner_config be_config; // system configuration | |||
typedef struct { | typedef struct { | |||
const char *name; | const char *name; | |||
const char *dvalue; | const char *dvalue; | |||
const char *help; | const char *help; | |||
} default_t; | } default_t; | |||
default_t defaults[] = { | default_t defaults[] = { | |||
{"tdelta","0","Time delta in seconds"}, | {"tdelta","0","Time delta in seconds"}, | |||
{"packet-buffer-timeout", "10", "Time in milliseconds between each callback from libpcap"}, | ||||
{0,0,0} | {0,0,0} | |||
}; | }; | |||
#ifdef HAVE_NETINET_IP_H | #ifdef HAVE_NETINET_IP_H | |||
#include <netinet/ip.h> | #include <netinet/ip.h> | |||
#endif | #endif | |||
const char *progname = 0; // name of the program | const char *progname = 0; // name of the program | |||
int debug = DEFAULT_DEBUG_LEVEL; // global variable, not clear why | int debug = DEFAULT_DEBUG_LEVEL; // global variable, not clear why | |||
skipping to change at line 86 | skipping to change at line 89 | |||
#define DEFAULT_REPORT_FILENAME "report.xml" | #define DEFAULT_REPORT_FILENAME "report.xml" | |||
/**************************************************************** | /**************************************************************** | |||
*** SCANNER PLUG-IN SYSTEM | *** SCANNER PLUG-IN SYSTEM | |||
****************************************************************/ | ****************************************************************/ | |||
scanner_t *scanners_builtin[] = { | scanner_t *scanners_builtin[] = { | |||
scan_md5, | scan_md5, | |||
scan_http, | scan_http, | |||
scan_netviz, | scan_netviz, | |||
scan_python, | // removed scan_python becasue it does not support Python 3 | |||
// scan_python, | ||||
scan_tcpdemux, | scan_tcpdemux, | |||
#ifdef USE_WIFI | #ifdef USE_WIFI | |||
scan_wifiviz, | scan_wifiviz, | |||
#endif | #endif | |||
0}; | 0}; | |||
bool opt_no_promisc = false; // true if we should not use promiscious mode | bool opt_no_promisc = false; // true if we should not use promiscious mode | |||
/* Long options! | /* Long options! | |||
* | * | |||
skipping to change at line 149 | skipping to change at line 153 | |||
std::cout << " -V : print version number and exit\n"; | std::cout << " -V : print version number and exit\n"; | |||
std::cout << " -w file : write packets not processed to file\n"; | std::cout << " -w file : write packets not processed to file\n"; | |||
std::cout << " -o outdir : specify output directory (default '.')\n"; | std::cout << " -o outdir : specify output directory (default '.')\n"; | |||
std::cout << " -X filename : DFXML output to filename\n"; | std::cout << " -X filename : DFXML output to filename\n"; | |||
std::cout << " -m bytes : specifies skip that starts a new stream (def ault " | std::cout << " -m bytes : specifies skip that starts a new stream (def ault " | |||
<< (unsigned)tcpdemux::options::MAX_SEEK << ").\n"; | << (unsigned)tcpdemux::options::MAX_SEEK << ").\n"; | |||
std::cout << " -F{p} : filename prefix/suffix (-hh for options)\n"; | std::cout << " -F{p} : filename prefix/suffix (-hh for options)\n"; | |||
std::cout << " -T{t} : filename template (-hh for options; default " | std::cout << " -T{t} : filename template (-hh for options; default " | |||
<< flow::filename_template << ")\n"; | << flow::filename_template << ")\n"; | |||
std::cout << " -Z do not decompress gzip-compressed HTTP transaction s\n"; | std::cout << " -Z do not decompress gzip-compressed HTTP transaction s\n"; | |||
std::cout << " -K: output|keep pcap flow structure.\n"; | ||||
std::cout << "\nSecurity:\n"; | std::cout << "\nSecurity:\n"; | |||
std::cout << " -U user relinquish privleges and become user (if running a s root)\n"; | std::cout << " -U user relinquish privleges and become user (if running a s root)\n"; | |||
std::cout << " -z dir chroot to dir (requires that -U be used).\n"; | std::cout << " -z dir chroot to dir (requires that -U be used).\n"; | |||
std::cout << "\nControl of Scanners:\n"; | std::cout << "\nControl of Scanners:\n"; | |||
std::cout << " -E scanner - turn off all scanners except scanner\n"; | std::cout << " -E scanner - turn off all scanners except scanner\n"; | |||
std::cout << " -S name=value Set a configuration parameter (-hh for info) \n"; | std::cout << " -S name=value Set a configuration parameter (-hh for info) \n"; | |||
if(level > 1) { | if(level > 1) { | |||
std::cout << "\n" "Activated options -S name=value:"; | std::cout << "\n" "Activated options -S name=value:"; | |||
skipping to change at line 172 | skipping to change at line 177 | |||
std::cout << '\n'; | std::cout << '\n'; | |||
be13::plugin::info_scanners(false,true,scanners_builtin,'e','x'); | be13::plugin::info_scanners(false,true,scanners_builtin,'e','x'); | |||
} | } | |||
std::cout << "\n" | std::cout << "\n" | |||
"Console output options:\n"; | "Console output options:\n"; | |||
std::cout << " -B: binary output, even with -c or -C (normally -c or -C tu rn it off)\n"; | std::cout << " -B: binary output, even with -c or -C (normally -c or -C tu rn it off)\n"; | |||
std::cout << " -c: console print only (don't create files)\n"; | std::cout << " -c: console print only (don't create files)\n"; | |||
std::cout << " -C: console print only, but without the display of source/d est header\n"; | std::cout << " -C: console print only, but without the display of source/d est header\n"; | |||
std::cout << " -0: don't print newlines after packets when printing to con sole\n"; | std::cout << " -0: don't print newlines after packets when printing to con sole\n"; | |||
std::cout << " -s: strip non-printable characters (change to '.')\n"; | std::cout << " -s: strip non-printable characters (change to '.')\n"; | |||
std::cout << " -J: output json format.\n"; | ||||
std::cout << " -D: output in hex (useful to combine with -c or -C)\n"; | std::cout << " -D: output in hex (useful to combine with -c or -C)\n"; | |||
std::cout << "\n"; | std::cout << "\n"; | |||
#ifndef HAVE_LIBCAIRO | #ifndef HAVE_LIBCAIRO | |||
std::cout << "Rendering not available because Cairo was not installed.\n\n"; | std::cout << "Rendering not available because Cairo was not installed.\n\n"; | |||
#endif | #endif | |||
std::cout << "expression: tcpdump-like filtering expression\n"; | std::cout << "expression: tcpdump-like filtering expression\n"; | |||
std::cout << "\nSee the man page for additional information.\n\n"; | std::cout << "\nSee the man page for additional information.\n\n"; | |||
if(level<2) return; | if(level<2) return; | |||
std::cout << "Filename Prefixes:\n"; | std::cout << "Filename Prefixes:\n"; | |||
std::cout << " -Fc : append the connection counter to ALL filenames\n"; | std::cout << " -Fc : append the connection counter to ALL filenames\n"; | |||
skipping to change at line 200 | skipping to change at line 206 | |||
std::cout << "\n" "Current limitations:" | std::cout << "\n" "Current limitations:" | |||
"\n" " get_max_fds() = " << tcpdemux::getInstance()->get_max_f ds(); | "\n" " get_max_fds() = " << tcpdemux::getInstance()->get_max_f ds(); | |||
std::cout << "\n" " NUM_RESERVED_FDS = " << NUM_RESERVED_FDS; | std::cout << "\n" " NUM_RESERVED_FDS = " << NUM_RESERVED_FDS; | |||
std::cout << '\n'; | std::cout << '\n'; | |||
} | } | |||
/** | /** | |||
* Create the dfxml output | * Create the dfxml output | |||
*/ | */ | |||
static void dfxml_create(class dfxml_writer &xreport,const std::string &command_ line) | static void dfxml_create(class dfxml_writer &xreport,int argc,char * const *argv ) | |||
{ | { | |||
xreport.push("dfxml","xmloutputversion='1.0'"); | xreport.push("dfxml","xmloutputversion='1.0'"); | |||
xreport.push("metadata", | xreport.push("metadata", | |||
"\n xmlns='http://afflib.org/tcpflow/' " | "\n xmlns='http://afflib.org/tcpflow/' " | |||
"\n xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " | "\n xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " | |||
"\n xmlns:dc='http://purl.org/dc/elements/1.1/'" ); | "\n xmlns:dc='http://purl.org/dc/elements/1.1/'" ); | |||
xreport.xmlout("dc:type","Feature Extraction","",false); | xreport.xmlout("dc:type","Feature Extraction","",false); | |||
xreport.pop(); | xreport.pop(); | |||
xreport.add_DFXML_creator(PACKAGE_NAME,PACKAGE_VERSION,"",command_line); | xreport.add_DFXML_creator(PACKAGE_NAME,PACKAGE_VERSION,"","command line to b e provided"); | |||
} | } | |||
/* String replace. Perhaps not the most efficient, but it works */ | /* String replace. Perhaps not the most efficient, but it works */ | |||
void replace(std::string &str,const std::string &from,const std::string &to) | void replace(std::string &str,const std::string &from,const std::string &to) | |||
{ | { | |||
if(from.size()==0) return; | if(from.size()==0) return; | |||
bool changed = false; | bool changed = false; | |||
std::stringstream ss; | std::stringstream ss; | |||
for(unsigned int i=0;i<str.size();){ | for(unsigned int i=0;i<str.size();){ | |||
skipping to change at line 417 | skipping to change at line 423 | |||
/* | /* | |||
* process an input file or device | * process an input file or device | |||
* May be repeated. | * May be repeated. | |||
* If start is false, do not initiate new connections | * If start is false, do not initiate new connections | |||
* Return 0 on success or -1 on error | * Return 0 on success or -1 on error | |||
*/ | */ | |||
#ifdef HAVE_INFLATER | #ifdef HAVE_INFLATER | |||
static inflaters_t *inflaters = 0; | static inflaters_t *inflaters = 0; | |||
#endif | #endif | |||
static int process_infile(tcpdemux &demux,const std::string &expression,const ch ar *device,const std::string &infile) | static int process_infile(tcpdemux &demux,const std::string &expression,std::str ing &device,const std::string &infile) | |||
{ | { | |||
char error[PCAP_ERRBUF_SIZE]; | char error[PCAP_ERRBUF_SIZE]; | |||
int dlt=0; | int dlt=0; | |||
pcap_handler handler; | pcap_handler handler; | |||
int waitfor = -1; | int waitfor = -1; | |||
int pipefd = -1; | int pipefd = -1; | |||
#ifdef HAVE_INFLATER | #ifdef HAVE_INFLATER | |||
if(inflaters==0) inflaters = build_inflaters(); | if(inflaters==0) inflaters = build_inflaters(); | |||
#endif | #endif | |||
skipping to change at line 457 | skipping to change at line 463 | |||
} | } | |||
#endif | #endif | |||
if ((pd = pcap_open_offline(file_path.c_str(), error)) == NULL){ / * open the capture file */ | if ((pd = pcap_open_offline(file_path.c_str(), error)) == NULL){ / * open the capture file */ | |||
die("%s", error); | die("%s", error); | |||
} | } | |||
tcpflow_droproot(demux); // drop root if requested | tcpflow_droproot(demux); // drop root if requested | |||
dlt = pcap_datalink(pd); /* get the handler for this kind of packe ts */ | dlt = pcap_datalink(pd); /* get the handler for this kind of packe ts */ | |||
handler = find_handler(dlt, infile.c_str()); | handler = find_handler(dlt, infile.c_str()); | |||
} else { | } else { | |||
/* if the user didn't specify a device, try to find a reasonable one */ | /* if the user didn't specify a device, try to find a reasonable one */ | |||
if (device == NULL){ | if (device.empty()){ | |||
if ((device = pcap_lookupdev(error)) == NULL){ | #ifdef HAVE_PCAP_FINDALLDEVS | |||
die("%s", error); | char errbuf[PCAP_ERRBUF_SIZE]; | |||
} | pcap_if_t *alldevs = 0; | |||
} | if (pcap_findalldevs(&alldevs,errbuf)){ | |||
die("%s", errbuf); | ||||
} | ||||
if (alldevs == 0) { | ||||
die("found 0 devices, maybe you don't have permissions, switch to ro | ||||
ot or equivalent user instead."); | ||||
} | ||||
device.assign(alldevs[0].name); | ||||
pcap_freealldevs(alldevs); | ||||
#else | ||||
const char* dev = pcap_lookupdev(error); | ||||
if (dev == NULL) | ||||
die("%s", error); | ||||
device.assign(dev); | ||||
#endif | ||||
} | ||||
/* make sure we can open the device */ | /* make sure we can open the device */ | |||
if ((pd = pcap_open_live(device, SNAPLEN, !opt_no_promisc, 1000, error)) == NULL){ | if ((pd = pcap_open_live(device.c_str(), SNAPLEN, !opt_no_promisc, packet _buffer_timeout, error)) == NULL){ | |||
die("%s", error); | die("%s", error); | |||
} | } | |||
tcpflow_droproot(demux); // drop root if requested | tcpflow_droproot(demux); // drop root if requested | |||
/* get the handler for this kind of packets */ | /* get the handler for this kind of packets */ | |||
dlt = pcap_datalink(pd); | dlt = pcap_datalink(pd); | |||
handler = find_handler(dlt, device); | handler = find_handler(dlt, device.c_str()); | |||
} | } | |||
DEBUG(20) ("filter expression: '%s'",expression.c_str()); | DEBUG(20) ("filter expression: '%s'",expression.c_str()); | |||
/* install the filter expression in libpcap */ | /* install the filter expression in libpcap */ | |||
struct bpf_program fcode; | struct bpf_program fcode; | |||
if (pcap_compile(pd, &fcode, expression.c_str(), 1, 0) < 0){ | if (pcap_compile(pd, &fcode, expression.c_str(), 1, 0) < 0){ | |||
die("%s", pcap_geterr(pd)); | die("%s", pcap_geterr(pd)); | |||
} | } | |||
skipping to change at line 497 | skipping to change at line 520 | |||
/* set up signal handlers for graceful exit (pcap uses onexit to put | /* set up signal handlers for graceful exit (pcap uses onexit to put | |||
* interface back into non-promiscuous mode | * interface back into non-promiscuous mode | |||
*/ | */ | |||
portable_signal(SIGTERM, terminate); | portable_signal(SIGTERM, terminate); | |||
portable_signal(SIGINT, terminate); | portable_signal(SIGINT, terminate); | |||
#ifdef SIGHUP | #ifdef SIGHUP | |||
portable_signal(SIGHUP, terminate); | portable_signal(SIGHUP, terminate); | |||
#endif | #endif | |||
/* start listening or reading from the input file */ | /* start listening or reading from the input file */ | |||
if (infile == "") DEBUG(1) ("listening on %s", device); | if (infile == "") DEBUG(1) ("listening on %s", device.c_str()); | |||
int pcap_retval = pcap_loop(pd, -1, handler, (u_char *)tcpdemux::getInstance ()); | int pcap_retval = pcap_loop(pd, -1, handler, (u_char *)tcpdemux::getInstance ()); | |||
if (pcap_retval < 0 && pcap_retval != -2){ | if (pcap_retval < 0 && pcap_retval != -2){ | |||
DEBUG(1) ("%s: %s", infile.c_str(),pcap_geterr(pd)); | DEBUG(1) ("%s: %s", infile.c_str(),pcap_geterr(pd)); | |||
return -1; | return -1; | |||
} | } | |||
pcap_close (pd); | pcap_close (pd); | |||
#ifdef HAVE_FORK | #ifdef HAVE_FORK | |||
if (waitfor != -1) { | if (waitfor != -1) { | |||
wait (0); | wait (0); | |||
skipping to change at line 540 | skipping to change at line 563 | |||
return sha256_generator::hash_buf(buf,bufsize).hexdigest(); | return sha256_generator::hash_buf(buf,bufsize).hexdigest(); | |||
} | } | |||
std::cerr << "Invalid hash name: " << be_hash_name << "\n"; | std::cerr << "Invalid hash name: " << be_hash_name << "\n"; | |||
std::cerr << "This version of bulk_extractor only supports MD5, SHA1, and SH A256\n"; | std::cerr << "This version of bulk_extractor only supports MD5, SHA1, and SH A256\n"; | |||
exit(1); | exit(1); | |||
} | } | |||
static feature_recorder_set::hash_def be_hash(be_hash_name,be_hash_func); | static feature_recorder_set::hash_def be_hash(be_hash_name,be_hash_func); | |||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | |||
{ | { | |||
int argc_original = argc; | ||||
char **argv_original = argv; | ||||
program_name = argv[0]; | program_name = argv[0]; | |||
int opt_help = 0; | int opt_help = 0; | |||
int opt_Help = 0; | int opt_Help = 0; | |||
feature_recorder::set_main_threadid(); | feature_recorder::set_main_threadid(); | |||
sbuf_t::set_map_file_delimiter(""); // no delimiter on carving | sbuf_t::set_map_file_delimiter(""); // no delimiter on carving | |||
#ifdef BROKEN | #ifdef BROKEN | |||
std::cerr << "WARNING: YOU ARE USING AN EXPERIMENTAL VERSION OF TCPFLOW \n"; | std::cerr << "WARNING: YOU ARE USING AN EXPERIMENTAL VERSION OF TCPFLOW \n"; | |||
std::cerr << "THAT DOES NOT WORK PROPERLY. PLEASE USE A RELEASE DOWNLOADED\n "; | std::cerr << "THAT DOES NOT WORK PROPERLY. PLEASE USE A RELEASE DOWNLOADED\n "; | |||
std::cerr << "FROM http://digitalcorpora.org/downloads/tcpflow\n"; | std::cerr << "FROM http://digitalcorpora.org/downloads/tcpflow\n"; | |||
std::cerr << "\n"; | std::cerr << "\n"; | |||
#endif | #endif | |||
bool opt_enable_report = true; | bool opt_enable_report = true; | |||
bool force_binary_output = false; | bool force_binary_output = false; | |||
const char *device = 0; // default device | std::string device; // default device | |||
const char *lockname = 0; | const char *lockname = 0; | |||
std::string reportfilename; | std::string reportfilename; | |||
std::vector<std::string> Rfiles; // files for finishing | std::vector<std::string> Rfiles; // files for finishing | |||
std::vector<std::string> rfiles; // files to read | std::vector<std::string> rfiles; // files to read | |||
tcpdemux &demux = *tcpdemux::getInstance(); // the de mux object we will be using. | tcpdemux &demux = *tcpdemux::getInstance(); // the de mux object we will be using. | |||
std::string command_line = dfxml_writer::make_command_line(argc,argv); | std::string command_line = dfxml_writer::make_command_line(argc,argv); | |||
std::string opt_unk_packets; | std::string opt_unk_packets; | |||
bool opt_quiet = false; | bool opt_quiet = false; | |||
/* Set up debug system */ | /* Set up debug system */ | |||
skipping to change at line 579 | skipping to change at line 604 | |||
if(sizeof(struct be13::ip4)!=20 || sizeof(struct be13::tcphdr)!=20){ | if(sizeof(struct be13::ip4)!=20 || sizeof(struct be13::tcphdr)!=20){ | |||
fprintf(stderr,"COMPILE ERROR.\n"); | fprintf(stderr,"COMPILE ERROR.\n"); | |||
fprintf(stderr," sizeof(struct ip)=%d; should be 20.\n", (int)sizeof(str uct be13::ip4)); | fprintf(stderr," sizeof(struct ip)=%d; should be 20.\n", (int)sizeof(str uct be13::ip4)); | |||
fprintf(stderr," sizeof(struct tcphdr)=%d; should be 20.\n", (int)sizeof (struct be13::tcphdr)); | fprintf(stderr," sizeof(struct tcphdr)=%d; should be 20.\n", (int)sizeof (struct be13::tcphdr)); | |||
fprintf(stderr,"CANNOT CONTINUE\n"); | fprintf(stderr,"CANNOT CONTINUE\n"); | |||
exit(1); | exit(1); | |||
} | } | |||
bool trailing_input_list = false; | bool trailing_input_list = false; | |||
int arg; | int arg; | |||
while ((arg = getopt_long(argc, argv, "aA:Bb:cCd:DE:e:E:F:f:gHhIi:lL:m:o:pqR :r:S:sT:U:Vvw:x:X:z:Z0", longopts, NULL)) != EOF) { | while ((arg = getopt_long(argc, argv, "aA:Bb:cCd:DE:e:E:F:f:gHhIi:lL:m:o:pqR :r:S:sT:U:Vvw:x:X:z:ZK0J", longopts, NULL)) != EOF) { | |||
switch (arg) { | switch (arg) { | |||
case 'a': | case 'a': | |||
demux.opt.post_processing = true; | demux.opt.post_processing = true; | |||
demux.opt.opt_md5 = true; | demux.opt.opt_md5 = true; | |||
be13::plugin::scanners_enable_all(); | be13::plugin::scanners_enable_all(); | |||
break; | break; | |||
case 'A': | case 'A': | |||
fprintf(stderr,"-AH has been deprecated. Just use -a\n"); | fprintf(stderr,"-AH has been deprecated. Just use -a\n"); | |||
break; | break; | |||
skipping to change at line 617 | skipping to change at line 642 | |||
break; | break; | |||
case '0': | case '0': | |||
demux.opt.console_output_nonewline = true; | demux.opt.console_output_nonewline = true; | |||
break; | break; | |||
case 'd': | case 'd': | |||
if ((debug = atoi(optarg)) < 0) { | if ((debug = atoi(optarg)) < 0) { | |||
debug = DEFAULT_DEBUG_LEVEL; | debug = DEFAULT_DEBUG_LEVEL; | |||
DEBUG(1) ("warning: -d flag with 0 debug level '%s'", optarg); | DEBUG(1) ("warning: -d flag with 0 debug level '%s'", optarg); | |||
} | } | |||
break; | break; | |||
case 'D': | case 'D': | |||
demux.opt.output_hex = true;DEBUG(10) ("Console output in hex"); | demux.opt.output_hex = true;DEBUG(10) ("Console output in hex"); | |||
demux.opt.output_strip_nonprint = false; DEBUG(10) ("Will not conv ert non-printablesto '.'"); | demux.opt.output_strip_nonprint = false; DEBUG(10) ("Will not conv ert non-printablesto '.'"); | |||
break; | break; | |||
case 'E': | case 'E': | |||
be13::plugin::scanners_disable_all(); | be13::plugin::scanners_disable_all(); | |||
be13::plugin::scanners_enable(optarg); | be13::plugin::scanners_enable(optarg); | |||
break; | break; | |||
case 'e': | case 'e': | |||
be13::plugin::scanners_enable(optarg); | be13::plugin::scanners_enable(optarg); | |||
demux.opt.post_processing = true; // enable post processing if anyth ing is turned on | demux.opt.post_processing = true; // enable post processing if anyth ing is turned on | |||
break; | break; | |||
case 'F': | case 'F': | |||
for(const char *cc=optarg;*cc;cc++){ | for(const char *cc=optarg;*cc;cc++){ | |||
skipping to change at line 652 | skipping to change at line 677 | |||
} | } | |||
} | } | |||
break; | break; | |||
case 'f': | case 'f': | |||
{ | { | |||
int mnew = atoi(optarg); | int mnew = atoi(optarg); | |||
DEBUG(1)("changing max_fds from %d to %d",demux.max_fds,mnew); | DEBUG(1)("changing max_fds from %d to %d",demux.max_fds,mnew); | |||
demux.max_fds = mnew; | demux.max_fds = mnew; | |||
break; | break; | |||
} | } | |||
case 'i': device = optarg; break; | case 'i': device = std::string(optarg); break; | |||
case 'I': | case 'I': | |||
DEBUG(10) ("creating packet index files"); | DEBUG(10) ("creating packet index files"); | |||
demux.opt.output_packet_index = true; | demux.opt.output_packet_index = true; | |||
break; | break; | |||
case 'g': | case 'g': | |||
demux.opt.use_color = 1; | demux.opt.use_color = 1; | |||
DEBUG(10) ("using colors"); | DEBUG(10) ("using colors"); | |||
break; | break; | |||
case 'l': trailing_input_list = true; break; | case 'l': trailing_input_list = true; break; | |||
case 'J': | ||||
demux.opt.output_json = true; | ||||
break; | ||||
case 'K':; | ||||
demux.opt.output_pcap = true; | ||||
demux.alter_processing_core(); | ||||
break; | ||||
case 'L': lockname = optarg; break; | case 'L': lockname = optarg; break; | |||
case 'm': | case 'm': | |||
demux.opt.max_seek = atoi(optarg); | demux.opt.max_seek = atoi(optarg); | |||
DEBUG(10) ("max_seek set to %d",demux.opt.max_seek); break; | DEBUG(10) ("max_seek set to %d",demux.opt.max_seek); break; | |||
case 'o': | case 'o': | |||
demux.outdir = optarg; | demux.outdir = optarg; | |||
flow::outdir = optarg; | flow::outdir = optarg; | |||
break; | break; | |||
case 'p': opt_no_promisc = true; DEBUG(10) ("NOT turning on promiscuous m ode"); break; | case 'p': opt_no_promisc = true; DEBUG(10) ("NOT turning on promiscuous m ode"); break; | |||
case 'q': opt_quiet = true; break; | case 'q': opt_quiet = true; break; | |||
skipping to change at line 808 | skipping to change at line 840 | |||
/* report file specified? If so, open it. | /* report file specified? If so, open it. | |||
* Note: If we are going to chroot, we need apply the chroot prefix also, | * Note: If we are going to chroot, we need apply the chroot prefix also, | |||
* but we need to open the file *now*. | * but we need to open the file *now*. | |||
*/ | */ | |||
if(reportfilename.size()>0 && opt_enable_report){ | if(reportfilename.size()>0 && opt_enable_report){ | |||
if (tcpflow_chroot_dir){ | if (tcpflow_chroot_dir){ | |||
reportfilename = std::string(tcpflow_chroot_dir) + std::string("/") + reportfilename; | reportfilename = std::string(tcpflow_chroot_dir) + std::string("/") + reportfilename; | |||
} | } | |||
std::cerr << "reportfilename: " << reportfilename << "\n"; | std::cerr << "reportfilename: " << reportfilename << "\n"; | |||
xreport = new dfxml_writer(reportfilename,false); | xreport = new dfxml_writer(reportfilename,false); | |||
dfxml_create(*xreport,command_line); | dfxml_create(*xreport,argc_original,argv_original); | |||
demux.xreport = xreport; | demux.xreport = xreport; | |||
} | } | |||
if(opt_unk_packets.size()>0){ | if(opt_unk_packets.size()>0){ | |||
if(input_fname.size()==0){ | if(input_fname.size()==0){ | |||
std::cerr << "currently the -w option requires the -r option\n"; | std::cerr << "currently the -w option requires the -r option\n"; | |||
exit(1); | exit(1); | |||
} | } | |||
if(access(input_fname.c_str(),R_OK)) die("cannot read: %s: %s",input_fna me.c_str(),strerror(errno)); | if(access(input_fname.c_str(),R_OK)) die("cannot read: %s: %s",input_fna me.c_str(),strerror(errno)); | |||
demux.save_unk_packets(opt_unk_packets,input_fname); | demux.save_unk_packets(opt_unk_packets,input_fname); | |||
} | } | |||
/* Debug prefix set? */ | /* Debug prefix set? */ | |||
std::string debug_prefix=progname; | std::string debug_prefix=progname; | |||
si.get_config("debug-prefix",&debug_prefix,"Prefix for debug output"); | si.get_config("debug-prefix",&debug_prefix,"Prefix for debug output"); | |||
init_debug(debug_prefix.c_str(),0); | init_debug(debug_prefix.c_str(),0); | |||
DEBUG(10) ("%s version %s ", PACKAGE_NAME, PACKAGE_VERSION); | DEBUG(10) ("%s version %s ", PACKAGE_NAME, PACKAGE_VERSION); | |||
const char *name = device; | const char *name = device.c_str(); | |||
if(input_fname.size()>0) name=input_fname.c_str(); | if(input_fname.size()>0) name=input_fname.c_str(); | |||
if(name==0) name="<default>"; | if(name==0) name="<default>"; | |||
feature_file_names_t feature_file_names; | feature_file_names_t feature_file_names; | |||
be13::plugin::get_scanner_feature_file_names(feature_file_names); | be13::plugin::get_scanner_feature_file_names(feature_file_names); | |||
feature_recorder_set fs(feature_recorder_set::NO_ALERT,be_hash,name,demux.ou tdir); | feature_recorder_set fs(feature_recorder_set::NO_ALERT,be_hash,name,demux.ou tdir); | |||
fs.init(feature_file_names); | fs.init(feature_file_names); | |||
the_fs = &fs; | the_fs = &fs; | |||
demux.fs = &fs; | demux.fs = &fs; | |||
si.get_config("tdelta",&datalink_tdelta,"Time offset for packets"); | si.get_config("tdelta",&datalink_tdelta,"Time offset for packets"); | |||
si.get_config("packet-buffer-timeout", &packet_buffer_timeout, "Time in mill iseconds between each callback from libpcap"); | ||||
/* Record the configuration */ | /* Record the configuration */ | |||
if(xreport){ | if(xreport){ | |||
xreport->push("configuration"); | xreport->push("configuration"); | |||
xreport->pop(); // configuration | xreport->pop(); // configuration | |||
xreport->xmlout("tdelta",datalink_tdelta); | xreport->xmlout("tdelta",datalink_tdelta); | |||
} | } | |||
/* Process r files and R files */ | /* Process r files and R files */ | |||
int exit_val = 0; | int exit_val = 0; | |||
End of changes. 22 change blocks. | ||||
20 lines changed or deleted | 54 lines changed or added |