Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Make it so that any program can read from STDIN

  1. #11
    Very good friend of the forum Gitsnik's Avatar
    Join Date
    Jan 2010
    Location
    The Crystal Wind
    Posts
    851

    Default

    Quote Originally Posted by Virchanza View Post
    Anybody been playing around with this some more? I still can't see why Aircrack won't work when you specify "/dev/stdin".
    I can't find my reference book on this topic (it's no doubt buried somewhere beneath a tonne of other books), but /dev/stdin is treated as a file when you try to open it, rather than as an input device - and it doesn't operate the same way as most other /dev/ nodes do.

    For example:
    Code:
    # echo password | aircrack-ng -w /dev/stdin -e devnetwork dev-01.cap
    Empty dictionnary
    Empty dictionnary
    Opening dev-01.cap
    Read 415 packets.
    
    Opening dev-01.cap
    Please specify a dictionary (option -w).
    
    
    Quitting aircrack-ng...
    And if I tried to write to the device node to begin with:
    Code:
    # echo password > /dev/stdin ; aircrack-ng -w /dev/stdin -e devnetwork dev-01.cap
    password
    Empty dictionnary
    Empty dictionnary
    Opening dev-01.cap
    Read 415 packets.
    
    Opening dev-01.cap
    Please specify a dictionary (option -w).
    
    
    Quitting aircrack-ng...
    Note the highlight. Now, if we start using the built in "-w -" which is probably setting the file descriptor to be 0 (stdin IIRC, and not a "filename" - rather a special case in the assembly code):
    Code:
    echo password > /dev/stdin ; aircrack-ng -w - -e devnetwork dev-01.cap
    The screen appears to "hang" because aircrack is waiting to get something from stdin - to do a "read(0, buffer, size_to_read);" call (as opposed to an fread), probably having just called fflush(stdin) to be sure it's not picking up rubbish as it goes.

    So that's a little convoluted but the premise is the same: when you write "/dev/stdin" most programs (if not all) are going to treat it as an actual file rather than a device node. When the file is empty, the program closes. Without looking at the actual code, I would guess that aircrack is either checking this, or is noting an empty filesize.

    BUT

    Isn't there always a but.

    cat is a special case - or perhaps not special, it's just coded differently yes - cat blocks on the device. A better illustration is to use tail:
    Code:
    tail /dev/stdin
    Which will just sit there and wait sort of like a network socket.

    Someone would have to explain the technical reasons behind all that. It's pretty early for me at the moment, but there it is.
    Still not underestimating the power...

    There is no such thing as bad information - There is truth in the data, so you sift it all, even the crap stuff.

  2. #12
    Good friend of the forums
    Join Date
    Jun 2008
    Posts
    425

    Default

    Havn't got linux booted but would something like this work
    echo password | aircrack-ng -w 1&>0 -e devnetwork dev-01.cap

  3. #13
    Very good friend of the forum Gitsnik's Avatar
    Join Date
    Jan 2010
    Location
    The Crystal Wind
    Posts
    851

    Default

    Quote Originally Posted by compaq View Post
    Havn't got linux booted but would something like this work
    echo password | aircrack-ng -w 1&>0 -e devnetwork dev-01.cap
    No. The ampersand would count as a redirection and break the command in two - bash/tcsh would start looking for a program called "-e" I think (Maybe a program called "0" actually) and everything would fall over.
    Still not underestimating the power...

    There is no such thing as bad information - There is truth in the data, so you sift it all, even the crap stuff.

  4. #14
    Just burned his ISO
    Join Date
    Jan 2010
    Posts
    11

    Default

    Quote Originally Posted by Gitsnik View Post
    No. The ampersand would count as a redirection and break the command in two - bash/tcsh would start looking for a program called "-e" I think (Maybe a program called "0" actually) and everything would fall over.
    You are correct. Perhaps compaq intended:

    echo password | aircrack-ng -w 2>&1 -e devnetwork dev-01.cap


    ...

    Erm, no that still is nonsensical. Why does he seem to be trying to do a stream redirect in the middle of a command?

    I see, he is trying to have it write to standard out by passing a stream redirect as a parameter. That is a clever idea, compaq, but unfortunately has no chance of working due to the way that program arguments are typically parsed (via getopts(..), which is how the aircrack suite parses args).

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •