General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 22nd, 2002, 05:45 AM
Hesham Hesham is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 Hesham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Hesham
How can I find out the user MAC ADDRESS?

I've read in deffirent articles about anonymousity that it's possible but I didn't find it in the server variables
any one knows how to do it??
in php if possible

Reply With Quote
  #2  
Old December 22nd, 2002, 01:58 PM
hadley hadley is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 63 hadley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
I don't think you can find the MAC address directly from PHP - it's not something that that is included in the http headers that a browser sends, so will not be present in server variables.

There does seem to be software available to find a MAC address given a IP address (google for "find mac address ip") but it only seems to work over a local network.

Why do you want the MAC address anyway?

Hadley

Reply With Quote
  #3  
Old December 23rd, 2002, 02:47 AM
Hesham Hesham is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 Hesham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Hesham
I want to deny any one from accessing the site except one person on sprcified machine
and becuase he doesn't have dedicated IP address so I don't have other wayt o make sure that he is the right person

and I read an article before about Anonymity that talks about the thing a web site can knows about you and they said that he can know your MAC address

Reply With Quote
  #4  
Old December 23rd, 2002, 05:23 AM
hadley hadley is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 63 hadley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Perhaps an easier way would be to use a username and password?

Hadley

Reply With Quote
  #5  
Old December 24th, 2002, 06:57 AM
bramp bramp is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 bramp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
if you really want his MAC address one solution would be to shell out some command line tools and parse their output, on *nix I think doing this would get the mac address:
PHP Code:
 $mac = `ping $ip && arp -a | grep $ip

The output may have to be parsed, and I'm unsure if you can include varibles inside backticks...

As previously stated this will only work on a local network, so via the internet is a no no...

Also I should note that its possible to spoof MAC Address, so don't reply 100% on them

bramp

Reply With Quote
  #6  
Old December 24th, 2002, 08:41 AM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
You'll have to find some other solution, using a MAC address will be impossible unless you're on a LAN. Even on a LAN, you couldn't do this from php without jumping through hoops.

Reply With Quote
  #7  
Old December 25th, 2002, 12:47 AM
Hesham Hesham is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 Hesham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to Hesham
thanks a lot ppl
it's all clear now

Reply With Quote
  #8  
Old February 9th, 2004, 12:45 PM
daniela1611 daniela1611 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 daniela1611 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Please if you know

Please, if you already know how to get the mac address from a user would you send to me how to do it???? I realy realy ned it!! thanks. My e-mail is: URL

Reply With Quote
  #9  
Old February 12th, 2004, 10:40 AM
nicat23's Avatar
nicat23 nicat23 is offline
Addicted to Chaos..
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: Ft. Worth, TX
Posts: 653 nicat23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 48 m 34 sec
Reputation Power: 0
Send a message via AIM to nicat23 Send a message via Yahoo to nicat23
Because of the way that the internet was designed and the way that the IP protocol works, you wouldn't be able to find a mac address of someone unless you were local to them. The post earlier about using ping and arp is correct. The mac address is put into the IP packet at the 2nd level of the OSI model, its a physical address... once you go out through a router the mac address of the reported packet is changed, and is changed each and every time.. think of the mac as a "Return" address. You send out a packet and it goes across the country, and goes through 5 routers, the mac address on the packet will change each and every time it goes through a router, where the IP address won't. It's a type of routing code that the routers use to identify where the packet came from and where to send a response to.

example

Machine A sends a packet to Machine B, and it passes through Firewall C and D. The packet does this:

Machine A sends the packet to firewall C, firwall C repackages the packet with its mac address and looks for the quickest route to machine B, it determines that firewall D is the closest to it, so it repackages the packet with its own mac address (since that is where D will send a response to if it cant get to machine B) and sends it on to D.. D does the exact same thing and sends the packet to B. Once Machine B receives the packet the entire process starts over again, the last mac address that is reported is for firewall D, but the IP points to Machine A, thats how it knows where to go.

HTH
Quote:
Originally Posted by daniela1611
Please, if you already know how to get the mac address from a user would you send to me how to do it???? I realy realy ned it!! thanks. My e-mail is: daniela1611@yahoo.es

Reply With Quote
  #10  
Old May 14th, 2004, 08:59 AM
mikestank mikestank is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 mikestank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
php function to get mac address

function returnMacAddress() {
// This code is under the GNU Public Licence
// Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot com
// Tested only on linux, please report bugs

// WARNING: the commands 'which' and 'arp' should be executable
// by the apache user; on most linux boxes the default configuration
// should work fine

// 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
// (you know, Murphy's laws)
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;
}

Reply With Quote
  #11  
Old July 6th, 2004, 09:05 AM
mikestank mikestank is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 mikestank User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
returnMacAddress now works better

Hy all
as mentioned before, be sure to understand the basics of the arp table since you can be sure that the obtained mac address is the right one only if the client is connected DIRECTLY to the php server,
if there are routers or gateways that NAT the traffic, the returned mac address will be that of the gateway, not the client beside it

thanks to marcus [riptide@digitaltorque.com] for some hacks on this code

function returnMacAddress() {
// This code is under the GNU Public Licence
// Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot
com
// Tested only on linux, please report bugs

// WARNING: the commands 'which' and 'arp' should be executable
// by the apache user; on most linux boxes the default configuration
// should work fine

// Get the arp executable path
$location = `which arp`;
$location = rtrim($location);

// Execute the arp command and store the output in $arpTable
$arpTable = `$location -n`;

// 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'];
$remoteIp = str_replace(".", "\\.", $remoteIp);

// 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 (you know,
Murphy's laws)
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;
}

Reply With Quote
  #12  
Old September 15th, 2004, 02:53 PM
wacook wacook is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 1 wacook User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This does not seem to work outside my local network

I got this code to work but cannot get an ip outside of my local lan. Any thoughts.



Quote:
Originally Posted by mikestank
Hy all
as mentioned before, be sure to understand the basics of the arp table since you can be sure that the obtained mac address is the right one only if the client is connected DIRECTLY to the php server,
if there are routers or gateways that NAT the traffic, the returned mac address will be that of the gateway, not the client beside it

thanks to marcus [riptide@digitaltorque.com] for some hacks on this code

function returnMacAddress() {
// This code is under the GNU Public Licence
// Written by michael_stankiewicz {don't spam} at yahoo {no spam} dot
com
// Tested only on linux, please report bugs

// WARNING: the commands 'which' and 'arp' should be executable
// by the apache user; on most linux boxes the default configuration
// should work fine

// Get the arp executable path
$location = `which arp`;
$location = rtrim($location);

// Execute the arp command and store the output in $arpTable
$arpTable = `$location -n`;

// 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'];
$remoteIp = str_replace(".", "\\.", $remoteIp);

// 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 (you know,
Murphy's laws)
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;
}

Reply With Quote
  #13  
Old October 22nd, 2004, 10:49 AM
Paul_L Paul_L is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 Paul_L User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Try SNMP

This might help as a technique:

http://edge.mcs.drexel.edu/GICL/people/sevy/snmp/snmp_package_introduction.html

Reply With Quote
  #14  
Old April 13th, 2005, 10:21 AM
SamsJ SamsJ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 1 SamsJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 55 sec
Reputation Power: 0
Windows PHP Mac address resolution

A Windows adoption of code Written by michael_stankiewicz (See above)

//any comments welcome 1samsj58 at solent dot ac dot uk

tested on windows XP SP1 and windows 98 SE both contained 4 ARP table entrees. I wanted to write it my self to completely under stand how it worked, I believe that through only retrieving one line of the ARP table this has reduced the complexity of the script and reduced the work of sorting a little, after viewing the output of converted script that removed extra spaces it became apparent the MAC address was always followed the IP address by one element. As you can see this is how i retrieved the MAC address from within the array using a loop to match the IP address and then obtain the next element. Although I do believe that using the regular expression would be better general practice it worked fine for me.


//First get the IP address then use the
//DOS command + only get row with client IP address
//This takes only one line of the ARP table instead
//of what could be a very large table of data to
//hopefull give a small speed/performance advantage

$remoteIp = rtrim($_SERVER['REMOTE_ADDR']);
$location = rtrim(`arp -a $remoteIp`);
print_r($remoteIp.$location);//display

//reduce no of white spaces then
//Split up into array element by white space
$location = preg_replace('/\s+/', 's', $location);
$location = split('\s',$location);//

$num=count($location);//get num of array elements
$loop=0;//start at array element 0
while ($loop<$num)
{
//mac address is always one after the
//IP after inserting the firstline
//(preg_replace) line above.
if ($location[$loop]==$remoteIp)
{
$loop=$loop+1;
echo "<h1>Client MAC Address:- ".$location[$loop]."</h1>";
$_SESSION['MAC'] = $loop;
return;
}
else {$loop=$loop+1;}
}
}
?>

Last edited by SamsJ : April 13th, 2005 at 10:38 AM. Reason: Change its formating

Reply With Quote
  #15  
Old April 17th, 2006, 08:14 AM
John the Geek John the Geek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 1 John the Geek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 46 sec
Reputation Power: 0
When I run that script as-is in Mac OS X (FreeBSD variant) I get this error on my log:

Code:
usage: arp [-n] hostname
       arp [-n] -a
       arp -d hostname [pub]
       arp -d -a
       arp -s hostname ether_addr [temp] [pub]
       arp -S hostname ether_addr [temp] [pub]
       arp -f filename


If I add the -a flag to arp it no longer errors, but I still get a blank page.

I made sure all of the comment lines weren't accidentally wrapped, as that was my first problem. This doesn't seem to want to work. I made sure that after the function I called it.

Any thoughts?

Reply With Quote
  #16  
Old February 27th, 2008, 03:39 PM
dobberph dobberph is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 1 dobberph User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 26 sec
Reputation Power: 0
Code:
// WARNING: the commands 'which' and 'arp' should be executable

I have complete access to apache2-configuration, but how can I do this?

Thanks,
Tobi

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > How can I find out the user MAC ADDRESS?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT