Solved

Sending L2 Packet from Window using Python

Posted on 2011-03-07
8
894 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
Comment Utility
It seems no expert is there to answer my question.
0
 
LVL 28

Expert Comment

by:pepr
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
Comment Utility
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
Comment Utility


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
Comment Utility
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
Comment Utility
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 curse of the end user strikes again      

You’ve updated all your end user’s email signatures. Hooray! But guess what? They’re playing around with the HTML, adding stupid taglines and ruining the imagery. Find out how you can save your signatures from end users today.

Join & Write a Comment

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…

772 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

10 Experts available now in Live!

Get 1:1 Help Now