IP Checker By IceCoder
 

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

IP Checker By IceCoder

Started by IceCoder, 15 December, 2003, 16:37:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

IceCoder

To use this write ranges like:
213.112.0.0-213.115.255.255;BBB


-- By IceCoder
-- Checks IP ranges

sBot = "-?-IPGuard-?-"
sRejectMessage = "Sorry, connections from your IP number is not allowed here. This hub is for 10Mbit users only. You are beeing redirected."

Allowip = {}
IpFile = "ip/ipranges.txt"

function Main()
frmHub:RegBot(sBot)
LoadIpList()
end


function NewUserConnected(curUser)
   allowed = CheckIP(curUser.sIP)
   if allowed == 0 then
    curUser:SendData(sBot, sRejectMessage)
    curUser:SendData("$ForceMove "..frmHub:GetRedirectAddress())
   end
end

function CheckIP(sIP)
local s,e,s1,s2,e1,e2, ipa, ipb
ipa,ipb = ComputeIP(sIP)
 for range,ab in Allowip do
  _,_,s,e = strfind(range, "(%S+)-(%S+)")
  s1,e1 = ComputeIP(s)
  s2,e2 = ComputeIP(e)
  if (tonumber(s1) <= tonumber(ipa)) and (tonumber(ipa) <= tonumber(s2)) then
   SendToAll(sBot, "1 Right")
   SendToAll(sBot, e1.." <= "..ipb.."     "..ipb.." <= "..e2)
   if (tonumber(e1) <= tonumber(ipb)) and (tonumber(ipb) <= tonumber(e2)) then
    SendToAll(sBot, "2 Right")
    return 1
   end
  end
 end
 return 0
end

function ComputeIP(sIP)
 local a,b
  _,_,a,b = strfind(sIP, "(%d+.%d+).(%d+.%d+)")
 return a, b
end

function LoadIpList()
   readfrom(IpFile)
   while 1 do
      local line = read()
      if line == nil then
         break
      else
               range = strsub(line, 1, strfind(line, ";")-1)
                         isp = strsub(line, strfind(line, ";")+1,-1)
          Allowip[range] = isp
      end
   end
   readfrom()
end

c h i l l a

#1
Little commercial ;),

depending on how many IP-Ranges you have.. above 10
the Logger is the fastest.

other question does your compute function really work?

plop

. matches everything, you need 2 escape it  %.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

IceCoder

#3
it works but it is a syntax

tezlo

until you get logger to precompute ranges.. calling it "the fastest" is not really accurate

anyway this doesnt work

c h i l l a

nope tezlo its really faster, cause it, searches the IP's  by 2^x search...

so like it only needs 10 runs do check if the IP is in 1024 IP-Ranges,  beat that with a foreach function...

thats why the Logger is the fastest, IP-Range script around..  precomputing the IP's  wouldn't make much difference, anymore.

WickeD

You are the best c h i l l a !!!!

Good work whit all scripts...!!

Thx m8!    ;)

//WickeD

IceCoder

the scripts works but if you write wrong in the txt file it gonna be a syntax


/ lol @ my english

c h i l l a

#8
thanks wicked,  but wouldn't go so far me the best.. haha, but thanks anyway, first I thaught you were opium because of the little devil ;)..

IceCoder,

I checked you script a little and I haven't tested it but you compute func, is quite cool actually, I think it really works, but I think it will only work like this but dunno, haven't tested, yet..

curUser.sIP
ipa,ipb = ComputeIP(curUser.sIP) 


for range,ab in Allowip do 
	_,_,s,e = strfind(range, "(%S+)-(%S+)") 
	s1,e1 = ComputeIP(s) 
	s2,e2 = ComputeIP(e)
	if tonumber(s1)<= ipa and ipa <= tonumber(s2) and tonumber(e1)<=ipb and ipb<=tonumber(e2) then
	end
end

function ComputeIP(sIP) 
	local a,b 
	_,_,a,b = strfind(sIP, "(%d+.%d+).(%d+.%d+)") 
	return a, b 
end

but anyway  the logger is faster ;)

but I prefer the compute func from patcezk, which is slightly better to understand and surely works

function ComputeIP(curIP)
	local _,_,a,b,c,d = strfind(curIP, "(%d+)%.(%d+)%.(%d+)%.(%d+)")
	if a and b and c and d then
		return a*16777216 + b*65536 + c*256 + d
	end
end

IceCoder

#9
Thanks anyway  :D


it works but you have to write right ranges in the txt file if you write wrong it gonna be a syntax

IceCoder

