Lua source encryption on the fly?

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Slopey
Posts: 24
Joined: Sun Jul 31, 2005 8:13 pm

Lua source encryption on the fly?

Post by Slopey »

Hi All,

Anyone have any cunning ideas on how to protect the main source file for a lua app?

I'm currently rattling through a little RPG which I'm coding and I'd quite like to prevent end users from easily changing the source. If it's left as is, it'll be woefully easy for someone to edit the source or any other files and become immortal, get the best items, infinte money etc etc.

Has this come up before in this forum? Is there any support for using something other than the plain text file in lua, or is there any planned?

I'm probably going to end up writing a little obfuscator program to rename variables and such like but even then it'll be simple to edit it. It's either that or I port the game in to C but it's nice and easy to whizz through it with Lua so I'd rather not (plus my C is pretty rusty!).

Anyone have any ideas?
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

It was discussed already somewhere in this forum. Please use Search.

Hint: Protected code
Geo Massar
Retired Engineer
Slopey
Posts: 24
Joined: Sun Jul 31, 2005 8:13 pm

Post by Slopey »

Yeah, I did, just didn't use "protected" :) Dug it up now, thanks.
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

One of my pet peeves is when a reasonable question like this is answered with a response like "search the forum" or "use google." Searching just the PSP Lua forum with the search terms you provided turns up no fewer than 191 unique message threads, including this one. If you really want to be helpful, why not provide a link to the relevant article? Clearly you have performed the search and found the answer. If you don't want to be helpful, then why post a response at all?

The PSP homebrew scene is still very young, so we can expect that the volume of newbie questions is only going to increase as time goes on. Let's either decide that we're going to help people get started, or else require that everyone pass a 100-page C++ programming test before being allowed to post here at all.

Give a man a fish and feed him for a day.
Teach a man to fish and he'll go hungry.
ooPo
Site Admin
Posts: 2023
Joined: Sat Jan 17, 2004 9:56 am
Location: Canada
Contact:

Post by ooPo »

People have already complained about that in the past.

Use the search feature to read more about it.
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

Ok, I am genuinely laughing now. Thanks!

But to rescue this thread from being yet another useless topic for people to wade through while searching for the real answer, let me say two things:

1. This topic has been discussed before. You can find the relevant topic by using the forum search feature. For best results, use the two keywords protected and code, separated by the and keyword to find articles that contain both keywords. And limit your search results to the Lua Player Forum to save yourself even more time.

2. Anyone who is tired of reading posts that ask a question that has already been answered should appreciate the irony of responding with perhaps the most-used phrase on this board: "use the search feature." If it is annoying to read repeat questions, it is 10X so to read the same old tired response.

Anyway, thanks ooPo for making me laugh. I'll go back to coding my game now...
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

Give a man a fish and feed him for a day.
Teach a man to fish and he'll go hungry.
I am not in favor with this teaching philosophy. It is BETTER to teach how to fish with teaching SUPPORT. He won't go hungry.

From me with half century teaching/engineering career.
Geo Massar
Retired Engineer
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

KawaGeo: I agree. The tagline was somewhat sarcastic. But do you agree that my answer is both more informative and generally results in more useful "wiki" as an end result? In my mind there is a huge difference between telling somebody what to do and telling them how to do it. The former is not "teaching," it is "managing."

I'm sure you all have some good ideas of what you want to tell me to do right now...

EDIT:In all fairness, I didn't mean to single anyone out. I think KawaGeo's response was actually more helpful than the typical "use search" auto-response, since he actually offered search keywords. I just hate reading promising-looking threads on this board that dead-end with that suggestion, and without a link to any useful information. If the goal is to reduce the noise level, then ultimately linking these posts to the answers buried in older ones is essential.

Alright, enough of my noise...
Last edited by Dr. Vegetable on Fri Dec 23, 2005 1:08 pm, edited 1 time in total.
dbeyer3069
Posts: 81
Joined: Mon Dec 19, 2005 4:09 pm

we're all new at some point.

Post by dbeyer3069 »

First some experience on the LUA encryption issue:

I developed a basic-style language for the bulletin board market (prior to internet) over 10 years ago and faced this issue. It was interpretive also.
What I did was create an EXE that could encrypt the ascii source code. My language also had a switch available that could write out a copy of it in encrypted form. When the source was read, it was unencrypted as each line was read into the interpretor (I loaded the whole script all at once as the system came up). This may not be as practical for the PSP as memory may be more of an issue. Either way, there wasn't much of a performance hit. The LUA could unencrypt the code once when the app is first loaded (before it starts executing anything) rather than as the program runs (which would be SLOW).

Obviously... as this is a wish list for those doing LUA coding. It's because of this very issue I opted to code using the pspsdk and C. I wish to keep my program proprietary because of new technologies that will be implemented in it later. This doesn't mean I won't share pieces here and there if people need it (I've gotten .WAV and a few other things working already).

ON THE SOAP BOX: Dr. Vegetable is right. We really need to support and help each other. This doesn't mean people shouldn't do any research on their own. I just spent 3 days researching EVERY message in 2 different web sites and EVERY example for a problem I was experiencing and still came up short. It was only by a LOT of trial and error (and persistence) that I got it working. A little help could have saved me a lot of time (and brought my product to market SOONER). There is simply not a lot of documentation (of quality or quantity) available for some of the more complex issues. Would be nice if people remembered what it was like when THEY were new.

