hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Programming Tutorials : How To: Protect your contracted work in PHP using Code Snip & IonCube
Reply

Programming Tutorials How-Tos related to programming, databases, and the like.
Forum Jump

How To: Protect your contracted work in PHP using Code Snip & IonCube

Reply Post New Thread In Programming Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 04-25-2004, 10:34 PM
pixd pixd is offline
Web Hosting Master
 
Join Date: May 2003
Posts: 598

How To: Protect your contracted work in PHP using Code Snip & IonCube


First of all, this isn't a guide on how to use Ioncube, this is for those people who are hired at freelance sites, basically, contracted over the internet to do a PHP script. I'm not a PHP overlord, so don't expect the best coding you've ever seen in your life, but it gets the job done, and I have done this for every project ever since I thought of this.

Forgive me if it's not exactly 100% user friendly, if you're a PHP coder who does work that's expensive enough to have to protect, you should be able to follow the steps with ease.

Scenario: You are paid $2000 to write a PHP script for Joe Montana. Joe pays you, you send him the script, all is well, until Joe reverses the charges, leaves you out in the cold while you just wasted several weeks and he gets a free script. Now you have to stress yourself with tracking him down, pressing charges, which 99% of the time never happens. I just read the same story on another forum, which is all too common, and this prompted me to share this with hopes of protecting other programmers time and profit.

Step 1

Find the file that is absolutely necessary for the script to run AND won't required any modification by the client for configuration purposes, this could be the functions file (preferably), the administration home file.... etc.. basically find a file that if taken out of the picture, the entire php script (or the better part of it) would not work.

