Author Topic: RAW Socket in C# for ARP Support  (Read 2233 times)

0 Members and 3 Guests are viewing this topic.

Offline absinthCore

  • NULL
  • Posts: 2
  • Cookies: 0
    • View Profile
RAW Socket in C# for ARP Support
« on: August 13, 2014, 03:22:57 pm »
Hi every one, I'm new here and need some help :/
I'm trying to create my own ARP Support Library for .NET but I have some problems with RAW socket and I don't find documentation about that.
I tried many things but I allways got an exception about a forbidden access to Sockets.

Thanks for attention and help

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: RAW Socket in C# for ARP Support
« Reply #1 on: August 13, 2014, 06:13:02 pm »
Dont take my word for it, because I honestly dont know for sure. But I dont think you will be able to send ARP packets with .NET. You will most likely need a third party library. I have used the winpcap library for various raw packet situations, but it really is raw, it does nothing for you other than checksums.

http://pcapdotnet.codeplex.com/ iirc
« Last Edit: August 13, 2014, 06:14:30 pm by ande »
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline absinthCore

  • NULL
  • Posts: 2
  • Cookies: 0
    • View Profile
Re: RAW Socket in C# for ARP Support
« Reply #2 on: August 13, 2014, 09:02:40 pm »
I actually import the iphlpapi.dll to use SendARP from Windows C Library, but I can't control how many request it sends.
ARP is in Network Layer, so it should be done thanks to Raw Sockets, but I don't find anything useful bout Raw Sockets in  C#.

Edit : I already know Pcap.NET but I forget it was open-source, I'll try to find a solution in his source code (I prefer to developp my own tools from scratch) I'll post what I'll find something.
« Last Edit: August 13, 2014, 09:05:05 pm by absinthCore »

Offline ande

  • Owner
  • Titan
  • *
  • Posts: 2664
  • Cookies: 256
    • View Profile
Re: RAW Socket in C# for ARP Support
« Reply #3 on: August 18, 2014, 02:38:42 pm »
I actually import the iphlpapi.dll to use SendARP from Windows C Library, but I can't control how many request it sends.
ARP is in Network Layer, so it should be done thanks to Raw Sockets, but I don't find anything useful bout Raw Sockets in  C#.

Edit : I already know Pcap.NET but I forget it was open-source, I'll try to find a solution in his source code (I prefer to developp my own tools from scratch) I'll post what I'll find something.

Sorry for late reply, dident see if earlier. I guess iphlpapi can be used indeed, if you need it here is pretty decent documentation for it: http://www.pinvoke.net/default.aspx/iphlpapi.SendARP

I understand the urge to create your tools from scratch, but libpcap is a library you dont want to recreate. Alltho the principles are simple, the library is huge and would take you ages to write on your own. Not to mention that you would need to write it as a driver and certainly not in .net. You will not "find a solution" in the pcap.net source because it simply uses the original libpcap driver (which is required to be installed on the machine). pcap.net is a wrapper.
if($statement) { unless(!$statement) { // Very sure } }
https://evilzone.org/?hack=true

Offline xor

  • Peasant
  • *
  • Posts: 59
  • Cookies: 32
    • View Profile
Re: RAW Socket in C# for ARP Support
« Reply #4 on: May 06, 2015, 04:16:55 am »
You can create RAW sockets in c#, or .NET in general, but you will only be able to do this whilst running Visual Studio as an Administrator. Elevated privileges are required to create RAW sockets on most Windows Systems.


Code: [Select]
var s = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP);


-- xor
« Last Edit: May 06, 2015, 04:17:24 am by xor »