op security 2 (i tried convert tool but didnt work)
 

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

op security 2 (i tried convert tool but didnt work)

Started by friend, 12 February, 2008, 21:05:22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

friend

hello guys. Pls help me for convert to this script. This script works without problems in Ptokax 0.3.6... But it gives error when using it in NEW API (0.4 betas) fatal. Please help me as hard as you can cose its realy importent for me. Thank you.
Your sincerly...


--[[ ======================================================== --

		OpSecurity.v2
		# Added: Checking of dynamic dns hosts, you need to place pxwsa.dll under libs directory
		# Rmved: Writing dynip to disable the check on the user since its quite useless
		# Chngd: Nearly rewrote the whole script structure to add more flexibility
		# Added: Commands to add, delete or show stored entries and profile level check for commands
		# Chngd: Ban type to tempban, sometimes it takes some time for hosts to be updated and we won't want
			      to fully ban an op accidentally
	- Statefully inspects connection attemps and blocks them
		? if they weren't initialized by an operator, needed especially in passive connection attemps
		? if they were initialized by an operator but remote user tries to connect after "iTimeout" seconds
	- Makes the regarding operator invisible for the user who tried to connect as long as user's session in the hub
	- Reports blocked attempts to all operators
	- Detects nick spoofing in passive connection attempt
	
]]-- ======================================================== --

tSettings = {
	-- Name of your bot
	sBotsNm = frmHub:GetHubBotName(),
	-- Mail adress of hub owner or anyone which are concerned with editing hosts
	sMailAd = "mail.me@owner.of.this.hub",
	-- Location of stored hosts
	sFileNm = "OPSecurity.tbl",
	-- Command strings
	sAddCMD = "addophost",
	sDelCMD = "delophost",
	sShwCMD = "showophost",
	-- Temp ban time in minutes if IP check fails
	iTmpBan = 5,
	-- Minimum profile level to access commands
	iMinLvl = 5,
	-- Profile levels (works with RoboCop and default settings, do not change unless you really need to)
	tPrfLvl = {	
		[-1] = 0,	-- Unreg Users
		[0] = 5,	-- Masters
		[1] = 3,	-- Operators
		[2] = 2,	-- VIPs
		[3] = 1,	-- Regs
		[4] = 4,	-- Moderators
		[5] = 6,	-- NetFounders
	},
	-- Timeout value for valid passive connection session from Op -> User
	iTimeout = 30,
	-- Temporary sessions table
	tSession = {
	},
}

-- Initializing WSA library
libinit = package.loadlib("PxWSA.dll", "_libinit")
libinit()

Main = function()
	local FileHandle = io.open(tSettings.sFileNm)
	if FileHandle then
		FileHandle:close()
	else
		local FileHandle = io.open(tSettings.sFileNm, "w+")
		FileHandle:write("tHosts = {\n}")
		FileHandle:close()
	end
	tFunctions.LoadFromFile(tSettings.sFileNm)
	SetTimer(1000)
	StartTimer()
end

OnExit = function()
	tFunctions.SaveToFile(tSettings.sFileNm, tHosts, "tHosts")
end

OnTimer = function()
	for Key,Table in pairs(tSettings.tSession) do
		for User,Time in pairs(Table) do
			if (os.time() - Time) > tSettings.iTimeout then
				tSettings.tSession[Key][User] = nil
			end
		end
	end
end

OpConnected = function(curUser)
	if tHosts[curUser.sName] then
		local Name = curUser.sName
		if ((tHosts[Name] == curUser.sIP)  or (WSA.GetHostByName(tHosts[Name]) == curUser.sIP)) then
			curUser:SendPM(tSettings.sBotsNm,"IP denetiminden basari ile gectiniz. - You have passed the IP check.")
		else
			curUser:SendData(tSettings.sBotsNm,"\r\n\r\n\tIP denetiminden gecemediginiz icin guvenlik nedeniyle girisiniz bir sureligine engellenmistir.\r\n\tYou have failed the IP check and tempbanned for security reasons.\r\n")
			SendToOps(tSettings.sBotsNm,Name.." isimli operat?r IP denetiminden gecemedigi icin guvenlik nedeniyle girisi bir sureligine engellenmistir.")
			curUser:TempBan(tSettings.iTmpBan, "IP denetimi basarisizligi - IP check failed", tSettings.sBotsNm, 0)
			curUser:Disconnect()
			return 1
		end
	else
		curUser:SendPM(tSettings.sBotsNm,"IP denetimini yapilamadi. L?tfen hub y?neticinize basvurun. - IP check couldn't be done. Please contact your hub administrator.")
	end
