PtokaX forum

PtokaX => Support => Topic started by: Mardeg on 13 May, 2004, 20:58:07

Title: IP Ranges in the permanent ban list
Post by: Mardeg on 13 May, 2004, 20:58:07
Ok only noticed this after having ptokax running for a long time now. If I double-click on the permanent ban list I get a dialog asking "Nick IP or Partial IP to ban:" and found out I can add things like  "150.101.*" (example only) and anything in that range will be banned.

I know banning 65355 possible combinations of IPs is drastic and have only used it on very rare occasions where a particularly persisent user just won't give up. I only wish this function was possible in the tempban list.

btw, how can IP ranges like this be added via a script? I tried

local _,_,iprng = strfind(user.sIP,"(%d+%.%d+%.)%d+%.%d+")
iprng = iprng.."*"
user:Ban(iprng)

but that didn't work, and typing

!banip 150.101.*

only returns syntax error by hub security.
Title:
Post by: nEgativE on 13 May, 2004, 23:18:58
I think that could b a idea for next ptokax public beta.

I use this IP Range Script by Phatty


--//RangeBlaster v2.07 by Phatty
--//IP Keys written by John, and Phatty

Bot = "Bot_name"

Ranges = {}

function Main()
frmHub:RegBot(Bot)
LoadIps()
end

function LoadIps()
local tmp = 0
local handle = openfile("Ranges.dat","r")
line = read(handle)
while line do
tmp = tmp + 1
local s,e,ipr1,ipr2 = strfind(line,"(%S+)|(%S+)")
if ipr2 == nil then
SendToAll(Bot,"Error on line "..line)
end
local s,e,ipa1,ipb1,ipc1,ipd1 = strfind(ipr1, "(%d*).(%d*).(%d*).(%d*)")
local s,e,ipa2,ipb2,ipc2,ipd2 = strfind(ipr2, "(%d*).(%d*).(%d*).(%d*)")
si1 = CheckNumber(ipa1)..CheckNumber(ipb1)..CheckNumber(ipc1)..CheckNumber(ipd1)
si2 = CheckNumber(ipa2)..CheckNumber(ipb2)..CheckNumber(ipc2)..CheckNumber(ipd2)
Ranges[si1] = si2
line = read(handle)
end

end

function Blocked(userip)
local s,e,range1,range2,range3,range4 = strfind(userip,"(%d+).(%d+).(%d+).(%d+)")
checker = CheckNumber(range1)..CheckNumber(range2)..CheckNumber(range3)..CheckNumber(range4)

--SendToAll(Bot,"IP-Test..."..checker)

for i,p in Ranges do
local s,e,xstart = strfind(i, "(%d*)")
local s,e,xend = strfind(p, "(%d*)")

if checker > xstart and checker < xend then
collectgarbage()
flush()
return 1
else
end
end
end

function CheckNumber(number)
numbera = tonumber(number)
if numbera < 10 then
numbera = "00"..number
elseif numbera < 100 then
numbera = "0"..number
else
numbera = number
end
return numbera
end

function DataArrival(user,data)
if strsub(data, 1, 8) == "$Version" then
if Blocked(user.sIP) == 1 then
user:SendData(Bot, "IP - Range Banido no LusoBrasil Hub.")
SendToOps(Bot, "? OP MSG ? Usu?rio(a): "..user.sName..", com o IP: ["..user.sIP.."] foi desconectado do Hub, motivo: IP - Range Banido.")
user:TempBan()
user:Disconnect()
end
end
end



Make a file in scripts dir/ "Ranges.dat"

150.101.0.0|150.101.255.255