{"id":337,"date":"2008-08-03T03:43:14","date_gmt":"2008-08-03T07:43:14","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/zeroday\/2008\/08\/03\/granted-wish-traceroute-pickling-in-scapy\/"},"modified":"2008-08-03T03:43:14","modified_gmt":"2008-08-03T07:43:14","slug":"granted-wish-traceroute-pickling-in-scapy","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/zeroday\/2008\/08\/03\/granted-wish-traceroute-pickling-in-scapy\/","title":{"rendered":"Granted Wish: Traceroute pickling in scapy"},"content":{"rendered":"<p>A friend of mine sent in a script that worked for him.  <\/p>\n<p><code><br \/>\n#!\/usr\/bin\/env python<\/p>\n<p>import scapy, pickle<\/p>\n<p># pickler<br \/>\ntr, un = scapy.traceroute([\"www.harvard.edu\"])<br \/>\nf = open(\"\/tmp\/pickle-out\", \"w\")<br \/>\np = pickle.Pickler(f)<br \/>\np.dump(tr)<br \/>\nf.close()<\/p>\n<p># unpickler<br \/>\nf = open(\"\/tmp\/pickle-out\", \"r\")<br \/>\nu = pickle.Unpickler(f)<br \/>\ntr = u.load()<br \/>\nprint \" Original tr:----------------------------\"<br \/>\ntr.display()<br \/>\n<\/code><\/p>\n<p>I still couldn&#8217;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&#8217;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&#8217;m still curious why this didn&#8217;t work when I simply downloaded the scapy.py code and executed it.  Once I get some working code I&#8217;ll post it here.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A friend of mine sent in a script that worked for him. #!\/usr\/bin\/env python import scapy, pickle # pickler tr, un = scapy.traceroute([&#8220;www.harvard.edu&#8221;]) f = open(&#8220;\/tmp\/pickle-out&#8221;, &#8220;w&#8221;) p = pickle.Pickler(f) p.dump(tr) f.close() # unpickler f = open(&#8220;\/tmp\/pickle-out&#8221;, &#8220;r&#8221;) u = pickle.Unpickler(f) tr = u.load() print &#8221; Original tr:&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#8221; tr.display() I still couldn&#8217;t get this to [&hellip;]<\/p>\n","protected":false},"author":214,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[274],"tags":[],"class_list":["post-337","post","type-post","status-publish","format-standard","hentry","category-interesting-tech"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/posts\/337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/users\/214"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/comments?post=337"}],"version-history":[{"count":0,"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/posts\/337\/revisions"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/media?parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/categories?post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/zeroday\/wp-json\/wp\/v2\/tags?post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}