Tuesday, February 6, 2007, 02:00 AM - code
I've picked out the packet capture part of PG and turned it into a reasonably useful and lightweight logger that should run on any UNIX system (tested on Linux). Packet length, remote IP, transaction direction, Country Code and port are all logged. Packet lengths are added over time, so you see an accumulation of traffic per IP.
Use (as root):
./pcap_collate <DEVICE> <PATH>This script will capture, log and collate TCP and UDP packets going over <DEVICE> (eth0, eth1 etc). the <PATH> argument sets the location the resulting GZIPped log will be written to, which will be updated every 1000 packets.
For this reason the script will automatically generate a new log on a new day and can be restarted at any time without losing more than 1000 packets of traffic.
The log is a dump of the dict containing comma separated fields structured as follows:
IP, direction, port, geo, lengthIt will filter out all the packets on the local network, and so is intended for use in recording Internet traffic going over a single host.
Ports to be filtered for can be set in the file config/filter.config
Stop capture with the script 'stop_capture'.
Get it here. Unpack and see the file README.txt.
| permalink
Thursday, February 2, 2006, 10:11 PM - code
Some fun to be had. To start with try this:
import ossaudiodev
from ossaudiodev import AFMT_S16_LE
from Numeric import *
dsp = ossaudiodev.open('w')
dsp.setfmt(AFMT_S16_LE)
dsp.channels(2)
dsp.speed(22050)
i = 0
x = raw_input("length: ")
x = int(x)
a = arange(x)
while 1:
# between 200 and 600 is good
while i < x:
i = i +1
b = a[i:]
dsp.writeall(str(b))
print i,":",x
else:
while i !=0:
i = i -1
b = a[i:]
dsp.writeall(str(b))
print i,":",x
Thursday, February 2, 2006, 10:10 PM - code
it's harder than you think!
here it is in python ported from some Java i found online.
Thursday, February 2, 2006, 10:10 PM - code
here's a wifi access point brower i wrote in python for Linux users that prefer to use console applications. i
'll get around to one that roams and pumps based on the best offer.
scent.py
Thursday, February 2, 2006, 10:09 PM - code
here's a little python script to let you know when your laptop battery is running low.
dacpi.py
back




