netcat, nc, listen to several requests

0

I am trying to debug a network client. I just need to see several HTTP requests made in sequence.

my first idea was o run nc -l 80, but it will keep open the socket after the first connection. Is there a way to run it quickly as a deamon or multithreaded mode? without having to setup inetd or the likes?

my inelegant solution so far is: while true; do echo 123 | sudo nc -l 80; done it works but is a pain to kill :)

Also you can see there that i do not care at all what is replied to the client. I just want to see the requests coming in without having to install apache/ngix/any more complex script than nc

gcb

Posted 2016-02-29T19:35:05.970

Reputation: 3 392

Why not use a packet sniffer like Wireshark? – Daniel B – 2016-02-29T20:26:03.233

mostly because every host nowadays have nc by default. So i want to learn something that i can use anytime without any overhead. – gcb – 2016-02-29T21:31:43.753

Answers

1

The simplest solution is probably to do:

sudo python -m SimpleHTTPServer 80

which will return proper HTTP responses to the requests also.

seumasmac

Posted 2016-02-29T19:35:05.970

Reputation: 336