Squashed commit of the following:
commit
4f8f260b315d4150cc7817c37cf52cf6d0bf85a4
Author: Bhagya Tholpady <bbantwal@cisco.com>
Date: Mon Jul 29 09:59:26 2019 -0400
ftp_telnet: add support for ftp file resume block by calculating path hash used as file id
file_flows->set_sig_gen_state( false );
status = file_flows->file_process(p, file_data, data_length,
- data_ssn->position, data_ssn->direction);
+ data_ssn->position, data_ssn->direction, data_ssn->path_hash);
if ( p->active->packet_force_dropped() )
{
data_ssn->file_xfer_info = ftp_ssn->file_xfer_info;
ftp_ssn->file_xfer_info = 0;
data_ssn->filename = ftp_ssn->filename;
+ data_ssn->path_hash = ftp_ssn->path_hash;
ftp_ssn->filename = nullptr;
+ ftp_ssn->path_hash = 0;
break;
}
}
if ( file_flows )
{
file_flows->file_process(DetectionEngine::get_current_packet(),
- nullptr, 0, SNORT_FILE_END, to_server(), 0);
+ nullptr, 0, SNORT_FILE_END, to_server(), fdfd->session.path_hash);
}
}
}
/* A file is being transferred on ftp-data channel */
char* filename;
+ size_t path_hash;
int file_xfer_info; /* -1: ignore, 0: unknown, >0: filename length */
unsigned char flags;
FTP_TELNET_SESSION ft_ssn;
snort::FlowKey ftp_key;
char* filename;
+ size_t path_hash;
int data_chan;
int file_xfer_info;
FilePosition position;
#include "detection/detection_engine.h"
#include "detection/detection_util.h"
+#include "hash/hashfcn.h"
#include "file_api/file_service.h"
#include "protocols/packet.h"
#include "stream/stream.h"
{
snort_free(ftpssn->filename);
ftpssn->filename = nullptr;
+ ftpssn->path_hash = 0;
ftpssn->file_xfer_info = FTPP_FILE_IGNORE;
}
memcpy(ftpssn->filename, req->param_begin, req->param_size);
ftpssn->filename[req->param_size] = '\0';
ftpssn->file_xfer_info = req->param_size;
+ char *file_name = strrchr(ftpssn->filename, '/');
+ if(!file_name)
+ file_name = ftpssn->filename;
+ ftpssn->path_hash = snort::str_to_hash((uint8_t *)file_name, strlen(file_name));
// 0 for Download, 1 for Upload
ftpssn->data_xfer_dir = CmdConf->file_get_cmd ? false : true;