[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1071
  • Last Modified:

Sending L2 Packet from Window using Python

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
srini_kandimalla
Asked:
srini_kandimalla
  • 5
1 Solution
 
srini_kandimallaAuthor Commented:
It seems no expert is there to answer my question.
0
 
peprCommented:
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
 
srini_kandimallaAuthor Commented:
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
David Johnson, CD, MVPOwnerCommented:
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
 
srini_kandimallaAuthor Commented:


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
 
srini_kandimallaAuthor Commented:
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
 
srini_kandimallaAuthor Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now