SRL Archive - Java Help and Tutorials

scar formatter/obfuscater


sherlockmeister

2008-12-21 19:03:49

hello, this is a little project that came into my head even though it had been i long time since i visited the forums. basically it is a scar script source code parser that either just writes the script to a file formatted or transforms it so that all names are replaced with nonsense, statements are all jumbled with labels/jumps, integer literals are obbed, and spacing is messed up. just run from the command line with in path, out path, and flags.
flags are like this:
none means just format
"-n" means mess up names/integers
"-j" means jumble up statements with gotos (also enables "-n")
"-t" means mess up spacing
well, heres and example to clear things up a little:
java Obfuscater "in.scar" "-j" "-t" "out.scar"
or
java Obfuscater "in.scar" "out.scar"
(make sure flags are between in and out path)
just as an example i will post bejeweled.scar (in you scripts\games directory lol) obfuscated with all flags

dont expect this to be completely bug free so you may not always get a compilable output

if you dont know how to run this and you really want to try it out then just post you script

(as you can see the obbed file with all flags is freaking huge so i will post it also without the spacing flag because it takes scar like 20 seconds to compile it)

ok another thing dont compile source file on your desktop!!! you will end up with like 30 separate class files!

Aser

2008-12-21 19:16:26

Just wondering, what is the point of this? I also think I'm a little confused… Does it just ruin a script?

A G E N T

2008-12-21 19:30:31

Very impressive :) Haven't looked at the source, as I don't have RAR support on this computer, but the output is very nice :)
@Aser, it messes it up, but so that it will still compile in SCAR.

Aser

2008-12-21 19:56:01

So wouldn't this make it easier for people to make password stealing scripts? I'm not trying to cut down your work, I'm just trying to get a full understanding of it.

bullzeye95

2008-12-21 19:56:04

Ahh, very nice! I love the use of gotos. Makes it really unreadable.

Great job.

EDIT: Aser, it's against the rules to release obfuscated scripts AFAIK.

Timer

2008-12-21 20:35:56

From: bullzeye95
EDIT: Aser, it's against the rules to release obfuscated scripts AFAIK.


Since When?

bullzeye95

2008-12-21 20:45:38

Ok, maybe I'm crazy…

noidea

2008-12-21 20:49:02

I thought Wizzup? was telling us awhile ago about not to release obbed scripts.

bullzeye95

2008-12-21 21:00:42

Yeah, probably. I know I saw it somewhere.

senrath

2008-12-21 21:32:54

From: bullzeye95
Yeah, probably. I know I saw it somewhere.


I'm pretty sure I saw it somewhere as well, but I haven't been able to find where.

MylesMadness

2008-12-21 21:48:28

From: Timer
Since When?
Since you posted a obbed script :p

Gu3st...

2008-12-22 05:14:29

I tried your obbed bjelwed (the first)
Successfully compiled (23398 ms)
Line 2659: [Warning] (2659:12): Calculation always evaluates to True in script
Line 3941: [Warning] (3941:59): "True and" is not needed in script
Line 4247: [Warning] (4247:1): "True and" is not needed in script
Line 4249: [Warning] (4249:90): "False or" is not needed in script
Line 4253: [Warning] (4253:1): "True and" is not needed in script
Line 4500: [Warning] (4500:10): "False or" is not needed in script
Line 4934: [Warning] (4934:1): "False or" is not needed in script
Line 5089: [Warning] (5089:25): "True and" is not needed in script
Line 5098: [Warning] (5098:1): "False or" is not needed in script
Line 5692: [Warning] (5692:16): Calculation always evaluates to False in script
Line 5697: [Warning] (5697:33): "False or" is not needed in script
Line 5703: [Warning] (5703:10): "True and" is not needed in script
Line 6175: [Warning] (6175:33): Calculation always evaluates to False in script
Line 6370: [Warning] (6370:1): "True and" is not needed in script
Line 6613: [Warning] (6613:52): "False or" is not needed in script
Line 11237: [Warning] (11237:1): "True and" is not needed in script
Line 11243: [Warning] (11243:1): Calculation always evaluates to False in script
Line 11252: [Warning] (11252:9): "False or" is not needed in script
Line 12184: [Warning] (12184:1): "True and" is not needed in script
Line 12193: [Warning] (12193:41): "False or" is not needed in script
Successfully executed

MylesMadness

2008-12-24 11:53:51

It makes it take for ever to compile.

Dan Cardin

2008-12-24 14:02:08

making it turn the script into one line would further the unreadability.

Yakman

2008-12-24 15:55:33

i disagree, all the junk in the script makes it more unreadable then if it was on one line

Dan Cardin

2008-12-25 10:53:40

From: Yakman
i disagree, all the junk in the script makes it more unreadable then if it was on one line


i was saying, keep it as it is (in the sense of how it changes the script already), and put it all on one line.

Ron

2009-01-03 19:06:37

Cool, this a very intricate program. Here's some critique.

If you run the program by itself, it generates a java error. You should have it check for FileNotFoundException.

File someFile = new File( "blah.txt" );
if ( someFile.exists( ) ) // if it exists, continue
…
else
System.err.println( "File was not found." );

Your formatting is off because your java file generated this block:

function replace(thestring, replacee, replacer: string): string;
var
a: longint;
begin
a := pos(replacee, thestring);
if (a > 0) then
begin
delete(thestring, a, length(replacee));
insert(replacer, thestring, a);
end;
result := thestring;
end;

When it should have generated:

function replace(thestring, replacee, replacer: string): string;
var
a: longint;
begin
a := pos(replacee, thestring);
if (a > 0) then
begin
delete(thestring, a, length(replacee));
insert(replacer, thestring, a);
end;
result := thestring;
end;

Also, -t seems to change the spacing AND the names. -n doesn't change the names, it seems that the program just ignores it. and -j doesn't change the names because it turns -n on which doesn't do anything.

Other than that, nice script. It twisted my DFM Parser perfectly and after obbed, the parser was still able to generate compilable scar form code. You have done a fantastic job!

Now it would be nice if you had a GUI. :) I hate using the command line in Windows.

Sandstorm

2009-02-18 23:40:51

Anyone who knows how to use this explain it to me? Thanks!

~Sandstorm

Method

2009-02-19 01:28:54

Extract it to a location of your choice, compile it using the javac command, then you can run it with one of the lines he provided in the first post.

Sandstorm

2009-02-19 18:15:15

Grr, it's not working :/.

Keeps throwing me this error:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings>java Desktop\Obfuscater2.class "C:\Documents a
nd Setting\Desktop\SCAR 3.15\Scripts\NameOfScriptHere" "-j" "-t" "
C:\Documents and Settings\Desktop\SCAR 3.15\Scripts\DLCaver.scar"
Exception in thread "main" java.lang.NoClassDefFoundError: Desktop\Obfuscater2/c
lass
Caused by: java.lang.ClassNotFoundException: Desktop\Obfuscater2.class
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: Desktop\Obfuscater2.class. Program will exit.

C:\Documents and Settings>

As you can tell, this is the command I'm using. It's not working though, and I've tried many ways of telling it where to find Obfuscater2.class :/.

java Desktop\Obfuscater2.class "C:\Documents a
nd Setting\Desktop\SCAR 3.15\Scripts\NameOfScriptHere" "-j" "-t" "
C:\Documents and Settings\Desktop\SCAR 3.15\Scripts\DLCaver.scar"

Any help at all is appreciated!

~Sandstorm

Method

2009-02-19 18:30:48

You don't include .class when you are using the javac command. Just do
java Desktop\Obfuscater2 "C:\Documents and Setting\Desktop\SCAR 3.15\Scripts\NameOfScriptHere" "-j" "-t" "C:\Documents and Settings\Desktop\SCAR 3.15\Scripts\DLCaver.scar"
and you should be fine.

Sandstorm

2009-02-19 18:46:29

Wtf. I changed it to the right path, and it still tells me the exact same error! Grr….

~Sandstorm

Method

2009-02-19 18:56:03

You want to do java Obfuscater2 … not java Obfuscater2.class. Make sure you're not still doing that. Also make sure you've compiled it with javac.

CamHart

2009-04-01 03:55:17

this is really neat

Clishem

2009-04-07 12:30:23

Hey there, could someone tell me what an 'obfuscater' is? Is it to protect a script from being de-compiled or something like that?

Method

2009-04-07 14:57:23

http://en.wikipedia.org/wiki/Obfuscated_code

That should fill you in.

noidea

2009-05-04 06:38:04

:< I read SandStorms posts and I still dont understand what to do.

Blender

2009-05-06 06:16:31

Do you have JDK installed?

rpg711

2009-05-15 00:53:14

Wouldn't an obfuscator for scarscripts be pointless since most scripts require values to be edited? Just my thoughts… obfuscation normally makes classes/methods/variables all weird n shit.

Yakman

2009-05-15 03:24:57

From: rpg711
Wouldn't an obfuscator for scarscripts be pointless since most scripts require values to be edited? Just my thoughts… obfuscation normally makes classes/methods/variables all weird n shit.


you can have a scar script with a form

footballjds

2009-05-15 03:51:00

2 months and 3 weeks later the fuscated script compiles ;)

noidea

2009-05-15 04:03:17

Lol, it changed a 2.5k line script into a 40k lined script.
It takes like 4 minutes to compile.

scuz 10

2010-06-19 01:31:44

Any chance this could be updated?

nielsie95

2010-06-19 04:27:29

Alternatives:

By Ron
By me
By mastaraymond

scuz 10

2010-06-19 04:44:36

From: nielsie95
Alternatives:

By Ron
By me
By mastaraymond


Yours is the only one that still works. I was hoping to run a script through yours and then through another for added protection. Can you find another working obfuscator? (I've been searching these forums for over an hour and I can't)