VIXCheck - IP range script needs a few changes!!!
 

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

VIXCheck - IP range script needs a few changes!!!

Started by Azmodan, 20 October, 2003, 11:00:35

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Azmodan

Hi guys i have a script that someone(sorry dont know who made it)  made for me.  It reads IP ranges from a txt file and checks to see if the user(on newconnection) has an IP that falls into the IP Range listed in the txt file..

My question is how do i change it from them receiving the message "Non_VIX_IP_Detected!" (if they arnt in the IP list) to stopping them from entering altogether?  It would be better if they never had a chance to enter the hub at all.. but it will have to send them a message once they have been rejected..

The Ranger.dat text looks like:

-----------------------------------
[VIX_IP_Detected!]        <-------this is the msg they get if thier IP falls into this range.
150.101.144.0 - 150.101.159.255
150.101.208.0 - 150.101.223.255
-----------------------------------

the Code is below:


---------------------------------------------------
ipRanges = {}


function compute(ip)

local s, e, a, b, c, d = strfind(ip, "^(%d+).(%d+).(%d+).(%d+)$")

if s then return a*16777216 + b*65536 + c*256 + d end return 0

end


function checkrange(table, ip)

return foreachi(table, function(id, tmp)

if (%ip >= tmp[1]) and (%ip <= tmp[2]) then return tmp end

end)

end


function load(name, data)

ipRanges[name] = ipRanges[name] or {}

gsub(data, "(%S+) %- (%S+)", function(s, e)

s, e = compute(s), compute(e)

tinsert(ipRanges[%name], { s, e })

end)

end


function Main()

local f = openfile("ranger.dat", "r") assert(f, "ranger.dat")

local file = read(f, "*a") closefile(f) gsub(file, "%[(%S+)%]([%c%d%s%-%.]+)", load)

end


function NewUserConnected(user)

local ip, isp = compute(user.sIP)

for name, range in ipRanges do

if checkrange(range, ip) then isp = name break end

end isp = isp or "Non_VIX_IP_Detected!" user:SendData(" "..isp)

end
---------------------------------------------------



Cheers guys ;-)

tezlo

must have been me..
just change the whole NewUserConnected function to
function NewUserConnected(user)
	local ip, isp = compute(user.sIP) 
	for name, range in ipRanges do 
		if checkrange(range, ip) then isp = name break end
	end
	if isp then user:SendData(" "..isp) 
	else user:SendData("*** You dont belong here.") user:Disconnect() end
end

Azmodan

#2
yep thx Tezlo, btw can i block these users before they enter the hub, NewUserConnected(user) function allows them to enter then disconnects them..


Also this script is designed to check the file for "allowed" IP ranges, how can i modify it so any IP ranges in the file will reject the user?

thx mate

Azmodan

can anyone help me with the above post ????

tezlo

1. yes.. either with your firewall
or EnableFullData() and check/kick them on $ValidateNick

2. easiest to do would be a special section in ranger.dat
and check it before the "allowed" ranges.. would that do?

c h i l l a

good but enablefulldata unless its changed isn't need with validatenick ;).

Azmodan

yep that would work well Tezlo, could either make the Ranger.dat file contain only NON allowed ranges OR add both allowed/non allowed!

tezlo

make a section called [BLOCK] in ranger.dat
and replace NewUserConnected() with this one..
function DataArrival(user, data)
	if user.bOperator or strsub(data, 1, 13) ~= "$ValidateNick" then return end
	local ip, isp = compute(user.sIP)
	if not checkrange(ipRanges["BLOCK"], ip) then
		for name, range in ipRanges do
			if checkrange(range, ip) then return end
		end
	end user:SendData(denyMsg) user:Disconnect()
end

SMF spam blocked by CleanTalk