Solved

How do I obfuscate literal strings like urls

Posted on 2009-06-30
2
899 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

623 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