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.

Get Mac Address !

Discussion in 'PHP' started by egoldseller, Jun 15, 2008.

  1. #1
    Hello !

    Hopr you're fine ;

    I wanna to know if , I can get client mac address and some other information using PHP Script?

    Thank's
     
    egoldseller, Jun 15, 2008 IP
    commandos likes this.
  2. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #2
    php runs on the server side, not the client-side.
     
    commandos, Jun 15, 2008 IP
  3. C.Whyte

    C.Whyte Peon

    Messages:
    802
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Exactly. There's your answer.
     
    C.Whyte, Jun 15, 2008 IP
  4. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #4
    i think you would need some activex if i'm not wrong ...never tested such thing
     
    commandos, Jun 15, 2008 IP
  5. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Only in IE

    <!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
        <head>
            <script id="clientEventHandlersJS" type="text/javascript">
            <!--
            function btnGo_onClick() {
                // Connect to WMI
                var locator = new ActiveXObject("WbemScripting.SWbemLocator");
                var service = locator.ConnectServer(".");
                
                // Get the info
                var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
                var e = new Enumerator (properties);
                
                // Output info
                document.write("<table border=1>");
                document.write("<thead>");
                document.write("<td>Caption</td>");
                document.write("<td>MAC Address</td>");
                document.write("</thead>");
                for (;!e.atEnd();e.moveNext ())
                {
                    var p = e.item ();
                    document.write("<tr>");
                    document.write("<td>" + p.Caption + "</td>");
                    document.write("<td>" + p.MACAddress + "</td>");
                    document.write("</tr>");
                }
                document.write("</table>");
            }
            //-->
            </script>
        </head>
        <body>
            <h1>MAC Address</h1>
            <INPUT id="btnGo" name="btnGo" type="button" value="Go" onclick="javascript:btnGo_onClick()">
        </body>
    </html>
    Code (markup):
     
    commandos, Jun 15, 2008 IP
  6. egoldseller

    egoldseller Guest

    Messages:
    213
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hello Friends !

    Thank you C.Whyte & commandos for help !

    I know that PHP run in server-side :D , and using IE Activex is not a good solution because it's not compatible with all web browser , an example activex & Vbscript are not accepted in Mozilla Firefox ,

    I've seen some php script that can extract Mac Address of client connected to you server , from network , using :

    system ("Unix Command") !!!

    mybe unix shell command like "ipconfig" can extract MAC address!

    thank's
     
    egoldseller, Jun 16, 2008 IP
  7. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #7
    ipconfig/ ifconfig would only get the server's ip address. MAC addresses are not passed across the whole internet from client to server.
     
    matthewrobertbell, Jun 16, 2008 IP
  8. egoldseller

    egoldseller Guest

    Messages:
    213
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hello !

    Asker will help now :D:D

    this command line get MAC Address :

     $mac = `ping $ip && arp -a | grep $ip`
    PHP:
    $ip is the remote IP address ,

    when you call this PHP function you will get the MAC Address :

    function returnMacAddress() {
    
    // Get the arp executable path
    
    $location = `which arp`;
    
    // Execute the arp command and store the output in $arpTable
    $arpTable = `$location`;
    
    // Split the output so every line is an entry of the $arpSplitted array
    
    $arpSplitted = split("\n",$arpTable);
    
    // Get the remote ip address (the ip address of the client, the browser)
    
    $remoteIp = $GLOBALS['REMOTE_ADDR'];
    
    // Cicle the array to find the match with the remote ip address
    
    foreach ($arpSplitted as $value) {
    
    // Split every arp line, this is done in case the format of the arp
    // command output is a bit different than expected
    
    $valueSplitted = split(" ",$value);
    
    foreach ($valueSplitted as $spLine) {
    
    if (preg_match("/$remoteIp/",$spLine)) {
    
    $ipFound = true;
    
    }
    // The ip address has been found, now rescan all the string
    
    // to get the mac address
    
    if ($ipFound) {
    
    // Rescan all the string, in case the mac address, in the string
    // returned by arp, comes before the ip address
    
    reset($valueSplitted);
    
    foreach ($valueSplitted as $spLine) {
    
    if (preg_match("/[0-9a-f][0-9a-f][:-]".
    
    "[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f][:-]".
    "[0-9a-f][0-9a-f]/i",$spLine)) {
    
    return $spLine;
    
    }
    }
    }
    $ipFound = false;
    }
    }
    return false;
    }
    PHP:
    Thank you for good idea !
     
    egoldseller, Jun 16, 2008 IP
  9. joffer

    joffer Peon

    Messages:
    85
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    This will only work on local machines aka if they are in a "lan" network

     
    joffer, Jun 16, 2008 IP
  10. egoldseller

    egoldseller Guest

    Messages:
    213
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Hi!


    There is an other way ?
     
    egoldseller, Jun 16, 2008 IP
  11. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #11
    not that i know , what are you trying to do ?
     
    commandos, Jun 16, 2008 IP
  12. egoldseller

    egoldseller Guest

    Messages:
    213
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hello!

    Thank's for help

    here I try to find a solution that detect client MAC addresse using PHP or Perl Scrpit , reason of security


    more inside I want to do a secure connection between to PC via internet ....

    Thank's for great ideas

    Best Regards
     
    egoldseller, Jun 16, 2008 IP
  13. clobberx

    clobberx Active Member

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #13
    You can use Javascript, but only works in IE
     
    clobberx, Jun 16, 2008 IP
  14. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #14
    I don't know why you think the MAC address is a secure way of forming a connection... MACs are EASILY cloned.

    There's tons of standard ways to make a secure connection between PCs on the internet. They're standard for a reason and will be quicker and more secure than your own code. You're probably after some form of VPN or SSH connection.
     
    TwistMyArm, Jun 17, 2008 IP
  15. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #15
    If you really need security, you should use a solid user management system, or a public-private key pair for authentication. There is no such thing as a secure connection to an anonymous user in any situation.
     
    jestep, Jun 17, 2008 IP
  16. chemouriamine

    chemouriamine Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    Egoldseller , means , whats the solution to secure your ressources ,

    example : I've a website for pey per click for unique IP , some user will click many time by changing IP, and there is many peoples they have a dynamic IP Address !!! I think to detect visitor by his MAC address !!!!

    or ther is an other solution to share?
     
    chemouriamine, Sep 10, 2008 IP
  17. ilook

    ilook Well-Known Member

    Messages:
    1,602
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    165
    #17
    there are MAC address changers also ;)
    easy as 123
     
    ilook, Sep 10, 2008 IP
  18. chemouriamine

    chemouriamine Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    I know , thery many way to change MAC , ex : in windows registry by changing Network Address Key ....
    and ther's many software do that ,

    but not many peoples know this way !!!

    Please if you have another idea share it here?
     
    chemouriamine, Sep 11, 2008 IP
  19. ilook

    ilook Well-Known Member

    Messages:
    1,602
    Likes Received:
    15
    Best Answers:
    1
    Trophy Points:
    165
    #19
    Would be great if other browsers also supports receive and store MAC addresses.
    Although its not 100%, its just an extra security feature for now, against clickfraud and also ban people.
     
    ilook, Sep 11, 2008 IP
  20. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #20
    The fact the IE does store it is more of a security concern than a solution to user identification. I wouldn't count on that one being around for a long time.
     
    jestep, Sep 11, 2008 IP