-- range fucker v1.1 by bastya_elvtars (the rock n' roll doctor) -- some code from easyranger by tezlo -- checks if ips are valid and if ranges are really ranges :D -- thx go out to Herodes for IP validation, Typhoon for paying attention, and plop for finding the bug i couldn't -- also thx to NightLitch, i always wanna make same scripts as him but much bettter ones :D -- enjoy --v1.0:released --v1.1: fixed some shit ;) -- prefixes:!+# cmd1="banrange" cmd2="showranges" cmd3="unbanrange" cmd4="rangehelp" Bot="---===Ranger===---" opsips=1 -- set 1 to check if a connecting op belongs 2 a banned IP range function DataArrival(user,data) if strsub(data, 1, 1) == "<" then data=strsub(data,1,strlen(data)-1) local _,_,cmd=strfind(data,"%b<>%s+[%!%+%#](%S+)") if cmd==cmd1 and user.iProfile==0 then checknban(user,data) return 1 elseif cmd==cmd2 and user.iProfile==0 then user:SendPM(Bot,showipranges()) return 1 elseif cmd==cmd3 and user.iProfile==0 then unbanrange(user,data) return 1 elseif cmd==cmd4 and user.iProfile==0 then help(user) return 1 elseif cmd==cmd1 or cmd==cmd2 or cmd==cmd3 or cmd==cmd4 and user.iProfile~=0 then user:SendData(Bot,"You dont have suficiebt rights to use this command.") return 1 end end end function checknban(user,data) local _,_,ip1,ip2=strfind(data,"%b<>%s+%S+%s+(%d+%.%d+%.%d+%.%d+)%-(%d+%.%d+%.%d+%.%d+)") if ip1 and ip2 then if ipchk(ip1)~="shit" then if ipchk(ip2)~="shit" then if calculate(ip1)=calculate(a) and calculate(user.sIP)<=calculate(b) then user:SendData(Bot,"Your IP range ("..a.."-"..b..") is banned in here...") user:Disconnect() return 1 end end ipranges=nil collectgarbage() flush() end -- --function ipchk(ip) -- gsub(ip,"(%d+)",function(ipp) -- if tonumber(ipp)>255 then -- return "shit" -- end -- end) --end function ipchk(ip) local tIP = {} _,_,tIP.a,tIP.b,tIP.c,tIP.d= strfind(ip, "(%d+)%.(%d+)%.(%d+)%.(%d+)") for a,b in tIP do if tonumber(b)> 255 then return "shit" end end tIP=nil collectgarbage() flush() end function unbanrange(user,data) local _,_,ip1,ip2=strfind(data,"%b<>%s+%S+%s+(%d+%.%d+%.%d+%.%d+)%-(%d+%.%d+%.%d+%.%d+)") if ip1 and ip2 then local ipranges=loadipranges() if ipranges[ip1]==ip2 then user:SendData(Bot,"Range "..ip1.."-"..ip2.." unbanned.") ipranges[ip1]=nil save(ipranges) else user:SendData(Bot,"Range was not banned...") end else user:SendData(Bot,"Bad usage! Usage: !"..cmd3.." xxx.xxx.xxx.xxx-yyy.yyy.yyy.yyy") end end function showipranges() local msg="All banned IP ranges:\r\n=============================\r\n" local ipranges=loadipranges() for a,b in ipranges do msg=msg..a.." - "..b.."\r\n" end msg=msg.."=============================\r\n" return msg end function Main() frmHub:RegBot(Bot) if opsips==1 then OpConnected=NewUserConnected end end function help(user) local msg="Bot usage:\r\n\r\n".. cmd1.." \t\tAdd an IP range to banlist.\r\n".. cmd2.."\t\tShow a list of currently banned IP ranges.\r\n".. cmd3.." \tUnbans an IP range.\r\n".. cmd4.."\t\t\tThis help screen ;)\r\n" user:SendPM(Bot,msg) end