Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
109 lines (83 sloc) 4.05 KB
pylibnet - Python module for the libnet packet injection library
Copyright (C) 2009 Nadeem Douba
Thank you for trying out pylibnet. I hope it will be of
great value to you. The examples in this directory come
from the efforts of you (the people) and I have been
inspired as of late to contribute to it as well.
To install this module you will need to install the following:
* libnet-1.1.x: to inject your packets.
All these prerequisites can be installed using apt-get, port, or fink.
Debian users can install the following packages to meet the pre-
requisite requirements:
* build-essential
* libnet1-dev
* python-dev
For Mac OS/X users, please use the libnet libraries that come from
the Fink or MacPorts distribution. If you try to compile libnet in
Mac OS/X you will run into a bug that causes "pblock not found" errors.
Mac OS/X users will have to install the following prerequisites
in MacPorts:
* libnet11
* python25 (this is essential since Mac OS/X Python only runs
in 64-bit mode and the libnet lib is 32-bit only)
After installing python25 use the following command to make the
MacPorts distro of Python active:
sudo python_select python25
Please let me know if we can improve this wrapper in any way. The
documentation is embedded in the library and can be accessed via
the help() function in the Python interpretter or pydoc.
Happy Injecting!
lnsh is now part of the standard package for pylibnet. As part
of this package lnsh will be automatically installed to
/usr/local/bin/lnsh for your hacking convenience. More details
about lnsh below.
The following examples require pylibnet, libnet and root
access in order for them to work. The newest addition to
the examples directory is 'lnsh'. It is an interactive
pylibnet console that provides a lot of shortcuts.
Take a look at the example scripts in the lnsh directory.
You can use this interpretter in interactive as well as
scripted mode. A few things to note:
- In interactive mode functions with no parameters can
be called without the round brackets. For example,
'ipv4' would create an ipv4 packet header with all
sorts of random defaults. However, In scripted mode
functions require paranthesis.
- The builders can be called without the 'autobuild_' and
'build_' prefixes. For automatic functions use 'auto_<name>',
and for non-automatic functions use just the '<name>'. For
example, autobuild_arp translates to auto_arp, while
build_ipv4 translates to ipv4. The old function names are
available as well for backwards compatibility.
- The diagnostic functions can be used without the 'get'
prefixes. For example, 'getpacket' translates to 'packet'
and so on. Also the 'diag_*' functions can be called
without the 'diag_' prefix. For example, 'diag_dump_context'
is just 'dump_context'.
- Finally, the injection and device parameters for the context
is specified at runtime. No need to build it within the
script itself. In script mode you will need to either modify
the she-bang (#!) line to specify the appropriate settings or
specify them at runtime. For example, 'tcpsyn.libnet' can be
run using the '-i' parameter ('./tcpsyn.libnet -i eth1') or
without the '-i' parameter ('./tcpsyn.libnet') because of the
she-bang ('#!/usr/local/bin/lnsh -i eth0 -t RAW4'). Additionally,
lnsh scripts can have their own parameters. Take a look at how
the dnsv4.libnet example script looks like for reference. The
she-bang must have a '--' appended to the end of it to accept
parameters (yes I know... it's ugly. but it works). For help in
interactive mode just run lnsh with -h for help or type 'help'
at the command line.
Hope you will enjoy using lnsh as I thoroughly enjoyed coding
it (yes... I have no life).
Please feel free to contribute examples or ideas to this project.
Your effort would be greatly appreciated by myself and most
importantly, the open source community. I can be reached at
<ndouba at gmail dot com>.
To all those who have contributed and provided bug reports.