Click to See Complete Forum and Search --> : [RESOLVED] Obfuscation


\\.\
10-11-2008, 10:46 AM
Wasn't sure where to put this as it is not exactly asking for help but asking members to try something.

I know that various forms of encoding stuff to hide it from plain sight exist. I and a friend had a challenge to produce a couple of functions, one encode and the other ... decode a string of data. The basic rule was to devise a simple way of coding a data stream and then decode back in to its original format, down to formatting, etc.

I won BTW, my functions are 3 and 4 lines long, his was a huge chunky 45 & 63 lines per function, mine won because it did not rely on having items in order, the chunks & blocks can be jumbled as well as your able to have encoded material within the string to be encoded, draw back is decode can not cope with encoded material within plain text :( but still, for a 4 line program, you can't complain.

Well anyway. I thought that you might like to rise to the challenge of not only decoding but to reverse engineering a function to unveil the content.

This is the challenge:
73,0,160;102,1,113,122,247;32,2,6,11,19,22,29,34,42,73,77,82,85,88,92,95,101,105,111,114,121,127,130 ,137,142,145,153,156,159,162,168,173,180,185,189,197,200,207,210,215,220,225,230,235,239,242;121,3,7 4,144,169,186;111,4,21,26,53,64,75,84,87,90,112,129,134,170,187,199,204,219,237,238,245,246;117,5,59 ,76,171,188;104,7,31,44,103,139,167,182,227;97,8,13,15,39,57,61,98,157,183,193,212,216,240;118,9;101 ,10,17,24,28,36,41,45,79,80,104,110,117,132,136,147,155,192,195,202,206,222,232;109,12,35,100,154;11 0,14,46,54,65,78,89,119,148,151,158,213,223;103,16,40,55,120,152;100,18,23,27,81,86,131,135,149,196, 201,205,214,224;116,20,30,43,58,62,83,102,126,128,138,166,179,181,184,194,198,209,226,231,234,236;99 ,25,96,133,175,190,203;105,32,63,93,99,108,118,123,140,150,165,177,208,228;115,33,37,38,66,94,125,14 1,146,174,218,221,229,241;46,47,48,49,67,248;10,50,51,68,69,115,163,211;67,52;114,56,107,124,172,176 ,191,244;108,60,71,72,97,217;65,70;119,91,164;112,106,178,243;122,109;98,116,143;77,161;120,233;

The above is a message, if you decode it you will know what to do.

Please do not take yourself away from your work or regular duties, all I am interested in is if anyone can reconstruct or engineer a function to decode the string, that's all.

David Harrison
10-11-2008, 07:42 PM
Whenever there are JavaScript decoding challanges, the decode function must be included for it to actually be decoded by the browser.

Therefore I never do the decoding, I simply let the function do the work for me and output the result.

Include your decode function as would be done in a page using this system and revealing the message will be entirely trivial.

\\.\
10-11-2008, 08:57 PM
Yes I am aware of that, you have not understood my post.

Without the functions being divulged the task is, if anyone is able to, to write a function to decode the string in to its original message without knowing how the string is compiled. If you don't want to script, you could manually attempt it.

The code string is not meant to appear in a web page but it could, it has been something I have been playing around with. The strings are meant to be sent via email, personal IM, etc where you want to obfuscate the message body. The recipient would have the decode functions before hand...

All I am interested in is if anyone who is bored and wants a challenge to try and decode the message, it would be pointless for me to post up the code to decode the message, it would defeat the object of obfuscation.

Anyone who does decode the message will see in the message what to do next.

David Harrison
10-11-2008, 11:02 PM
Well, I'm tired and I'm going to bed now, but let me know if I'm close with any of the following:

Since you said the order of the numbers in each chunk doesn't matter, I gather that part of the decryption is addition of those numbers, possibly taking the average of the chunk (although this results in some non-interger values which require rounding).

Since you also said that the order of the chunks going into the decryption function doesn't matter, I believe the correct order of these may be determined based on the lowest number in each chunk.

I have been proceeding with the assumption that each chunk represents one character, and that after running some function on a chunk and arriving at a value, that value is taken modulo 128 to get an ASCII code.

As I said, I'm a little tired now, but unless I have an epiphany when I wake up, I think I'm going to need a hint or three.

scragar
10-11-2008, 11:37 PM
Well, I'm tired and I'm going to bed now, but let me know if I'm close with any of the following:

Since you said the order of the numbers in each chunk doesn't matter, I gather that part of the decryption is addition of those numbers, possibly taking the average of the chunk (although this results in some non-interger values which require rounding).

Since you also said that the order of the chunks going into the decryption function doesn't matter, I believe the correct order of these may be determined based on the lowest number in each chunk.

I have been proceeding with the assumption that each chunk represents one character, and that after running some function on a chunk and arriving at a value, that value is taken modulo 128 to get an ASCII code.

As I said, I'm a little tired now, but unless I have an epiphany when I wake up, I think I'm going to need a hint or three.

rofl, I tried exactly the same approach and can't get anywhere, I've been spewing all the combo's within a reasonable set of characters(a-z, 0-9, A-Z, space, comma, full stop etc) in a whole range of ways(broken both into sets by comma and by semi-colon) from averages of each group to the highest/lowest value, sum, powers, everything I could think off.

\\.\
10-12-2008, 06:00 AM
Like I said, don't lose sleep over this or spend any special time on it.

Clues... The only clue I can give is "Think Simple" theirs no actual math, modulo or shifting of bits or other algorithm based ciphers in the data string.

Thanks for having a go.

Dok
10-12-2008, 09:20 AM
If you have managed to decode this message then...

Congratulations.

All you need to do now is claim the prize of
being first to decode this by sending me an IM
with your script that you created to decode it
and also send this text too as proof.

;)

\\.\
10-12-2008, 09:53 AM
Well done DOK

Nice function, don't see how .apply(null,r); returns a string but...
as I understand it, the function passes the array 'r' to the fromCharCode function as an array but where does the 'null' come in to it?

Dok
10-12-2008, 10:06 AM
The apply method is used to invoke a function f as a method of an object o. So
f.apply(o,null);
is the same as
o.f();
but without o actually having a method f.

The second argument to apply is an array or arguments which is passed to f. So
f.apply(o,[1,2,3]);
is the same as
o.f(1,2,3);
If f is not a method but a function as String.fromCharCode is makes no sense to invoke it as a method of any object. If the first argument to apply is null then the second argument - the array - is still passed as the arguments to f.

This provide a shorthand for passing an unknown amount of arguments to a function. So
String.fromCharCode.apply(null, [1,2,3]);
is the same as
String.fromCharCode(1,2,3);
A very useable technique...maybe I should write a short article on call and apply.

\\.\
10-12-2008, 06:25 PM
Cheers. I can see how that would improve slightly on my version of the script.

It seems to be a pretty useful item which I can use.

Ta.

Dok
10-12-2008, 06:44 PM
Do the rest of you want to try for yourself or am I allowed to post the solution?

HazardTW
10-12-2008, 10:31 PM
Post it ;)

Dok
10-13-2008, 05:47 AM
For each block the first number is the character code and subsequent numbers is that characters position within the string. To decode a string pass it to this function
function decode(s) {
var r = [];
var b;
var a = s.split(';');
var l = a.length;
for(var i=0; i<l; i++) {
b = a[i].split(',');
for(var j=1; j<b.length; j++)
r[b[j]] = b[0];
}
return String.fromCharCode.apply(null,r);
}

\\.\
10-13-2008, 06:00 AM
@hazzardTW

Why post it? It takes all the fun out of it.

\\.\
10-13-2008, 06:02 AM
@DOK

U should have posted it up encoded just for a laugh :)

Dok
10-13-2008, 06:18 AM
If someone else had solved it I would certainly like to know the solution myself...I'm sorry if I ruined the fun for anyone else.

HazardTW
10-13-2008, 05:49 PM
That was just my impatience rearing it's ugly head.

Is it too late to rescind your reply with the answer so it is not spoiled for others?