Hi all,
have made a fast build of IPTstate with the following compiler output
ipfire build chroot (x86_64) root:/tmp/iptstate-2.2.8_dev$ make
+------------------------------------------------------------+
| Welcome to IP Tables State by Phil Dibowitz |
| |
| PLEASE read the LICENSE and the README for important info. |
| |
| You may also wish to read the README for install info, |
| the WISHLIST for upcoming features, BUGS for known bugs |
| and info on bug reports, and the Changelog to find out |
| what's new. |
| |
| Let's compile... |
+------------------------------------------------------------+
g++ -O2 -g0 -pipe -Wall -fexceptions -fPIC -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection -m64 -mtune=generic -fcf-protection=full iptstate.cc -o iptstate -lncursesw -lnetfilter_conntrack -lnfnetlink
iptstate.cc: In function 'WINDOW* start_curses(flags_t&)':
iptstate.cc:609:7: warning: variable 'y' set but not used [-Wunused-but-set-variable]
609 | int y, x;
| ^
iptstate.cc: In function 'void switch_scroll(flags_t&, WINDOW*&)':
iptstate.cc:706:10: warning: variable 'y' set but not used [-Wunused-but-set-variable]
706 | int x, y;
| ^
iptstate.cc: In function 'void get_input(WINDOW*, std::string&, const std::string&, const flags_t&)':
iptstate.cc:753:10: warning: variable 'y' set but not used [-Wunused-but-set-variable]
753 | int x, y;
| ^
iptstate.cc: In function 'int conntrack_hook(nf_conntrack_msg_type, nf_conntrack*, void*)':
iptstate.cc:1080:31: warning: ':' directive output may be truncated writing 1 byte into a region of size between 0 and 5 [-Wformat-truncation=]
1080 | snprintf(ttlc, 11, "%3i:%02i:%02i", hours, minutes, seconds);
| ^
iptstate.cc:1080:22: note: directive argument in the range [-59, 59]
1080 | snprintf(ttlc, 11, "%3i:%02i:%02i", hours, minutes, seconds);
| ^~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:970,
from /usr/include/c++/14.2.0/cstdio:42,
from /usr/include/c++/14.2.0/ext/string_conversions.h:45,
from /usr/include/c++/14.2.0/bits/basic_string.h:4154,
from /usr/include/c++/14.2.0/string:54,
from /usr/include/c++/14.2.0/bits/locale_classes.h:40,
from /usr/include/c++/14.2.0/bits/ios_base.h:41,
from /usr/include/c++/14.2.0/ios:44,
from /usr/include/c++/14.2.0/istream:40,
from /usr/include/c++/14.2.0/fstream:40,
from iptstate.cc:49:
In function 'int snprintf(char*, size_t, const char*, ...)',
inlined from 'int conntrack_hook(nf_conntrack_msg_type, nf_conntrack*, void*)' at iptstate.cc:1080:11:
/usr/include/bits/stdio2.h:68:35: note: '__builtin___snprintf_chk' output between 10 and 16 bytes into a destination of size 11
68 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
70 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
All done. Do 'make install' as root and you should be set to go!
the changelog from 2021 (also last release) lines also the fix of compiler warnings out but with new compilers some more stuff comes up. The ttlcs buffer size can lead to a buffer overflow which should be fixed IMO.
If you use this tool extensiv you can may help the developer by reporting and may fixing these things ?
First idea to fix both problems:
diff -Naur iptstate-2.2.8_dev.orig/iptstate.cc iptstate-2.2.8_dev/iptstate.cc
--- iptstate-2.2.8_dev.orig/iptstate.cc 2025-04-23 10:51:00.484970700 +0000
+++ iptstate-2.2.8_dev/iptstate.cc 2025-04-23 11:10:57.993010120 +0000
@@ -606,7 +606,7 @@
*/
static WINDOW* start_curses(flags_t &flags)
{
- int y, x;
+ int y __attribute__((unused)), x;
initscr();
cbreak();
noecho();
@@ -703,7 +703,7 @@
*/
void switch_scroll(flags_t &flags, WINDOW *&mainwin)
{
- int x, y;
+ int y __attribute__((unused)), x;
if (flags.noscroll) {
getmaxyx(stdscr, y, x);
// remove stuff from the bottom window
@@ -750,7 +750,7 @@
*/
input = "";
- int x, y;
+ int y __attribute__((unused)), x;
getmaxyx(stdscr, y, x);
WINDOW *cmd = subpad(win, 1, x, 0, 0);
if (!flags.nocolor)
@@ -1035,7 +1035,7 @@
// some vars
struct protoent* pe = NULL;
int seconds, minutes, hours;
- char ttlc[11];
+ char ttlc[16];
ostringstream buffer;
/*
@@ -1077,7 +1077,7 @@
minutes = minutes%60;
seconds = seconds%60;
// Format it with snprintf and store it in the table
- snprintf(ttlc, 11, "%3i:%02i:%02i", hours, minutes, seconds);
+ snprintf(ttlc, 16, "%3i:%02i:%02i", hours, minutes, seconds);
entry->ttl = ttlc;
entry->family = nfct_get_attr_u8(ct, ATTR_ORIG_L3PROTO);
Have build it with this patch with the following results
iptstate-2.2.8_dev.tar.gz checksum OK
====================================== Installing iptstate-2.2.8_dev ...
Install started; saving file list to /usr/src/lsalr ...
cd /usr/src/iptstate-2.2.8_dev && patch -Np1 < /usr/src/src/patches/iptstate-extend_buffer-mark_unused_var.patch
patching file iptstate.cc
cd /usr/src/iptstate-2.2.8_dev && make -j4
make[1]: Entering directory '/usr/src/iptstate-2.2.8_dev'
+------------------------------------------------------------+
| Welcome to IP Tables State by Phil Dibowitz |
| |
| PLEASE read the LICENSE and the README for important info. |
| |
| You may also wish to read the README for install info, |
| the WISHLIST for upcoming features, BUGS for known bugs |
| and info on bug reports, and the Changelog to find out |
| what's new. |
| |
| Let's compile... |
+------------------------------------------------------------+
g++ -O2 -g0 -pipe -Wall -fexceptions -fPIC -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -fstack-clash-protection -m64 -mtune=generic -fcf-protection=full iptstate.cc -o iptstate -lncursesw -lnetfilter_conntrack -lnfnetlink
All done. Do 'make install' as root and you should be set to go!
have tested the patched version a little on IPFire and so far it works.
Apart from that and as mentioned above, connections.cgi makes a similar job, also, the IPTstate project seems to be off or at least outdated but maybe you can help out to (test first and) update it ?
Best,
Erik
P.S.: ntpong is not comparable to IPTstate ā
- iptstate a tool for real-time inspection of the connection state tableāgood for quick, terminal-based diagnostics on firewalls.
- ntopng is a extensible network traffic analysis platform, providing deep visibility (nDPI), analytics, and reporting for entire networks.