2

I am looking to spoof UDP packets using Java. Are there any good Java libraries out there that allow you to create your own RAW SOCKETS?

Raedwald
  • 46,613
  • 43
  • 151
  • 237
Javamann
  • 2,882
  • 2
  • 25
  • 22

4 Answers4

5

I would use a Java API that wraps libpcap.

libpcap has an "inject" function that allows you to send a raw packet. (Of course, you must have root or administrator priveleges on the machine you're trying to send the packet from.) There are a number of Java APIs that are available, such as jNetPcap or jpacp. jpcap, for example, has a class that allows you to send any packet.

mpontillo
  • 13,559
  • 7
  • 62
  • 90
0

That is not something that requires a different library. It's usually part of the standard socket library on the platform, like Winsock or Berkeley sockets. The relevant option is often called ASOCK_RAW.

unwind
  • 391,730
  • 64
  • 469
  • 606
0

In Windows XP SP2 (and presumably higher versions, including vista, but I'm not certain of that), raw sockets are disabled. These restrictions are somewhat less strict for UDP sockets than for TCP sockets, so you may still be able to do whatever you are trying to do. That link contains info on what you can do and how to do it that will probably help you, or at least help you determine if it's possible.

rmeador
  • 25,504
  • 18
  • 62
  • 103
-2

If you are looking to writing a java program to spoof the UDP packets then I would use jNetPcap or jpcap as suggested by Mike. If you just want to spoof (not to write the program) then I would try wireshark.

Gilbeg
  • 741
  • 2
  • 9
  • 19
  • 2
    By spoofing he imply creating packet not just capturing. Wireshark doesn't have a Packet Builder but JPcap and JNetPcap support the operation. – h3xStream Jan 06 '11 at 02:56