SRL Archive - First Scripts

ChaoSCAR - SCAR Obfuscator


arcix

2007-09-11 22:57:22

ChaoSCAR is a program I wrote in C++*. It is a obfuscator for the Scar/Pascal scripting language. An obfuscator, for those of you who are unaware, is a program that makes source code extremely difficult to read/alter/decipher. Obfuscation can be used as a method of script protection, something that seems to be lacking from SCAR, when combined with authorization functions.

This is the beta 1.0 release of ChaoSCAR; I may or may not release future versions. I have tested it on several SRL4-compatible scripts, one of which I included as an attachment. ( Gobbiez public autofighter, the original and obfuscated files are both there ) However, this is by no means a stable version; extremely large variable names/files may cause ChaoSCAR to crash due to memory errors. This is just one bug I am aware of (don't worry about trying it, it won't mess up your script) and I am sure there are others.

To use ChaoSCAR, run the executable (ChaoSCAR.exe) and select a file by either clicking on File…, typing in the full or relative path of the file, or dragging a file from Explorer into the window (I apologize, by the way, for the ugly form, its not my thing >_<) and then clicking Obfuscate. **Make sure the script you are trying to obfuscate compiles on Scar 3.11 before doing so!** The program will NOT edit the original script file at all. Rather, it will save the results to CS_originalname.scar.

I wrote ChaoSCAR from scratch in Visual Studio 2003. Feel free to use/distribute this program in any way you like, as long as

1) You attribute it to me (Handle - Arcix at srl-forums.com, e-mail - [email]consummant@gmail.com[/email])
2) You do not sell the obfuscated version of your script.

If you find any bugs/the program crashes on your script, please post them here or send me an e-mail, preferably with your script attached (although I can understand if you wouldn't want to do that.) Enjoy!


*Obviously, this isn't a script, although it is my first contribution to the forums and it doesn't seem like there is an appropriate sub-forum for this… Mods, please move the thread as necessary.



**Update (Beta 2)**

-Fixed a bug that caused an infinite loop when a type declaration followed a global variable declaration.

-Fixed some memory errors.

-Known bug (not fixed): does not recognize type declarations unless they use "record" to declare type objects.

alach11

2007-09-11 23:11:42

Wow… cool. Jotti scan was clean for me btw guys.

Diamond

2007-09-13 05:01:44

is it safe to use?

Buckleyindahouse

2007-09-13 05:53:02

From: Diamond
is it safe to use?


Can you read…..?

arcix

2007-09-13 10:05:21

From: Diamond
is it safe to use?


Of course, you don't have to trust me on this as I am new to the forums, but yes, it is completely safe.

Sp0rky

2007-09-13 10:11:34

Wow, all I can say. This is amazing. Great work. I'll definately be using this in the future and crediting you fully. Thank you for releasing.

mastaraymond

2007-09-13 10:23:03

Aah, its like the same as mine! :-). Nice work.

itSchRis917

2007-09-13 10:29:46

Very nice work man. Useful!

ckeboss

2007-09-13 10:42:03

Wow, nice. Scar has never really had an auto system… I think this will help with scripters, but once you distrubute the script like this, the user cant edit it, right?

arcix

2007-09-13 10:50:59

That's right, it will be extremely difficult for users to edit the obfuscated script (which is the point; only the original author can make changes)

Infantry001

2007-09-13 11:36:25

Is this supposed to take a long time?

If it is, good job :D

Sp0rky

2007-09-13 11:43:52

Takes about 2 seconds to obfuscate scripts for me.

Maybe its your comp? =p

Infantry001

2007-09-13 11:53:51

heh, hope not. its new and freakin awesome :D

the scar noob

2007-09-13 12:22:07

why not making it so it doesn't obfuscate the Player Array and constants?

Macrosoft

2007-09-13 12:35:15

Completely sweet!

do you mind if i try and edit it so it doesn't block the const and players array? Ill need the source code for that…

Im a c++ person too lol

Sp0rky

2007-09-13 13:44:02

I doubt he's going to give you the source.

Dumpin

2007-09-13 14:53:52

DAMN awsome…..
this will be so handy…

bye bye all leechers that download and claim own with little editing..

mastaraymond

2007-09-13 14:55:38

From: Dumpin
DAMN awsome…..
this will be so handy…

bye bye all leechers that download and claim own with little editing..

Bye bye seeing what the script does with your pass.:rolleyes:

arcix

2007-09-13 15:10:25

Thanks for all the positive feedback guys!

@Infinity: On my mediocre computer (1.7GhZ,1GB RAM), it takes about 8 seconds to obfuscate a 100kb file (that's a big script!). The reason it takes a while is because the program has to read the entire file into a buffer and then work with that buffer, reading and replacing strings within the buffer. The functions can be optimized, I am sure, but I don't think there is much need for it… unless you are writing 1mb script files O.o

@the scar noob: Good idea, I hadn't thought of the fact that users may need to edit things for the script to work. For now, you can take all of the procedures/constants that you DON'T want obfuscated (such as the DeclarePlayers proc), move them into a separate script file, and add an include in your main script referencing that one. I'll have to add options where you pick constants/procedures that you don't want obfuscated in the future.

@Macrosoft: Sorry, I don't plan on releasing the source to anybody at this point… but I will PM you if I change my mind.

Sir R. M8gic1an

2007-09-13 15:40:13

freaky. and awesome. freakin awesome then i guess? :p
great job man, great contribution.

Macrosoft

2007-09-13 19:14:00

no problem, ill be waiting for that pm lol. Probably wouldn't be too hard to make one myself, but im working on some scar scripts and my c++ tut, ao im sorta tired and lazy lol.

corl455

2007-09-13 21:52:00

would there be a way to leave stuff out.. like user defineable stuff,…. like username password and what not

Sir R. M8gic1an

2007-09-14 02:11:52

From: corl455
would there be a way to leave stuff out.. like user defineable stuff,…. like username password and what not


read, that was already asked and arcix already gave a temp solution for that.


@the scar noob: Good idea, I hadn't thought of the fact that users may need to edit things for the script to work. For now, you can take all of the procedures/constants that you DON'T want obfuscated (such as the DeclarePlayers proc), move them into a separate script file, and add an include in your main script referencing that one. I'll have to add options where you pick constants/procedures that you don't want obfuscated in the future.

LordGregGreg

2007-09-14 03:24:12

Very well done, good job :D

NOw, i think you all already know my opinion on this.. but im going to say it here anyways.

scar code , i feel, is inheretly open souce, and free for everyone to see exactly how everyhjting is done.

this is valuable from protection reasons , like making sure the script doesnt email the creator my user name and pass word., and alspo good for teaching other people..

there really is no good reason to obfuscate a screipt unless you are trying to sell it.

please, we have plently enough copy buster to make sure that a script credit doesnt get stolen.

i know that wihtout all of the scripts that i looked at, i would be a prety crap scrtiper, evne with all of the tutorials, and other help i had.

Santa_Clause

2007-09-14 04:58:35

This just gave me an unknown error and then closed…

~alex~

2007-09-14 06:34:17

Great work man, keep it up :D. Also I think this belongs in the c++ section.

Infantry001

2007-09-14 16:48:24

But no one looks there…

Any ideas as to why this just freezes up when I try to obfuscate a script?

arcix

2007-09-14 22:12:21

If it crashes on your script and you have verified that the script actually compiles and runs on Scar 3.11, then there you probably have a particularly long string/variable/procedure name in there somewhere that causes a memory error due to insufficient memory allocation… In any case, please e-mail the script to me so I can find the problem and fix.

Infantry001

2007-09-14 22:17:18

http://www.villavu.com/forum/showthread.php?t=14453

That's the script I was testing this on.

shanolo1

2007-09-15 07:47:35

will this make it harder to use the scripts or change the way they look

Santa_Clause

2007-09-15 07:49:35

It'll change the way they look so it makes it harder to copy the code…but still as easy to use…

arcix

2007-09-15 13:25:03

Updated, ChaoSCAR_B2

@Infantry: I know that fixed your problem
@Santa: Try that script you were getting an unknown error on and tell me if the update fixed it.

Infantry001

2007-09-16 21:14:40

Ok, this is really cool :D Great job, arcix!

Dark_Sniper

2007-09-17 00:57:25

make it so you can De Obfuscate it…

this way we can tell if someone is messing with r User and pass.
lol just dont let scar connect to any site not already in your on your safe list of scar.

me likey scar Obfuscator

Macrosoft

2007-09-26 23:22:25

hey man, im back, I want to make something that converts srl 3.81 scripts into srl 4 scripts. I was wondering if you could tell me what include you used to edit stuff on a .scar file, and how I could do so. Also, Im not sure how to make it executable, so yeah, I would really apreciat the help. I have learned up to pretty advanced stuff about c++ so dont try to dumb it down lol.

CodyTheBaddie

2007-09-26 23:28:27

Very nice man, props.

arcix

2007-09-27 15:36:22

.scar files are really just basic text files with a custom extension so scar recognizes them.. so I used the old C-style file functions to open the file and read bytes from it (they are included in stdio.h):

FILE * pFile = fopen("nameofscript.scar","r"); // opens for read access
char c = fgetc(pFile); // reads characters out of the file and increments the stream

Then there is fread for reading a certain number of bytes and fscanf for reading formatted data (reading one word at a time).

You can also use C++ streams (iostream) to do the same thing, I am just used to file pointers.

Once you pull the text out of the file, you have to analyze it yourself to see what it actually is… I go through the entire file buffer one word at a time, and look for key words like "var", "procedure", "function", "const", etc and from there, determine what to do. Be wary of comments and strings.. if you find the word procedure in a string, for example, it doesn't mean anything so you should just ignore it. If you find the double slash in a string, that doesn't mean it is a comment, etc.

How to make it an executable? Compile the code. I don't know what compiler you use, but there is usually a "build" option that will create an exectable for you.

Macrosoft

2007-09-27 16:05:38

I mean, how did you get it to have the little window thing that said location of script and the button that said obfusticat3

also, I am using microsoft visual c++ express addition. I am more familiar with iostream, so if you could tell me how to do it like that.


ok, so basicly i have the cin be the pointer, i get the text from the file, how do i search for stuff in the text…

BobboHobbo

2007-09-27 18:08:01

Now this is what you call AWSESEOM!!!

Im wondering is ther a way to de-Obfuscator the script if that makes sence.

Smartzkid

2007-09-27 18:09:09

From: BobboHobbo
Now this is what you call AWSESEOM!!!


I dunno about you, but I'd call it AWESOME! :p

BobboHobbo

2007-09-27 18:19:15

From: Smartzkid
I dunno about you, but I'd call it AWESOME! :p


Lol, my Bad

arcix

2007-09-28 16:20:16

I am the wrong person to ask about windowing, because the way I did it was pretty bootleg: (although if you do it this way you will understand window controls much better)

To make the main window, you need to set up a window class and call CreateWindow to create it. If you are using VS and you make a new "windows application" type project, it will do all of that for you. Now I went to the window callback procedure ( LRESULT CALLBACK WinProc is the default type + name ) and for the WM_CREATE case in the switch block, which is called when your main window is created, I added some more CreateWindow statements, this time to create the buttons and edit boxes. You need 4 important things you need when you are creating control windows (the other parameters are the location/size/style of the control): the class name (the two I used are EDIT and BUTTON, its obvious what they do), the parent window ( this will be hWnd, your main window handle ), the instance of your module ( hInstance, it is one of the parameters passed to WinMain, save it as a global for later use ), and an HMENU, which is really just a unique ID for the control that you use later. Use the WS_VISIBLE style when creating controls so that they appear immediatly upon creation. To process messages from control windows, you need to change the WM_COMMAND case in your main window's switch block to handle handle events. To get a handle to your control window, you need to call GetDlgItem(hWnd,UID), where hWnd is the main window handle and UID is the HMENU unique identifier of the control window. Once you have a window handle you can do whatever you want with the control (ei: calling SetWindowText to change the text in an edit box)

In Visual Studio, you can create an entire window template and it will be added to your code automatically… but I've never done that before >_> and I don't know how to.

As for C++ file operators, check out this link: http://www.angelfire.com/country/aldev0/cpphowto/cpp_BinaryFileIO.html

To "search" for a string in the file, the only thing you can do is read the file stream x bytes at a time, where x is the number of bytes in your search string, and compare the string to your search string. Then if you want to search for something else you need to rewind(pFile) the file (C style) or reset the fstream pointer (C++, its in that link). I recommend copying the entire file into a character buffer first and then working with that buffer.

Macrosoft

2007-10-01 23:45:59

…i only got about half of that, but its 2:00 am and im really tired, so ill reread in the morning. Thanks for the response!

cracker667

2007-10-07 00:30:51

:google:
Looks Good To Me Ty Man

pro2

2007-12-23 19:14:00

sounds good lemme try though

gamer 5

2007-12-23 19:41:03

Cool Program!!!

I going to use it alot!:D

Puffo

2007-12-24 18:26:19

Wow nice work!
and relly usefull