views:

82

answers:

5

Hello all,

I have a set of PHP scripts sitting on several clients servers and I want to get the mac address for that server so that I can store it and determine that the PHP scripts are not being used on another server.

How can I get the Mac address of a computer using PHP somehow?

Is there a better way to determine if the PHP scripts are being used on a different machine?

Thanks all

+2  A: 

Until you don't obfuscate the code, smart clients can fake their mac addresses.

Edit: (Just a simple idea)

When you install your app on clients' machine you should create a unique token that belongs to that machine only.

Example:

  • File create timestamps
  • Install timestamp
  • File locations (big chance not the same at all clients)

Merge these, hash it, store it then check at every page call.

fabrik
PHP Code is obfuscated. :) I am just trying to put something in that will fix the scripts to one machine.
Abs
Can you access your clients machines? I mean you can put some unique data on the machine then look for it?
fabrik
@fabrik, if I do that, it is something that I have to do for every client, I was hoping for automated generic solution.
Abs
+1  A: 

I don't think there is an easy way to get a MAC address from a visiting PC, but I'm not sure about that.

How about a simpler way: use a session? Just assign a session if there is none, you'll end up with one per machine (unless they use different browsers). You could lock the execution to that.

It's not as "perfectly secure" as locking on MAC, but still goes a long way...

Blizz
I'd say this question isn't about the number of HTTP-clients connected, but enforcing a single-server license.
Piskvor
Its not for a visiting PC, its actually for the PC the scripts reside on.
Abs
Guess we typed at the same time. In that case you should probably use an encoder like Zend Safeguard or Nusphere Nucoder to lock the script to that single machine.
Blizz
@Blizz, I think this is going to be the best option. I opted for a decent encoder and avoided the expensive ones, but that functionality is useful.
Abs
A: 

for a long time ago i have used the tool PHTML Encoder (url http://www.rssoftlab.com/) this tool can protected your php code and you can set some function like "only run on this machine". you have to install this as php extension. eventually this is a solution for you.

kind regards

Sinderella_42
A: 

I think the best way to accomplish this is by generating your own algorithm to fingerprint the server, the code that's used to create the finger print should be obfuscated to prevent reverse engineering but it can be possible.

create a algorithm hasher that does not stick to 1 value per fingerprint, let the values vary.

so that you can ping a primary server the hash witch then gets validated.

for example

function GenerateFingerPrint($account) //Each machine has a static UNIQUE ID
{
    //Create a fingerprint for the machine and machines location

    //Post the $account + $fingerprint to MAINSERVER.COM

    // Get hashed responce

    //Decode it and validate it to continue with script.
}

But all that code should be highly obfuscated due to reverse engineering !

RobertPitt
Hmm, what if the client machine disables internet connectivity for that server. Scripts are unusable?
Abs
well you cauld store a responce hash locally that would be valid for 7 days, then it would need a revalidate, if there's no internet access it used the store hash else it will update X times per day. HTTPS Would be required!
RobertPitt
+1  A: 

If you want to get the mac address of the web server which is running your php code then:

system ('ipconfig /all') 

on windows and usually (depending on flavour!)

system('netstat -i')

will go you a bunch of network information including the mac address.

However I must warn you that if you stop your script working when the mac addresses do not match your clients will hate you!

Think of the circumstances when a mac address changes and how applying for a new "license" would (not) fit in:-

  • Broken network card is replaced
  • Software is transferred to a shiny new server.
  • System Admin initiates a flexable Virtual Machine cluster.
  • Software fails over to another machine in a cluster.
  • Client finds cheaper/better hosting provider.
  • Disaster strikes and client is trying get things up and running on another machine in another data centre.
  • Clients machine has more than one network card.
James Anderson
What if 'system' disabled?
fabrik
I thought the exact same about him using mac addresses.. there just not reliable and static to be feasible.
RobertPitt
fabric, then you ask the user to update his configuration to suite the needs of the application, you cant cater for everything.
RobertPitt
@James, thank you for your answer. You have raised my awareness of the problems with using a mac address. Btw, I have just found you can also use `getmac` via dos command.
Abs
@RobertPitt: Did you mean ask the client to enable a feature that is disabled with good reason? Seems ceremonious and unacceptable for me.
fabrik
@fabrik, its only vulnerable if your system is. otherwise if you have a good tight application then a hacker would not be able to use such commands.
RobertPitt