Commit graph

501 commits

Author SHA1 Message Date
Simone Mainardi
09f9254aa7 Prevents non-admins to switch to system interface
Partially addresses #5324
2021-05-25 17:04:51 +02:00
Luca Deri
d81d8a3295 Fixes bug that precvented session key to work when multiple ntopng instances are started per host 2021-05-21 23:29:15 +02:00
Simone Mainardi
33495e0188 Fixes system interface selection mixed between Lua and C++ 2021-05-11 12:51:34 +02:00
Simone Mainardi
81f43876c6 Removes shutdown check performed in Netfilterinterface 2021-04-09 17:52:45 +02:00
Luca Deri
1a3713394b Compilation fix 2021-04-09 16:02:48 +02:00
Luca
a4047c5a1c Implements flow callbacks and alerts in C++
Scaffolding code of the host scripts

Scaffolding code for host alerts

Adds host_callbacks/ for .cpp files

Implements all classes for host callbacks

Removes pro/enterprise host callbacks

Adds typedefs with callback deltas

Compilation fix

Creates instances of host callbacks in loader

Link fix

Removes redundant/non-necessary host alerts

Merges Scan and Flood callbacks together

Removes outdated API files

Refactors alert keys into entity|id

Refactors all flow alert_{...} into flow_alert_{...}

Refactors C++ flow alert_{...} into flow_alert_{...}

Reworks alert ids to include an entity type

Cleanup and merge alertTypeRaw with getAlertType

Minor fix

Refactors alert definitions and keys into sub directories

Implement host alert callback execution and trigger/release logic

Update callbacks API

Adds base CallbacksLoader for {Host,Flow}CallbacksLoader

Implements load of host user scripts with periodicities

Implements runtime reload of host callbacks

Add logic for periodic callbacks

Add 'expired' flag to host alerts

Implements execution of host callbacks and SYN flood checks

Adds triggerAlertAsync calls to SYNFlood

Implements JSON host alert generation info

Handle callback getPeriod. Optimize callback lookup.

Implements host recipients in C++

Add callback status

Define destructor

Iterator fixes

Cleanup host Lua calls (now performed in C++)

Changes to show new host alerts in SQLite

Adds release/engage action on alert JSON

Move AlertableEntity to OtherAlertableEntity, inheriting from a new AlertableEntity. Add HostAlertableEntity.

Implements SYN Flood Attacker with params

Uses parametrized thresholds to trigger syn flood alerts

Implements build alert of both attacker and victim

Implement HostAlertableEntity

Implements SYN scan attacker/victim alerts

Implements flow flood attacker/victim alerts

Removes a debug flag

Add virtual allocStatus

Add HostAlert disableAutoRelease()

Add Ãexplicit releaseAlert()

Implements SYNFloodHostCallbackStatus

Implements SYNScanHostCallbackStatus

Implements FlowFloodHostCallbackStatus

Change trigger API to handle cli/src score

Implements {DNS,SMTP,NTP}ServerContactsAlert

Reworks ServerContacts host alerts

Implement exclusion bitmaps for host alerts

Implements {SMTP,DNS,NTP}ServerContactsAlert

Adds host_info to the generated alert JSON

Minor cleanup

Optimize access to callback status

Move RepliesRequestsRatio to pro

Rework triggerAlert on host to avoid multiple call and unneeded status data

Compilation fix

Reworked host alerts API (wip)

Cleanup unused host callbacks

Compilation fixes

Finishes backend implementation of host alerts exclusions

Rework host callbacks executor

Implements disable of host alerts

Port SYNFlood to the new api

Cleanup

Reduce duplicated code

Comments

Port ServerContacts to the new api

Clenaup

Adds parsing of configuration for host callbacks

Port SYNScanAlert to the new API

Port FlowFlood to the new API

Cleanup unused HostAlert getName

Reworks DNSRequestsErrorsRatioAlert

Adds JSON for DNSTrafficAlert

Adds FlowsAlert

Adds P2PTrafficAlert

Add RepliesRequestsRatioAlert

Adds ScoreAlert

Adds ThroughputAlert

Adds TrafficAlert

Fixes for scan/flood alerts

DNS ratio alert support

Add HTTP stats getters

Implements deltas for many host callbacks

Host score inc

Adds missing Alert params to host alerts

Release all host alerts on idle

Refactors score classes

Implements class Score to contain scores for hosts, flows, etc

Adds scores to VLANs, Networks, ASes and Countries

Host callbacks can trigger a single alert now

FlowFlood, SYNFloo, SYNScan now inherit from FlowHits

Move severity and score to constructor

Add else branch to hits callbacks

Alert definition update for flows_flood, syn_flood, syn_scan

Update field name

Engaged alert init

Adds score incs/decs for AS, VLAN, country, os and network

Restore network scripts

Restored other alert definitions for floods

Handle decreasing alert score

Removes include

Rename flows_flood to flow_flood for consistency

Restored alert_tcp_syn_flood_victim alert_tcp_syn_scan_victim definitions

Fixes for non-host engaged/release alerts

Cleanup LuaEngineFlow and LuaEngineHost classes

Fixes old calls to host lua during shutdown

Removes AlertCheckLuaEngine instance

Fixes purging of flows

Fixes alerts release upon shutdown causing wrong uses

Removes a debug flag

Fix getNumEngagedAlerts

Cleanup unnecessary host callbacks

Removes array of callback statuses inside host

Bitmap fixes

Refactors Bitmap into Bitmap128

Implements 16-bits bitmaps for host alerts

Adds class HostCallbacksStatus

Moves callback status p2p and DNS inside HostCallbacksStatus

Removes unused callbacks in typedefs

Minor cleanup

Adds trigger/release for DNS/p2p alerts

Reworks UI of hosts user scripts

Rename HostCallbackType to HostCallbackID, getType to getID, others
2021-04-03 09:53:15 +02:00
Alfredo Cardigliano
e86fffcc58 Add message to restart ntopng after importing all conf. Improve max post data check. Remove unnecessary exported modules. 2021-03-08 11:14:44 +01:00
Luca Deri
ad9e629e36 Fixes #4961 2021-02-02 18:39:24 +01:00
Luca Deri
34e7f765ee Missing Server: header from HTTP requests 2021-01-25 15:10:21 +01:00
Luca Deri
a1178a0791 Updated (C) 2021-01-02 12:08:23 +01:00
Luca Deri
9c16489912 FreeBSD compilation fixes
Various warning fixes
2020-12-31 18:05:44 +01:00
Luca Deri
2ef29c7c5e Cleanup code removing .inc files 2020-11-25 22:05:06 +01:00
Luca Deri
7353b2d3cc Added Origin under _SERVER variable 2020-11-19 13:49:57 +01:00
Simone Mainardi
049bfdcf4a Implements bitmap-based limited privileges for non-admins
Implements #4489
2020-10-09 15:50:22 +02:00
Simone Mainardi
b5781eea2c Cleanup unused flow_acle lua context member 2020-09-30 18:44:39 +02:00
Alfredo Cardigliano
3be4b69ea8 Fix CSRF check in case of non-REST POST with JSON payload 2020-08-28 15:05:42 +02:00
Simone Mainardi
b31a209e73 Removes a debug print 2020-08-25 17:38:26 +02:00
Simone Mainardi
f4affe2c6c Fixes CSRF vulnerabilities when POSTing JSON
Fixes #4285
2020-08-25 16:47:20 +02:00
Luca Deri
643e78f8d5 Implements most of #4113
- Removed unused google assistant scripts
- Cleaned up existing REST calls using _POST["payload"]

