Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 11-29-2010, 07:25 AM PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
basically, i'd like to know how to encrypt a URL, for inclusion at the bottom of every page in a script.

That way, it's just that much harder for the non-programmers out there to remove it.


I don't expect you to do it for me, but maybe a quick run-down would be nice. (yeah: I could google it, but we wouldn't really have a forum now, would we? lol)
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-29-2010, 07:41 AM Re: PHP encryption
Gakoyu Ojima's Avatar
Skilled Talker

Posts: 59
Location: Netherlands.
Trades: 0
You could use a class for this, which should be better, but if you're not that precise, you could do it with a simple base64_encode().

PHP Code:
<?php
/* string */
    
$encr 'your uri';
/* encode string and echo */
    
$uri base64_encode($encr);
    echo(
$uri);
?>
Using the above example, the output should be:

Code:
eW91ciB1cmw=
__________________
$gocore = new gakoyucore();
$con = mysql_connect($gocore->server, $gocore->username, $gocore->password) or die(mysql_error());
Gakoyu Ojima is offline
Reply With Quote
View Public Profile
 
Old 11-29-2010, 11:59 AM Re: PHP encryption
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Gakoyu's method takes the uri and gives you the encryption. I think what you want is to get the uri from the encryption:
PHP Code:
$encr 'base64encodeoutput';
$uri base64_decode($encr); 
Usually what people do is encode the entire footer so the user can't just remove the encoded text without ruining the display of the template.

If you're footer was something like this:
Code:
<div class="footer">
<a href="http://mysite.com/">My Site</a>
</div>
</html>
then the encoded text would be:

Code:
PGRpdiBjbGFzcz0iZm9vdGVyIj4NCjxhIGhyZWY9Imh0dHA6Ly9teXNpdGUuY29tLyI+TXkgU2l0ZTwvYT4NCjwvZGl2Pg0KPC9odG1sPg==
and you would want to put the following in place of the footer:

PHP Code:
$footer 'PGRpdiBjbGFzcz0iZm9vdGVyIj4NCjxhIGhyZWY9Imh0dHA6Ly9teXNpdGUuY29tLyI+TXkgU2l0ZTwvYT4NCjwvZGl2Pg0KPC9odG1sPg==';

echo 
base64_decode($footer); 
It's likely that your footer will contain some PHP code. In that case you'll want to evaluate it:

PHP Code:
eval(base64_decode($footer)); 
You should be aware that doing this, depending on how it's implement, may hurt the usability of your application. A user may want to make a modification to the encoded portion of the code that does not involve removing your link. Personally when I have to reverse engineer encrypted code it just makes me want to remove whatever the author put there.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-04-2010, 03:40 AM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
I tend to ask a lot of security-related questions. You don't know how to (adequately) LOCK UP information unless you know how to BREAK INTO it, no?

Fortunately for my question: the lot of people (I guess, including myself up until now) will be entirely unfamiliar with what we're talking about here. The only people i'd have to worry about (as far as intellectual property is concerned) are the people who already possess this information for themselves and are willing to reverse-engineer and/or obfuscate something I created... which is (perhaps) simultaneously a compliment and an insult.

Now I guess the next question I have concerning matters related to this would be...

say someone has managed to remove your encrypted link (without paying for it)


Is it LEGAL/Recommended to create a way to access their site (using a backdoor in the script itself); as a way of throwing insults at the perpetrator, or DELETING all the records from their database and/or filesystem?

I guess that would be my next question. What is the recommended practice here?
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 12-04-2010, 03:44 AM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
I guess a huge part of the reason I ask that is that I have heard rumours from several webmasters before me of a software company being able to "hack" into a users Administrator/Moderator account(s) and throw insults at the site's members...

most people did steal that script though, but there were also a few who didn't and they were ALSO victims of this software company's campaign.


What do you think of something like that?
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 12-04-2010, 04:33 AM Re: PHP encryption
Junior Talker

Posts: 3
Trades: 0
Well, I think it's ok to use a backdoor in the script to disable the script if someone steals it. But it may not be ok to destroy their systems for stealing the script.
Imagine that you install windows on PC and don't pay for it; windows will stop working, but won't erase your BIOS.
__________________
I deal with
Please login or register to view this content. Registration is FREE
.
eugen_r2 is offline
Reply With Quote
View Public Profile
 
