How to python raw socket ????

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Leon

    #1

    How to python raw socket ????

    have any relate module ??
    or write example ??

    .>_<.

    Please help me


  • Diez B. Roggisch

    #2
    Re: How to python raw socket ????

    Leon wrote:
    [color=blue]
    > have any relate module ??
    > or write example ??
    >
    > .>_<.
    >
    > Please help me[/color]



    Source code: Lib/socket.py This module provides access to the BSD socket interface. It is available on all modern Unix systems, Windows, MacOS, and probably additional platforms. Availability: not ...

    Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.


    --
    Regards,

    Diez B. Roggisch

    Comment

    • Michel Claveau - abstraction méta-galactique non t

      #3
      Re: How to python raw socket ????

      Hi !

      I had see that : http://monkey.org/~dugsong/pypcap/

      It's what you search ?

      @-salutations
      --
      Michel Claveau
      mél : http://cerbermail.com/?6J1TthIa8B





      Comment

      • Leon

        #4
        Re: How to python raw socket ????

        thanks Michel

        I find socket module use socket.SOCK_RAW

        but... the setsockopt(leve l,option,value) fuction,I don't know how to use it

        like 'level' .....because I want to modify ip header....

        ^_^ libpap I can try it.....thanks you very much

        "Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle."
        <unseulmcmcmcmc @msupprimerlepo int.claveauPOIN Tcom> ¼¶¼g©ó¶l¥ó·s»D: 416fb93e$0$2881 2$8fcfb975@news .wanadoo.fr...[color=blue]
        > Hi !
        >
        > I had see that : http://monkey.org/~dugsong/pypcap/
        >
        > It's what you search ?
        >
        > @-salutations
        > --
        > Michel Claveau
        > mél : http://cerbermail.com/?6J1TthIa8B
        >
        >
        >
        >
        >[/color]


        Comment

        • Michel Claveau - abstraction méta-galactique non t

          #5
          Re: How to python raw socket ????

          Hi !

          ......because I want to modify ip header

          Wouaaah ! You want to make a proxy/router, a firewall, or a backdoor in
          Python ?
          It is not my normal work ; but, by curiosity, I would like to read examples
          of code.

          *sorry for my bad english*

          @-salutations
          --
          Michel Claveau
          mél : http://cerbermail.com/?6J1TthIa8B
          sites : http://mclaveau.com http://bergoiata.org http://ponx.org
          newsgroup : news://news.zoo-logique.org/programmation.Paradox









          Comment

          • Grant Edwards

            #6
            Re: How to python raw socket ????

            On 2004-10-15, Leon <square690410@y ahoo.com.tw> wrote:

            It's not good form to rely on the subject of the message to ask
            your question. Repeat the question in the body of the message:

            <http://www.catb.org/~esr/faqs/smart-questions.html>
            [color=blue]
            > have any relate module ??[/color]

            Not that I'm aware of.
            [color=blue]
            > or write example ??[/color]

            Here's a raw socket demo that sends and receives raw Ethernet
            packets using protocol number 0x55aa on interface eth1. The
            file is available at <ftp://ftp.visi.com/users/grante/python/rawDemo.py>.

            Last time I looked, the socket module supported raw sockets
            under Linux only.

            ---------------------------------8<---------------------------------
            #!/usr/bin/python

            import sys
            import string
            import struct
            from socket import *

            proto = 0x55aa

            s = socket(AF_PACKE T, SOCK_RAW, proto)
            s.bind(("eth1", proto))

            ifName,ifProto, pktType,hwType, hwAddr = s.getsockname()

            srcAddr = hwAddr
            dstAddr = "\x01\x02\x03\x 04\x05\x06"
            ethData = "here is some data for an ethernet packet"

            txFrame = struct.pack("!6 s6sh",dstAddr,s rcAddr,proto) + ethData

            print "Tx[%d]: "%len(ethDa ta) + string.join(["%02x"%ord( b) for b in ethData]," ")

            s.send(txFrame)

            rxFrame = s.recv(2048)

            dstAddr,srcAddr ,proto = struct.unpack(" !6s6sh",rxFrame[:14])
            ethData = rxFrame[14:]

            print "Rx[%d]: "%len(ethDa ta) + string.join(["%02x"%ord( b) for b in ethData]," ")

            s.close()
            ---------------------------------8<---------------------------------



            --
            Grant Edwards grante Yow! ... I want to perform
            at cranial activities with
            visi.com Tuesday Weld!!

            Comment

            Working...