[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Can a website detect a persons mac address?

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

Expert Comment

by:Sam Panwar
ID: 16672433
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

ID: 16677443
> 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

ID: 16762606


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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

LVL 18

Expert Comment

by:Sam Panwar
ID: 16765933

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

Accepted Solution

Sam Panwar earned 400 total points
ID: 16977470

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
ID: 16977482
this is asp.net script
LVL 51

Expert Comment

ID: 16977761
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
ID: 16978312
Hi- ahoffmann -

HAve see my code its not political-ethical .

Just define it with my code its not harmful
LVL 51

Expert Comment

ID: 16979011
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
ID: 16980970
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/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…
What You Need to Know when Searching for a Webhost Provider
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

834 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