Unexpected output with grep

greppipestderrstdout

I am using pyrit. For those who don't know, pyrit allows among other things to check if a wpa handshake key is valid:

pyrit -r file0.cap analyze 

when a file does not contain a valid key, here is the output:

Parsing file 'file0.cap' (1/1)...
 AccessPoint e0:xx:xx:xx:xx:xx ('AP_name0'):
No valid EAOPL-handshake + ESSID detected.

Now I am just wondering why when issuing:

pyrit -r file0.cap analyze | grep good 

it always gives me (when there is no valid handshake key) :

No valid EAOPL-handshake + ESSID detected.

when there is a valid key, it works; we have the following output:

HMAC_SHA1_AES, good, spread 1

Best Answer

I think it is because this line

No valid EAOPL-handshake + ESSID detected.

is probably standard error of the pyrit command, not standard out. Normally, | pipes standard out to the next command, with the standard error written immediately to the terminal. Instead, if you want to pass both standard error and out through the pipe, then you can use |&. i.e.

pyrit -r file0.cap analyze |& grep good 
Related Question