Jon Nelson on 8 Jul 2010 05:09:00 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Simple Python Help WAS:Filtering Packets in Monitor Mode


On Thu, Jul 8, 2010 at 12:44 AM, jim fisher <jedijf@myfisher.org> wrote:
It works, I just used a small test file so the ncurses went too fast -
poc was just print - this works with ncurses too!

#!/usr/bin/env python

from time import sleep
import curses
# create curses screen using whole display
stdscr = curses.initscr()
# I realize this is an infinite loop
# parse the CSV file
for line in open('foo-01.csv'):
   # look for the line with the right MAC
   index=line.find(':5a:84')
   while index != -1:
       start = index + 1
       index = line.find(':5a:84', start)

     # send the line to the screen
#        print line
       stdscr.addstr(0, 0, line)
       sleep(2)
     # redraw the screen
       stdscr.refresh()


sleep added so I could see results.



That did not work for me.  I did not see any results on the screen and it just went back to the command prompt.  Also, sleeping for two seconds would be too much as I need to see the fluctuation of signal strength in real time as much as possible.

On the other hand, Edmond's suggestion of adding ":" to the if line in my original script did work.  Thanks!  An oversight on my part.  There is still and unacceptable latency in the results.  Any thoughts on how to speed it up?  Here is the working code:

#!/usr/bin/env python

import curses
# create curses screen using whole display
stdscr = curses.initscr()
# I realize this is an infinite loop
while True:
  # parse the CSV file
  for line in open('foo-01.csv'):
    # look for the line with the right MAC
    if line.find(':5A:84') != -1:
      # send the line to the screen
      stdscr.addstr(0, 0, line)
      # redraw the screen
      stdscr.refresh()
# I realize I am not properly cleaning up, but will get to that later

On 7/7/10, Jon Nelson <dotcop@gmail.com> wrote:
> On Wed, Jul 7, 2010 at 7:26 PM, jim fisher <jedijf@myfisher.org> wrote:
>
>> This works, without the ncurses stuff:
>
>
>> #!/usr/bin/env python
>>
>> import curses
>> # create curses screen using whole display
>> #stdscr = curses.initscr()
>> # I realize this is an infinite loop
>> # parse the CSV file
>> for line in open('foo-01.csv'):
>>    # look for the line with the right MAC
>>     index=line.find(':5a:84')
>>    while index != -1:
>>        start = index + 1
>>        index = line.find(':5a:84', start)
>>
>>      # send the line to the screen
>>         print line
>> #        stdscr.addstr(0, 0, line)
>>       # redraw the screen
>> #        stdscr.refresh()
>> # I realize I am not properly cleaning up, but will get to that later
>> jimf@dell6000:~$
>>
>>
> Jim,
>
> I didn't realize that I cut out some important stuff when I changed the
> subject line.
>
> I am trying to filter the output of airodump-ng so that I can focus on one
> MAC.  It was suggested that I might have to resort to writing a script and
> using a FIFO.  The constant output file for airodump-ng, foo-01.csv, acts
> like one.  So what I was trying to accomplish with the script was just read
> in the file, print the pertinent line, and loop.  That's the reason for the
> ncurses stuff, otherwise the lines are printed one after the other.
>
> I hope that makes sense.
>
> Jon
>


--
jim fisher
Jedijf

irc freenode  #ubuntu-us-pa
www.myfisher.org

"Do, or do not. There is no 'try.'"
 --  Jedi Master Yoda
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug