Skip to content

Commit

Permalink
Refreshed ntopng code
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Aug 25, 2024
1 parent 5720846 commit e34224a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
*
*/

#ifndef _FR_MALICIOUS_JA3_ALERT_H_
#define _FR_MALICIOUS_JA3_ALERT_H_
#ifndef _FR_MALICIOUS_FINGERPRINT_ALERT_H_
#define _FR_MALICIOUS_FINGERPRINT_ALERT_H_

#include "ntop_includes.h"

class FlowRiskMaliciousJA3Alert : public FlowRiskAlert {
class FlowRiskMaliciousFingerprintAlert : public FlowRiskAlert {
public:
static ndpi_risk_enum getClassRisk() { return NDPI_MALICIOUS_JA3; }
static ndpi_risk_enum getClassRisk() { return NDPI_MALICIOUS_FINGERPRINT; }
static FlowAlertType getClassType() {
return FlowRiskAlerts::getFlowRiskAlertType(getClassRisk());
}
static u_int8_t getDefaultScore() {
return FlowRiskAlerts::getFlowRiskScore(getClassRisk());
}

FlowRiskMaliciousJA3Alert(FlowCheck *c, Flow *f) : FlowRiskAlert(c, f){};
~FlowRiskMaliciousJA3Alert(){};
FlowRiskMaliciousFingerprintAlert(FlowCheck *c, Flow *f) : FlowRiskAlert(c, f){};
~FlowRiskMaliciousFingerprintAlert(){};

FlowAlertType getAlertType() const { return getClassType(); }
ndpi_risk_enum getAlertRisk() const { return getClassRisk(); }

bool autoAck() const { return false; };
};

#endif /* _FR_MALICIOUS_JA3_ALERT_H_ */
#endif /* _FR_MALICIOUS_FINGERPRINT_ALERT_H_ */
2 changes: 1 addition & 1 deletion include/flow_alerts_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#include "flow_alerts/FlowRiskHTTPSuspiciousUserAgentAlert.h"
#include "flow_alerts/FlowRiskKnownProtocolOnNonStandardPortAlert.h"
#include "flow_alerts/FlowRiskMalformedPacketAlert.h"
#include "flow_alerts/FlowRiskMaliciousJA3Alert.h"
#include "flow_alerts/FlowRiskMaliciousFingerprintAlert.h"
#include "flow_alerts/FlowRiskMaliciousSHA1CertificateAlert.h"
#include "flow_alerts/FlowRiskMalwareHostContactedAlert.h"
#include "flow_alerts/FlowRiskPeriodicFlowAlert.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@
class FlowRiskMaliciousJA3 : public FlowRisk {
private:
FlowAlertType getAlertType() const {
return FlowRiskMaliciousJA3Alert::getClassType();
return FlowRiskMaliciousFingerprintAlert::getClassType();
}

public:
FlowRiskMaliciousJA3(){};
~FlowRiskMaliciousJA3(){};

FlowAlert *buildAlert(Flow *f) {
return new FlowRiskMaliciousJA3Alert(this, f);
return new FlowRiskMaliciousFingerprintAlert(this, f);
}

std::string getName() const {
return (FlowRiskAlerts::getCheckName(
FlowRiskMaliciousJA3Alert::getClassRisk()));
FlowRiskMaliciousFingerprintAlert::getClassRisk()));
}
ndpi_risk_enum handledRisk() {
return FlowRiskMaliciousJA3Alert::getClassRisk();
return FlowRiskMaliciousFingerprintAlert::getClassRisk();
}
};

Expand Down
2 changes: 1 addition & 1 deletion include/flow_checks_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "flow_checks/FlowRiskHTTPSuspiciousURL.h"
#include "flow_checks/FlowRiskKnownProtocolOnNonStandardPort.h"
#include "flow_checks/FlowRiskMalformedPacket.h"
#include "flow_checks/FlowRiskMaliciousJA3.h"
#include "flow_checks/FlowRiskMaliciousFingerprint.h"
#include "flow_checks/FlowRiskMaliciousSHA1Certificate.h"
#include "flow_checks/FlowRiskMalwareHostContacted.h"
#include "flow_checks/FlowRiskPeriodicFlow.h"
Expand Down
5 changes: 2 additions & 3 deletions src/Flow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
/* static so default is zero-initialization, let's just define it */

const ndpi_protocol Flow::ndpiUnknownProtocol = {
NDPI_PROTOCOL_UNKNOWN, /* master_protocol */
NDPI_PROTOCOL_UNKNOWN, /* app_protocol */
{ NDPI_PROTOCOL_UNKNOWN /* master_protocol */, NDPI_PROTOCOL_UNKNOWN /* app_protocol */ },
NDPI_PROTOCOL_UNKNOWN, /* protocol_by_ip */
NDPI_PROTOCOL_CATEGORY_UNSPECIFIED, NULL};
// #define DEBUG_DISCOVERY
Expand Down Expand Up @@ -3191,7 +3190,7 @@ void Flow::setRisk(ndpi_risk risk_bitmap) {
ndpi_flow_risk_bitmap = risk_bitmap;

has_malicious_cli_signature =
NDPI_ISSET_BIT(ndpi_flow_risk_bitmap, NDPI_MALICIOUS_JA3);
NDPI_ISSET_BIT(ndpi_flow_risk_bitmap, NDPI_MALICIOUS_FINGERPRINT);
}

/* *************************************** */
Expand Down

0 comments on commit e34224a

Please sign in to comment.