Solved

How do I obfuscate literal strings like urls

Posted on 2009-06-30
2
890 Views
Last Modified: 2013-11-11
I know I could buy a programme to encrypt my swf-files, but Im really only interested in obfuscating the urls of my movies. Particularly the loadMovieNum-url in my loading-movie.
I have no idea how, but Im hopng for someting like this if the swf is decompiled:
Original url:
loadMovieNum("http://www.mysite.com/my1folder/my2folder/my3folder/myfile.swf",1);
Obfuscated url:
loadMovieNum(kj,-78,372,??/hl884-334,1)
meaning something completely nonsense that will take forever to figure out even if you have acces to see the function.
0
Comment
Question by:petersego
2 Comments
 
LVL 8

Accepted Solution

by:
ccarey earned 500 total points
ID: 24743841
You could design a simple encryption to make the value initially unreadable. There are some complex methods around (http://labs.boulevart.be/index.php/2007/05/23/encryption-in-as2-and-as3/) but it sounds like you're more interested in just making it hard to read.

Have a go at the snippet below. Your loadMovie call would turn into this:

loadMovieNum(unObfuscate("104,116,116,112,58,47,47,119,119,119,46,109,121,115,105,116,101,46,99,111,109,47,109,121,49,102,111,108,100,101,114,47,109,121,50,102,111,108,100,101,114,47,109,121,51,102,111,108,100,101,114,47,109,121,102,105,108,101,46,115,119,102"), 1)

That should work in AS2 or AS3. You would need to obfuscate your string prior to using it, and keep a local reference (notepad) to which string goes with what obfuscated equivalent.

function obfuscate(str:String) : String {
	var result:Array = [];
	for(var i=0;i<str.length;i++){
		result.push( str.charCodeAt(i) );
	}
	return result.join(",");
}
 
function unObfuscate(str:String) : String {
	var ob:Array = str.split(",");
	var result:String = "";
	var c:Number;
	for(var i=0;i<ob.length;i++) {
		c = parseInt(ob[i]);
		if(isNaN(c)) continue;
		result += String.fromCharCode(c);
	}
	return result;
}
 
var obfuscatedURL:String = obfuscate("http://www.mysite.com/my1folder/my2folder/my3folder/myfile.swf");
// result is 
// 104,116,116,112,58,47,47,119,119,119,46,109,121,115,105,116,101,46,99,111,109,47,109,121,49,102,111,108,100,101,114,47,109,121,50,102,111,108,100,101,114,47,109,121,51,102,111,108,100,101,114,47,109,121,102,105,108,101,46,115,119,102
trace("--- OBFUSCATED ---");
trace(obfuscatedURL);
 
trace("--- UNOBFUSCATED ---")
trace(unObfuscate(obfuscatedURL));

Open in new window

0
 

Author Closing Comment

by:petersego
ID: 31598249
Thanks. Maybe not unbreakable, but works fine for me as a startingpoint..
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question