Old 12-04-2010, 05:42 AM Re: PHP encryption
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Quote:
Originally Posted by eugen_r2 View Post
Well, I think it's ok to use a backdoor in the script to disable the script if someone steals it. But it may not be ok to destroy their systems for stealing the script.
Imagine that you install windows on PC and don't pay for it; windows will stop working, but won't erase your BIOS.
Agreed. Though it might be funny to log into your backdoor in order to prank the offending party, instead of just disabling their system
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-04-2010, 10:14 AM Re: PHP encryption
Extreme Talker

Posts: 156
Trades: 0
Have a search for some Base64 encoding functions
dagaul101 is offline
Reply With Quote
View Public Profile
 
Old 12-04-2010, 09:37 PM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
Agreed. Though it might be funny to log into your backdoor in order to prank the offending party, instead of just disabling their system
I don't know, and i'm thinking Highly Illegal.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 12-04-2010, 09:43 PM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
While we're on the subject, can anyone tell me how to create a backdoor in PHP?

sorry if it seems like we've entered Gangster Computing 101 all the sudden: but for the sake of saying that it's legal to create such backdoors in PHP... teach a novice like myself to be a 733T PHP security expert. Thanks.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 12-04-2010, 11:06 PM Re: PHP encryption
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by Lashtal View Post
While we're on the subject, can anyone tell me how to create a backdoor in PHP?
If, for example, you wanted to disable the script remotely you could do something like this:

PHP Code:
//backdoor.php
$password $_GET['disable'];
$hash '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8';

if(
$hash == hash('sha256'$password))
{
/*
do something here to disable to script such as delete a file or the database
*/

All you would have to do in this case to shut down the script would be to visit the following url:
Code:
http://somesite.com/backdoor.php?disable=password
Of course in this case anyone who knew that the backdoor existed and knew the password could disable any copy of the script.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-04-2010, 11:20 PM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
Dude, I would give you all the Talkupation! points possible... but i'm afraid I keep giving them to you like every thread.

But thank you: so much, for all of this awesome info that I haven't heard not a single word about in any PHP book i've read, or tutorials i've seen thus far.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 12-04-2010, 11:22 PM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
"/*
do something here to disable to script such as delete a file or the database
*/
"

Delete the config file! Delete the users table! and user-email table!

replace index.php with a new index that says, "if you want to use this script, you must stop stealing and buy it from thesoftwaresite.com/purchase"
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE

Last edited by Lashtal; 12-04-2010 at 11:24 PM.. Reason: Nullpointer rocks.
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 12-05-2010, 12:54 AM Re: PHP encryption
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
If this is something you're planning on implementing just be aware that it is potentially a way for anyone to disable your script. The password hash is available right there in the source code, and even though generating a collision for a sha256 hash is not trivial, with enough time and enough users attempting to break it, it's possible. Technically this problem can be marginalized by using multiple passwords each with a different encryption method.

A clever user might be able to trick you into giving up your password by installing a stolen version of your software and making a simple modification to the code:
PHP Code:
//backdoor.php 
$password $_GET['disable']; 
$hash '5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8'

if(
$hash == hash('sha256'$password)) 

     
$fh fopen('password.txt''w');
     
fwrite($fh$password);
     
fclose($fh);

In addition to this, if people are distributing stolen versions of your script then it is possible that someone has removed the backdoor all together.

Reading this thread might be helpful in understanding the difficulty in securing a script:
http://www.webmaster-talk.com/php-fo...-with-php.html
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 12-05-2010 at 12:59 AM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-05-2010, 04:48 AM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
a difficulty indeed then.

---

i'm going to play with this and see what I come up with.

It wont keep out the uber-hax0rz, but I think I can come up with something that'll rattle the chain of about 99.9% of users (i.e.- those not wholly versed in the mysteries and miracles of PHP).
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 12-05-2010, 04:49 AM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
Quote:
Originally Posted by Lashtal View Post
"/*
do something here to disable to script such as delete a file or the database
*/
"

Delete the config file! Delete the users table! and user-email table!

replace index.php with a new index that says, "if you want to use this script, you must stop stealing and buy it from thesoftwaresite.com/purchase"
or, better yet: a header redirect to thesoftwaresite.com/purchase
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 12-09-2010, 02:43 PM Re: PHP encryption
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by sophiatristin View Post
I am using it for encryption it in password files and security files.
You're confusing encoding with encrypting. If you're storing the base 64 encoding of passwords then all that would be required to obtain the original password would be to decode it. You should be using a 1 way hashing function.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-11-2010, 02:04 AM Re: PHP encryption
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 680
Name: Lashtal
Trades: 0
there are programmers who encode all their functions, and it deters A LOT of would-be reverse engineering attempts.
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP encryption
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.00296 seconds with 12 queries