Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Forgive me if this question seems off-topic but I can't really find a forum that seems more apropos for it, and since the purpose is security related, I put it here.
When I grep for non-icmp output from tcpdump, the following works as intended.
tcpdump -n -vvv | grep 'arp' | perl ps2.pl
where 'perl ps2.pl' is the sub-command that runs a script of mine (ps2.pl) under the perl interpretor, using the grepped output of tcpdump. The script is trivial at this point, all it wants to do is take the input being piped to it using the ol' angle brackets thangy:
somehow, some way, the output (lines from tcpdump having 'icmp') don't get piped into the script, instead, these lines get printed on the screen, but don't go into the script --- what is happening? I tried some "2>&1" type stuff, to no avail. And like I said, the input gets piped successfully if the search term is 'arp' or other non-icmp terms, but as soon as the term being grepped for is icmp, boom, the output stops going where I want it to.
and then get GRC to scan me, it prints out output lines, like:
00:53:31.701798 IP (tos 0x0, ttl 119, id 32768, offset 0, flags [none], proto 1, length: 28) 220.127.116.11 > 18.104.22.168: icmp 8: echo request seq 0
00:53:32.187198 IP (tos 0x0, ttl 119, id 32768, offset 0, flags [none], proto 1, length: 28) 22.214.171.124 > 126.96.36.199: icmp 8: echo request seq 0
00:53:32.687328 IP (tos 0x0, ttl 119, id 32768, offset 0, flags [none], proto 1, length: 28) 188.8.131.52 > 184.108.40.206: icmp 8: echo request seq 0
but when I try to pipe these lines into my perl script, they don't get there, although as long as the grep-string isn't 'icmp', the outputted lines WILL get into the script! I know, this is really strange, and I don't have a clue what is happening..
No, that's what I thought, too --- at first: It's using 2 STDIN and STDERR or STDOUT, when it should be using just one of them (like I mentioned in the OP, "...tried 2>&1 stuff ...") but it doesn't help.
This is too wierd. When I use:
tcpdump -n -vvv | grep 'icmp' | perl ps2.pl
the output goes to the screen, not the script, but when I use:
tcpdump -n -vvv | grep 'arp' | perl ps2.pl
the output successfully gets directed into the script.
tcpdump version 3.8
libpcap version 0.8.3
grep (GNU grep) 2.5.1
which is odd, given my frequent runs of "yum -y update" --- I would have thought that I'd have the latest versions of everything including tcpdump of which I have version 3.8 and not version 3.8.3 that you have.
Oh well, thank god for the fact there's more than one way to do things --- how does that turbo-geek saying go? tim-toady or smt equally special.
I thought I would build as much functionality as I could by cobbling apps together on the command line just as an exercise in command line skills, of which i have a pitifull lack, having been such a recent microsoft defector (I've been running FC4 for a week now). But in the end, I put more functionality in the script instead of the command line with the following:
open ZZ, "tcpdump -n -vvv 2>&1 | " or die "I died because I couldn't start the input pipe $!\n";
print "I seem to have started ... \n";
print "#---> " . $_;
And it works.
I've tried EVERYTHING involving line buffering specifications, wide/narrow character settings, snaplen, the works. Still, as soon as the grepped-for term is icmp and not ANYTHING else, output stops going into the script, so I gave up and decided to use regex's within the script instead of grepping on the command line. It's probably better this way anyway. But I'm still absolutely mystified as to why changing the grep-string to "icmp" has the effect that it does.