Jump to content

'compiled' resources


Stratospheria

Recommended Posts

  • 2 months later...
who said you can't?
Ah. Well I just drew that conclusion, because many people provide rapidshare like links to compiling software. It makes me think they made something custom, rather then using standard Lua compiler from the Lua binaries. :)

Another question: I see many people saying that compiling has really no advantages, other then protecting your code a little bit. But in many languages pre-compiling can improve the performance of your code. As the language doesn't have to be interpreted while running. Is this not the case with Lua or MTA:Lua?

Link to comment

Just download it from the lua website! Compiling the code will protect it from casual viewers, but not hackers etc. It will very slightly speed up the loading of the resource, but have no impact on it's performance while it's running.

Link to comment

Compiling is good to keep noobs from building off your Lua script, but if you really want noone else to "use" your script (say its mostly clientside), then you need to host the files somewhere trustworthy and send the client script using loadstring and some magic. The client code will only exist in memory, this means the client will always download the script (bad). This could be used in a limited way for small scripts or pieces of scripts so said hackers don't have all the puzzle pieces to play with.

I don't recommend doing this unless you have something SMALL and truly exceptional. Someone stealing your vehicle spawning script isn't that big a deal.

Server Lua file:

 function RecieveScriptFromServer () 
    local file = fileOpen ( 'CLIENTSIDE.lua', true )--This opens the script containing the clientside script inside the resource 
    if file then    
        local packets = {} 
        local counter = 1 
        while not fileIsEOF(file) do              
            packets[counter] = fileRead(file, 30000)--65535 byte send limit per trigger 
            counter = counter + 1 
        end 
        fileClose(file)  
        triggerClientEvent ( "onRequestClientFiles", root, packets) 
    else 
        outputConsole("Client files are missing serverside!") 
    end 
end 
addEvent( "onRecieveScriptFromServer", true ) 
addEventHandler( "onRecieveScriptFromServer", root, RecieveScriptFromServer )    

Client Lua file:

 triggerServerEvent ( "onRecieveScriptFromServer", getLocalPlayer() )  
  
function RequestClientFiles (clientCode) 
    append = "" 
    for k,v in ipairs(clientCode) do 
        append = append..v 
    end 
    loadstring(append)() 
end 
addEvent( "onRequestClientFiles", true ) 
addEventHandler( "onRequestClientFiles", root, RequestClientFiles ) 

The clientside script can only be obtained physically by a hacker sniffing out MTA packets. Lua script sent through loadstring cannot be compiled (in my testing), although it would not matter much. If someone knew how to sniff packets surely they could deal with a compiled Lua file. The script can be obfuscated immensely before sent, but again thieves would still be able to 'use' the script, even if they don't understand it, which defeats the purpose of using this method.

This is what I have learned recently anyway.

Link to comment
Another interesting method is compiling all client scripts to one file. It's can be done by lua compiler too.

Also can be more tables in first lines of script.

array = { { { } } } 

Decompilator can't decompile this file.

Edited by Guest
Link to comment
  • 2 months later...

I use the same method as Ransom since months ago but I just read all files and split the finished text each trigger limit characters, probably a bit longer than Ransom's method, put it in a table and send to the client then make all in one and loadstring() but the problem is with the 'onClientResourceStart' event...

Link to comment
i CAN Compile any LUA file .. and NO ONE << yea NO ONE

can DeCompile it ..

Contact by PM if you want to know what i can do , and i can compile ur script but i will not tell anyone how i can do it

@ lol'd

if you dont Believe me you can test me with any noob script

test me ^^

Link to comment
  • 2 months later...

I love to bump lol

There was a method with pawn to add some code which makes it impossible to decompile the script. Well, impossible, the decompiled file only showed three lines of includes which might not even be present in the script itself. Just read some other topic about compiling, so that's what remind me of this. Now I'm wondering; isnt't there some code for lua to achieve the same?

Link to comment
  • Discord Moderators

We wrote an obfuscator for LUA once at DKR. It was never implemented in praxis though, seems like lost effort when it's only code we can protect. Most people nail the models.

If you want, I can probably pull out some details. Obfuscation doesn't make it impossible, but depending on the technique very hard and time consuming to reverse engineer the script.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...