[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

sending a rip1 request via python

scripteaze@gmail.com

12/19/2007 2:26:00 PM

ok, im new to this sort of coding so excuse me if im not exactly sure
as to what i need to pull this off.

I need to be able to send a rip1 request to my rip1 enabled device.,
so i need python to send :

01 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
10

which is an RIP1 request and then have it respond back to me. im not
to worried about the returned format, but is there anyway to do this
in just a few lines of python?

i was looking at this page for ideas:

http://www.larsen-b.com/Articl...

its just one of the few google responses for : sending packets with
python.

any responses welcome, thanks :)
5 Answers

Dirk Loss

12/19/2007 4:34:00 PM

0

scripteaze wrote:
> I need to be able to send a rip1 request to my rip1 enabled device.,
> so i need python to send :
> 01 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> 10

Use Scapy:

from scapy import *
myrip = RIP()/RIPEntry(metric=16)
ans, unans = sr(IP(dst="192.168.1.1")/UDP(sport=520)/myrip)

http://www.secdev.org/proje...

Regards
Dirk

scripteaze@gmail.com

12/19/2007 11:15:00 PM

0

On Dec 19, 10:34 am, Dirk Loss <li...@dirk-loss.de> wrote:
> scripteaze wrote:
> > I need to be able to send a rip1 request to my rip1 enabled device.,
> > so i need python to send :
> > 01 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> > 10
>
> Use Scapy:
>
> from scapy import *
> myrip = RIP()/RIPEntry(metric=16)
> ans, unans = sr(IP(dst="192.168.1.1")/UDP(sport=520)/myrip)
>
> http://www.secdev.org/proje...
>
> Regards
> Dirk

Well, i use scapy quite often, however, this needs to be very portable
from one box to another with out the installation of extra

scripteaze@gmail.com

12/19/2007 11:18:00 PM

0

On Dec 19, 5:14 pm, scripteaze <scripte...@gmail.com> wrote:
> On Dec 19, 10:34 am, Dirk Loss <li...@dirk-loss.de> wrote:
>
>
>
> > scripteaze wrote:
> > > I need to be able to send a rip1 request to my rip1 enabled device.,
> > > so i need python to send :
> > > 01 01 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
> > > 10
>
> > Use Scapy:
>
> > from scapy import *
> > myrip = RIP()/RIPEntry(metric=16)
> > ans, unans = sr(IP(dst="192.168.1.1")/UDP(sport=520)/myrip)
>
> >http://www.secdev.org/proje...
>
> > Regards
> > Dirk
>
> Well, i use scapy quite often, however, this needs to be very portable
> from one box to another with out the installation of extra

I was not finished, lol, for some reason my keyboard went haywire and
did its own thing. Anywho, scapy is out of the question. any code
examples? and also, whats the alternative.

thanks in advance

Dirk Loss

12/19/2007 11:50:00 PM

0

scripteaze wrote:
>>> I need to be able to send a rip1 request to my rip1 enabled device.,
> Well, i use scapy quite often, however, this needs to be very portable

import socket
rip_request = '\x01\x01\x00\x00\x00\x02' + '\x00' * 17 + '\x10'
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.sendto(rip_request, ("servername", 520))
s.close()

If you also want to handle the replies, you might want to have a look at
the SocketServer module:

http://docs.python.org/lib/module-SocketS...

Regards
Dirk

scripteaze@gmail.com

12/21/2007 1:57:00 AM

0

On Dec 19, 5:50 pm, Dirk Loss <li...@dirk-loss.de> wrote:
> scripteaze wrote:
>
> >>> I need to be able to send a rip1 request to my rip1 enabled device.,
ok i got everthing setup and its sending the packets, do i have to
create a socket server or cant i simply setup a buf = 1024 and recieve
the replies and display them, i dont need to interact, just view the
returned data if any, thanks

>
> Well, i use scapy quite often, however, this needs to be very
portable
>
> import socket
> rip_request = '\x01\x01\x00\x00\x00\x02' + '\x00' * 17 + '\x10'
> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> s.sendto(rip_request, ("servername", 520))
> s.close()
>
> If you also want to handle the replies, you might want to have a look at
> the SocketServer module:
>
> http://docs.python.org/lib/module-SocketS...
>
> Regards
> Dirk