PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Bollebus on 20 December, 2004, 21:17:33

Title: IP Script to Ptokax
Post by: Bollebus on 20 December, 2004, 21:17:33
Hey all folks

i need a script to ptokax there only ppl whit them ip number Range i have write can get in
 can someone here write a script like that ?

i can put in the ip Range number if u told me where i put in them

//Bolle
Title:
Post by: bastya_elvtars on 20 December, 2004, 21:28:33
QuoteOriginally posted by Bollebus
Hey all folks

i need a script to ptokax there only ppl whit them ip number Range i have write can get in
 can someone here write a script like that ?

i can put in the ip Range number if u told me where i put in them

//Bolle

there is some script in here i bet... use search.
Title:
Post by: TTB on 20 December, 2004, 22:40:35
This is I think you are looking for:

http://www.plop.nl/ptokaxbots/NightLitch/IP-Shield.1.0.rar

If you want to add 1 IP, use for example !addrange 192.1.1.1-192.1.1.1

Greetz
Title:
Post by: Bollebus on 21 December, 2004, 12:40:26
Thanks  

//Bolle

QuoteOriginally posted by TTB
This is I think you are looking for:

http://www.plop.nl/ptokaxbots/NightLitch/IP-Shield.1.0.rar

If you want to add 1 IP, use for example !addrange 192.1.1.1-192.1.1.1

Greetz
Title:
Post by: Bollebus on 27 December, 2004, 18:54:07
can someone edit this script so them who's ip its not in my list  them redirect to another hub

-------------------------------------------------------------------------------------------
-- IP-Shield / Version: 1.0 / By: NightLitch / 2004-03-09
-------------------------------------------------------------------------------------------
-- Example to add a range:
-- !addrange 192.168.0.1-192.168.0.255 Local
-------------------------------------------------------------------------------------------
BotName = "--IP-Check--"
Prefix = "!"
-------------------------------------------------------------------------------------------
AllowRange = {}
AllowFile = "Ranges/Ranges.dat"
-------------------------------------------------------------------------------------------
function Main()
   frmHub:RegBot(BotName)
   LoadFromFile(AllowFile)
end
-------------------------------------------------------------------------------------------
function ComputeIP(curIP)
   local _,_,a,b,c,d = strfind(curIP, "(%d+).(%d+).(%d+).(%d+)")
   return a*16777216 + b*65536 + c*256 + d
end
-------------------------------------------------------------------------------------------
function GetRange(ip,table)
   local _,_,a,b,c,d = strfind(ip, "(%d*).(%d*).(%d*).(%d*)")
   if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then
      local uip = ComputeIP(ip)
      if uip then
         local c = ""
         for r,i in table do
            local _,_,range1,range2 = strfind(r, "(.*)-(.*)")
            range1 = ComputeIP(range1)
            range2 = ComputeIP(range2)
            if uip>=range1 and uip<=range2 then
               c = "1"
               return 1,r
            end
         end
      end
   end
end
-------------------------------------------------------------------------------------------
function NewUserConnected(curUser,data)
   curUser:SendData(BotName,"Running IP-Shield 1.0 By: NightLitch")
   local Allow,Range = GetRange(curUser.sIP,AllowRange)
   local Network = ""
   if Allow==1 then
      curUser:SendData(BotName,"Your IP is Allowed here...")
      return 1
   else
      curUser:SendData(BotName,"Your IP is not Allowed here...")
      curUser:Disconnect()
      return 1
   end
end
-------------------------------------------------------------------------------------------
function DataArrival(curUser, data)
   if strsub(data, 1, 4) == "$To:" then
      local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
      if to == BotName then
         data = text
         data = strsub(data,1,strlen(data)-1)
         if (GetCom(curUser,data) == 1) then
            return 0
         else
            return 0
         end
      end
   end
