Wishlist: Scapy traceroute object pickling

Some of the projects I am working on require that I gather data about particular addresses on the Internet. One method I’ve been experimenting with is scapy’s traceroute function which allows for neat graphing  secdev.org]. One can also combine two arbitrary traceroutes for graphing as simply as:


traceroute1, unans = traceroute([1.2.3.4])
traceroute2, unans = traceroute([5.6.7.8])
combined_traceroutes = traceroute1 + traceroute2

So for me the next logical step was to start storing all the traceroutes in a database so I could combine two or more at will and see interesting things. Not only could I see differences in different paths but I could even see changes of a single path over time! I fought with scapy for a while and finally realized that the export_object and save_object functions are wrappers for cPickle. I’m not entirely familiar with Pickle so I’ve had to do some reading on the topic. So far it does not look promising. No one has come up with a solution for this just yet although there are some promising recipes in the O’Reilly “Python Cookbook” which touch on this subject in a more abstract way. ["Using the cPickle Module on classes and Instances"]

I’ll document some of the errors in case someone else decides to try this and wants to save some time:

>>> trace, unans = traceroute(["4.2.2.2"])

>>> save_object("/tmp/hi", trace)
Traceback (most recent call last):
File "", line 1, in
File "scapy.py", line 876, in save_object
cPickle.dump(obj,gzip.open(fname,"wb"))
File "/usr/lib/python2.5/copy_reg.py", line 69, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle function objects

>>> export_object(trace)
Traceback (most recent call last):
File "", line 1, in
File "scapy.py", line 867, in export_object
print base64.encodestring gzip.zlib.compress(cPickle.dumps(obj,2),9))
PicklingError: Can't pickle : attribute lookup __builtin__.function failed

Creative Commons License
The Wishlist: Scapy traceroute object pickling by Zeroday 01100100011010010, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Share Alike 3.0 License.

Post a Comment

You must be logged in to post a comment.