Page 1 of 2

anticheat

PostPosted: Mon Aug 29, 2016 07:51
by rnd
A cheat detection mod that detects fly, noclip and too fast resource mining

Licenses :
LGPL (all files excluding anticheat_routines.bin)
WTFPL (anticheat_routines.bin)

Note: to discourage cheaters analyzing the code cheat checking routines are in binary. If you are trustworthy you can see them by request.

Depends : default

Download: https://github.com/ac-minetest/anticheat/archive/master.zip
----------------------------------------------------------------------------------------------------------

Who is this for:
Server admins who want to run serious survival servers, free of "ill fly around and noclip underground to get 999 mese/diamonds in 5 minutes while being undetected".

Does it work:
Yes, its being used in practice on @test@ Just Test II [SERVER] with 40-50 players.

Features:
+ Spoiler

Re: anticheat

PostPosted: Mon Aug 29, 2016 08:43
by Naj
Looks nice !

Seems that source of anticheat_routines.bin is missing in github

Re: anticheat

PostPosted: Mon Aug 29, 2016 09:27
by Calinou
Naj wrote:Looks nice !

Seems that source of anticheat_routines.bin is missing in github


It looks like it's a proprietary mod: https://github.com/ac-minetest/antichea ... ua#L78-L79

I urge the mod author to actually release the source code of it, it's not a security threat at all. (We don't allow proprietary mods in Mod Releases, by the way.)

Re: anticheat

PostPosted: Mon Aug 29, 2016 09:32
by Naj
Ok, I was misleaded by the license text :p

Re: anticheat

PostPosted: Mon Aug 29, 2016 09:42
by rnd
Source is provided - just not for the sensitive part of checking. complete source - making it easy for cheaters to see what they should look for kinda defeats the purpose of it. So we have 2 possibilities:
1. weaken it by providing full source
2. play it smarter

What license do you suggest?

Re: anticheat

PostPosted: Mon Aug 29, 2016 09:49
by Calinou
rnd wrote:Source is provided - just not for the sensitive part of checking. complete source - showing cheaters what they should look for kinda defeats the purpose of it. So we have 2 possibilities:
1. weaken it by providing full source
2. play it smarter

What license do you suggest?


The license used currently is fine (GPLv3+), but it's nothing if the full source code isn't available. Also, random server-side checks are not really weakened by providing source codeā€¦

But a binary-only mod only makes it harder to fix and improve.

Re: anticheat

PostPosted: Mon Aug 29, 2016 10:18
by rubenwardy
Correction: play it dumber, and have no one use your mod. I personally would not use a mod with hidden code.

Looks like it uses find_nodes_in_area and line_of_sight to detect fly and noclip, along with get_player_controls

Re: anticheat

PostPosted: Mon Aug 29, 2016 10:22
by rnd
i certainly agree to show full source to certain trusted people for review, just not to publish it openly.

Re: anticheat

PostPosted: Mon Aug 29, 2016 10:26
by Naj
In that case you have to choose another license. GPL implies that you give away the source.

Re: anticheat

PostPosted: Mon Aug 29, 2016 10:29
by rubenwardy
Yeah, under the GPL license anyone that downloads this mod can demand to see the source of the bin file, and you'd be legally obligated to comply

Re: anticheat

PostPosted: Mon Aug 29, 2016 10:31
by Naj
Sorry, I missed some messages. I don't know if it is possible, but I guess yes, to have open source system preventing from cheating. Your mod could certainly be a basis for such a system. But as said Calinou, improvement is made harder without sources.

Re: anticheat

PostPosted: Mon Aug 29, 2016 12:22
by rnd
For now ill just include source but encrypted with password. Anyone trustworthy can see it.

I still didn't find any good example of open source anti cheat system, either they are long time abandoned or empty.

Re: anticheat

