Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Find MAC Address plugin v1

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
Aliresalat
Smarty Rookie


Joined: 09 Feb 2014
Posts: 23
Location: Iran

PostPosted: Wed Jul 23, 2014 11:44 am    Post subject: Find MAC Address plugin v1 Reply with quote

What is a MAC Address?
Whether you work in a wired network office or a wireless one, one thing is common for both environments: It takes both network software and hardware (cables, routers, etc.) to transfer data from your computer to another—or from a computer thousands of miles away to yours.

And in the end, to get the data you want right to YOU, it comes down to addresses.

So not surprisingly, along with an IP address (which is networks software), there's also a hardware address. Typically it is tied to a key connection device in your computer called the network interface card, or NIC. The NIC is essentially a computer circuit card that makes it possible for your computer to connect to a network.

An NIC turns data into an electrical signal that can be transmitted over the network.
Hey Nick. Meet Mac.

Every NIC has a hardware address that's known as a MAC, for Media Access Control. Where IP addresses are associated with TCP/IP (networking software), MAC addresses are linked to the hardware of network adapters.

A MAC address is given to a network adapter when it is manufactured. It is hardwired or hard-coded onto your computer's network interface card (NIC) and is unique to it. Something called the ARP (Address Resolution Protocol) translates an IP address into a MAC address. The ARP is like a passport that takes data from an IP address through an actual piece of computer hardware.

Once again, that's hardware and software working together, IP addresses and MAC addresses working together.

For this reason, the MAC address is sometimes referred to as a networking hardware address, the burned-in address (BIA), or the physical address. Here's an example of a MAC address for an Ethernet NIC: 00:0a:95:9d:68:16.

As you've probably noticed, the MAC address itself doesn't look anything like an IP address (see yours here). The MAC address is a string of usually six sets of two-digits or characters, separated by colons.

Some well-known manufacturers of network adapters or NICs are Dell, Belkin, Nortel and Cisco. These manufacturers all place a special number sequence (called the Organizationally Unique Identifier or OUI) in the MAC address that identifies them as the manufacturer. The OUI is typically right at the front of the address.

For example, consider a network adapter with the MAC address "00-14-22-01-23-45." The OUI for the manufacture of this router is the first three octets—"00-14-22." Here are the OUI for other some well-known manufacturers.

Dell: 00-14-22
Nortel: 00-04-DC
Cisco: 00-40-96
Belkin: 00-30-BD

It's common for the larger manufacturers of networking equipment to have more than one set of OUIs.
Networks and MAC addresses.

All devices on the same network subnet have different MAC addresses. MAC addresses are very useful in diagnosing network issues, such as problems with IP addresses.

MAC addresses are useful for network diagnosis because they never change, as opposed to a dynamic IP address, which can change from time to time. For a network administrator, that makes a MAC address a more reliable way to identify senders and receivers of data on the network.
Wireless Routers and MAC Filtering

On wireless networks, a process called MAC filtering is a security measure to prevent unwanted network access by hackers and intruders. In MAC address filtering, the router is configured to accept traffic only from specific MAC addresses. This way, computers whose MAC addresses are approved will be able to communicate through the network—even if they were given a new IP address by DHCP.

Meanwhile, a hacker who's hijacked a network IP address will be blocked because their MAC address will not be on the approved list and will be filtered out.

--------------------------------------------
( Okay, now we'll see a plugin )

It was the pain that you put more of your script to block local
To anyone other than you can not use it

Code:


<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * MAC Find plugin v1
 * File name: function.macfind.php
 * Name:     MAC Find
 * Date:     2014.07.23
 *
 * Examples: {macfind}
 *
 * @author : Ali Resalat (300) <info.Aliresalat@Gmail.com>
 * @Yahoo ID : Mitooo.Mitooo
 */
 
 
function smarty_function_macfind($params, &$smarty)
{
ob_start(); // Turn on output buffering
system('ipconfig /all'); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer
$findme = "Physical";
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=substr($mycom,($pmac+36),17); // Get Physical Address
echo $mac;
}

/* vim: set expandtab: */

?>




A very simple example : {macfind}

Output : xx-xx-xx-xx-xx-xx Your mac address
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7365
Location: Lincoln Nebraska, USA

PostPosted: Wed Jul 23, 2014 7:48 pm    Post subject: Reply with quote

This will only work on a windows system FYI. Linux could look something like:

Code:
ifconfig -a | grep --only-matching --regexp '\([A-Fa-f0-9]\{1,2\}:\)\{5\}[A-Fa-f0-9]'
Back to top
View user's profile Send private message Visit poster's website
Aliresalat
Smarty Rookie


Joined: 09 Feb 2014
Posts: 23
Location: Iran

PostPosted: Thu Jul 24, 2014 6:00 am    Post subject: Find MAC Address plugin v1 Reply with quote

Yes, this only works on Windows
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1555

PostPosted: Wed Aug 06, 2014 11:52 am    Post subject: Reply with quote

It will only work on very poorly configured english only Windows system with only one adpater and not disabled system call.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP