Can a website detect a persons mac address?

Posted on 2006-05-12
Last Modified: 2010-04-20
What info can the collect about site viewers?
Question by:gharnett
    LVL 18

    Expert Comment

    by:Sam Panwar
    No its not possible to get mac address through the website. It means you can search the computer and website or explorer have not right about it .

    But try these may be

    First you can use Gethostbyaddr() to get remote host's name
    then you can use Netbios()(setting ncb.command =ncbstat)
    then you can get the mac address of remote host's net adapter

    2.You cannot do this without platform-specific code which is off-topic here.
    The C language does not provide networking support
    3. Mac address of the remote connected machine

    command promt>

    arp ? then enter

    run this

    3.C program for Mac address

    #include <stdio.h>

    int main(void)
            char mac_address[257];

            printf("Enter the MAC address of the remote computer: ");

            fgets(mac_address,sizeof(mac_address), stdin);
            if (mac_address[strlen(mac_address) - 1] == '\n')
                    mac_address[strlen(mac_address) - 1] = 0;

            printf("The MAC address of the remote computer is %s\n",

            return 0;


    5.Try: 'nbtstat -A <IP>' or 'nbtstat -a computername' (note, the -A and -a
    are case sensitive). For example, if the 95's name is MyPC and its IP is, you might use either of the following:

      nbtstat -a MyPC

      nbtstat -A
    LVL 51

    Expert Comment

    > Can a website detect a persons mac address?
    only if you manage to use malware (JavaScript, ActiveX, etc.) on the client which is able to read the NIC sesstings

    Author Comment



    How would I use that program you gave if I were a webmaster?

    LVL 18

    Expert Comment

    by:Sam Panwar

    You can use in your website and your webserver support these mime type.
    LVL 18

    Accepted Solution


    Use the ffollowing script in your webpage : ITS 100% show the MAC address I tested it.

    But you have the permission on the server for run this script otherwise you get error.

    Option Compare Text
    Option Explicit On
    Option Strict On

    Partial Class _Default
        Inherits System.Web.UI.Page

        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            Label1.Text = ""
            For Each mac As String In GetMac()
                Label1.Text += mac + ", "
        End Sub

        Public Function GetMac() As List(Of String)

            Dim nic() As NetworkInterface
            Dim mac As New List(Of String)
            Dim add As PhysicalAddress

            If NetworkInterface.GetIsNetworkAvailable Then
                nic = NetworkInterface.GetAllNetworkInterfaces

                For Each ni As NetworkInterface In nic
                    add = ni.GetPhysicalAddress
            End If

            Return mac

        End Function

    End Class

    LVL 18

    Expert Comment

    by:Sam Panwar
    this is script
    LVL 51

    Expert Comment

    RomMod, if posting such harmless code is illegal (while uncle Sam violates human rights, and people's privarcy all over the world), it would probably be time to totally blacklist EE. Keep in mind that the code is "malware" (in my definition just like JavaScript) and will not be executed on a properly configured browser ;-)
    Please undelete the comments or inform responsible EE people (netminder, Wes).

    BTW, the asnser to the initial question has alreday be given: NO

    ---- this comment may be deleted afterwords, could do it  myself, but won't put on my PE hat ...
    LVL 18

    Expert Comment

    by:Sam Panwar
    Hi- ahoffmann -

    HAve see my code its not political-ethical .

    Just define it with my code its not harmful
    LVL 51

    Expert Comment

    Abs_jaipur, my comment was for the moderators, I don't see a problem with your code (as long as not run on my machine:-))
    LVL 18

    Expert Comment

    by:Sam Panwar
    Hi -RomMod & ahoffmann -

    Ok sorry for it. And thank you for restore my post.

    This is not harmful code and anyone can't run this without permisssion.


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    A web service ( is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
    Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now