1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Retrieve client MAC address over internet

Discussion in 'PHP' started by fr33d0m, Aug 22, 2007.

  1. #1
    Well, i know this looks like a stupid qn :p
    But i really need to know whether it's achievable or not.
    I need to get client's MAC address that register to our website, i found a jscript that can achieve this. But it only can run in IE.
    I also found some PHP scripts but they are only for local network.
    Is there any way to achieve this using PHP script?
    Can someone guide me, pls? Thanks in advance...

    Below is the JScript :
    
    <HTML>
    	<HEAD>
    		<SCRIPT type="text/Javascript">
    			var address = new Array();
    			var i = 0;
    			var wsh = new ActiveXObject("WScript.Shell");
    			var fso = new ActiveXObject("Scripting.FileSystemObject");
    
    			wsh.Run("cmd /C ipconfig /all > c:\\temp.txt", 0);
    
    			function getMacAddress() {
    				var file = fso.OpenTextFile("c:\\temp.txt", 1);
    				var currentLine;
    				var colon;
    
    				while(file.AtEndOfStream != true) {
    					currentLine = file.ReadLine();
    
    	               	if(currentLine.indexOf("Physical Address") >= 0) {
    						colon = currentLine.indexOf(":");
    			            address[i] = currentLine.substr(colon + 1);
    			            i++;
    			        }
    				}
    
    				file.Close();
    				f = fso.GetFile("c:\\temp.txt");
    				f.Delete();
    			}
    
    			function writeAddress() {
    				for(j = 0; j < i; j++) {
    					mac.innerHTML = mac.innerHTML + "  <BR>Mac Address: " + address[j]
    				}
    		}
    		</SCRIPT>
    	</HEAD>
    	<BODY>
    		<P id=mac>	</P>
    		<form method="POST" action="#">
    			<Input type="Button" Value="Retrieve Mac Addresses" onClick="getMacAddress()">
    			<Input type="Button" Value="Display Addresses" onClick="writeAddress()">
    		</form>
    	</BODY>
    </HTML>
    
    Code (markup):

     
    fr33d0m, Aug 22, 2007 IP
  2. techMonster

    techMonster Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    If the javascript that you have mentioned works, than you can use Ajax to send it to server.
     
    techMonster, Aug 23, 2007 IP
  3. webrickco

    webrickco Active Member

    Messages:
    268
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Using the FileSystemObject on the browser of your site visitors is not recommended nor ethical. Best practices do not recommend such programming.

    Like you said it will run on IE only on for those user that will allow it to run, with minimum security level on their browser.

    Why do you need the mac address anyway? Is IP not enough?
     
    webrickco, Aug 23, 2007 IP
  4. ssanders82

    ssanders82 Peon

    Messages:
    77
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Agree w/ webrickco. Unless you're sure users are running IE, and have loose security levels for ActiveX, this will not work. I'm sure their are better ways to uniquely identify a computer if you tell us what you're using it for.
     
    ssanders82, Aug 23, 2007 IP
  5. fr33d0m

    fr33d0m Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi, i need the computer ID for the software that is provided in our website.
    To stop user for distributing the software to his friends.
    We're using Java for the software and we need to save this computer ID inside the software before user downloads it.
    Any idea how to achieve this?
     
    fr33d0m, Aug 24, 2007 IP
  6. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You're going to have to use a proper authentication system then as the MAC address is not guaranteed to be unique. Well, in theory it is but the fact of the matter is that it is very simple for an end user to change it to whatever they want...
     
    TwistMyArm, Aug 24, 2007 IP
  7. fr33d0m

    fr33d0m Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi TwistMyArm,
    Thanks for the reply :)
    Do u have any suggestions for the authentication system? How to achieve it?
    My group is already considering to use Public Key Infrastructure to achieve this, but due to deadline we aren't able to change our code.
    Can u guide me, pls? Thanks
     
    fr33d0m, Aug 25, 2007 IP
  8. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Well.... if you're not able to change your code due to the deadline, then NOTHING I suggest is going to be usable because EVERYTHING I suggest will require code changes.

    In theory it should have all been encapsulated so you would basically just pull the code out of one spot and replace it... now that wouldn't change at all by using PKI so I can only assume that you would need to replace code in a fair number of places.

    Therefore, if it were me, I'd work on encapsulating the authentication system and change the code wherever it needs to be changed just this once. Then, if / when you change the authentication system again you won't have to change code anywhere else.

    As to what to use instead of a MAC address? I haven't used any systems for protecting a Java application, so I can't give a definitive answer. Having said that, Googling "Java copy protection" turns up a number of solutions that at least use the right buzzwords. Maybe prefix that search query with "free" if need be. As far as I'm concerned, I think it's worth the money to buy a system pre-made if buying from the right (read: 'way smarter than me') people.

    Not that it matters too much... let's face it, if people REALLY want to copy your software they'll just distribute a VMWare image, right? I don't know of any solutions other than hardware dongles (which are also not 100%) that would defeat that at the moment.

    In fact, I'm surprised I haven't seen VMWare images available via torrents with everything preinstalled :)
     
    TwistMyArm, Aug 26, 2007 IP
  9. fr33d0m

    fr33d0m Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hmm, thanks for your advice :)
    This is for my final year project :)
    I'll discuss about it with my group.
    Thanks again
     
    fr33d0m, Aug 26, 2007 IP