CTM filter (deflood)
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

CTM filter (deflood)

Started by plop, 04 April, 2005, 23:14:59

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

plop

here is the standalone version of the ConnectToMe filter from deflood converted 2 lua 5.
tiny bit enhanced, ip's are linked 2 nicks.
but only 1 nick per IP.
--------------------------------
--		LUA 5.
--------------------------------
-- standalone CTM filter.
-- kicks wrong of private IP's.
-- you need a folder called "deflood".
--------------------------------
-- by plop.
--------------------------------

tSet = {
   ---- the name of the bot.
   Bot = "Deflood_5.0",

   ---- how long the time ban takes.
   iTimeBan = 10,

   ---- don't check the next IP's on fake $ConnectToMe's.
   ---- (for hub owners who are behind a NAT router)
   -- ["ip"] = "nickname",
   tIPs = { 
	["127.0.0.1"] = "certainnick", 
	["127.0.0.2"] = "othernick",
   }
}

------ DON"T TOUCH THE NEXT TABLE.
tPriv = {
	[3232235520] = 3232301055,
	[2886729728] = 2887778303,
	[167772160] = 184549375
}
------ ok you can start touching below here again.

function ConnectToMeArrival(user, data)
   local sUser = user.sName
   local s,e,ip = string.find(data, "(%S+):%d+|$")
   if ip and tSet.tIPs[user.sIP] ~= user.sName then
	if ip ~= user.sIP then
	   local s,e,dIP1,dIP2,dIP3,dIP4 = string.find(ip, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
	   if dIP1 and dIP2 and dIP3 and dIP4 then
		dIP1 = (tonumber(dIP1) * 16777216) + (tonumber(dIP2) *65536) + (tonumber(dIP3) * 256) + (tonumber(dIP4))
		for a,b in tPriv do
		   if dIP1 >= a and dIP1 <= b then
			local sLog = (os.date("%X").." - "..sUser.." - "..user.sIP.." private IP.")
			StoreLog(sLog)
			SendPmToOps(tSet.Bot, sLog)
			local sSend = "You either left the IP box from your active settings empty or you placed a private IP"..
			   "in there by accident!\r\nIP's like this will not resolve outside your local network, change it for "..user.sIP
			user:SendData(tSet.Bot, sSend)
			user:Disconnect()
			return 1
		   end
		end
		local sSend = "You have the wrong IP in the active settings from your DC client!!\r\n"..
		   "You have set it to "..ip..", the IP you should have set it on is: "..user.sIP..".\r\n"..
		   "For Safety reasons you are now banned for  minutes\r\n"..
		   "For more info about how to setup active mode you should look at the next website's:\r\n"..
		   "Default router setup manual: --->  [URL]http://www.plop.nl/lua_tools/dc-active.zip\r\n[/URL]"..
		   "Specialized router manuals: ---> [URL]http://www.portforward.com\r\n[/URL]"..
		   "Official dc++ faq: ---> [URL]http://dcplusplus.sourceforge.net/faq/faq.php?display=faq&faqnr=11&catnr=2&prog=1&lang=en&onlynewfaq=1[/URL]"
		local sLog = os.date("%X").." - "..sUser.." - "..user.sIP.." wrong IP."
		StoreLog(sLog)
		SendPmToOps(tSet.Bot, sLog)
		user:SendData(tSet.Bot, sSend)
		user:TimeBan(tSet.iTimeBan)
	   else
		local sLog = (os.date("%X").." - "..sUser.." - "..user.sIP.." incomplete/faulty IP.")
		StoreLog(sLog)
		SendPmToOps(tSet.Bot, sLog)
		local sSend = "An IP contains 4 numbers seperated by 3 dots. Your correct IP is "..user.sIP
		user:SendData(tSet.Bot, sSend)
		user:Disconnect()
	   end
	   return 1
	end
   end
end

function StoreLog(msg)
   local sDate = string.gsub(os.date("%x"), "%D", "-")
   local fFile = io.open("deflood/"..sDate..".log", "a+")
   fFile:write(msg.."\n")
   fFile:close()
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Jaakko

Could you please modify this so it would work silently.
Thank you in advance.

jiten

QuoteOriginally posted by Jaakko
Could you please modify this so it would work silently.
Thank you in advance.
If you want to make it completely silent for everyone (user/OPs) comment the lines starting with "user:SendData" and "SendPmToOps".
If only for Ops just those beginning with "SendPmToOps".

Cheers

damo

#3
i use 2 clients from the same internal ip i have 2 diferent names but when you put the internal ip and names in only alows 1 the other one gets d/c can you change it to alow the use of 2 names on the same internal ip

Psycho_Chihuahua

then try setting 1 client with 127.0.0.1 and the other with whatever IP your network card has like 192.168.1.1 or so

otherwise in the script you can also set ips not to be checked
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

bastya_elvtars

You can try 127.0.0.2 or so.
Everything could have been anything else and it would have just as much meaning.

damo

i have put in the names and the ip's not to be checked  the first name in the list is d/c and time banned. my internaml ip is 192.168.0.2 it worked for both when deflood was stand alone before it was built into ptokax

jiten

QuoteOriginally posted by damo
i have put in the names and the ip's not to be checked  the first name in the list is d/c and time banned. my internaml ip is 192.168.0.2 it worked for both when deflood was stand alone before it was built into ptokax
Try also adding 192.168.0.x to tIPs and see what happens.

Cheers

damo

still the same as before no change at all

jiten

QuoteOriginally posted by damo
still the same as before no change at all
For example, if this is your table:
  tIPs = { 
	["127.0.0.1"] = "localnick", 
	["192.168.0.2"] = "netnick",
   }

Then, connect with "localnick" to 127.0.0.1 and "netnick" to 192.168.0.2
It must work this way.

Cheers

damo

still aint working doing it that way to :(

jiten

QuoteOriginally posted by damo
still aint working doing it that way to :(
I tested it earlier and it worked. Didn't get disconnected.
The IP and nicks in the scripts and clients have to exactly the same.

Madman

#12
--------------------------------
--LUA 5.
--------------------------------
-- standalone CTM filter.
-- kicks wrong of private IP's.
-- you need a folder called "deflood".
--------------------------------
-- by plop.
--------------------------------
-- Modded by Madman
-- Added a counter, at the 5 warnign msg, they will get tempbanned
-- Requested by Pothead

tSet = {
	---- the name of the bot.
	Bot = "Deflood_5.0",

	---- how long the time ban takes.
	iTimeBan = 10,

	---- don't check the next IP's on fake $ConnectToMe's.
	---- (for hub owners who are behind a NAT router)
	-- ["ip"] = "nickname",
	tIPs = { 
	["127.0.0.1"] = "certainnick", 
	["127.0.0.2"] = "othernick",
	}
}

------ DON"T TOUCH THE NEXT TABLE.
tPriv = {
[3232235520] = 3232301055,
[2886729728] = 2887778303,
[167772160] = 184549375
}
------ ok you can start touching below here again.

-- Table to store the Warnings
WarnLog = {}

function ConnectToMeArrival(user, data)
	local sUser = user.sName
	local s,e,ip = string.find(data, "(%S+):%d+|$")
	if ip and tSet.tIPs[user.sIP] ~= user.sName then
		if ip ~= user.sIP then
			local s,e,dIP1,dIP2,dIP3,dIP4 = string.find(ip, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
			if dIP1 and dIP2 and dIP3 and dIP4 then
				dIP1 = (tonumber(dIP1) * 16777216) + (tonumber(dIP2) *65536) + (tonumber(dIP3) * 256) + (tonumber(dIP4))
				for a,b in tPriv do
					if dIP1 >= a and dIP1 <= b then
						local sLog = (os.date("%X").." - "..sUser.." - "..user.sIP.." private IP.")
						StoreLog(sLog)
						SendPmToOps(tSet.Bot, sLog)
						local sSend = "You either left the IP box from your active settings empty or you placed a private IP"..
						"in there by accident!\r\nIP's like this will not resolve outside your local network, change it for "..user.sIP
						user:SendData(tSet.Bot, sSend)
						user:Disconnect()
						return 1
					end
				end
				sSend = "You have the wrong IP in the active settings from your DC client!!\r\n"..
				"You have set it to "..ip..", the IP you should have set it on is: "..user.sIP..".\r\n"..
				"For more info about how to setup active mode you should look at the next website's:\r\n"..
				"Default router setup manual: --->  [URL]http://www.plop.nl/lua_tools/dc-active.zip\r\n[/URL]"..
				"Specialized router manuals: ---> [URL]http://www.portforward.com\r\n[/URL]"..
				"Official dc++ faq: ---> [URL]http://dcplusplus.sourceforge.net/faq/faq.php?display=faq&faqnr=11&catnr=2&prog=1&lang=en&onlynewfaq=1\r\n[/URL]"
				if WarnLog[user.sName] == nil then
					WarnLog[user.sName] = 1
				else
					WarnLog[user.sName] = WarnLog[user.sName] + 1
				end
				if WarnLog[user.sName] >= 5 then
					sSend = sSend.."For Safety reasons you are now banned for " ..tSet.iTimeBan.. " minutes\r\n"
					user:TimeBan(tSet.iTimeBan)
					WarnLog[user.sName] = nil
				end
				local sLog = os.date("%X").." - "..sUser.." - "..user.sIP.." wrong IP."
				StoreLog(sLog)
				SendPmToOps(tSet.Bot, sLog)
				user:SendData(tSet.Bot, sSend)
			else
				local sLog = (os.date("%X").." - "..sUser.." - "..user.sIP.." incomplete/faulty IP.")
				StoreLog(sLog)
				SendPmToOps(tSet.Bot, sLog)
				local sSend = "An IP contains 4 numbers seperated by 3 dots. Your correct IP is "..user.sIP
				user:SendData(tSet.Bot, sSend)
				user:Disconnect()
			end
			return 1
		end
	end
end

function StoreLog(msg)
	local sDate = string.gsub(os.date("%x"), "%D", "-")
	local fFile = io.open("deflood/"..sDate..".log", "a+")
	fFile:write(msg.."\n")
	fFile:close()
end
A small mod ;)
Give 4 warnigns, at 5th it tempbans
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

electronic_Psycho

Hi Ppl .. G Morning..

its can be convert to lua 5.1 ?  ::)

tnx  ;D

6Marilyn6Manson6

Change:

for a,b in tPriv do


Whit:

for a,b in pairs(tPriv) do

electronic_Psycho

 Good Morning  :D

Thanks you Very Much 6Marilyn6Manson6 !!! :-*

6Marilyn6Manson6

Good Morning and welcome :D

SMF spam blocked by CleanTalk