One of the things that I find lacking in netcat is a timestamp feature. You can log the requests but you can not easy log the exact timestamps. Instead of writing a wrapper around netcat I wrote a small python script that can act as a simple TCP or UDP network server.
A lot of the code is inspired on code at http://ilab.cs.byu.edu/python/select/echoserver.html and http://www.binarytides.com/udp-socket-programming-in-winsock/
All of the code can be found on Github together with a basic UDP client and server script. You can download the scripts easily
svn export https://github.com/cudeso/tools/trunk/network-servers
Feel free to contribute.
The script requires a couple of parameters
- -p –port : the network port;
- -t –protocol : the network protocol;
- -l –logfile : where to log the requests;
- -i –ip : the ip of the server, only used for logging (can be free text);
- -e –echo (not mandatory) : reply the request (default ‘echo’);
- -s –single (not mandatory) : stop after one single request;
The request size in the script is limited to 1024. No other sanity checks are done.
Start it with
./simple-server.py -p 9898 -t udp -l 9898.udp.log -i 192.168.1.1
Because of the lack of security checks it’s best to run this simple server in a disposable virtual server.