Register for your free account! | Forgot your password?
Rust Cheats

You last visited: Today at 04:35

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[How-to]Protect your lua code

Discussion on [How-to]Protect your lua code within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.

Reply
 
Old   #1
 
d3m0n3's Avatar
 
elite*gold: 0
Join Date: Jun 2011
Posts: 75
Received Thanks: 178
[How-to]Protect your lua code

hello all,

Today I want to explain how to protect your code from prying eyes, first we have to install the lua 5.0 support on freebsd if you do not have it in this way:

Code:
# cd /usr/ports/lang/lua50  && make install clean
now we have installed on our server lua 5.0 support and can pass to the compilation of the code in this way:

Code:
# /usr/local/bin/lua50/luac -o myFile myFile.lua
We get a compiled file ( myFile ) can not be read by eye but we can load it using the "dofile"

for example of an application we can use my tournament quest:


we can see the quest using various functions written by me

functions:

Code:
TORNEO_READ			= 0
TORNEO_PLUS			= 1
TORNEO_NEW			= 3
TORNEO_NEXT			= 4

TORNEO_MEMBER		= 1
TORNEO_REGISTRED	= 2
TORNEO_START		= 3
TORNEO_FINISH		= 4
TORNEO_STAGE		= 5
TORNEO_ROUND		= 6

function torneo_open_regi()
	local TORNEO_PATH = "locale/italy/quest/object/torneo/"
	local TORNEO_FILE = "torneo_stage_*"
	os.execute("cd "..TORNEO_PATH.." && rm -rf "..TORNEO_FILE)
	game.set_event_flag("torneo_close", 0)
end

function torneo_round(number)
	local stage = { 8,16,24,32,40,48,56,64 }
	local x = 1
	while true do
		if stage[x] == nil then break end
		if number <= stage[x] then
			return x
		end
		x = x + 1
	end
end

function torneo_tool(linea, stage, round, modo)
	local TORNEO_PATH = "locale/italy/quest/object/torneo/"
	local TORNEO_FILE = "torneo_stage_"..stage.."_round_"..round..".txt"
	local x = 1
	local file
	local newRound
	local result
	if modo == 0 then
		file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
		while true do
			local line = file:read("*l")
			if line == nil then 
				break 
			end
			local text = string.gsub(line, "\n", "")
			if x == linea then 
				io.close(file)
				return text
			end
			x = x + 1
		end
		io.close(file)
	elseif modo == 1 then
		file = io.open(TORNEO_PATH..TORNEO_FILE, "a+")
		file:write(linea.."\n")
		io.close(file)
	elseif modo == 2 then
		if round <= 2 then
			newRound = 1
		elseif round <= 4 then
			newRound = 2
		elseif round <= 6 then
			newRound = 3
		elseif round <= 8 then
			newRound = 4
		end
		local TORNEO_NEWFILE = "torneo_stage_"..stage.."_round_"..newRound..".txt"
		file = io.open(TORNEO_PATH..TORNEO_NEWFILE, "a+")
		file:write(linea.."\n")
		io.close(file)
		return newRound
	end
end

function torneo_data(linea, modo)
	local TORNEO_PATH = "locale/italy/quest/object/torneo/"
	local TORNEO_FILE = "torneo.txt"
	local x = 1
	local file = ""
	if modo == TORNEO_READ then
		file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
		while true do
			local line = file:read("*l")
			if line == nil then 
				break 
			end
			local text = string.gsub(line, "\n", "")
			if x == linea then 
				io.close(file)
				return text
			end
			x = x + 1
		end
		io.close(file)
	elseif modo == TORNEO_PLUS then
		local linee = {}
		local x = 1
		local y = 1
		file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
		while true do
			linee[x] = file:read("*l")
			if linee[x] == nil then 
				break 
			end
			x = x + 1
		end
		io.close(file)
		os.rename(TORNEO_PATH..TORNEO_FILE, TORNEO_PATH..TORNEO_FILE..".BAK")
		local update = io.open(TORNEO_PATH..TORNEO_FILE, "a+")
		while true do
			if linee[y] == nil then break end
			if y == linea then 
				local newPoint = tonumber(linee[y]) + 1
				update:write(newPoint.."\n")
			else
				update:write(linee[y].."\n")
			end
			io.flush()
			y = y + 1
		end
		io.close(update)
	elseif modo == TORNEO_NEXT then
		local linee = {}
		local x = 1
		local y = 1
		file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
		while true do
			linee[x] = file:read("*l")
			if linee[x] == nil then 
				break 
			end
			x = x + 1
		end
		io.close(file)
		local newMember = tonumber(linee[1])/2
		local newFinish = 0
		local newStage = tonumber(linee[5])+1
		local newRound = 1
		local newStart = tonumber(linee[3])+1
		local update = io.open(TORNEO_PATH..TORNEO_FILE, "w+")
		update:write(newMember.."\n"..linee[2].."\n"..newStart.."\n"..newFinish.."\n"..newStage.."\n"..newRound.."\n")
		io.close(update)
	elseif modo == TORNEO_NEW then
		file = io.open(TORNEO_PATH..TORNEO_FILE, "w+")
		file:write(linea.."\n0\n0\n0\n1\n1\n")
		io.close(file)
	end
end

function torneo_opp(posizione, stage, round)
	local member = {}
	local x = 1
	local sfidanti = tonumber(torneo_member(stage, round))/2
	while true do
		member[x] = torneo_tool(x, stage, round, 0)
		if member[x] == nil then break end
		x = x + 1
	end
	local opps = sfidanti + posizione
	local chll = posizione - sfidanti
	if posizione <= sfidanti then
		return member[opps]
	else
		return member[chll]
	end
end

function torneo_member(stage, round)
	local TORNEO_PATH = "locale/italy/quest/object/torneo/"
	local TORNEO_FILE = "torneo_stage_"..stage.."_round_"..round..".txt"
	local x = 1
	local file = io.open(TORNEO_PATH..TORNEO_FILE, "r")
	while true do
		local line = file:read("*l")
		if line == nil then break end
		x = x + 1
	end
	io.close(file)
	local result = x - 1
	return result
end		

function torneo_number(name, stage, round)
	local player = {}
	local x = 1
	while true do
		player[x] = torneo_tool(x, stage, round, 0)
		if player[x] == name then break end
		x = x + 1
	end
	return x
end
how can I protect my code?

simple compiling the source "torneo_lib.lua" as described previously we get a file like this:



now we need only to put in questlib.lua the line(I created the lib directory but we can put it anywhere):

Code:
dofile("locale/italy/quest/lib/torneo_lib");
and functions name in quest_functions


i hope be useful

enjoy

d3m0n3
d3m0n3 is offline  
Thanks
8 Users
Old 09/21/2012, 04:48   #2
 
elite*gold: 0
Join Date: Jan 2011
Posts: 22
Received Thanks: 19
Cescoso is offline  
Old 09/21/2012, 07:42   #3
 
d3m0n3's Avatar
 
elite*gold: 0
Join Date: Jun 2011
Posts: 75
Received Thanks: 178
Quote:
Originally Posted by Cescoso View Post
and?
d3m0n3 is offline  
Old 09/21/2012, 10:06   #4
 
ReckLess.'s Avatar
 
elite*gold: 0
Join Date: Dec 2011
Posts: 85
Received Thanks: 192
It can still easily be converted..
ReckLess. is offline  
Thanks
1 User
Old 09/21/2012, 10:45   #5
 
d3m0n3's Avatar
 
elite*gold: 0
Join Date: Jun 2011
Posts: 75
Received Thanks: 178
Quote:
Originally Posted by ReckLess. View Post
It can still easily be converted..
it's true but are not left unencrypted data if someone wants to take it have a complication
is like saying I leave the door open because you can break it have no sense
d3m0n3 is offline  
Old 09/21/2012, 12:13   #6
 
Mijago's Avatar
 
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,598
Nothing really new..
I can convert it back with just 1 Lua Command
Try to do it as i did - write an obfuscater for Questfiles
Mijago is offline  
Old 09/21/2012, 13:18   #7
 
atag's Avatar
 
elite*gold: 0
Join Date: Jan 2009
Posts: 104
Received Thanks: 126
It's not a protection...

(lua 5.0)
(lua 5.1)
atag is offline  
Old 09/21/2012, 13:19   #8
 
d3m0n3's Avatar
 
elite*gold: 0
Join Date: Jun 2011
Posts: 75
Received Thanks: 178
Quote:
Originally Posted by Mijago View Post
Nothing really new..
I can convert it back with just 1 Lua Command
Try to do it as i did - write an obfuscater for Questfiles
obfuscator is a locally way but you can not distribute code without giving a library to make it readable to interpreter
if you want only to protect your private code there are many ways...

in this case the code can also be redistributed

Quote:
Originally Posted by atag View Post
It's not a protection...

this tool is for lua 5.1 we use lua 5.0
d3m0n3 is offline  
Old 09/21/2012, 13:54   #9
 
Mijago's Avatar
 
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,598
I have created a difference File for the Game so it can read crypted Quests from mine..
So it is still possible; And Lua hast some really awesome "hidden" functions to do the same or some like this without give out the function itself; You can also run LBytecode that noone can decrypt/decompile if you compile it the right way
Mijago is offline  
Old 09/21/2012, 17:56   #10
 
elite*gold: 0
Join Date: Nov 2011
Posts: 395
Received Thanks: 29
thanks a lot for share @d3m0n3
Laben is offline  
Old 09/21/2012, 20:43   #11
 
wzy26022's Avatar
 
elite*gold: 0
Join Date: Feb 2010
Posts: 64
Received Thanks: 14
Fare molto bene
wzy26022 is offline  
Old 10/01/2012, 19:17   #12
 
elite*gold: 0
Join Date: Oct 2010
Posts: 43
Received Thanks: 14
How decompile your lua protect code (only with luaC)

Go to



Download and enjoy!
WarXWar is offline  
Old 10/01/2012, 21:56   #13
 
elite*gold: 0
Join Date: Sep 2012
Posts: 17
Received Thanks: 4
It's an old and knowed method, and this don't give a protection.
GerardFernandes is offline  
Reply


Similar Threads Similar Threads
[Release] Q-Protect Anti hack source code
10/12/2012 - Flyff PServer Guides & Releases - 12 Replies
Hi, I thought I release the source code now as I promised it ones I'm not working on this project anymore so no reason to keep it for myself. Well I hope you all can use it well or even improve it if you like too. If you are going to use this source don't forget to give me some credits Download: http://ompldr.org/vYnY5Nw
Protect in ein Protect rein setzten ?
10/08/2011 - Minecraft - 3 Replies
Moin, Ich hab meine ganze Stadt protectet mit worldguard und möchte dort kleine protects rein machen damit dort USER bauen können. Geht das oder wie könnte ich das machen?
[Source Code]DDos Protect
06/23/2011 - Flyff Private Server - 0 Replies
Hallo Elitepvpers, Ich Wollte hier mal da ich an der Beta Version von mein Dos Protect nicht weiter coden werde sondern mit der anderen version anfange, habe ich mich entschlossen Den source Code zu Relasen. Der Haupt Exe #AutoIt3Wrapper_Icon=..\Icon.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Run_Obfuscator=y
protect.dll
03/06/2008 - Kal Online - 2 Replies
:D hey nur ne frage ich hab mal die protect.dll vom xiu p-server mit tdump von delhi geöffet und das is dabei rausgekommen und könnte ma die dll nich so umschreiben sodass kal nich imma schließt wenn er ne hackengine oda ähnliches findet? answer fast pls ich hab auch nochma die engine.exe mit tdump geöffnet falls es euch hilft aba ich werd nich schlau daraus^^



All times are GMT +1. The time now is 04:37.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.