36

Can someone give me some pointers on picking up the user's MAC address from an HTTP request?

The users will be from outside my network.

Community
  • 1
  • 1
Richard Gale
  • 1,816
  • 5
  • 28
  • 45

3 Answers3

55

It depends on your network setup. But probably no.

Here is a short refresher on Ethernet and IP. The MAC address is a unique address of the network card. It is used to identify for which user on the network segment a packet is. You can use ARP to get a MAC address for an IP address. But this works as expected only if you are on the same network segment.

So the question is, what is a network segment? It depends on the technology you use, but here are the common cases. An entire wireless network is a network segment. Every user on the network can talk via Ethernet to every other user. On wire based networks, this depends on the hardware. If you have good old BNC or a hub you have one network segment with all uses. Again each user can talk to any other. With a switch in the network a network segment is only cable that connects you to the switch. Here you can only talk to the switch via Ethernet. Every other user needs at least IP.

Too bad that most situations with HTTP, which builds on TCP/IP, you are 99.99% never in the same network segment as your user. You can use ARP, but will only get the MAC address of the first hop. It get's better, depending on your hardware, you may not even be on an IP network that is based on Ethernet; ATM for example...

Beatles1692
  • 5,214
  • 34
  • 65
rioki
  • 5,988
  • 5
  • 32
  • 55
  • 11
    Hi Sean, Thank you for confusing the situation further! lol, no seriously, good informative post, cheers – Richard Gale Jul 22 '10 at 14:07
  • Huh? Wha? Unless you use a technique that can be considered violating the basic privacy of users, such as installing a plugin/active-x/tojan on the user's system the answer is: **No, Technically impossible**. I only tried to explain why... Maybe you or someone else can learn and understand... – rioki Jul 22 '10 at 18:41
  • 1
    I think this is not entirely correct: the ports of the switch are not the same segment, however one can talk via Ethernet between different switch ports. There is an ARP cache on a switch for that. – EFraim Sep 27 '15 at 21:54
2

I don't think there is a way to do it in ASP.NET.
MAC is a property of a TCP packet, and on HTTP level there're no packets or MACs (for example, a single HTTP request might be assembled of several TCP packets).

You could try using a packet sniffer (like WireShark) to capture TCP packets, and then analyze them to extract MACs and map them to HTTP requests.

Anyway, you won't get any useful data unless the user is in the same network segment as your server.

UPD. As was pointed out in the comments, I mixed up the network layers. MAC address is a property of Ethernet frame, not a TCP packet.
The conclusion is still correct, however.

VladV
  • 10,093
  • 3
  • 32
  • 48
  • 5
    The MAC address is in a tcp packet? Since when? MAC addresses are from a much lower transport layer and not even in the ip packet header. – Christopher Creutzig Jul 22 '10 at 13:39
  • 1
    Yes, MAC addresses are very low level – Richard Gale Jul 22 '10 at 14:08
  • What he meant was a packet in general. In the case from TCP you don't have packets, its a stream. In the case from IP you have frames... And normally you can't access any of these in user mode code. – rioki Jul 22 '10 at 18:45
  • @ChristopherCreutzig There is only one transport layer. – shiva Mar 16 '17 at 17:11
  • @shiva Correct, my bad. The transport layer doesn't use MAC addresses, though, those are only used at the network layer. which, I also should say, is not “much” lower … – Christopher Creutzig Mar 21 '17 at 19:04
1

This is not possible, unless you intend to create an ActiveX component, in which case it will only work on IE.

zahstra
  • 117
  • 3