Solved

How do I obfuscate literal strings like urls

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
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…
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.

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now