Add this snippet of code to the top of the file (it doesn't need to be the very top, it needs to be above the critical code though).

PHP Code:
$lines file('http://www.example.com/joemontana.txt');
foreach (
$lines as $line_num => $line) {
$license htmlspecialchars($line);
if (
$license == "kill") {
exit(
"<font color=white><b>Your Script License Has Been Terminated<br><br>Please Contact <a href=mailto:YOUREMAIL><font color=white>YOURCOMPANY</a> Immediately</b></font>");
}

You'll want to edit the URL example.com to your website, and point it to a text file that is unique to this project (ie: joemontana.txt). You can also edit the HTML to say whatever you want.

What this does, is it opens this text file on your server, checks it, and continues with the script. If you write the one word...

kill

Inside the text file, his script will exit every single time someone tries to run it. If your server is down, the file doesn't exist, anything other then the word "kill" is in it, etc. etc. the script will run fine.

Step 2

You now need to encode this PHP file so that they cannot remove that code snippet and be on with their day. I prefer Ioncube, but if you use something else, by all means, go ahead... as long as it's secure.

Go to http://www.ioncube.com - Go to Products -> Online Encoder. It costs 50 cents to encode a file (You have to make a minimum $5 deposit though, which is good if you plan on doing this for all your projects). Encode the file. If you open it in a text editor, it should look like a bunch of jibberish.

Step 3

If you used Ioncube, when you distribute the script to your client, ensure that you include a ioncube loader for their server (it includes instructions on how to install it for their server administrator), and make sure you instruct them to upload the encrypted file in BINARY mode.

That's it. Now if you get a chargeback, just put the word 'kill' in that file that the code snippet points to and be on with your day. At least now if they screw you, you can screw them back.

I encourage you to let your client know that this one file is encrypted, but after a provisionary period of 1-2 months (whatever, long enough so that they can't charge you back) you'll send them the real file which won't require any more ioncube extensions.

This is a pretty basic solution, because there are some ways around it I'm sure, but only if they realize how you are doing it, I'm not going to publish any possible ways (and I encourage none of you to either) in the event that someone comes searching for a way to "undo" your protections.

These instructions are provided without warranty. Any damage or loss, yadda yadda yadda *insert long disclaimer here*, is your own fault.

Reply With Quote


Sponsored Links
  #2  
Old 05-20-2004, 04:15 AM
nzbm nzbm is offline
Registered User
 
Join Date: May 2004
Location: New Zealand
Posts: 346
Thats a mean trick. I like it very much!

Reply With Quote
  #3  
Old 05-25-2004, 12:59 PM
wscreate wscreate is offline
Disabled
 
Join Date: Apr 2001
Posts: 182
What if YOU accidently delete the joemontana.txt file? You might want to make the encrypted file have an if/else statement.

Reply With Quote
Sponsored Links
  #4  
Old 05-25-2004, 02:39 PM
monaghan monaghan is offline
Web Hosting Master
 
Join Date: Dec 2003
Location: UK
Posts: 652
The answer's in the code snippet :-)

If you delete the file, then you'll have no way of killing the remote PHP script as it looks for the work "kill". The customer will work fine.

Reply With Quote
  #5  
Old 06-27-2004, 02:33 PM
vg-force vg-force is offline
New Member
 
Join Date: Sep 2003
Posts: 0
I've been trying to figure something like this out for a while now. Thanks so much!

Reply With Quote
  #6  
Old 07-05-2004, 07:12 AM
hostlab hostlab is offline
Junior Guru Wannabe
 
Join Date: Jun 2003
Location: Manchester, UK
Posts: 89
Thanks alot - I agree, thats a FANTASTIC idea

Reply With Quote
  #7  
Old 07-05-2004, 07:50 AM
TR Seeks TR Seeks is offline
Web Hosting Master
 
Join Date: Jan 2004
Location: UK
Posts: 1,345
This is a great how to sort of thing. I may use it in one of my projects

Reply With Quote
  #8  
Old 07-06-2004, 10:51 PM
Bruin03 Bruin03 is offline
Registered User
 
Join Date: Jun 2004
Posts: 137
You rock! I love this!
How about changing the message to "The owners of this website are weasels who don't pay for work"

That would be very mean but good

Reply With Quote
  #9  
Old 07-07-2004, 10:18 PM
zinet zinet is offline
WHT Addict
 
Join Date: Sep 2003
Posts: 151
The only problem with this is that Joe can just set the dns entry for example.com to his server. When the script looks up example.com it will go to his server.

Reply With Quote
  #10  
Old 07-08-2004, 05:31 AM
barrywien barrywien is offline
Aspiring Evangelist
 
Join Date: May 2002
Location: Durham - UK
Posts: 445
If the scripts encoded it wil be difficult for him to find example.com though. Overall this is a useful bit of code.

Reply With Quote
  #11  
Old 07-12-2004, 12:27 AM
iGravity iGravity is offline
Web Hosting Guru
 
Join Date: Jun 2004
Posts: 340
I have never thought of that. Thanks for the tip!

Reply With Quote
  #12  
Old 07-12-2004, 10:31 AM
Takinghold Takinghold is offline
WHT Addict
 
Join Date: Jul 2004
Location: United Kingdom
Posts: 129
Id suggest using a system which logs onto your server, logs in whenever ran, and an i,p of were its ran from is stored, so if more than one i,p uses it you can de-activate it by like hiding the login in a file thats required in every file, and it just exits that script, but you'll need to encode this file so people cant take out the login and sell it off.

Reply With Quote
  #13  
Old 07-16-2004, 05:31 PM
nick[x1] nick[x1] is offline
Account Suspended
 
Join Date: Apr 2004
Posts: 171
I have been coding a mySQL based one, so when you do file() it opens the file and looks in a table for the domain. If the domain is not found it returns 0 which means no such licence, if its found but expired it returns 1, etc
And so far it works

Reply With Quote
  #14  
Old 07-16-2004, 05:49 PM
barrywien barrywien is offline
Aspiring Evangelist
 
Join Date: May 2002
Location: Durham - UK
Posts: 445
I thought file() only displays html if its connecting to an external server?

Reply With Quote
  #15  
Old 08-21-2004, 05:13 PM
eusnaur eusnaur is offline
Newbie
 
Join Date: Aug 2004
Posts: 12
Great script! Very neat idea and easy to work with... I like it. So now if I was going to sell any script away.. I'd definitely use this .

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
Switch Datacenters Launches Incubator for Energy Efficient Data Center Hardware Web Hosting News 2012-11-19 13:09:07
DigiCert Launches Extended Validation Code Signing Certificates Web Hosting News 2012-08-15 15:30:28
Students Contribute to Joomla through Google Summer of Code Program Web Hosting News 2012-05-08 15:22:35
Q&A: Afilias SVP and CMO Roland LaPlante on New gTLDs Web Hosting News 2012-01-16 16:46:01
Non-Profit New Zealand Computer Society to Develop Cloud Code of Practice Web Hosting News 2011-09-02 17:22:36


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?