Solved

How do I obfuscate literal strings like urls

Posted on 2009-06-30
2
895 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

737 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