473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to python raw socket ????

have any relate module ??
or write example ??

.>_<.

Please help me
Jul 18 '05 #1
5 14050
Leon wrote:
have any relate module ??
or write example ??

.>_<.

Please help me

http://www.catb.org/~esr/faqs/smart-questions.html
http://docs.python.org/lib/module-socket.html
http://www.google.com/

--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
Hi !

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

It's what you search ?

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

Jul 18 '05 #3
thanks Michel

I find socket module use socket.SOCK_RAW

but... the setsockopt(level,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."
<un************@msupprimerlepoint.claveauPOINTco m> ¼¶¼g©ó¶l¥ó·s»D:41***********************@news.wana doo.fr...
Hi !

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

It's what you search ?

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


Jul 18 '05 #4
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



Jul 18 '05 #5
On 2004-10-15, Leon <sq**********@yahoo.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>
have any relate module ??
Not that I'm aware of.
or write example ??


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_PACKET, SOCK_RAW, proto)
s.bind(("eth1",proto))

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

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

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

print "Tx[%d]: "%len(ethData) + 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(ethData) + 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!!
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Nick Keighley | last post by:
I'm probably missing something rather obvious, but is there a known problem with getting a Python based socket program to communicate with a C based socket program? A simple echo server written in...
0
by: Eric Brunel | last post by:
Hi all, I just compiled Python 2.3.2 on Linux Mandrake 8.0, upgrading from Python 2.1. I have one problem that I can't figure out: when I wanted to get "the" IP address of the current host with...
13
by: Wayne Folta | last post by:
I've been a long-time Perl programmer, though I've not used a boatload of packages nor much of the tacky OO. A couple of years ago, I decided to look into Python and Ruby. Python looked OK, but...
4
by: Edmond Rusjan | last post by:
Hi All, I'd like to use Python-2.3.4 on OSF1 V4.0, but have trouble installing. With a plain "./configure; make" build, I cannot import socket. If I uncomment the socketmodule in Modules/Setup,...
3
by: Michael Sparks | last post by:
Hi, I'm posting a link to this since I hope it's of interest to people here :) I've written up the talk I gave at ACCU Python UK on the Kamaelia Framework, and it's been published as a BBC...
0
by: Kurt B. Kaiser | last post by:
Patch / Bug Summary ___________________ Patches : 393 open (+15) / 3315 closed (+17) / 3708 total (+32) Bugs : 908 open (+22) / 5975 closed (+49) / 6883 total (+71) RFE : 223 open...
0
by: dan.jakubiec | last post by:
I'm trying to write a Python app which accepts a socket connection and then spawns another Python process to handle it. I need it to run under both Linux and Windows. I have it working under...
6
by: Maxim Veksler | last post by:
Hello, I wish to do some low level network stuff using python. I've googled somewhat and came up with pylibpcap, trouble is I can't compile it on my Ubuntu 6.10 workstation. Can someone please...
0
by: Riccardo Di Meo | last post by:
Hi everyone, I'm practicing with embedding python into C code and i have encountered a very strange problem: I'm unable to call the "accept" method of a (correctly created) server socket without...
0
by: GeicoGecko | last post by:
Hey guys, There was no python section in the "Web Development" forum so I'm hoping I can pose my question in here. Our system We currently have a python webserver using SimpleHTTPServer,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.