Solved

Sending L2 Packet from Window using Python

Posted on 2011-03-07
8
914 Views
Last Modified: 2012-05-11
Hi,

I want to send L2 Packet from Windows using Python. I installed the packages necessary for this.
They are used as import as below.

import dpkt
import pcap
import dnet


sock = dnet.eth('device')

where device is MAC Address of PC
The above call is faling on Windows.

Is there any other way to send a L2 packet from windows.
Like, using pcap or other means.

But the following call is success.

sock = dnet.ip()

You can also look at the link below for reference.
http://libdnet.sourceforge.net/pydoc/

Thanks

0
Comment
Question by:srini_kandimalla
  • 5
8 Comments
 

Author Comment

by:srini_kandimalla
ID: 35071973
It seems no expert is there to answer my question.
0
 
LVL 28

Expert Comment

by:pepr
ID: 35072519
Request the attention of the zone administrator to redirect the question to some other zone related to the networking, protocols, etc.  Speaking for myself, I can help you how to do it with Python; however, I had to know first how it works generally.
0
 

Author Comment

by:srini_kandimalla
ID: 35074264
first, you need to install dpkt, pypcap,dnet.

These downloads are Python2.5 ( 2.5.4 is OK) compatible.

http://code.google.com/p/libdnet/downloads/detail?name=dnet-1.12.win32-py2.5.exe&can=2&q=
http://code.google.com/p/pypcap/downloads/detail?name=pcap-1.1.win32-py2.5.exe&can=2&q=
http://code.google.com/p/dpkt/downloads/detail?name=dpkt-1.7.win32.exe&can=2&q=

After installing these,  you search for some of the sample codes available on the web.

I am able to capture packets and decoding them using dpkt.
But I am unable to send the L2 packets as I mentioned in my original posting.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
LVL 79

Expert Comment

by:David Johnson, CD, MVP
ID: 35075450
raw sockets have been pretty much taken away from windows from xp sp2 onwards
Limitations on Raw Sockets

On Windows 7, Windows Vista, Windows XP with Service Pack 2 (SP2), and Windows XP with Service Pack 3 (SP3), the ability to send traffic over raw sockets has been restricted in several ways:

    * TCP data cannot be sent over raw sockets.
    * UDP datagrams with an invalid source address cannot be sent over raw sockets. The IP source address for any outgoing UDP datagram must exist on a network interface or the datagram is dropped. This change was made to limit the ability of malicious code to create distributed denial-of-service attacks and limits the ability to send spoofed packets (TCP/IP packets with a forged source IP address).
    * A call to the bind function with a raw socket for the IPPROTO_TCP protocol is not allowed.

      Note  The bind function with a raw socket is allowed for other protocols (IPPROTO_IP, IPPROTO_UDP, or IPPROTO_SCTP, for example).
0
 

Author Comment

by:srini_kandimalla
ID: 35075494


I am aware of this limitation specified by MSDN documentation, but I am not using IP layer, That description is meant for RAW sockets to IP layer. I want directly communicate with Ethernet (L2) layer.

Thanks
0
 

Accepted Solution

by:
srini_kandimalla earned 0 total points
ID: 35227325
http://www.secdev.org/projects/scapy/doc/installation.html#windows
Follow the instructions given in this link . Using scapy you can send any kind of packets from windows.
0
 

Author Closing Comment

by:srini_kandimalla
ID: 35292493
I did not get any answer from any of the members. I did lot of work and found it as mentioned in the solution.
0

Featured Post

Want to promote your upcoming event?

Attending an event? Speaking at a conference? Or exhibiting at a trade show? Easily inform your contacts by using a promotional banner in your email signature. This will ensure your organization’s most important contacts are in the know.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now