end
-------------------------------------------------------------------------------------------
function GetCom(curUser,data)
   local _,_,cmd = strfind(data,"^%b<>%s+%"..Prefix.."(%S+)")
   if cmd then
      if IPCommand[cmd] and curUser.iProfile==0 then
         local Com = IPCommand[cmd](curUser,data)
         return 1
      end
   end
end
-------------------------------------------------------------------------------------------
IPCommand = {
["addrange"] = function(curUser,data)
         local _,_,range,network = strfind(data,"%b<>%s+%S+%s+(%S+-%S+)%s+(%S+)")
         if range==nil or network==nil then
            curUser:SendPM(BotName,"Syntax: "..Prefix.."addrange ")
            return 1
         end
         if AllowRange[range] then
            curUser:SendPM(BotName,range.." is already in Allow File...")
            return 1
         end
         AllowRange[range] = {["NETWORK"] = network,["TAG"] = {"["..network.."]"}}
         SaveToFile(AllowFile , AllowRange , "AllowRange")
         curUser:SendPM(BotName,"Range: ( "..range.." ) - Network: "..network.." is added to Allow File")
         return 1
      end,
["delrange"] = function(curUser,data)
         local _,_,range = strfind(data,"%b<>%s+%S+%s+(%S+-%S+)")
         if range==nil then
            curUser:SendPM(BotName,"Syntax: "..Prefix.."delrange ")
            return 1
         end
         if AllowRange[range] then
            AllowRange[range] = nil
            SaveToFile(AllowFile , AllowRange , "AllowRange")
            curUser:SendPM(BotName,"Range: ( "..range.." ) is deleted from Allow File.")
            return 1
         else
            curUser:SendPM(BotName,"Range: ( "..range.." ) is not found in Allow File.")
            return 1
         end
      end,
["show"] = function(curUser,data)
         local Network = ""
         local Msg = "\r\n\r\n"
         Msg = Msg .. "\r\n   Allow Range's "
         Msg = Msg .. "\r\n -------------=========================================================================================-------------"
         Msg = Msg .. "\r\n       Network         Range   "
         Msg = Msg .. "\r\n       ???????         ??????   "
         local Nr = 0
         for Range,Index in AllowRange do
            local Network = ""
            local ISP = ""
            local tmp = AllowRange[Range]
            if tmp then
               Network = tmp["NETWORK"]
               Nr = Nr +1
               Msg = Msg .. "\r\n    "..Network.." "..strrep("\t", 45/(8+strlen(Network))).." "..Range.." "
            end
         end
         Msg = Msg .. "\r\n "
         Msg = Msg .. "\r\n   Total "..Nr.." Range(s)"
         Msg = Msg .. "\r\n -------------=========================================================================================-------------"
         curUser:SendPM(BotName,Msg)
         return 1
      end,
["findip"] = function(curUser,data)
         local _,_,GetIP = strfind(data,"%b<>%s+%S+%s+(%S+)")
         if GetIP==nil then
            curUser:SendPM(BotName,"Syntax: "..Prefix.."findip ")
            return 1
         end
         LoadFromFile(AllowFile)
         local Msg = "\r\n\r\n"
         Msg = Msg .. "\r\n   Result on IP ( "..GetIP.." ) :\r\n"
         local Allow,Range = GetRange(GetIP,AllowRange)
         local Network = ""
         if Allow==1 then
            local tmp = AllowRange[Range]
            if tmp then
               Network = tmp["NETWORK"]
            end
            Msg = Msg .. "\r\n   Range: "..Range..""
            Msg = Msg .. "\r\n   Network: "..Network.." \r\n\r\n"
            curUser:SendPM(BotName,Msg)
         else
            curUser:SendPM(BotName,"Syntax: IP not found...")
            return 1
         end
      end,
["whois"] = function(curUser,data)
         local _,_,_,str1 = strfind( data,"%b<>%s+(%S+)%s+(%S+)%s*")
         if (str1 == nil or str1 == "") then
            curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
            return 1
         end
         if str1 and GetItemByName(str1) then
            str1 = GetItemByName(str1).sIP
         elseif str1 and not GetItemByName(str1) then
            local _,_,a,b,c,d = strfind(str1,"(%d*).(%d*).(%d*).(%d*)")
            if (a == "" or b == "" or c == "" or d == "") then
               curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
               return 1
            end
         else
            curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
            return 1
         end
         local socket,err,Database = "","",""
         Database = "RIPE"
         socket, err = connect("whois.ripe.net", 43)
         curUser:SendPM(BotName,"Checking the "..Database.."-Database for  "..str1.."  ...")
         local msg = "\r\n"
         if not err then
            local line = ""
            socket:timeout(2)
            err = socket:send(str1..strchar(13, 10))
            while not err do
               line, err = socket:receive("*l")
               if (line ~= "" and strsub(line, 1, 1) ~= "%" and strsub(line,strlen(line),strlen(line)) ~= strchar(124)) then
                  msg = msg.."\t"..line.."\r\n"
               end
            end socket:close()
         end
         msg = msg.."\r\n\tDone...\r\n"
         curUser:SendPM(BotName,"\r\n"..msg)
      end,
["help"] = function(curUser,data)
         local Msg = "\r\n\r\n"
         Msg = Msg .. "\r\n             IP-Shield Command Help "
         Msg = Msg .. "\r\n -------------=========================================================================================-------------"
         Msg = Msg .. "\r\n "
         Msg = Msg .. "\r\n   "..Prefix.."help               -   Show this Help"
         Msg = Msg .. "\r\n   "..Prefix.."addrange    -   Add Range"
         Msg = Msg .. "\r\n   "..Prefix.."delrange          -   Del Range"
         Msg = Msg .. "\r\n   "..Prefix.."show               -   Show Ranges "
         Msg = Msg .. "\r\n   "..Prefix.."findip             -   Find IP in Range File"
         Msg = Msg .. "\r\n   "..Prefix.."whois             -   Whois RIPE.NET Database"
         Msg = Msg .. "\r\n "
            Msg = Msg .. "\r\n -------------=========================================================================================-------------"
         Msg = Msg .. "\r\n\r\n "
         curUser:SendPM(BotName,Msg)
         return 1
      end,
}
-------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
   assert(tTable, "tTable equals nil");
   assert(sTableName, "sTableName equals nil");
   assert(hFile, "hFile equals nil");

   assert(type(tTable) == "table", "tTable must be a table!");
   assert(type(sTableName) == "string", "sTableName must be a string!");

   sTab = sTab or "";

   write(hFile, sTab..sTableName.." = {\n" );

   for key, value in tTable do
      local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

      if(type(value) == "table") then
         Serialize(value, sKey, hFile, sTab.."\t");
      else
         local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
         write(hFile, sTab.."\t"..sKey.." = "..sValue);
      end

      write(hFile, ",\n");
   end

   write(hFile, sTab.."}");
