Nmap Development mailing list archives

Proposal for a new feature to Ncat


From: "codergaz" <coder () gazapos org>
Date: Mon, 23 Jan 2023 20:26:57 +0100

Hello,

First of all, I wanted to thank you for your work in developing great software. I use Ncat on a daily basis and it is a 
must have tool for services management. And I would like to contribute to the project.

A very useful feature would be for Ncat messages to have a timestamp, to know when connections have been established. 
Especially in listen mode, but also in connect mode.

For example, recently I solved a problem based on the time elapsed between connections. But current Ncat version 
doesn't help about that:

Ncat: Listening on :::8080
Ncat: Listening on 0.0.0.0:8080
Ncat: Connection from ::1.
Ncat: Connection from ::1:62307.
Ncat: Connection from ::1.
Ncat: Connection from ::1:62310.

So I've modified the code to add this new feature: print a timestamp in front of each log line...

2023-01-23T19:51:53+0100 Ncat: Listening on [::]:8080
2023-01-23T19:51:53+0100 Ncat: Listening on 0.0.0.0:8080
2023-01-23T19:57:06+0100 Ncat: Connection from 127.0.0.1:59092.

I've tried to modify the minimum:

- a new function log2err in ncat/util.c
- refactoring log* (loguser, logdebug...) functions to use the new function

I pass you the diff, in case you think it can be a useful feature for other people.

I imagine that not everyone will like this type of log, so I've been thinking about how it could be configured:

- showing the timestamp only if the verbose level is high (-vv)

  I don't like the idea: it requires to log too much information just to have the timestamp.

- adding a new parameter to configure whether to add the timestamp to the log or not

  It's an option to consider, but I think you will have more criteria than me

- in the end I've added a constant in ncat/ncat.h: LOG_TIMESTAMP

Do you find it useful?
Do you think more people will like it?
Would it be better to add a parameter to configure it?

Regards
Miguel MacĂ­as

Attachment: nmap.patch
Description:

_______________________________________________
Sent through the dev mailing list
https://nmap.org/mailman/listinfo/dev
Archived at https://seclists.org/nmap-dev/

Current thread: