Official Soldat Forums

Soldat Fans => Fan Apps => Topic started by: Hacktank on February 08, 2011, 07:17:55 pm

Title: Script Obfuscater
Post by: Hacktank on February 08, 2011, 07:17:55 pm
Hello, i have written a program that 'obfuscates', essentially encrypts, soldat scripts. While the server can still use them just fine, if not better, they are virtually impossible to decipher for a human. It renames every user-defined variable and function, removes all whitespace, and removes all comments.

Here are a couple of screenshots (only the first one shows the spruced up command-line output)

CLI/Usage example:
(http://img824.imageshack.us/img824/2572/cli2.png)

Obfuscation of the standardish Explode function:
(http://img826.imageshack.us/img826/9503/explodeout.png)

And Finally a chunk of my private zrpgevolved script:
Its rather large, so im just going to link it. Clickie (http://dl.dropbox.com/u/3180075/output.png)

Version 1.0.0

Download: From my Dropbox (http://goo.gl/XGcHi) (zip format)

Feedback, suggestions, and criticism please.
Title: Re: Script Obfuscater
Post by: Polifen on February 09, 2011, 04:04:58 am
Minute in Notepad++ and it should be readable, maybe it won't look clean ( no tabulators, and still most variables will have strange names ) but shouldn't be too hard to read.
Title: Re: Script Obfuscater
Post by: DarkCrusade on February 09, 2011, 09:32:20 am
Minute in Notepad++ and it should be readable, maybe it won't look clean ( no tabulators, and still most variables will have strange names ) but shouldn't be too hard to read.

The point is to make it harder to read. Large scripts will just be impossible to read, due to hundreds of functions without any comments or clue-giving names. Sure, small scripts are still readable, but think bigger :P
Title: Re: Script Obfuscater
Post by: thegrandmaster on February 09, 2011, 09:43:58 am
where would this be used?
Title: Re: Script Obfuscater
Post by: DorkeyDear on February 09, 2011, 10:00:19 am
Awesome!

I noticed some unnecessary spaces that could still be removed without issues (a - b -> a-b, etc.), not that huge of a deal.

I suggest more weird variable names than a, b, c, etc. It might be harder to tell what is what if variable names are all in a format like "_981566" or something, maybe a unique base64-like value after the underscore or something; again, not a huge deal.

Thanks :)
Title: Re: Script Obfuscater
Post by: VirtualTT on February 09, 2011, 10:51:39 am
Actually most of the scripts these days are completely unreadable without any obfuscation. ;D
So you should write a tool with opposite purpose...
Title: Re: Script Obfuscater
Post by: Polifen on February 09, 2011, 01:04:57 pm
Minute in Notepad++ and it should be readable, maybe it won't look clean ( no tabulators, and still most variables will have strange names ) but shouldn't be too hard to read.

The point is to make it harder to read. Large scripts will just be impossible to read, due to hundreds of functions without any comments or clue-giving names. Sure, small scripts are still readable, but think bigger :P

I didn't mean syntax highlighting, but ctrl + f and replace tab, replace ";" with ";\n" and you have a nice new lines ( it's not perfect, but it fixes most new lines ).

@Suggestions, that is totally weird but you could for ex. change :
Code: [Select]
var
ID : byte;
begin
ID:=12;
end;
to:
Code: [Select]
var
ID:byte;
begin
ID := 93196;
end;

Byte's range is 0 to 255, so 256 will be treated as 0, so number + random(1, 20) * 256 won't change the number itself.
Title: Re: Script Obfuscater
Post by: jrgp on February 09, 2011, 04:48:10 pm
This is just simple minification (http://en.wikipedia.org/wiki/Minification_%28programming%29), not obfusication (http://en.wikipedia.org/wiki/Obfuscated_code).

Still interesting though.
Title: Re: Script Obfuscater
Post by: JotEmI on February 10, 2011, 12:24:03 am
Well, like jrgp pointed out it's not a proper obfuscator but gj anyway. I guess it's pretty useless with small scripts but I've  tested it with +8k LOC script and indeed lack of comments and clue-giving names makes it way harder to understand (not impossible though).

You could also give up changing names of parameters of predefined procedures (like OnMapChange()) since everyone knows what they're used for.
Title: Re: Script Obfuscater
Post by: chutem on February 10, 2011, 11:25:01 pm
Might make a simple tool to help de-obfuscate code.