Solved

Sending L2 Packet from Window using Python

Posted on 2011-03-07
8
958 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 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 80

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

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

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

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

733 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