end
-------------------------------------------------------------------------------------------
function SaveToFile(file , table , tablename)
   local hFile = openfile(file, "w");
   Serialize(table, tablename, hFile);
   closefile(hFile);
end
-------------------------------------------------------------------------------------------
function LoadFromFile (file)
   assert(readfrom(file),file.." is not found.Generating new "..file..". All is fine. Don't panic.")
   dostring(read("*all"))
   readfrom()
end
-------------------------------------------------------------------------------------------
-- By: NightLitch 2004-03-09
Title:
Post by: imby on 27 December, 2004, 20:08:10
this might do it, sorry i can't test it, don't have those .dat files required.

-------------------------------------------------------------------------------------------
-- IP-Shield / Version: 1.0 / By: NightLitch / 2004-03-09
-------------------------------------------------------------------------------------------
-- Example to add a range:
-- !addrange 192.168.0.1-192.168.0.255 Local
-------------------------------------------------------------------------------------------
BotName = "--IP-Check--"
Prefix = "!"
sAddy = "redirect.mine.nu" -- HUB Addy to redirect the non regged
-------------------------------------------------------------------------------------------
AllowRange = {}
AllowFile = "Ranges/Ranges.dat"
-------------------------------------------------------------------------------------------
function Main()
frmHub:RegBot(BotName)
LoadFromFile(AllowFile)
end
-------------------------------------------------------------------------------------------
function ComputeIP(curIP)
local _,_,a,b,c,d = strfind(curIP, "(%d+).(%d+).(%d+).(%d+)")
return a*16777216 + b*65536 + c*256 + d
end
-------------------------------------------------------------------------------------------
function GetRange(ip,table)
local _,_,a,b,c,d = strfind(ip, "(%d*).(%d*).(%d*).(%d*)")
if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then
local uip = ComputeIP(ip)
if uip then
local c = ""
for r,i in table do
local _,_,range1,range2 = strfind(r, "(.*)-(.*)")
range1 = ComputeIP(range1)
range2 = ComputeIP(range2)
if uip>=range1 and uip<=range2 then
c = "1"
return 1,r
end
end
end
end
end
-------------------------------------------------------------------------------------------
function NewUserConnected(curUser,data)
curUser:SendData(BotName,"Running IP-Shield 1.0 By: NightLitch")
local Allow,Range = GetRange(curUser.sIP,AllowRange)
local Network = ""
if Allow==1 then
curUser:SendData(BotName,"Your IP is Allowed here...")
return 1
else
curUser:SendData(BotName,"Your IP is not Allowed here...")
curUser:SendData("$ForceMove "..sAddy.."|")
return 1
end
end
-------------------------------------------------------------------------------------------
function DataArrival(curUser, data)
if strsub(data, 1, 4) == "$To:" then
local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == BotName then
data = text
data = strsub(data,1,strlen(data)-1)
if (GetCom(curUser,data) == 1) then
return 0
else
return 0
end
end
end
end
-------------------------------------------------------------------------------------------
function GetCom(curUser,data)
local _,_,cmd = strfind(data,"^%b<>%s+%"..Prefix.."(%S+)")
if cmd then
if IPCommand[cmd] and curUser.iProfile==0 then
local Com = IPCommand[cmd](curUser,data)
return 1
end
end
end
-------------------------------------------------------------------------------------------
IPCommand = {
["addrange"] = function(curUser,data)
local _,_,range,network = strfind(data,"%b<>%s+%S+%s+(%S+-%S+)%s+(%S+)")
if range==nil or network==nil then
curUser:SendPM(BotName,"Syntax: "..Prefix.."addrange ")
return 1
end
if AllowRange[range] then
curUser:SendPM(BotName,range.." is already in Allow File...")
return 1
end
AllowRange[range] = {["NETWORK"] = network,["TAG"] = {"["..network.."]"}}
SaveToFile(AllowFile , AllowRange , "AllowRange")
curUser:SendPM(BotName,"Range: ( "..range.." ) - Network: "..network.." is added to Allow File")
return 1
end,
["delrange"] = function(curUser,data)
local _,_,range = strfind(data,"%b<>%s+%S+%s+(%S+-%S+)")
if range==nil then
curUser:SendPM(BotName,"Syntax: "..Prefix.."delrange ")
return 1
end
if AllowRange[range] then
AllowRange[range] = nil
SaveToFile(AllowFile , AllowRange , "AllowRange")
curUser:SendPM(BotName,"Range: ( "..range.." ) is deleted from Allow File.")
return 1
else
curUser:SendPM(BotName,"Range: ( "..range.." ) is not found in Allow File.")
return 1
end
end,
["show"] = function(curUser,data)
local Network = ""
local Msg = "\r\n\r\n"
Msg = Msg .. "\r\n Allow Range's "
Msg = Msg .. "\r\n ------------- =========================================================================== ==============-------------"
Msg = Msg .. "\r\n Network Range "
Msg = Msg .. "\r\n ??????? ?????? "
local Nr = 0
for Range,Index in AllowRange do
local Network = ""
local ISP = ""
local tmp = AllowRange[Range]
if tmp then
Network = tmp["NETWORK"]
Nr = Nr +1
Msg = Msg .. "\r\n "..Network.." "..strrep("\t", 45/(8+strlen(Network))).." "..Range.." "
end
end
Msg = Msg .. "\r\n "
Msg = Msg .. "\r\n Total "..Nr.." Range(s)"
Msg = Msg .. "\r\n ------------- =========================================================================== ==============-------------"
curUser:SendPM(BotName,Msg)
return 1
end,
["findip"] = function(curUser,data)
local _,_,GetIP = strfind(data,"%b<>%s+%S+%s+(%S+)")
if GetIP==nil then
curUser:SendPM(BotName,"Syntax: "..Prefix.."findip ")
return 1
end
LoadFromFile(AllowFile)
local Msg = "\r\n\r\n"
Msg = Msg .. "\r\n Result on IP ( "..GetIP.." ) :\r\n"
local Allow,Range = GetRange(GetIP,AllowRange)
local Network = ""
if Allow==1 then
local tmp = AllowRange[Range]
if tmp then
Network = tmp["NETWORK"]
end
Msg = Msg .. "\r\n Range: "..Range..""
Msg = Msg .. "\r\n Network: "..Network.." \r\n\r\n"
curUser:SendPM(BotName,Msg)
else
curUser:SendPM(BotName,"Syntax: IP not found...")
return 1
end
end,
["whois"] = function(curUser,data)
local _,_,_,str1 = strfind( data,"%b<>%s+(%S+)%s+(%S+)%s*")
if (str1 == nil or str1 == "") then
curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
return 1
end
if str1 and GetItemByName(str1) then
str1 = GetItemByName(str1).sIP
elseif str1 and not GetItemByName(str1) then
local _,_,a,b,c,d = strfind(str1,"(%d*).(%d*).(%d*).(%d*)")
if (a == "" or b == "" or c == "" or d == "") then
curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
return 1
end
else
curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
return 1
end
local socket,err,Database = "","",""
Database = "RIPE"
socket, err = connect("whois.ripe.net", 43)
curUser:SendPM(BotName,"Checking the "..Database.."-Database for "..str1.." ...")
local msg = "\r\n"
if not err then
local line = ""
socket:timeout(2)
err = socket:send(str1..strchar(13, 10))
while not err do
line, err = socket:receive("*l")
if (line ~= "" and strsub(line, 1, 1) ~= "%" and strsub(line,strlen(line),strlen(line)) ~= strchar(124)) then
msg = msg.."\t"..line.."\r\n"
end
end socket:close()
end
msg = msg.."\r\n\tDone...\r\n"
curUser:SendPM(BotName,"\r\n"..msg)
end,
["help"] = function(curUser,data)
local Msg = "\r\n\r\n"
Msg = Msg .. "\r\n IP-Shield Command Help "
Msg = Msg .. "\r\n ------------- =========================================================================== ==============-------------"
Msg = Msg .. "\r\n "
Msg = Msg .. "\r\n "..Prefix.."help - Show this Help"
Msg = Msg .. "\r\n "..Prefix.."addrange - Add Range"
Msg = Msg .. "\r\n "..Prefix.."delrange - Del Range"
Msg = Msg .. "\r\n "..Prefix.."show - Show Ranges "
Msg = Msg .. "\r\n "..Prefix.."findip - Find IP in Range File"
Msg = Msg .. "\r\n "..Prefix.."whois - Whois RIPE.NET Database"
Msg = Msg .. "\r\n "
Msg = Msg .. "\r\n ------------- =========================================================================== ==============-------------"
Msg = Msg .. "\r\n\r\n "
curUser:SendPM(BotName,Msg)
return 1
end,
}
-------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