end

OpDisconnected = function(curUser)
	if tSettings.tSession[curUser.sName] then
		tSettings.tSession[curUser.sName] = nil
	end
end

ChatArrival = function(curUser, data)
	curUser.SendMessage = curUser.SendData
	return tFunctions.GetCommands(curUser, data)
end

ToArrival = function(curUser, data)
	local s,e,to = string.find(data, "$To:%s+(%S+)%s+From:")
	if to == tSettings.sBotsNm then
		curUser.SendMessage = curUser.SendPM
		return tFunctions.GetCommands(curUser, data)
	end
end

ConnectToMeArrival = function(curUser, Data)
	local _,_,sRemoteNick,sUsersIP,iUsersTCPPort = string.find(Data,"$ConnectToMe%s+(%S+)%s+(%d+%.%d+%.%d+%.%d+):(%d+)|")
	if sRemoteNick then
		local User = GetItemByName(sRemoteNick)
		if User then
			if User.bOperator and not curUser.bOperator then
				if tSettings.tSession[sRemoteNick] and tSettings.tSession[sRemoteNick][curUser.sName] then
					if ( os.time() - tSettings.tSession[sRemoteNick][curUser.sName] ) > tSettings.iTimeout then
						curUser:SendData("$Quit "..sRemoteNick)
						SendPmToOps(tSettings.sBotsNm,"Active connection attempt to our operator "..sRemoteNick.." was blocked and now "..sRemoteNick.." is invisible for \[  "..curUser.sName.."  ("..curUser.sIP..")  \]")
						return 1
					else
					end
				else
					curUser:SendData("$Quit "..sRemoteNick)
					SendPmToOps(tSettings.sBotsNm,"Active connection attempt to our operator "..sRemoteNick.." was blocked and now "..sRemoteNick.." is invisible for \[  "..curUser.sName.."  ("..curUser.sIP..")  \]")
					return 1
				end			
			end
		end
	end
end

RevConnectToMeArrival = function(curUser, Data)
	local _,_,sUsersNick,sRemoteNick = string.find(Data,"$RevConnectToMe%s+(%S+)%s+(%S+)|")
	if sRemoteNick then
		local User = GetItemByName(sRemoteNick)
		if User then
			if sUsersNick == curUser.sName then
				if curUser.bOperator then
					tSettings.tSession[curUser.sName] = tSettings.tSession[curUser.sName] or {}
					tSettings.tSession[curUser.sName][sRemoteNick] = os.time()
				else
					if User.bOperator then
						curUser:SendData("$Quit "..sRemoteNick)
						SendPmToOps(tSettings.sBotsNm,"Passive connection attempt to our operator "..sRemoteNick.." was blocked and now "..sRemoteNick.." is invisible for \[  "..curUser.sName.."  ("..curUser.sIP..")  \]")
						return 1
					end
				end
			else
				curUser:SendData("$Quit "..sRemoteNick)
				SendPmToOps(tSettings.sBotsNm,"*** Nick spoofing detected in passive connection attempt to our operator "..sRemoteNick.." from \[  "..curUser.sName.."  ("..curUser.sIP..")  \]")
				SendPmToOps(tSettings.sBotsNm,"Passive connection attempt to our operator "..sRemoteNick.." was blocked and now "..sRemoteNick.." is invisible for \[  "..curUser.sName.."  ("..curUser.sIP..")  \]")
				return 1
			end
		end
	end
end