Do you know why no one has posted a IP/ISP Script in this forum?  ?(

tezlo

#11
right.. last post on this subject

its not just how many runs..
but also what you need to do in each of them
and precomputing the ranges does make huge difference

i just tested with a table of 200 ranges and..
your raw tSearch performs the same as a plain search on precomputed values

the more ranges the better tSearch performs relatively
and obviously.. tSearch will perform best on a sorted table

edit.. actually logger is the fastest only when you have over 200 ranges

sorry to spoil your illusion but you dont want to lie to these fine people

c h i l l a

#12
nope never lie to them..  but you should maybe post the script you used..  or so..
no proof, and we can go on and on and on...

but I cam up with 10 cause then the logger needs,
3 searches for a 10 items big table + 3*2 computings
equals 9 funcs  thats less than 10.

well I tested it again the tsearch func..  and let it compute a ip 2 twice with each search...  just like the logger does...  and results are you can't test it unless you have a real time OS.  You got one, then I apologize...

but form the average runs I did...  I had some weird results...  normal search is about the same up to 100  search entries,  my cpu time was always zero.. then on any type of search...  above then..  it switches between zero and xE-5  and above 1000 entries then I see a  difference between  the searchalgo.  and a normal search, well as said 100 times before the kernel fucks it up.

ends up to really start a battle we need a real time OS.

IceCoder

hehe tezlo post your script here so we can see  :D

IceCoder

did you guys live me??  :O

IceCoder

#15
Can someone post more  IP checks here?  :O

meumeu

thx a lot thats the script i m looking for.
i have problem about sending mesages to main chat.
how can i disable it??
i mean how can i disabe for examle:
1 Right
0.0 <= 82.208 82.208 <= 255.255
2 Right

IceCoder

#17
-- By IceCoder
-- Checks IP ranges

sBot = "-?-IPGuard-?-"
sRejectMessage = "Sorry, connections from your IP number is not allowed here. This hub is for 10Mbit users only. You are beeing redirected."

Allowip = {}
IpFile = "ip/ipranges.txt"

function Main()
frmHub:RegBot(sBot)
LoadIpList()
end


function NewUserConnected(curUser)
allowed = CheckIP(curUser.sIP)
if allowed == 0 then
curUser:SendData(sBot, sRejectMessage)
curUser:SendData("$ForceMove "..frmHub:GetRedirectAddress())
end
end

function CheckIP(sIP)
local s,e,s1,s2,e1,e2, ipa, ipb
ipa,ipb = ComputeIP(sIP)
for range,ab in Allowip do
_,_,s,e = strfind(range, "(%S+)-(%S+)")
s1,e1 = ComputeIP(s)
s2,e2 = ComputeIP(e)
if (tonumber(s1) <= tonumber(ipa)) and (tonumber(ipa) <= tonumber(s2)) then
if (tonumber(e1) <= tonumber(ipb)) and (tonumber(ipb) <= tonumber(e2)) then
return 1
end
end
end
return 0
end

function ComputeIP(sIP)
local a,b
_,_,a,b = strfind(sIP, "(%d+.%d+).(%d+.%d+)")
return a, b
end

function LoadIpList()
readfrom(IpFile)
while 1 do
local line = read()
if line == nil then
break
else
range = strsub(line, 1, strfind(line, ";")-1)
isp = strsub(line, strfind(line, ";")+1,-1)
Allowip[range] = isp
end
end
readfrom()
end


----------------------------------------
Thx meumeu :P

This is without:
1 Right
0.0 <= 82.208 82.208 <= 255.255
2 Right

meumeu

Thats the bot everyone must use i use 10 ranges and no problem it ll grow up later.  :D

IceCoder


acethecase

#20
Hi..
Can some one please post IP Range for/ISP [BBB]
I only want to have 10Mbit in my hub..

TY ppl ..

sajy2k

hello, i need  a script which can automatically  detect and ban the users who use fake IP . Please anyone post the scripts

NightLitch

suggest you try this one:

--Correct-IP-V.1 for Active users 
--Idea by [aDe] , by c h i l l e r 
--For TD4 

function Main() 
frmHub:EnableSearchData(1) 
end 

function DataArrival(curUser, data) 
if (strsub(data, 1, 7) == "$Search") then 
_,_,userIP_Port,_ = strfind( data, "$Search%s+(%S+)%s+(.*)" ) 
_,_,userIP,_ = strfind( userIP_Port, "(%S+):(.*)" ) 
IsIPnumber = gsub(userIP,"%p", "") 
IsIPnumber = tonumber(IsIPnumber) 
if IsIPnumber then 
if userIP ~= curUser.sIP then 
curUser:SendData("Please insert your correct Active IP address : "..curUser.sIP) 
curUser:Disconnect() 
end 
end 
end 
end
//NL

Intel

How is it possible to have a Fake ip ? I mean Is it really possible to fake the ip ?
Punnakku

[G-T-E]Gate?

Ive just obtained a new isp contract with 10mb. I wish to allow only 10mb and or over to enter hub.
Ive been looking for ip ranges to add to the text file but have had no luck. Can anyone please assit me.
I just copied the -- By IceCoder
-- Checks IP ranges

SMF spam blocked by CleanTalk