Merge branch 'master' into feature-kni

This commit is contained in:
崔一鸣
2019-11-15 21:22:44 +08:00
5 changed files with 25 additions and 23 deletions

View File

@@ -24,16 +24,11 @@ typedef enum _PULL_RESULT_TYPE
PULL_FW_RESULT
}PULL_RESULT_TYPE;
enum tsg_protocol{
TSG_PROTOCOL_UNKNOWN = 0,
TSG_PROTOCOL_SSL,
TSG_PROTOCOL_HTTP
};
#define TSG_DOMAIN_MAX 256
extern Maat_feather_t g_tsg_maat_feather;
int tsg_rule_init(const char *conffile);
int tsg_rule_init(const char *conffile, void *logger);
int tsg_scan_nesting_addr(Maat_feather_t maat_feather, const struct streaminfo *a_stream, tsg_protocol_t proto, scan_status_t *mid, Maat_rule_t*result, int result_num);

View File

@@ -8,14 +8,6 @@ extern "C"
{
#endif
struct _opt_unit_t
{
int opt_type;
int opt_len;
char *opt_value;
};
typedef struct _tsg_log
{
int result_num;
@@ -23,9 +15,24 @@ typedef struct _tsg_log
struct streaminfo *a_stream;
}tsg_log_t;
typedef enum _tld_type
{
TLD_TYPE_LONG=1,
TLD_TYPE_STRING,
TLD_TYPE_FILE
}TLD_TYPE;
int tsg_sendlog_init(char *filename);
void tsg_send_log(const tsg_log_t* log_msg, struct _opt_unit_t* log_opt, int opt_num, int thread_id);
typedef void* TLD_handle_t;
typedef void* tsg_log_instance_t;
extern tsg_log_instance_t g_tsg_log_instance;
TLD_handle_t TLD_create(int thread_id);
int TLD_append(TLD_handle_t handle, char *key, void *value, TLD_TYPE type);
int TLD_cancel(TLD_handle_t handle);
int tsg_send_log(tsg_log_instance_t instance, TLD_handle_t handle, tsg_log_t *log_msg, int thread_id);
#ifdef __cplusplus

View File

@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
add_definitions(-fPIC)
set(SRC tsg_entry.cpp tsg_rule.cpp ssl_utils.cpp tsg_send_log.cpp)
set(SRC tsg_entry.cpp tsg_rule.cpp tsg_ssl_utils.cpp tsg_send_log.cpp)
include_directories(${CMAKE_SOURCE_DIR}/inc)
include_directories(/opt/MESA/include/MESA/)

View File

@@ -2,7 +2,7 @@
#include "MESA/MESA_handle_logger.h"
#include "Maat_rule.h"
#include "Maat_command.h"
#include "ssl_utils.h"
#include "tsg_ssl_utils.h"
#include "tsg_rule.h"
enum kni_scan_table{
@@ -16,7 +16,7 @@ const char *g_kni_scan_table_name[SCAN_TABLE_MAX];
int g_kni_scan_tableid[SCAN_TABLE_MAX] = {0};
static void protocol_identify(char *buff, int buff_len, struct _identify_info *result){
result->protocol = -1;
result->proto = PROTO_MAX;
//TODO: http: get from http protocol plugin
/*
if(is_http){
@@ -29,7 +29,7 @@ static void protocol_identify(char *buff, int buff_len, struct _identify_info *r
struct ssl_chello *chello = NULL;
chello = ssl_chello_parse((const unsigned char*)buff, buff_len, &chello_status);
if(chello_status == CHELLO_PARSE_SUCCESS){
result->protocol = PROTO_SSL;
result->proto = PROTO_SSL;
if(chello->sni == NULL){
result->domain_len = 0;
}
@@ -66,11 +66,11 @@ int tsg_scan_shared_policy(Maat_feather_t maat_feather, void *pkt, int pkt_len,
struct _identify_info *identify_info, scan_status_t *mid, void *logger, int thread_seq){
memset(identify_info, 0, sizeof(*identify_info));
protocol_identify((char*)pkt, pkt_len, identify_info);
if(identify_info->protocol != TSG_PROTOCOL_SSL && identify_info->protocol != TSG_PROTOCOL_HTTP){
if(identify_info->proto != PROTO_SSL && identify_info->proto != PROTO_HTTP){
return -1;
}
int tableid;
if(identify_info->protocol == TSG_PROTOCOL_SSL){
if(identify_info->proto == PROTO_SSL){
tableid = g_kni_scan_tableid[TSG_FIELD_SSL_SNI];
}
else{

View File

@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "ssl_utils.h"
#include "tsg_ssl_utils.h"
#define ALLOC(type, number) ((type *)calloc(sizeof(type), number))
#define FREE(p) {free(*p);*p=NULL;}