scapy on the n900

I came across this rather neat tool called scapy, after playing around with on my desktops I wondered if it would run on my phone(nokia n900) so I checked the repos, and it was in there

Unfortunately AT&T blocks trace-routes :(      oh well, the n900 has wifi so it’s all good \o/

Here’s a demo of me doing a trace-route \o/

Start scapy :D

Start scapy :D

enter in the traceroute command

enter in the traceroute command

run it and watch the moving text :o

run it and watch the moving text :o

oh yay, it's done :D

oh yay, it's done :D

Then run    res.graph(target=”> /tmp/graph.svg”)     to export the graph to a svg   (For me it errors out if I just run res.graph()

Then you can view the .svg in the maemo browser :D

mmmm graphs

mmmm graphs

Of course you can do anything else that scapy allows you to do *evil grin* >.>   but I would highly recommend scripting that, entering in commands on the n900 is quite annoying xD

ex: my crappy but working script for the above:

#! /usr/bin/env python
import sys, os
from scapy.all import *
#txt file with a list
#remove \n
#get name of image to create
name_img = raw_input('enter in name for image: ')
askfile = raw_input('use file for server list? yes/NO: ')
 
if askfile == "yes" or askfile == "y":
	serverfile = open("/root/python/scapy/fromfile/servers", "r")
	servers = [line[:-1] for line in serverfile]
elif askfile == "no" or askfile == 'n' or askfile == "":
	servers = []
	serversin = raw_input("enter in domain/ip(seprate with a space): ")
	servers = serversin.split()
print servers
 
#broken D:
#askport = raw_input('Use default ports?(80, 443)?(YES/no): ')
#if askport == "" or askport == 'yes':
#	ports = "80, 443"
#else:
#	ports = raw_input("enter in ports(seprate with comma): ")
	#ports = portin.split()
#print ports
 
#wiere you want svg and pngs to poop out
path="/home/pronto/images/scapy/"
#scapy stuff
res,unans=traceroute(servers[0:],dport=[22,80,443],maxttl=20,retry=-2)
res.graph(target="> %s%s.svg" % (path,name_img))
  1. First to say thank you for your post.

    If you could help me somehow, i would be grateful.
    When i run scapy on n900 (instaled from repo’s)i get:

    INFO: Can’t import python gnuplot wrapper…
    INFO: Can’t import PyX…

    I know i am missing something and i am sure you know what that is. I see you dont get that “info”.

    Again thank you

    • you need to install them, on the n900 do apt-cache search gnuplut (and for pyx) to get the package name (

      apt-get install gnuplot

      python-xdg – PyXDG is a python library to access freedesktop.org standards.
      gnuplot – The most famous graph drawing program in the world.

  2. I’m afraid that doesn’t solve my problem.
    Both of them (python-xdg and gnuplot) are installed to newest versions on the device and still getting that “INFO” when starting scapy.
    Will try to overcome this somehow…
    Thank you for efforts, if you come up with any ideas, please let me know.

    • Hrm, interesting
      well if it helps any here is what i have installed:

      $ dpkg -l|egrep -i 'pyx|gnuplot|xdg'
      ii gnuplot 4.2.6-7 The most famous graph drawing program in the world.
      ii gnuplot-nox 4.2.6-7 A command-line driven interactive plotting program
      ii gnuplot-x11 4.2.6-7 X11-terminal driver for gnuplot
      ii python-xdg 0.19-0maemo2 PyXDG is a python library to access freedesktop.org stan

      and anything python related:

      ~ $ dpkg -l|egrep -i 'python'
      ii gnome-python 2.18.0-2maemo6 Python bindings for GConf and GnomeVFS
      ii hildon-desktop-python-loader 0.1.0-1maemo3 Hildon Desktop Python Plugin Loader
      ii n900ftp 0.2.1-1 A Python FTP-Client for N900.
      ii pyradio 3.5 A Pandora Radio implementation in full python.
      ii python 2.5.2-3maemo4 An interactive high-level object-oriented language (defa
      ii python-alarm 0.1-0maemo3 Python bindings for libalarm library
      ii python-all 2.5.2-3maemo4 Package depending on all supported Python runtime versio
      ii python-bluez 0.18-1maemo1 Python wrappers around BlueZ for rapid bluetooth develop
      ii python-cairo 1.4.12-1.2maemo2 Python bindings for the Cairo vector graphics library
      ii python-central 0.6.11.1maemo2 register and build utility for Python packages
      ii python-conic 0.1-6 Python bindings for Internet Connectivity library
      ii python-crypto 2.0.1+dfsg1-4maemo0 cryptographic algorithms and protocols for Python
      ii python-dbus 0.83.0-1maemo3 simple interprocess messaging system (Python interface)
      ii python-evolution 0.0.4-maemo2 Python bindings for Evolution Data Server.
      ii python-facebook 0.svn20090225-0maemo2 Python wrappers for the Facebook API
      ii python-gconf 2.26.1-1maemo1 Python bindings for the GConf configuration database sys
      ii python-gdata 2.0.2-0maemo1 Google Data Python client library
      ii python-glade2 2.12.1-6maemo10 GTK+ bindings: Glade support
      ii python-gobject 2.16.1-1maemo2 Python bindings for the GObject library
      ii python-gst0.10 0.10.14-2maemo5 generic media-playing framework (Python bindings)
      ii python-gtk2 2.12.1-6maemo10 Python bindings for the GTK+ widget set
      ii python-hildon 0.9.0-1maemo18 Python bindings for Hildon Framework.
      ii python-hildondesktop 0.1.0-1maemo3 Python bindings for libhildondesktop
      ii python-httplib2 0.4.0-0maemo1 A comprehensive HTTP client library written in python
      ii python-imaging 1.1.6-3maemo2 Python Imaging Library
      ii python-location 0.2-1 Python bindings for liblocation.
      ii python-matplotlib-data 1.0.0-1 Python based plotting system (data package)
      ii python-minimal 2.5.2-3maemo4 A minimal subset of the Python language (default version
      ii python-notify 0.1.1-2maemo1 Python bindings for libnotify
      ii python-numeric 24.2-9maemo4 Numerical (matrix-oriented) Mathematics for Python
      ii python-numpy 1:1.4.0-1maemo4 Numerical Python adds a fast array facility to the Pytho
      ii python-oauth 1.0.1-1 Library for OAuth version 1.0a
      ii python-oauth2 1.2.1-1 A Python OAuth class with several useful features.
      ii python-osso 0.4-0maemo5 Python bindings for libosso library
      ii python-pycurl 7.18.2-1maemo1 Python bindings to libcurl
      ii python-pygame 1.9.1release-0maemo1 SDL bindings for games development in Python
      ii python-runtime 1.0-11 Python runtime environment.
      ii python-scapy 2.0.1-1maemo2 Packet generator/sniffer and network scanner/discovery
      ii python-simplejson 2.0.9-1maemo1 Simple, fast, extensible JSON encoder/decoder for Python
      ii python-support 1.0.6maemo1 automated rebuilding support for Python modules
      ii python-telepathy 0.15.17-1 Python language bindings for telepathy
      ii python-twitter 0.6-maemo1 A pure python interface for the Twitter API.
      ii python-xdg 0.19-0maemo2 PyXDG is a python library to access freedesktop.org stan
      ii python-xml 0.8.4-10.1maemo4 XML tools for Python
      ii python-ystockquote 0.1-0maemo1 Python API for retrieving stock data from Yahoo Finance
      ii python2.5 2.5.4-1maemo6 An interactive high-level object-oriented language (vers
      ii python2.5-dateutil 1.4.1-1 The dateutil module provides powerful extensions to the
      ii python2.5-icalendar 2.0.1-1 The iCalendar package is a parser/generator of iCalendar
      ii python2.5-minimal 2.5.4-1maemo6 A minimal subset of the Python language (version 2.5)
      ii python2.5-mobility-common 4.7.5-maemo1 Shared files for PyQt4
      ii python2.5-mobility-location 4.7.5-maemo1 Shared files for PyQt4
      ii python2.5-qt4 4.7.5-maemo2 Complete Python binding set for Qt4 (PR1.2)
      ii python2.5-qt4-common 4.7.5-maemo2 Shared files for PyQt4
      ii python2.5-qt4-core 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-dbus 4.7.5-maemo2 Python bindings for Qt dbus mainloop.
      ii python2.5-qt4-gl 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-gui 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-maemo5 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-multimedia 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-network 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-phonon 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-script 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-sql 4.7.5-maemo2 Python bindings for PyQt4's SQL module
      ii python2.5-qt4-svg 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-test 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-webkit 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-xml 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-qt4-xmlpatterns 4.7.5-maemo2 Python bindings for Qt4 Core components.
      ii python2.5-sip4 4.11-maemo0 Python/C++ bindings generator runtime library.

  3. After comparing with above, i can see that i have everything installed…i guess it’s just this crazy device harassing me.

  4. avatar Sleepless NSeattle

    Thanks for posting the scapy traceroute script. Earlier, I wasted a bunch of time sifting through O’reilly books trying to create the ‘read from file’ functionality. You rock.

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>