OneLiner ICMP sniffer in Python

echo "exec(\"import socket, os\nwhile True:\n\tprint (socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)).recvfrom(65565)\")" | sudo python
Quick OneLiner to sniff for ICMP traffic, proof of concept socket code. Needs root privs to run.
Sample Output
('E\x00@\x00k\xc8\x00\x00@\x01\x00\x00\n\x00\x00\x04\n\x00\x00\x04\x00\x00\x19\xd4\xf0I\x00\x00Ua\x88\xa1\x00\x08,\xd4\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./01234567', ('', 0))
('E\x00@\x00\x9an\x00\x00@\x01\x00\x00\n\x00\x00\x04\n\x00\x00\x04\x00\x00\x18\x06\xf0I\x00\x01Ua\x88\xa2\x00\x08.\xa0\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./01234567', ('', 0))
('E\x00@\x00WH\x00\x00@\x01\x00\x00\n\x00\x00\x04\n\x00\x00\x04\x00\x00\x06\xf9\xf0I\x00\x02Ua\x88\xa3\x00\x08?\xab\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./01234567', ('', 0))

By: justinf
2015-05-24 08:19:55

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: