You are viewing a read-only archive of the Blogs.Harvard network. Learn more.
Skip to content

Granted Wish: Traceroute pickling in scapy

A friend of mine sent in a script that worked for him.


#!/usr/bin/env python

import scapy, pickle

# pickler
tr, un = scapy.traceroute(["www.harvard.edu"])
f = open("/tmp/pickle-out", "w")
p = pickle.Pickler(f)
p.dump(tr)
f.close()

# unpickler
f = open("/tmp/pickle-out", "r")
u = pickle.Unpickler(f)
tr = u.load()
print " Original tr:----------------------------"
tr.display()

I still couldn’t get this to work on my Ubuntu box. However in a later chat with my colleague Elphine I found out that Ubuntu had it’s own package for scapy. So I used apt-get to install scapy and this time it DID work. This is great since now I can start sticking objects into a database and move on to the next task of combining arbitrary traceroutes for the purposes of making graphs. I’m still curious why this didn’t work when I simply downloaded the scapy.py code and executed it. Once I get some working code I’ll post it here.

Post a Comment

You must be logged in to post a comment.