Part of Deflood to lua 5
 

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

Part of Deflood to lua 5

Started by witch, 02 October, 2005, 13:36:25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

witch

Hola,
is it posseble to convert this part of Deflood4.5.4. to lua 5.
  -- ConnectToMe filter.
   elseif strsub(data, 1, 12) == "$ConnectToMe" then
	local s,e,ip = strfind(data, "(%S+):%d+|$")
	if ip and tIPs[user.sIP] == nil then
	   if ip ~= user.sIP then
		local s,e,dIP1,dIP2,dIP3,dIP4 = strfind(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
			   user:SendPM(Bot, "You either left the IP box from your active settings empty or you placed a private IP in there by accident!\r\n"..
				   "IP's like this will not resolve outside your local network, change it for "..user.sIP.."|")
			   user:Disconnect()
			   return 1
			end
		   end
		   user:SendPM(Bot, "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 "..iConnect.." 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: --->  http://www.plop.nl/lua_tools/dc-active.zip\r\n"..
			"Specialized router manuals: ---> http://www.portforward.com\r\n"..
			"Official dc++ faq: ---> http://dcplusplus.sourceforge.net/faq/faq.php?display=faq&faqnr=11&catnr=2&prog=1&lang=en&onlynewfaq=1 |")
		   msg = user.sName.." - "..user.sIP.." - "..date().." - time banned for a wrong ip in the $ConnectToMe, but this could be a hub flooder!! (bad/fake ConnectToMe)"
		   StoreLog(user.sName, msg)
		   if CheckLevel(user) then
			if iKill then
			   user:TimeBan(iConnect)
			else
			   user:Disconnect()
			end
		   else
			user:Disconnect()
		   end
		else
		   user:SendPM(Bot, "An IP contains 4 numbers seperated by 3 dots. Your correct IP is "..user.sIP.."|")
		   user:Disconnect()
		end
		return 1
	   end
	end

thx in advince  :P



Typhoon

--------------------------------
--		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

here you go..

Typhoon?



witch

thx a lot Typhoon? for replay,
i tested it and still can log in with wrong IP as users and OP, no syntax errors.

any ideas?

thx  :))



bastya_elvtars

QuoteOriginally posted by witch
thx a lot Typhoon? for replay,
i tested it and still can log in with wrong IP as users and OP, no syntax errors.

any ideas?

thx  :))

It checks on download attempt, since it can NOT check on login. This is a protocol restriction. But you should use ActiveChecker instead of this, sorry for advertising. :)

Find it here: http://ptxscriptdb.psycho-chihuahua.net/download.php?view.85
Everything could have been anything else and it would have just as much meaning.

witch

me bad, i reinstal plop's script and it's starts to works fine, but is it posseble to desable report to Op function? really anoying this 1

thx in advince :))
QuoteOriginally posted by bastya_elvtars

It checks on download attempt, since it can NOT check on login. This is a protocol restriction. But you should use ActiveChecker instead of this, sorry for advertising. :)

Find it here: http://ptxscriptdb.psycho-chihuahua.net/download.php?view.85
your script works, but blockes downloads/uploads on half of the hub....

is this msg should helps?
You cannot download.
Possible reasons:
    1) Check your firewall settings. You will have to open a static TCP and a static UDP port in it and you will have to specify these in DC++. See [URL]http://www.broadbandreports.com/faq/8197[/URL]
    2) If everything is correct in your firewall settings, your ISP is blocking. Either choose another port or use passive mode.
]]
thx, but i don't think we want to use passive ggg  :)



bastya_elvtars

The ports are specified incorrectly if it does. They could not download then anyway.
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk