fix
This commit is contained in:
parent
b5cf1b9e1a
commit
b880ae0cd3
3 changed files with 18 additions and 14 deletions
22
Riddle.cpp
22
Riddle.cpp
|
@ -109,11 +109,16 @@ int main ( int argc, char **argv ) {
|
||||||
pcap_t *pcap_handle;
|
pcap_t *pcap_handle;
|
||||||
|
|
||||||
if ( vm.count ( "input" ) ) {
|
if ( vm.count ( "input" ) ) {
|
||||||
|
|
||||||
pcap_handle = pcap_open_offline ( vm["input"].as<string>().c_str(), error_buffer );
|
pcap_handle = pcap_open_offline ( vm["input"].as<string>().c_str(), error_buffer );
|
||||||
|
|
||||||
if ( pcap_handle == NULL ) {
|
if ( pcap_handle == NULL ) {
|
||||||
pcap_fatal ( "pcap_open_offline", error_buffer );
|
cerr << "ERROR >> pcap_open_offline: " << error_buffer << endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << ">> Reading packets from " << vm["input"].as<string>() << endl;
|
cerr << ">> Reading packets from " << vm["input"].as<string>() << endl;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
string pcap_device;
|
string pcap_device;
|
||||||
|
@ -121,17 +126,26 @@ int main ( int argc, char **argv ) {
|
||||||
if ( vm.count ( "iface" ) ) {
|
if ( vm.count ( "iface" ) ) {
|
||||||
pcap_device=vm["iface"].as<string>();
|
pcap_device=vm["iface"].as<string>();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Cerca e restituisce interfaccia
|
// Cerca e restituisce interfaccia
|
||||||
char *dev=pcap_lookupdev ( error_buffer );
|
char *dev=pcap_lookupdev ( error_buffer );
|
||||||
if ( dev!=NULL ) pcap_device = dev;
|
if ( dev!=NULL ) {
|
||||||
else pcap_fatal ( "pcap_lookupdev", error_buffer );
|
pcap_device = dev;
|
||||||
|
} else {
|
||||||
|
cerr << "ERROR >> pcap_lookupdev: " << error_buffer << endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apre il device in mod promiscua
|
// Apre il device in mod promiscua
|
||||||
pcap_handle = pcap_open_live ( pcap_device.c_str(), 4096, 1, 0, error_buffer );
|
pcap_handle = pcap_open_live ( pcap_device.c_str(), 4096, 1, 0, error_buffer );
|
||||||
|
|
||||||
if ( pcap_handle == NULL ) {
|
if ( pcap_handle == NULL ) {
|
||||||
pcap_fatal ( "pcap_open_live", error_buffer );
|
cerr << "ERROR >> pcap_open_live: " << error_buffer << endl;
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cerr << ">> Sniffing on device " << pcap_device << endl;
|
cerr << ">> Sniffing on device " << pcap_device << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,14 +34,6 @@
|
||||||
#include "libRiddle.h"
|
#include "libRiddle.h"
|
||||||
#include "../commons/libDump.h"
|
#include "../commons/libDump.h"
|
||||||
|
|
||||||
// Non mettere using namespace generali in header file.
|
|
||||||
|
|
||||||
void pcap_fatal ( const char *error_in, const char *error_buffer ) {
|
|
||||||
std::stringstream ss;
|
|
||||||
ss<<"Fatal Error in "<<error_in<<": "<<error_buffer;
|
|
||||||
throw ( std::runtime_error ( ss.str() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void memPrint ( const unsigned char *start, char len, int index ) {
|
static void memPrint ( const unsigned char *start, char len, int index ) {
|
||||||
printf ( "0x%08x | ",index );
|
printf ( "0x%08x | ",index );
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -38,8 +38,6 @@
|
||||||
} *
|
} *
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void pcap_fatal ( const char *error_in, const char *error_buffer );
|
|
||||||
|
|
||||||
/* Funzioni per la stampa su schermo dei dati in formato esadecimale */
|
/* Funzioni per la stampa su schermo dei dati in formato esadecimale */
|
||||||
void hexDump ( const unsigned char *start, struct pcap_pkthdr header );
|
void hexDump ( const unsigned char *start, struct pcap_pkthdr header );
|
||||||
void rawDump ( const unsigned char *start, struct pcap_pkthdr header );
|
void rawDump ( const unsigned char *start, struct pcap_pkthdr header );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue