Anti Bot Systems

One of many OTCv8 bot advantages it’s his capability to work around anti-bot systems.
Since this client is bot, basically everything that happens on screen can be detected and processed.

There was already many requests regarding this kind of scripts so we decided to make tutorial for them.

Whole process to create such script can be listed in two or three steps:

  1. Finding anti-bot message (which contains requested value)
  2. optional: decoding the message (ie. removing “:” between numbers)
  3. Returning full expression

Let’s begin with detecting the message.

Based on our requests, we can assume that vast majority of anti-bot systems are text (server) messages. There are probably other ways or different protections against botting that we are not aware of - it that case just inform us about it and we will cover them also.

 

To get the idea, we will start off with simple example:

anti-bot-1.png

So like mentioned before, most anti bot systems are based server messages. To detect those we will use one of two callbacks:

onTextMessage
onTalk – this one will require additional protection to prevent it from being triggered by players messages

For this example we should use onTextMessage. But it will return every message user receives, so we have to narrow it to only those from anti bot system:

onTextMessage(function(mode, text)
  if string.find(text:lower(), "anti bot system") then 
  	print("OK now the rest")
  end
end) 

 

Since this is simple example, this system won’t require additional formatting the message, all we have to do is extract the value and return it. The value will be the last number within the string.

local returnValue
onTextMessage(function(mode, text)
  if string.find(text:lower(), "anti bot system") then 
  	returnValue = string.match(text, "%d+$")
  end
end) 

in this example returnValue will become 92558, so all that is left to do is to return the full expression:

local returnValue
onTextMessage(function(mode, text)
  if string.find(text:lower(), "anti bot system") then 
  	returnValue = string.match(text, "%d+$")
    say(“!antibot ” .. returnValue)
  end
end) 

Done.

Now let’s try with little more complicated example, it will require formatting.

anti-bot-2.png

This time simple string.find function wont work, due to colons between digits. We need to use regex.
*To test regex expressions you can use pages like https://regex101.com/

First we need to find our coded returnValue within the string:

local returnValue
local regex = "([0-9:]*)" -- use https://regex101.com/ to see how it will behave

Next thing to do is to remove colons from returnValue. To do so, we will prepare a simple table with value to replace and end value:

local replace = {
    {":", ""} -- value[1] = ":", value[2] = ""
}

Now we have everything we need to make our script:

local returnValue
local regex = "([0-9:]*)" -- use https://regex101.com/ 
local replace = {
    {":", ""} -- val[1] = ":", val[2] = ""
}

onTextMessage(function(mode, text)
    if string.find(text:lower(), "anti bot system") then       -- narrowing to only anti bot messages 
    	local re = regexMatch(text, regex)        			   -- finding regex within our string
    	if #re == 1 then 									   -- if found only one match
        	returnValue = re[1][1]                             -- save it
        	for key, val in ipairs(replace) do
            	returnValue = returnValue:gsub(val[1], val[2]) -- removing colons by replacing values (table)
        	end
        say("!antibot ".. returnValue)                         -- returning the full expression 
    	end
	end
end)

 Done.

 

That’s with the examples, for what we could see most of systems works in very similar way. If very different  request will show up. Good luck!