tCommands = {}
tCommands[tSettings.sAddCMD] = function(curUser, data)
	local s,e,nick,arg  = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)") 
	if nick then
		if arg then
			if tHosts[nick] then
				curUser:SendMessage(tSettings.sBotsNm, "Error: An entry for "..nick.." with IP/Host "..tHosts[nick].." is already in check list."..
				" Delete it first if you want to modify this entry.")
			else
				tHosts[nick] = arg
				tFunctions.SaveToFile(tSettings.sFileNm, tHosts, "tHosts")
				curUser:SendMessage(tSettings.sBotsNm, "You have successfully added "..nick.." with IP/Host "..arg.." to check list.")
			end
		else
			curUser:SendMessage(tSettings.sBotsNm, "Error: You have to enter a host (IP, DNS Host or just \"dynip\") Usage: !"..tSettings.sAddCMD.." <nick> <host>")
		end
	else
		curUser:SendMessage(tSettings.sBotsNm, "Error: You have to enter a nick! Usage: !"..tSettings.sAddCMD.." <nick> <host>")
	end
	return 1
end

tCommands[tSettings.sDelCMD] = function(curUser, data)
	local s,e,nick = string.find(data,"%b<>%s+%S+%s+(%S+)") 
	if nick then
		if tHosts[nick] then
			tHosts[nick] = nil
			tFunctions.SaveToFile(tSettings.sFileNm, tHosts, "tHosts")
			curUser:SendMessage(tSettings.sBotsNm, "You have successfully deleted "..nick.." from check list.")
		else
			curUser:SendMessage(tSettings.sBotsNm, "Error: There is no entry for "..nick.." in check list.")
		end
	else
		curUser:SendMessage(tSettings.sBotsNm, "Error: You have to enter a nick! Usage: !"..tSettings.sDelCMD.." <nick>")
	end
	return 1
end

tCommands[tSettings.sShwCMD] = function(curUser, data)
	local Listing,LoopCount = "",0
	for i,v in pairs(tHosts) do
		LoopCount = LoopCount + 1
		Listing = Listing.."\r\n\t"..string.format("%02d",LoopCount)..". Nick: "..i.."\r\n\t      Host: "..v..""
	end
	if LoopCount ~= 0 then
		local sMsg = "\r\n"..
					"\t"..string.rep("_",50).."\r\n"..
					"\tOP Security Host Check List\r\n"..
					"\t"..string.rep("?",50)..""..
					""..Listing.."\r\n"..
					"\t"..string.rep("_",50).."\r\n"
		curUser:SendMessage(tSettings.sBotsNm,sMsg)
	else
		local sMsg = "\r\n"..
					"\t"..string.rep("_",50).."\r\n"..
					"\tOP Security Host Check List\r\n"..
					"\t"..string.rep("?",50)..""..
					"\r\n\tNo entries found!\r\n"..
					"\t"..string.rep("_",50).."\r\n"
		curUser:SendMessage(tSettings.sBotsNm,sMsg)
	end
	return 1
end

tFunctions = {}
tFunctions.GetCommands = function(curUser, data)
	local data = string.sub(data, 1, (string.len(data)-1))
	local s,e,Command = string.find(data, "%b<>%s+%p(%S+)")
	if Command and tCommands[Command] then
		if tSettings.tPrfLvl[curUser.iProfile] >= tSettings.iMinLvl then
			return tCommands[Command](curUser, data)
		else
			curUser:SendMessage(tSettings.sBotsNm, "Error: You are not allowed to use this command!")
		end
		return 1
	end
end

tFunctions.Serialize = function(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");
	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");
	sTab = sTab or "";
	sTmp = ""
	sTmp = sTmp..sTab..sTableName.." = {\n"
	for key, value in pairs(tTable) do
		local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
		if(type(value) == "table") then
			sTmp = sTmp..tFunctions.Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end
		sTmp = sTmp..",\n"
	end
	sTmp = sTmp..sTab.."}"
	return sTmp
end

tFunctions.SaveToFile = function(file , table , tablename)
	local handle = io.open(file,"w+")
	handle:write(tFunctions.Serialize(table, tablename))
	handle:flush()
	handle:close()
end

tFunctions.LoadFromFile = function(filename)
	local f = io.open(filename)
	if f then
		local r = f:read("*a")
		f:flush()
		f:close()
		local func,err = loadstring(r)
		if func then x,err = pcall(func) end
	end
end

bastya_elvtars

This script uses PXWSA so it won't work with the new API only by conversion. It needs to be rewritten.
Everything could have been anything else and it would have just as much meaning.

SMF spam blocked by CleanTalk