Solved

How do I obfuscate literal strings like urls

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

911 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

20 Experts available now in Live!

Get 1:1 Help Now