Solved

Sending L2 Packet from Window using Python

Posted on 2011-03-07
8
986 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
8 Comments
 

Author Comment

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

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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 81

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
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…

695 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