2

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.

Eric O. Lebigot
  • 91,433
  • 48
  • 218
  • 260
Searene
  • 25,920
  • 39
  • 129
  • 186

3 Answers3

1

scapy should let you do this.

JJC
  • 9,547
  • 8
  • 48
  • 53
0

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.

Eric O. Lebigot
  • 91,433
  • 48
  • 218
  • 260
  • thx a lot, but i mean that i want to send to the specific ip address using specific port, IOW i want to camouflage an application to send the packets – Searene Mar 01 '12 at 12:46
  • Yeah, but someone said that codes Raw socket using python may not be as convenient as C, so i am considering which language should i use, and just as what i have said above, it seems that ms has disabled raw socket from XP SP2, so i dont know whether it does work now. have you ever used `socket.SOCK_RAW` before? @Kimvais – Searene Mar 01 '12 at 12:50
0

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)
Kimvais
  • 38,306
  • 16
  • 108
  • 142
  • can you give a more detail example? e.g. i want to edit each part of that packet, can python realize it? – Searene Mar 01 '12 at 15:08