low level networking in python

kyosohma at gmail.com kyosohma at gmail.com
Tue Apr 3 17:43:57 CEST 2007


On Apr 3, 10:29 am, "Maxim Veksler" <hq4e... at gmail.com> wrote:
> Hello,
>
> I wish to do some low level network stuff using python.
>
> I've googled somewhat and came up with pylibpcap[1], trouble is I
> can't compile it on my Ubuntu 6.10 workstation. Can someone please
> suggest a way to read some bits from random ports? I'm looking to
> write a simple pen-testing tool that would try from one side
> connecting to ports and from the other side sniff traffic to see on
> what ports traffic is coming.
>
> For pylibpcap I'm getting:
>
> """
> hq4ever at lucky:~/development/personal/pylibpcap/pylibpcap-0.5.1$ python
> setup.py build
> running build
> running build_ext
> building '_pcapmodule' extension
> swig -python -shadow -ISWIG -o pcap.c pcap.i
> pcap.i:72: Warning(124): Specifying the language name in %typemap is
> deprecated - use #ifdef SWIG<LANG> instead.
> pcap.i:77: Warning(124): Specifying the language name in %typemap is
> deprecated - use #ifdef SWIG<LANG> instead.
> pcap.i:82: Warning(124): Specifying the language name in %typemap is
> deprecated - use #ifdef SWIG<LANG> instead.
> /usr/bin/python ./build-tools/docify.py pcap.c
> /usr/bin/python ./build-tools/docify-shadow.py pcap.py
> Traceback (most recent call last):
>   File "./build-tools/docify-shadow.py", line 30, in ?
>     raise 'source file doesn\'t look like swigged shadow class code'
> source file doesn't look like swigged shadow class code
> error: command '/usr/bin/python' failed with exit status 1
> """
>
> [1]http://pylibpcap.sourceforge.net/
> [2]http://py.vaults.ca/apyllo.py/126307487
>
> --
> Cheers,
> Maxim Veksler
>
> "Free as in Freedom" - Do u GNU ?

I would assume you could use the socket module. This post details
someone else who opened ports with Python:

http://www.thescripts.com/forum/thread44280.html

Here's another resource using some python servers:

http://docs.python.org/lib/socket-example.html

Finally, a Socket programming howto:
http://www.amk.ca/python/howto/sockets/

I'm also told that the Twisted framework is excellent for this sort of
thing.

Mike




More information about the Python-list mailing list