PostPosted: Mon Aug 29, 2016 12:39
by rubenwardy
If you write the server/client in the correct way using client side prediction / server side reconciliation, there is no need to use anti cheat, as the algorithms include it - the server simulates movement on its end, as well as on the client, to make sure there's no problems. But Minetest doesn't do this, and it's a little late to do add this

Re: anticheat

PostPosted: Mon Aug 29, 2016 12:49
by rnd
Right, that seems to be nicely explained here:
http://gabrielgambetta.com/fpm2.html

Btw there is strange bug in minetest where:

minetest.get_node(player:getpos()).name

does not always return name of node at player feet position, for player positions where pos.y<0 it actually returns node 1 below player feet position. Another thing:

When player jumps and then lands on floor with sneaking sometimes player:getpos() will report player y-position not at integer.5 ( 4.5 for example), but something like integer.49888...288 ( strangely this number is always the same). This causes minetest.get_node(player:get_pos()).name to read position 1 block down again - making it unnecessarily difficult to read correct position without rounding it first.

Re: anticheat

PostPosted: Fri Oct 21, 2016 22:35
by SaKeL
Whats wrong ? I do have "anticheat_routines.bin" in the mod folder..

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
2016-10-21 23:56:38: ERROR[Main]: ModError: Failed to load and run script from /home/juraj/.minetest/mods/anticheat/init.lua:
2016-10-21 23:56:38: ERROR[Main]: /home/juraj/.minetest/mods/anticheat/init.lua:94: attempt to call local 'anticheat_routines' (a nil value)
2016-10-21 23:56:38: ERROR[Main]: stack traceback:
2016-10-21 23:56:38: ERROR[Main]:    /home/juraj/.minetest/mods/anticheat/init.lua:94: in main chunk


line in init file:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local anticheat_routines=loadfile(minetest.get_modpath("anticheat").."/anticheat_routines.bin")
check_noclip, check_fly, check_player = anticheat_routines(minetest,cheat,CHECK_AGAIN,punish_cheat);

Re: anticheat

PostPosted: Sat Oct 22, 2016 09:14
by rnd
only reason i can think of:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
string.dump(function)
Returns a binary representation of the given function, so that a later loadstring on that string returns a copy of the function. Function must be a Lua function without upvalues.


-> maybe binary made on windows can't be loaded on linux. In this case someone needs to do it on linux.

Re: anticheat

PostPosted: Sat Oct 22, 2016 09:22
by SaKeL
i have linux, i could try it out if you give me some indication on what needs to be done.

EDIT: found some examples on how to do it, will try to do it on example lua files but eventually i will need the source.

Re: anticheat

PostPosted: Sat Oct 22, 2016 11:14
by rnd
i was curious so i installed minetest 0.4.14 under linux ubuntu from and gave it a try. Did:
0. installed minetest using Synaptic Package manager under Lubuntu
Image
1. extracted https://github.com/ac-minetest/antichea ... master.zip into home/$name/.minetest/mods, renamed folder names: anticheat-master to anticheat
Image
2. run minetest game in singleplayer with "anticheat" mod checked
3. it runs ok, with anticheat mod working:
Image

Re: anticheat

PostPosted: Sat Oct 22, 2016 15:45
by SaKeL
Weird..i try to remove my anticheat folder from my mods folder and clone it again..i dont see any other solution at this point...hope that will work

FYI: im using daily builds, not sure what is in the synaptic repositories atm

Re: anticheat

PostPosted: Sat Oct 22, 2016 16:35
by SaKeL
nope...

- removed the mod
- clone it again
- not working

- removed the mod
- downloaded the .zip file
- not working

- each time i have created new map with only default mods and anticheat mod enabled

Seems like there is something else on my machine what is causing this not to work since it works on rnd's machine.

Re: anticheat

PostPosted: Sat Oct 22, 2016 16:48
by ExeterDad
I'm assuming the bin file is compiled lua. Does compiled lua need to be run with identical lua versions? This is just a guess btw. I know to decompile lua, version IS important in many cases.

Edit: Just found this.
Lua programs that have been precompiled for one version will not load in a different version.

Re: anticheat

PostPosted: Sat Oct 22, 2016 16:59
by SaKeL
Found the problem, just adjust the minetest.conf file with:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
#    Prevent mods from doing insecure things like running shell commands.
secure.enable_security = false


This will open vulnerability for any mod to run shell commands on your server or pc. Maybe it would be better to use "request_insecure_environment()" function in your mod so people can include it in the "secure" list instead of disabling the security for all mods ;)

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
#    Comma-separated list of trusted mods that are allowed to access insecure
#    functions even when mod security is on (via request_insecure_environment()).
#secure.trusted_mods =

Re: anticheat

PostPosted: Sat Oct 22, 2016 17:58
by rnd
indeed, in [0.4.12-dev] Mod security it says
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
But the following things shouldn't work:
    Using some insecure functions like require(), os.execute(), or debug.getlocal().
    Running compiled Lua bytecode.

Re: anticheat

PostPosted: Sun Oct 30, 2016 21:59
by bigfoot547
Can I please see the code?

+1 for open source!

Re: anticheat

PostPosted: Tue Nov 01, 2016 22:35
by red-001
It's trivial to decompile lua bytecode. If someone is going to take the time to try and find a weakness in an anticheat system, compiling lua to bytecode isn't going to do much to stop them.

Re: anticheat

PostPosted: Tue Nov 01, 2016 23:05
by rubenwardy
I spent an hour or so trying to decompile it using unluac, hex editors, and other tools. I don't understand the obscurity side of lua though

Re: anticheat

PostPosted: Tue Nov 01, 2016 23:15
by red-001
AFAIK Lua JIT uses a different format for bytecode so you need a decompiler that written for Lua JIT.

Re: anticheat

PostPosted: Tue Nov 01, 2016 23:59
by bigfoot547
I think that you should make the mod open-source because:
  1. Your license assumes that your code is open-source (GPL v3.0)
  2. This defeats the whole purpose of the linux operating system
  3. With your license you would have to give the code when someone asks (see #1)
  4. This is not allowed in mod releases
And for what?
If you don't want cheaters to analyze the code to cheat undetectably, the cheater would go to the next server. I mean, the server list shows the mod list! If I were a cheater and I saw an anticheat mod, I would not go on that server.

That is all.
Cheers, bigfoot547.

Re: anticheat

PostPosted: Wed Nov 02, 2016 00:41
by maikerumine
bigfoot547 wrote:I think that you should make the mod open-source because:
  1. Your license assumes that your code is open-source (GPL v3.0)
  2. This defeats the whole purpose of the linux operating system
  3. With your license you would have to give the code when someone asks (see #1)
  4. This is not allowed in mod releases
And for what?
If you don't want cheaters to analyze the code to cheat undetectably, the cheater would go to the next server. I mean, the server list shows the mod list! If I were a cheater and I saw an anticheat mod, I would not go on that server.

That is all.
Cheers, bigfoot547.

For what it's worth,

The code is pretty solid and has done a great job deterring cheaters on the Just Test 2 server. :)

Re: anticheat

PostPosted: Fri Nov 04, 2016 08:58
by xeranas
Either way your mod is not GPL: (misleading license)
Linking a GPL covered work statically or dynamically with other modules is making a combined work based on the GPL covered work. Thus, the terms and conditions of the GNU General Public License cover the whole combination.


Or you violating GPL (by hidding source code):
if you release the modified version to the public in some way, the GPL requires you to make the modified source code available to the program's users, under the GPL.


Even by asking source code is provided only for "trustworthy" so definitely not for everyone.

I understand mod author intentions. However what stops me from creating "anticheat over 9000" mod include crappy binary which do some harm to user?. If there no source code its not open source as simple as that. Obfuscated source form is not valid source code.
The source code for a work means the preferred form of the work for making modifications to it.