BlogMatrix
 

MAC Address Java Applet

edit Tim Desjardins 2008-02-11 17:36 UTC 7 comments  ·  ·  ·  ·

See the link below for source and what is more or less a toy applet to demonstrate sniffing the MAC Address(es) of a machine from the browser. The HTML illustrates the simplest (albeit hackish) approach for cross browser support. I've tested this with FF 2.x, IE 5-7 and Safari 3.x on Windows, unfortunately Leopard doesn't support Java 6 yet. This solution will only work with Java 6, I do no checking in the code for this fact, it's a demonstration after all.

One thing is for sure, IE treats Java as a third class citizen, I've done some timings: FireFox averages  10.5 seconds to start the Java plugin (which is barely acceptable), but IE is terrible with an average startup time of 31.8 seconds this is after clicking through the two levels of dialog about how this applet is insecure and may destroy your system, "oh the humanity" of course this can be turned off, but the default for most folks is to try and scare the pants of you.

You can find the package and source here:

http://www.softwaresamurai.com/Agwego/mac/macaddressapplet-1.0.tar.gz 

Comment #1Joel Lazzari

2008-05-02 17:35:22

this applet is worderfull. Great.

I need to get the serial number of my hard disk - anyone have a idea?

Comment #2Torquato

2008-11-06 18:26:49
Windows Vista returned null, any suggestions? thanks

Comment #3Tim D

2008-11-12 03:50:11

Unfortunately I haven't tested this on VISTA, but are you sure you have Java version 6 or higher?

Comment #4Torquato

2008-11-12 09:45:36
Yes, the version is correct, the problem and configuration of Vista. Finding the solution I describe.

Comment #5Torquato

2008-11-12 13:24:33
Resolved, the problem in Vista that returns more than one mac, being the first null.
Changed the source to discard this mac null.

public static String macToString( ...

...

if (macAddress.length ()! = 0)
(
    macAddress.toString return ();
)

... }

Comment #6Brad

2008-11-12 17:09:27

Works super!  Ran into the same issue with Vista, but realized right away that it is just the first result and if you return ALL mac addresses, you do get them.  Thanks for making this available.

Comment #7Tim D

2008-11-13 04:09:13

Thanks, this was my prototype app, and indeed if your machine has more than one interface (and the loopback counts) the problem gets a little more complicated. I have a production app in place that ignores the loopback and can deal with multiple interfaces. Unfortunately that wasn't the app I made available for free use. When I get time I'll update the app with appropriate code and comments.

Add Comment