PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: witch on 02 October, 2005, 13:36:25

Title: Part of Deflood to lua 5
Post by: witch on 02 October, 2005, 13:36:25
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
Title:
Post by: Typhoon on 02 October, 2005, 14:32:38
--------------------------------
-- 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?
Title:
Post by: witch on 02 October, 2005, 16:29:49
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  :))
Title:
Post by: bastya_elvtars on 02 October, 2005, 17:30:19
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
Title:
Post by: witch on 05 October, 2005, 14:19:13
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  :)
Title:
Post by: bastya_elvtars on 05 October, 2005, 15:21:26
The ports are specified incorrectly if it does. They could not download then anyway.