2
votes

I want to send a packets which I define the ip address, port, data, .etc, at first I thought maybe I can use raw sockets on windows, but after googling for a while, I found that it seemed ms has disabled raw sockets from XP SP2 (is it really?), now I don't know how to do. Someone tells me to use winPcap, then I go to the home page of that software, only to find the last version of that software was released on 02 jul 10, which is too old, I dont know whether it still works now. If possible, I preferred to use Python to complete the task, but it seems inconvenient to use python to realize the raw socket, now I don't know how to do it. Does anyone have a good idea about it? any help appreciated.

3
And does socket.socket not fit your need? - Thomas Orozco

3 Answers

1
votes

scapy should let you do this.

0
votes

This works at least on Win7 when the python is run as administrator:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_RAW)
s.sendto(b"\x00"*16, (192.168.0.255, 0)
0
votes

Have you tried something like

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_RAW)
s.sendto('\xff'*6 + '\x00\x50\xe4\x59\xd9\x30'*16, ('168.1.0.0', 4444))

The documentation for the socket module reads (last example) "The example requires administrator privileges to modify the interface", so you might want to check out how to do this.