#endif
#include "appid_efp_process_event_handler.h"
+#include "detection/detection_engine.h"
#include "appid_debug.h"
#include "appid_inspector.h"
const std::string& name = efp_process_event.get_process_name();
uint8_t conf = efp_process_event.get_process_confidence();
+ const std::string& server_name = efp_process_event.get_server_name();
+ AppId app_id = APP_ID_NONE;
- AppId app_id = asd->get_odp_ctxt().get_efp_ca_matchers().match_efp_ca_pattern(name,
- conf);
+ if (!name.empty())
+ {
+ app_id = asd->get_odp_ctxt().get_efp_ca_matchers().match_efp_ca_pattern(name,
+ conf);
+
+ asd->set_efp_client_app_id(app_id);
+ }
if (appidDebug->is_active())
LogMessage("AppIdDbg %s encrypted client app %d process name '%s', "
- "confidence: %d\n", appidDebug->get_debug_session(), app_id, name.c_str(), conf);
+ "confidence: %d, server name '%s'\n", appidDebug->get_debug_session(), app_id,
+ name.c_str(), conf, server_name.c_str());
- asd->set_efp_client_app_id(app_id);
-}
+ if (!server_name.empty())
+ {
+ AppId client_id;
+ AppId payload_id;
+ AppidChangeBits change_bits;
+ snort::Packet* p = snort::DetectionEngine::get_current_packet();
+
+ if (!asd->tsession)
+ asd->tsession = new TlsSession();
+ asd->tsession->set_tls_host(server_name.c_str(), server_name.length(), change_bits);
+ asd->set_tls_host(change_bits);
+
+ asd->get_odp_ctxt().get_ssl_matchers().scan_hostname(reinterpret_cast<const uint8_t*>(server_name.c_str()),
+ server_name.length(), client_id, payload_id);
+ asd->set_payload_id(payload_id);
+ asd->set_ss_application_ids_payload(payload_id, change_bits);
+
+ asd->publish_appid_event(change_bits, *p);
+ }
+}
api.set_ss_application_ids(client_id, payload_id, change_bits, *flow);
}
+void AppIdSession::set_ss_application_ids_payload(AppId payload_id,
+ AppidChangeBits& change_bits)
+{
+ assert(flow);
+ api.set_ss_application_ids_payload(payload_id, change_bits, *flow);
+}
+
void AppIdSession::set_application_ids_service(AppId service_id, AppidChangeBits& change_bits)
{
assert(flow);
void set_ss_application_ids(AppId service, AppId client, AppId payload, AppId misc,
AppId referred, AppidChangeBits& change_bits);
void set_ss_application_ids(AppId client, AppId payload, AppidChangeBits& change_bits);
+ void set_ss_application_ids_payload(AppId payload, AppidChangeBits& change_bits);
void set_application_ids_service(AppId service_id, AppidChangeBits& change_bits);
void examine_ssl_metadata(AppidChangeBits& change_bits);
}
}
+void AppIdSessionApi::set_ss_application_ids_payload(AppId payload_id,
+ AppidChangeBits& change_bits, Flow& flow)
+{
+ if (application_ids[APP_PROTOID_PAYLOAD] != payload_id)
+ {
+ application_ids[APP_PROTOID_PAYLOAD] = payload_id;
+ change_bits.set(APPID_PAYLOAD_BIT);
+ if (flow.ha_state)
+ flow.ha_state->add(FlowHAState::MODIFIED | FlowHAState::MAJOR);
+ }
+}
+
void AppIdSessionApi::set_ss_application_ids(AppId client_id, AppId payload_id,
AppidChangeBits& change_bits, Flow& flow)
{
void set_ss_application_ids(AppId service, AppId client, AppId payload, AppId misc,
AppId referred, AppidChangeBits& change_bits, Flow& flow);
void set_ss_application_ids(AppId client, AppId payload, AppidChangeBits& change_bits, Flow& flow);
+ void set_ss_application_ids_payload(AppId payload, AppidChangeBits& change_bits, Flow& flow);
void set_application_ids_service(AppId service_id, AppidChangeBits& change_bits, Flow& flow);
void set_netbios_name(AppidChangeBits& change_bits, const char* name);
void set_netbios_domain(AppidChangeBits& change_bits, const char* domain);
Packet::Packet(bool) { }
Packet::~Packet() = default;
+
+Packet* DetectionEngine::get_current_packet()
+{
+ static Packet p;
+ return &p;
+}
+}
+
+void AppIdSession::publish_appid_event(AppidChangeBits&, const Packet&, bool, uint32_t)
+{
+ return;
+}
+
+bool SslPatternMatchers::scan_hostname(const uint8_t*, size_t, AppId&, AppId&)
+{
+ return true;
+}
+
+void AppIdSession::set_ss_application_ids_payload(AppId, AppidChangeBits&)
+{
+ return;
}
void ApplicationDescriptor::set_id(const Packet&, AppIdSession&, AppidSessionDirection,
void AppIdModule::reset_stats() { }
void AppIdDebug::activate(snort::Flow const*, AppIdSession const*, bool) { }
+
AppId EfpCaPatternMatchers::match_efp_ca_pattern(const string&, uint8_t)
{
return APPID_UT_ID;
if ( !asd.tsession )
asd.tsession = new TlsSession();
- if ( (field=attribute_data.quic_sni()) != nullptr )
+ if ( !asd.tsession->get_tls_host() and (field=attribute_data.quic_sni()) != nullptr )
{
if ( appidDebug->is_active() )
LogMessage("AppIdDbg %s Flow is QUIC\n", appidDebug->get_debug_session());
EfpProcessEvent(const snort::Packet& p, const char* process, uint8_t process_conf) :
p(p), process_name(process), process_confidence(process_conf) { }
+ EfpProcessEvent(const snort::Packet& p, const char* server) : p(p), server_name(server) { }
+
const snort::Packet* get_packet() override { return &p; }
const std::string& get_process_name() const
return process_confidence;
}
+ const std::string& get_server_name() const
+ {
+ return server_name;
+ }
+
+ void set_server_name(const char* server)
+ {
+ if (server)
+ server_name = server;
+ }
+
private:
const snort::Packet &p;
std::string process_name;
uint8_t process_confidence = 0;
+ std::string server_name;
};
#endif