Jump to content
Sign in to follow this  
Horner

Code "Signing" or String Comparison for Security

Recommended Posts

Now, I'm just a person who codes for arma, so I have no idea if this idea is anywhere near being possible. But here goes...

In wake of all hackers, I thought of this. Is there a way, similar to addon-signing, to "sign" scripts? Like on mission load, it would compile all the functions used for the mission, and do various other things in the init.sqf, then you could basically broadcast all the compiled functions to all clients, and whenever a thread is spawned or called ([] call {} or [] spawn {}) it compares the code that is being spawned, and if it is not "signed" already by the mission, then it just doesn't run. I think this could be a good way to stop hackers. If this is in no way possible, my apologies for being dumb, but I thought I'd try to help contribute.

Here's some psuedocode on how I would think it could work. And the commands "signCode" and "disableUnsignedCode" only work before the init is completed.

fnc_someCode = compile preProcessFile "f\fnc_someCode.sqf";
fnc_otherCode = compile preProcessFile "f\fnc_otherCode.sqf";
fnc_unSignedCode = compile preProcessFile "f\fnc_unSignedCode.sqf";

signCode [fnc_someCode,fnc_otherCode];
disableUnsignedCode true;

[] call fnc_someCode;
[] call fnc_otherCode;
[] call fnc_unSignedCode;

The first 2 calls would work while the third would not.

---------- Post added at 03:51 PM ---------- Previous post was at 03:06 PM ----------

Or something else, like command event handlers and add an option for them to be removable, if the eh returns true then the command is run, if not then the command is not run. See example below.

Sytax

player addCommandEventHandler ["preProcessFile", {true}, false];

"preProcessFile" - command that triggers the EH

{} - code that is processed, if returns true, then command is run, if returns false then command is not run.

false - if true then EH is removable, if false, eh is not removable.

So, we could do something like this in the init.


fnc_something = compile preProcessFile "f\fnc_something.sqf";
fnc_other = compile preProcessFile "f\fnc_other.sqf";
fnc_unSigned = compile preProcessFile "f\fnc_unSigned.sqf";

// Unremovable
player addCommandEventHandler ["call", 
{
private["_args","_code","_arr","_ret"];
// [arg1, arg2] call {hintSilent (str (arg1 + arg2)); - Args would be as follows - [[arg1, arg2], {hintSilent (str (arg1 + arg2))}]
_args = _this select 0;
_code = _this select 1;
_arr = [(str fnc_something), (str fnc_other)];
_ret = false;
if ((str _code) in _arr) then
{
	_ret = true;
};

_ret
}, false];

player addCommandEventHandler ["spawn", 
{
private["_args","_code","_arr","_ret"];
// [arg1, arg2] spawn {hintSilent (str (arg1 + arg2)); - Args would be as follows - [[arg1, arg2], {hintSilent (str (arg1 + arg2))}]
_args = _this select 0;
_code = _this select 1;
_arr = [(str fnc_something), (str fnc_other)];
_ret = false;
if ((str _code) in _arr) then
{
	_ret = true;
};

_ret
}, false];

// NO FUTURE addCommandEventHandlers can be run
player addCommandEventHandler ["addCommandEventHandler", {false}, false];

// Calls fnc_something, fires EH, if EH returns true, command is run, if EH returns false, command doesn't run
// Runs without issues
[] call fnc_something;

// Doesn't run
[] call fnc_unSigned;

Keep in mind this could also be used for A PLEATHER of other things for mission makers. Also remember, I have no idea how difficult any of this is to implement, just dishing out ideas.

Edited by Horner
Curse my redundant english.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×