sTab = sTab or "";

write(hFile, sTab..sTableName.." = {\n" );

for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
write(hFile, sTab.."\t"..sKey.." = "..sValue);
end

write(hFile, ",\n");
end

write(hFile, sTab.."}");
end
-------------------------------------------------------------------------------------------
function SaveToFile(file , table , tablename)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end
-------------------------------------------------------------------------------------------
function LoadFromFile (file)
assert(readfrom(file),file.." is not found.Generating new "..file..". All is fine. Don't panic.")
dostring(read("*all"))
readfrom()
end
-------------------------------------------------------------------------------------------
-- By: NightLitch 2004-03-09
-- edited by imby to suit Bollebus' needs - quickly taken from nerbo's script

Hope it works, maybe someone more experienced can optimize it.
Title:
Post by: imby on 27 December, 2004, 20:11:53
+ please always use [*code] insert_script_here [*/code] (without the *'s)when adding a script. keeps the original formatting which makes it easier to read.
Title:
Post by: Bollebus on 27 December, 2004, 23:22:24
Hey

its will not work for me its say

Syntax Error: unfinished string;
  last token read: `"
 -------------  ===========' at line 118 in string "---------------------------------------------------------------..."

i cant edit that i hope u can fix it



//Bolle
Title:
Post by: imby on 28 December, 2004, 01:06:11
hold on, something weird is going on here. give me a sec to work it out
Title:
Post by: Bollebus on 28 December, 2004, 01:13:15
OK

i wainting and hope u can fix it

realy nice to u and fix it

/Bolle

QuoteOriginally posted by imby
hold on, something weird is going on here. give me a sec to work it out
Title:
Post by: imby on 28 December, 2004, 01:16:13
incredibly bizarre, if i edit in the changes into the script you gave me when it's loaded into the hubsoft, then close and reopen the hub completely, it works. If i paste it from here, it gives me the error you got. Therefore i still must be pasting it wrong :S
Title:
Post by: imby on 28 December, 2004, 01:18:57
-------------------------------------------------------------------------------------------
-- IP-Shield / Version: 1.0 / By: NightLitch / 2004-03-09
-------------------------------------------------------------------------------------------
-- Example to add a range:
-- !addrange 192.168.0.1-192.168.0.255 Local
sAddy = "redirect.mine.nu"   -- HUB Addy to redirect the non regged
-------------------------------------------------------------------------------------------
BotName = "--IP-Check--"
Prefix = "!"
-------------------------------------------------------------------------------------------
AllowRange = {}
AllowFile = "Ranges/Ranges.dat"
-------------------------------------------------------------------------------------------
function Main()
frmHub:RegBot(BotName)
LoadFromFile(AllowFile)
end
-------------------------------------------------------------------------------------------
function ComputeIP(curIP)
local _,_,a,b,c,d = strfind(curIP, "(%d+).(%d+).(%d+).(%d+)")
return a*16777216 + b*65536 + c*256 + d
end
-------------------------------------------------------------------------------------------
function GetRange(ip,table)
local _,_,a,b,c,d = strfind(ip, "(%d*).(%d*).(%d*).(%d*)")
if ( tonumber(a) and tonumber(b) and tonumber(c) and tonumber(d) ) then
local uip = ComputeIP(ip)
if uip then
local c = ""
for r,i in table do
local _,_,range1,range2 = strfind(r, "(.*)-(.*)")
range1 = ComputeIP(range1)
range2 = ComputeIP(range2)
if uip>=range1 and uip<=range2 then
c = "1"
return 1,r
end
end
end
end
end
-------------------------------------------------------------------------------------------
function NewUserConnected(curUser,data)
curUser:SendData(BotName,"Running IP-Shield 1.0 By: NightLitch")
local Allow,Range = GetRange(curUser.sIP,AllowRange)
local Network = ""
if Allow==1 then
curUser:SendData(BotName,"Your IP is Allowed here...")
return 1
else
curUser:SendData(BotName,"Your IP is not Allowed here...")
curUser:SendData("$ForceMove "..sAddy.."|")
return 1
end
end
-------------------------------------------------------------------------------------------
function DataArrival(curUser, data)
if strsub(data, 1, 4) == "$To:" then
local s,e,to,from,text = strfind(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == BotName then
data = text
data = strsub(data,1,strlen(data)-1)
if (GetCom(curUser,data) == 1) then
return 0
else
return 0
end
end
end
end
-------------------------------------------------------------------------------------------
function GetCom(curUser,data)
local _,_,cmd = strfind(data,"^%b<>%s+%"..Prefix.."(%S+)")
if cmd then
if IPCommand[cmd] and curUser.iProfile==0 then
local Com = IPCommand[cmd](curUser,data)
return 1
end
end
end
-------------------------------------------------------------------------------------------
IPCommand = {
["addrange"] = function(curUser,data)
local _,_,range,network = strfind(data,"%b<>%s+%S+%s+(%S+-%S+)%s+(%S+)")
if range==nil or network==nil then
curUser:SendPM(BotName,"Syntax: "..Prefix.."addrange ")
return 1
end
if AllowRange[range] then
curUser:SendPM(BotName,range.." is already in Allow File...")
return 1
end
AllowRange[range] = {["NETWORK"] = network,["TAG"] = {"["..network.."]"}}
SaveToFile(AllowFile , AllowRange , "AllowRange")
curUser:SendPM(BotName,"Range: ( "..range.." ) - Network: "..network.." is added to Allow File")
return 1
end,
["delrange"] = function(curUser,data)
local _,_,range = strfind(data,"%b<>%s+%S+%s+(%S+-%S+)")
if range==nil then
curUser:SendPM(BotName,"Syntax: "..Prefix.."delrange ")
return 1
end
if AllowRange[range] then
AllowRange[range] = nil
SaveToFile(AllowFile , AllowRange , "AllowRange")
curUser:SendPM(BotName,"Range: ( "..range.." ) is deleted from Allow File.")
return 1
else
curUser:SendPM(BotName,"Range: ( "..range.." ) is not found in Allow File.")
return 1
end
end,
["show"] = function(curUser,data)
local Network = ""
local Msg = "\r\n\r\n"
Msg = Msg .. "\r\n Allow Range's "
Msg = Msg .. "\r\n ------------- =========================================================================== ==============-------------"
Msg = Msg .. "\r\n Network Range "
Msg = Msg .. "\r\n ??????? ?????? "
local Nr = 0
for Range,Index in AllowRange do
local Network = ""
local ISP = ""
local tmp = AllowRange[Range]
if tmp then
Network = tmp["NETWORK"]
Nr = Nr +1
Msg = Msg .. "\r\n "..Network.." "..strrep("\t", 45/(8+strlen(Network))).." "..Range.." "
end
end
Msg = Msg .. "\r\n "
Msg = Msg .. "\r\n Total "..Nr.." Range(s)"
Msg = Msg .. "\r\n ------------- =========================================================================== ==============-------------"
curUser:SendPM(BotName,Msg)
return 1
end,
["findip"] = function(curUser,data)
local _,_,GetIP = strfind(data,"%b<>%s+%S+%s+(%S+)")
if GetIP==nil then
curUser:SendPM(BotName,"Syntax: "..Prefix.."findip ")
return 1
end
LoadFromFile(AllowFile)
local Msg = "\r\n\r\n"
Msg = Msg .. "\r\n Result on IP ( "..GetIP.." ) :\r\n"
local Allow,Range = GetRange(GetIP,AllowRange)
local Network = ""
if Allow==1 then
local tmp = AllowRange[Range]
if tmp then
Network = tmp["NETWORK"]
end
Msg = Msg .. "\r\n Range: "..Range..""
Msg = Msg .. "\r\n Network: "..Network.." \r\n\r\n"
curUser:SendPM(BotName,Msg)
else
curUser:SendPM(BotName,"Syntax: IP not found...")
return 1
end
end,
["whois"] = function(curUser,data)
local _,_,_,str1 = strfind( data,"%b<>%s+(%S+)%s+(%S+)%s*")
if (str1 == nil or str1 == "") then
curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
return 1
end
if str1 and GetItemByName(str1) then
str1 = GetItemByName(str1).sIP
elseif str1 and not GetItemByName(str1) then
local _,_,a,b,c,d = strfind(str1,"(%d*).(%d*).(%d*).(%d*)")
if (a == "" or b == "" or c == "" or d == "") then
curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
return 1
end
else
curUser:SendPM(BotName,"Syntax: "..Prefix.."whois ")
return 1
end
local socket,err,Database = "","",""
Database = "RIPE"
socket, err = connect("whois.ripe.net", 43)
curUser:SendPM(BotName,"Checking the "..Database.."-Database for "..str1.." ...")
local msg = "\r\n"
if not err then
local line = ""
socket:timeout(2)
err = socket:send(str1..strchar(13, 10))
while not err do
line, err = socket:receive("*l")
if (line ~= "" and strsub(line, 1, 1) ~= "%" and strsub(line,strlen(line),strlen(line)) ~= strchar(124)) then
msg = msg.."\t"..line.."\r\n"
end
end socket:close()
end
msg = msg.."\r\n\tDone...\r\n"
curUser:SendPM(BotName,"\r\n"..msg)
end,
["help"] = function(curUser,data)
local Msg = "\r\n\r\n"
Msg = Msg .. "\r\n IP-Shield Command Help "
Msg = Msg .. "\r\n ------------- =========================================================================== ==============-------------"
Msg = Msg .. "\r\n "
Msg = Msg .. "\r\n "..Prefix.."help - Show this Help"
Msg = Msg .. "\r\n "..Prefix.."addrange - Add Range"
Msg = Msg .. "\r\n "..Prefix.."delrange - Del Range"
Msg = Msg .. "\r\n "..Prefix.."show - Show Ranges "
Msg = Msg .. "\r\n "..Prefix.."findip - Find IP in Range File"
Msg = Msg .. "\r\n "..Prefix.."whois - Whois RIPE.NET Database"
Msg = Msg .. "\r\n "
Msg = Msg .. "\r\n ------------- =========================================================================== ==============-------------"
Msg = Msg .. "\r\n\r\n "
curUser:SendPM(BotName,Msg)
return 1
end,
}
-------------------------------------------------------------------------------------------
function Serialize(tTable, sTableName, hFile, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");
assert(hFile, "hFile equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

sTab = sTab or "";

write(hFile, sTab..sTableName.." = {\n" );

for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

if(type(value) == "table") then
Serialize(value, sKey, hFile, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
write(hFile, sTab.."\t"..sKey.." = "..sValue);
end

write(hFile, ",\n");
end

write(hFile, sTab.."}");
end
-------------------------------------------------------------------------------------------
function SaveToFile(file , table , tablename)
local hFile = openfile(file, "w");
Serialize(table, tablename, hFile);
closefile(hFile);
end
-------------------------------------------------------------------------------------------
function LoadFromFile (file)
assert(readfrom(file),file.." is not found.Generating new "..file..". All is fine. Don't panic.")
dostring(read("*all"))
readfrom()
end
-------------------------------------------------------------------------------------------
-- By: NightLitch 2004-03-09
Title:
Post by: imby on 28 December, 2004, 01:21:06
Above script seems to work, above script stolen from nightlight/some code stolen from nerbos, edited for Bollebus' needs.
Title:
Post by: Bollebus on 28 December, 2004, 01:31:33
Now its realy works perfeck

Thanks man im realy happy now

//Bolle

QuoteOriginally posted by imby
Above script seems to work, above script stolen from nightlight/some code stolen from nerbos, edited for Bollebus' needs.
Title:
Post by: Requiem on 30 December, 2004, 02:30:09
can somebody tell me why i am not able to use any commands of this script? and i don't know how to manually add ranges. can smo show me an example ?