This version is much faster (very low cpu usage, a bit increased memory usage but not too serious), and more accurate, but it requires some more testing. Please try it and test it. You will have to create a folder called logs inside the scripts folder.
Enjoy!
Nice script!
Although the clone checking on Main() was originally a secondary thing I have added to mine, that grown to a primary thing for many reasons, this is documented in my script's comments. Although yours is smaller because it has no immunelist feature via command. :)
Both scripts do the very same thing in a very similar way, though, I am just keen on metamethods, because if I am adding to a hash table anyway, the table itself can call the function on addition, which seemed more convenient for me, but this is a typical YMMV-syndrome.
Get the RC from my download page (http://lawmaker.no-ip.org/pages/downloads.php).
1.7 released, grab it from the DL site (http://lawmaker.no-ip.org/pages/downloads.php).
well does both the scripts has provision to leave socks connected uesrs (not checked yet).
Quote from: achiever on 14 May, 2007, 09:32:37
well does both the scripts has provision to leave socks connected uesrs (not checked yet).
You haven't posted any feedback at my forum, it should work in theory.
well i m so sorry, do i'll it now.
bastya ur script is not kicking me if i login thru socks5 instantaneously but kicks me if i login 2 more times or if i restart script i.e ur script clonealert1.7
i checked ips thru ip script i have
Quote[18:10:38] <ach> +ip 172.19.60.31
[18:10:38] <Fusion> Nick: achi IP: 172.19.60.31 LastSeen: Currently Online Mode: Active
[18:10:38] <Fusion> Nick: achiev IP: 172.19.60.31 LastSeen: Currently Online Mode: Socket 5
thks
Quote from: achiever on 14 May, 2007, 14:51:16
well i m so sorry, do i'll it now.
bastya ur script is not kicking me if i login thru socks5 instantaneously but kicks me if i login 2 more times or if i restart script i.e ur script clonealert1.7
Have you tried changing the
protect_socks value? It is not supposed to kick socks users by default.
Edit: the script start kick is indeed a bug. Please replace
Main() to this and tell me whether it works:
function Main()
setmetatable(_tIPStorage,_mtIPStorage)
for _,user in ipairs(frmHub:GetOnlineNonOperators()) do
if protect_socks == 1 then
if not string.find(user.sMyInfoString,"M:[S5]") then
_tIPStorage[user.sIP]=user.sName
end
else
_tIPStorage[user.sIP]=user.sName
end
end
if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end
end
[18:25] Syntax ...Downloads\0.3.5.2[Fusion Hub]\scripts\clonealert.lua:88: attempt to index global 'curUser' (a nil value)
Modified the above, I love the different legacy varnames, but also hate cleaning up code. ;D
nope getting again
[18:37] Syntax ...Downloads\0.3.5.2[Fusion Hub]\scripts\clonealert.lua:88: attempt to index global 'curUser' (a nil value)
I left one, edited.
yes working now
So do you think it is handling socks users as it should?
it is not kicking me now when i login using socks5 connection and same share size.
i think it should kick me as i have same share size(irrespective of ip due to socks connection) , shouldnt it?
Quote from: achiever on 14 May, 2007, 15:45:51
it is not kicking me now when i login using socks5 connection and same share size.
i think it should kick me as i have same share size(irrespective of ip due to socks connection) , shouldnt it?
You are right, I'll fix this. Also, I will make it so all users sharing the same IP must be behid a socks5 proxy - if not, then there is some cheat. How about this?
yup u r right
1 more thing in the last change i had stoped kicking me completely even without socks, just noticed it.
so now i have got a bit confused, i m clearing it:-
1)kick all users with same ip and same share.
2)kick all users with same ip.
3)kick all user with socks connection and same share.
4) leav users with socks connection and different share.
is this correct?
Quote from: achiever on 14 May, 2007, 15:57:39
1 more thing in the last change i had stoped kicking me completely even without socks, just noticed it.
Well, this bug seems obscure. Switching between normal connection and socks is not like life. :P
Quote from: achiever on 14 May, 2007, 15:57:39
so now i have got a bit confused, i m clearing it:-
1)kick all users with same ip and same share.
2)kick all users with same ip.
3)kick all user with socks connection and same share.
4) leav users with socks connection and different share.
is this correct?
1) Yes.
2) No, if share is different, only raise a warning.
3) Yes.
4) Yes, except if there is a user with the same IP and not socks.
Quote from: bastya_elvtars on 14 May, 2007, 16:16:54
1) Yes.
2) No, if share is different, only raise a warning.
3) Yes.
4) Yes, except if there is a user with the same IP and not socks.
2) can u report it to ops
4) how can two user have same ip if not socks connected or a clone?
Quote from: achiever on 14 May, 2007, 16:27:27
2) can u report it to ops
4) how can two user have same ip if not socks connected or a clone?
2) it is how itr works now
4) I mean: user1 connects, he is Active, user2 connects, he is Socks5. This is weird, unless user1 hosts the proxy for user2, in that case you can still immune.
Okay, please try this:
-- Clone Alert 1.7
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten
--- -- touched by Herodes
-- heavily optimised
-- moved to 1.5
-- now it's 1.6, after bastya_elvtars did some more optimization to the detector. :P
-- 1.7:
-- changed: rewrote the clone checking routine, so it no longer loops on every user connecion
-- added: it also ckecks clones on startup, that makes the hub 100% immune to clones
-- changed: removed opchatbot detection, using SendToOpChat() instead
-- added: Socks checking (requested by achiever)
-- 1.7.5:
-- changed: rewrote the socks routine to a more effective one, thanks achiever
Bot = frmHub:GetHubBotName() -- Rename to you main Px bot
kick = 0 -- 0 to only disconnect, otherwise enter a number, and user will be kicked for that amount of minutes.
kick_other_too=1 -- 1 to disconnect/kick the already logged in user, 0 to not
protect_socks=1 -- set to 0 to handle SOCKS users as others.
-- This is disrecommended as users between the same proxy usually share the same IP.
PmOps = 1 -- 1:enables / 0:disables operator notification (STRONGLY recommended to leave enabled!)
_tIPStorage={}
tIPStorage={}
clonedout={}
tImmune = {}
_mtIPStorage=
{
__newindex=function(tbl,ip,nick) -- This function gets called when a new entry is added to _tIPStorage
-- The value finally gets added to _tIPStorage, hence _tIPStorage is a so-called proxy tanle
-- See http://www.lua.org/pil/13.4.4.html for detailed explanation
if tIPStorage[ip] then -- hey, this ip is already in use!
local User,curUser=GetItemByName(tIPStorage[ip]),GetItemByName(nick) -- now who does it belong to?
-- curUser refers to the newly connected user, User refers to his clone
-- you may ask, why we have this since there can be more than 1 clones of a user, but there cannot, cause
-- they get checked on startup and only 1 can remain, like in Highlander. :-P
if User then -- yes, the clone is online
local GetProxyState=function (user,user2)
-- only 1 user proxied:
if string.find(user.sMyInfoString,"M:[S5]") and not string.find(user2.sMyInfoString,"M:[S5]") then return 1
-- both users proxied:
elseif protect_socks == 1 and string.find(user.sMyInfoString,"M:[S5]") and string.find(user2.sMyInfoString,"M:[S5]") then return 2
-- none of the 2 are proxied:
else return 1 end
end
local det=function (user,user2)
user:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..user2)
local done
if kick~=0 then
done="timebanned for "..kick.." minutes"
user:SendPM(Bot,"You're being timebanned. Your IP: "..user.sIP)
user:TimeBan(kick)
else
done="disconnected"
user:SendPM(Bot,"You're being disconnected.")
user:Disconnect()
end
if PmOps == 1 then
SendToOpChat("*** Cloned user <"..user.sName.."> ("..user.sIP..") has been found and "..done..". User is a clone of <"..user2..">")
end
end
if not(tImmune[curUser.sName] or tImmune[User.sName]) and not User.bOperator then
-- we don't check curUser for being an op, because we do NewUserConnected() and GetOnlineNonOperators()
-- Users have to meet one of the following criteria:
-- * SAME SHARE
-- * ONE OR BOTH OF THEM NON-PROXIED
if curUser.iShareSize==User.iShareSize and GetProxyState (User,curUser) == 1 then
local nick1,nick2=curUser.sName,User.sName
clonedout[curUser.sName]=User.sName -- clonedout[connectedguy]=existantguy - see OnExit()
det(curUser,nick1)
if kick_other_too==1 then
clonedout[User.sName]=curUser.sName -- clonedout[existantguy]=connectedguy - see OnExit()
det(User,nick2)
end
else
tIPStorage[curUser.sIP]=curUser.sName
if PmOps == 1 then
if GetProxyState (User,curUser) == 1 then -- at least one of them is not proxied, else they're considered non-suspicious
SendToOpChat("*** A user "..curUser.sName.." hass been found to have the same IP as "..User.sName.." but share sizes are different, please check.")
clonedout[User.sName]=curUser.sName
end
end
end
end
else
tIPStorage[curUser.sIP]=curUser.sName
end
else
tIPStorage[ip]=nick
end
end
}
function Main()
setmetatable(_tIPStorage,_mtIPStorage)
for _,user in ipairs(frmHub:GetOnlineNonOperators()) do
_tIPStorage[user.sIP]=user.sName
end
if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end
end
function OnExit()
local f = io.open("logs/cloneimmune.txt", "w+")
local m = "tImmune = { "
for a, b in pairs(tImmune) do m = m..(string.format("[%q]=",a)..b..","); end
m = m.." }"
f:write( m ); f:flush(); f:close();
end
function NewUserConnected(curUser,sdata)
_tIPStorage[curUser.sIP]=curUser.sName
end
function ChatArrival (user,data)
if (user.bOperator) then
local data = string.sub( data, 1, -2 )
local s,e,cmd = string.find( data, "%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse( user, cmd, data, false )
end
end
end
function ToArrival ( user, data )
if ( user.bOperator ) then
local data = string.sub( data , 1, -2 )
local s,e, cmd = string.find( data , "%$%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse ( user, cmd , data , true )
end
end
end
function UserDisconnected(user)
if clonedout[user.sName] then
if not GetItemByName(clonedout[user.sName]) then -- if the clone isn't online either, remove the ip only then
tIPStorage[user.sIP]=nil
else -- else the IP gets the value of the clone who is still online
tIPStorage[user.sIP]=GetItemByName(clonedout[user.sName]).sName
end
else -- normal disconnection
tIPStorage[user.sIP]=nil
end
end
function Parse( user, cmd, data, how )
local function SendBack( user, msg , from, how )
if how then user:SendPM( from or Bot , msg );return 1; end;
user:SendData( from or Bot, msg );return 1;
end
local t = {
--- Add to cloneList
["+clone"] = function ( user , data , how )
local s,e, name = string.find( data, "%b<>%s+%S+%s+(%S+)" )
if not name then user:SendData(Bot, "*** Error: Type +clone nick") end
if tImmune[name] then user:SendData("nope") end
local nick = GetItemByName(name)
if not nick then user:SendData(Bot, "*** Error: User is not online.") end
tImmune[name] = 1
OnExit()
user:SendData(Bot, name.." is now immune to clone checks!")
return 1
end ,
--- Remove from cloneList
["-clone"] = function ( user , data , how )
local s,e, name = string.find(data, "%b<>%s+%S+%s+(%S+)")
if not name then user:SendData(Bot, "*** Error: Type -clone nick") end
if not tImmune[name] then user:SendData(Bot,"The user "..name.." is not immune!") end
local nick = GetItemByName( name )
if not nick then user:SendData(Bot, "*** Error: That user is not online.") end
tImmune[name] = nil
OnExit()
user:SendData(Bot,"Now "..name.." is not no longer immune to clone checks!")
return 1
end,
--- Show cloneList
["?clone"] = function ( user , data, how )
local m = ""
for nick, _ in pairs(tImmune) do
local s = "Offline"
if GetItemByName(nick) then s = "Online" end
m = m.."\r\n\t ? ("..s..") "..nick
end
if m == "" then return SendBack( user, "There are no users that can have a clone", Bot, how ) end
m = "\r\nThe following users can have clones in this hub:"..m
return SendBack( user, m , Bot, how )
end,
--- Show cloneBot help
["?clonehelp"] = function ( user, data , how )
local m = "\r\n\r\nHere are the commands for the CloneBot:"..
"\r\n\t+clone \t allows to have a clone"..
"\r\n\t-clone \t removes from the clone list"..
"\r\n\t?clone\t\t shows the users allowed to have a clone"..
"\r\n\t?clonehelp \t allows to have a clone"
return SendBack( user, m, Bot, how )
end, }
if t[cmd] then return t[cmd]( user, data, how ) end
end
Quote from: achiever on 14 May, 2007, 16:27:27
4) how can two user have same ip if not socks connected or a clone?
This Is Possible For Static Ip...Static Ip Not Is Clone And Not Is A Socked And Not Is A Proxy ???
you can also go active with 2 clients from the same IP if you use seperate ports (done that before)
Quote from: Psycho_Chihuahua on 14 May, 2007, 22:24:32
you can also go active with 2 clients from the same IP if you use seperate ports (done that before)
sure? but bastya one said that: the IP cannot be equal? but the IP can be equal? obvious that but the port must be various
Quote from: Psycho_Chihuahua on 14 May, 2007, 22:24:32
you can also go active with 2 clients from the same IP if you use seperate ports (done that before)
Yes and if the share size differs, the bot will not disconnect them. IP AND share have to be the same, I refuse to disconnect only for having the same IP.
bastya the script is working good for points 1) and 3) i.e when users have same ip and share it disconnects them.
but it is not giving op ne notification if 2 users op same ip only r connected i.e in case 2) and 4) , or thus this part needs to be configured in the script?
Is the opchatbot (settable in PtokaX) registered in the hub? Just asking because this works for me (at least 2), cannot tell anything about 4).
yes it is ticked
Quote[15:30:19] <opchat> *** Cloned user <bastyaelvtars> (127.0.0.1) has been found and disconnected. User is a clone of <bastyaelvtars>
[15:30:19] <opchat> *** Cloned user <bastya@home> (127.0.0.1) has been found and disconnected. User is a clone of <bastya@home>
i m getting <Fusion> *** A user achi hass been found to have the same IP as achie but share sizes are different, please check.
for point but ony if i restart the script when both users are online.
Quote from: achiever on 15 May, 2007, 15:37:59
i m getting <Fusion> *** A user achi hass been found to have the same IP as achie but share sizes are different, please check.
for point but ony if i restart the script when both users are online.
That's how it's supposed to work. It will not kick users whose shares are different and I refuse to add such a feature.
ok. thanks a lot.
Does it work now as expected?
oh yes. a bit slow to react but working good
Quote[16:16:22] <opchat> *** A user bastya hass been found to have the same IP as bastya@home but share sizes are different, please check.
Works fine here.
http://lawmaker.no-ip.org/pages/downloads.php
Added 1.7.5, 1.7 is still there for safety.
Quote from: bastya_elvtars on 15 May, 2007, 17:42:11
Added 1.7.5, 1.7 is still there for safety.
whats the difference between these 2.
Quote from: achiever on 16 May, 2007, 08:00:17
whats the difference between these 2.
1.7.5 has a better socks checking method.
ok.
can i disable the feature to report to ops in case of same ip and different share thru scoks5 connection, i kno i was the 1 all eger for this but as there r many ppl in my hub using socks so this message keeps on popingup. no other changes.
so is it possible?
Quote from: achiever on 16 May, 2007, 10:35:45
ok.
can i disable the feature to report to ops in case of same ip and different share thru scoks5 connection
It only reports if there are users with the same IP and not socks5. Socks5 is a proxy, all should come proxied or all unproxied - especially on LAN hubs, where you should disallow SOCKS5 globally.