The _GET["parameter"] element is still present and it will be removed soon
2020-07-06 18:06:40 +02:00
andpp
87d77d12d6 Fixing redirection issue after changing interface (#4022)
Simplifies interface switch send redirect code

Addresses https://github.com/ntop/ntopng/pull/4022
2020-06-08 10:31:16 +02:00
Simone Mainardi
fed5cc9577 Enforces CSRF checks only when a session is used
When direct username:password are submitted, there is no need to enforce
such checks as it cannot be a CSRF attack. Indeed, CSRF attacks rely
on a session.

Fixes #4014
2020-06-03 09:59:31 +02:00
Luca Deri
8c948de437 SNMP code reorganization 2020-05-25 23:50:36 +02:00
Simone Mainardi
0050f3b732 Prevents interface switch to default to ifid 0 upon failure 2020-05-20 11:31:41 +02:00
emanuele-f
4460a98afd Fix form submit when ntopng login is disabled 2020-05-18 16:00:19 +02:00
Luca Deri
ccf76ca54d Added "real" intefaceId validation
Initial work towards REST API
2020-05-17 20:47:46 +02:00
emanuele-f
6b4c507492 Move CSRF token from request to session
Now the CSRF token is bound to the user session.
This addresses the issues outlined in #3866 , in particular the CSRF expiration issues.
2020-05-06 13:04:12 +02:00
Luca Deri
f99e184e90 Split LuaEngine.cpp apart (further improvements are necessary) 2020-04-19 12:29:13 +02:00
Simone Mainardi
6ea50fb004 Implements the Elasticsearch alerts endpoint
Implements #3105

Initial work to add elastisearch alerts

Initial implementation of ES alerts

Implements version check

Implements flow alerts format

Changes Elasticsearch index name

Comments the Elasticsearch alert endpoint
2020-04-18 16:35:14 +02:00
emanuele-f
c6b43f1af3 Pass client timezone as a cookie to properly format time 2020-04-15 17:44:08 +02:00
emanuele-f
64ceaa5b89 Fix discarded first RRD point in gauges
The point was discarded because of a bad RRD start time during the RRD creation.
The start time is now computed as "insertion_timestamp - heartbeat".

Fixes #3751
2020-04-15 12:55:31 +02:00
emanuele-f
0ad1b65512 Add plugins support for httpdocs, HTML templates and Lua modules
Such resources can be placed into the following plugin subdirs:

- ./httpdocs: javascript, css and similar, see plugins_utils.getHttpdocsDir
- ./modules: Lua modules, see plugins_utils.loadModule
- ./templates: HTML templates, see plugins_utils.renderTemplate
2020-04-14 17:53:25 +02:00
Luca Deri
f7b1e7d689 Initial work for widget implementation 2020-04-13 14:24:50 +02:00
Luca Deri
edd8715b4a Added ntop.speedtest() API call 2020-04-11 10:47:07 +02:00
emanuele-f
3f5bd04e7a Fix possible lua stack corruptions
Basic rules to avoid corruptions:
  - CONST_LUA_OK must be followed by a lua_push* / lua_newtable
  - CONST_LUA_ERROR must *not* be followed by a lua_push* / lua_newtable

Detailed information can be found at https://www.lua.org/manual/5.2/manual.html#lua_CFunction
2020-04-09 11:26:06 +02:00
Luca Deri
770aae078a Cleanuo 2020-04-07 22:02:28 +02:00
emanuele-f
c66181c3ff Update the ntop_reg API 2020-04-06 12:57:19 +02:00
emanuele-f
f75b84ff33 Remove unused API markers 2020-04-03 18:29:07 +02:00
emanuele-f
151c9581d5 Update interface lua C API 2020-04-03 18:25:59 +02:00
Luca Deri
7eca89e9f5 Merge branch 'dev' of https://github.com/ntop/ntopng into dev 2020-04-02 19:58:56 +02:00
Luca Deri
48b3fbc348 Reworked error messages 2020-04-02 19:50:31 +02:00
emanuele-f
daa8441282 Document the host and network user scripts C API 2020-04-02 18:03:45 +02:00
emanuele-f
a11313c6fd Document the flow user scripts API 2020-04-02 17:10:15 +02:00
Alfredo Cardigliano
a254a3ad6b Support for Enterprise L license 2020-04-02 11:02:56 +00:00
Simone Mainardi
43284e22f8 Fixes crash and removes unused PortContactStats
Class was not used and didn't handle concurrent accesses to strings,
yielding crashes such as

Thread 14 "stats_update.lu" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffb3fff700 (LWP 25268)]
0x00005555556b9183 in IpAddress::intoa (this=0x28c, buf=0x7fffb3ffe030 "", bufLen=64, bitmask=255 '\377') at src/IpAddress.cpp:352
352     src/IpAddress.cpp: No such file or directory.
(gdb)
(gdb) bt
    at src/GenericHash.cpp:222
    #9  0x00005555556c0413 in NetworkInterface::walker (this=0x555556159e70, begin_slot=0x7fffb3ffe454, walk_all=true, wtype=walker_flows, walker=0x5555556c6b79 <host_flow_update_stats(GenericHashEntry*, void*, bool*)>,
        user_data=0x7fffb3ffe458) at src/NetworkInterface.cpp:795
	#10 0x00005555556c6f7c in NetworkInterface::periodicStatsUpdate (this=0x555556159e70, vm=0x7fffac0a5578) at src/NetworkInterface.cpp:2589
	#11 0x0000555555671d62 in ntop_periodic_stats_update (vm=0x7fffac0a5578) at src/LuaEngine.cpp:6304
	#12 0x000055555576c2f6 in luaD_precall ()
	#13 0x0000555555777acd in luaV_execute ()
	#14 0x000055555576c5cf in luaD_call ()
	#15 0x000055555576c621 in luaD_callnoyield ()
	#16 0x000055555576ba42 in luaD_rawrunprotected ()
	#17 0x000055555576c91b in luaD_pcall ()
	#18 0x0000555555769cd4 in lua_pcallk ()
	#19 0x0000555555681e8a in LuaEngine::run_loaded_script (this=0x7fffac01fe10) at src/LuaEngine.cpp:12188
	#20 0x000055555563eca2 in ThreadedActivity::runScript (this=0x555562aee4e0, now=1585309410, script_path=0x7fff88002620 "/usr/share/ntopng/scripts/callbacks/interface/stats_update.lua", iface=0x555556159e70, deadline=1585309420)
	    at src/ThreadedActivity.cpp:418
	    #21 0x00005555556ba04d in ThreadPool::run (this=0x5555624525a0) at src/ThreadPool.cpp:103
	    #22 0x00005555556b9c79 in doRun (ptr=0x5555624525a0) at src/ThreadPool.cpp:31
	    #23 0x00007ffff65aa6db in start_thread (arg=0x7fffb3fff700) at pthread_create.c:463
	    #24 0x00007ffff3ea388f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
2020-03-27 13:36:51 +01:00
Alfredo Cardigliano
18a15a8b86 Reset host names when setting the name from Lua 2020-03-27 10:58:14 +00:00
Alfredo Cardigliano
081c68d4c7 Add setResolvedAddress lua API 2020-03-26 14:17:28 +00:00
emanuele-f
15c013922d Improve plugins reload to avoid transient errors
A "shadow directory" is now populated when the reload occurs and then swapped as the active directory.
This avoids breaking the directory structure or changing files when other threads are possibly working
on them.

Fixes #3595
2020-03-26 14:21:11 +01:00
Luca Deri
49c80c4615 Win changes 2020-03-20 09:50:36 +01:00
emanuele-f
26520abf34 Add IPv6 support in HTTP monitor and don't follow the redirects
Fixes #3560
Fixes #3554
2020-03-16 11:23:37 +01:00
emanuele-f
0be214cfae Implement HTTP RTT Monitoring 2020-03-13 19:03:33 +01:00