David Beyer
KawaGeo
Posts: 191
Joined: Sat Aug 27, 2005 6:52 am
Location: Calif Mountains

Post by KawaGeo »

I just got an idea of compressing/decompressing technique for Lua scripts. In the past, I developed a special case text editor that optionally generates a compressed text file to be read later on Palm handhelds with limited memory. The reader on Palm then decompresses the file in order to read the materials. It was called "BigDoc" and was sold as shareware.

This concept might be applicable to Lua Player only if it were rebuilt with a decompressor. If it recognizes the compressed file, it would first decompress and load it unto the Lua dictionary. Compressed files would save memory space on sticks.

Currently, I am working on a project similar to my BigDoc but the goal is for the Lua Player platform. I might add the compressor to it as a special feature.

Just an idea.
Geo Massar
Retired Engineer
Koba
Posts: 59
Joined: Thu Sep 29, 2005 10:57 am

Post by Koba »

hmmm, even though LUA is a safe language, i would still say, why? why would you not want to produce open source, its the future... and your code could be used to help make someone else's program a whole lot better, this community is about making more and more better software, not kicking everyone else out and making your software the king... code good programs, share it with the community, help each other out, and lastly, stick it to the man!
dbeyer3069
Posts: 81
Joined: Mon Dec 19, 2005 4:09 pm

open source

Post by dbeyer3069 »

I would agree in a lot of cases with open source. In my case, the program I am developing uses proprietary technology which I also own (more on this later after it's released). Exchange of data between the program and servers, etc. must be protected.

David Beyer
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Re: open source

Post by romero126 »

dbeyer3069 wrote:I would agree in a lot of cases with open source. In my case, the program I am developing uses proprietary technology which I also own (more on this later after it's released). Exchange of data between the program and servers, etc. must be protected.

David Beyer
Unfortunatly you have limited option in this since you are working with an open source enviroment. I would suggest working on a different protocol to use instead if you want to keep your "proprietary technology" secret.

Later of course you can always make your "Proprietary Technology" backwards compatable with your "Open Source Software".

We are not Microsoft nore should we exploit the freedom of "PSP Hacking" just to further our own agenda's since what we are doing is not condoned by the people who created the PSP.

If you truely need to use your own Propriatary code. Then please use source of what LUA player has to offer and compile your own with that command/ability. It shouldent be too hard.
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

On the one hand, romero126 is right, you can't expect to distribute a Lua application and simultaneously protect the inner workings of your code. It is just too easy (even if you somehow encrypt the source) for someone to modify Lua itself to output a decrypted/decompiled version of your program. You really have to build it using a compiled language to have any semblance of security. Even then, there are limits to how secure it is, as demonstrated by how quickly the compiled&encrypted PSP firmware was reverse-engineered.

On the other hand, Koba and romero completely miss the point regarding the use of proprietary technology vs. open source. There are times when an author may own certain intellectual property (or restrictive license to use it) that does not allow them to share the source code. Just because an author chooses not to release their source doesn't mean that they are somehow trying to take advantage of others. After all, one of the greatest contributors to this forum and most prolific of open source authors has recently stated that he is using PSPSDK on commercial projects, presumably closed-source.

Sure, we all like to download free, open source code. We can learn from it, borrow from it, modify it, and occasionally even contribute back to the original project. (In my experience releasing open-source software, it is extremely rare to get so much as a quick thank you e-mail from a user, let alone any real coding contributions.)

But if given the choice, I would rather see someone release a closed-source project to this community than have them release nothing at all. Please respect the rights and wishes of all developers here, and don't try to dictate how they provide these gems to you.
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

Remember LUA is an open source enviroment at this point in time.
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

Lua may be open source, but so is GCC. How does that impose restrictions on whether the author chooses to make their own project open source? (Regardless of programming language used.)
dbeyer3069
Posts: 81
Joined: Mon Dec 19, 2005 4:09 pm

Re: open source

Post by dbeyer3069 »

Unfortunatly you have limited option in this since you are working with an open source enviroment. I would suggest working on a different protocol to use instead if you want to keep your "proprietary technology" secret.

Later of course you can always make your "Proprietary Technology" backwards compatable with your "Open Source Software".
I mentioned someplace before, but I don't program in LUA. My program is written in C and uses the pspsdk so that I can keep my code "non open source". I use some of LUA's graphics libraries (graphics.c) which is why I keep an eye open in this forum.
We are not Microsoft nore should we exploit the freedom of "PSP Hacking" just to further our own agenda's since what we are doing is not condoned by the people who created the PSP.
The beauty of a free and open society is that we can do anything we want, even if it doesn't agree with others' opinions of how something should be used or done, so long as we are willing to accept the consequences. This development environment was created by people with a vision of doing it their own way and for their own reasons and that entrepreneur spirit will be continued :) Of course, people are entitled to their opinions.

David Beyer
romero126
Posts: 200
Joined: Sat Dec 24, 2005 2:42 pm

Post by romero126 »

Like I said ealier You should compile your own application useing the LUA source provided and add your own commands. Enough bickering on the subject if you want to get things done.

(Please note the LUA Libraries are the best place to start with for adding your own custom commands to the scripting language.)
Post Reply