CloneAlert 1.7
 

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

CloneAlert 1.7

Started by bastya_elvtars, 26 January, 2007, 01:19:28

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bastya_elvtars

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!
Everything could have been anything else and it would have just as much meaning.

bastya_elvtars

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.
1.7 released, grab it from the DL site.
Everything could have been anything else and it would have just as much meaning.

achiever

well does both the scripts has provision to leave socks connected uesrs (not checked yet).
thks,
achiever.

bastya_elvtars

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.
Everything could have been anything else and it would have just as much meaning.

achiever

#4
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
thks,
achiever.

bastya_elvtars

#5
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
Everything could have been anything else and it would have just as much meaning.

achiever

[18:25] Syntax ...Downloads\0.3.5.2[Fusion Hub]\scripts\clonealert.lua:88: attempt to index global 'curUser' (a nil value)
thks,
achiever.

bastya_elvtars

Modified the above, I love the different legacy varnames, but also hate cleaning up code. ;D
Everything could have been anything else and it would have just as much meaning.

achiever

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)
thks,
achiever.

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

achiever

thks,
achiever.

bastya_elvtars

So do you think it is handling socks users as it should?
Everything could have been anything else and it would have just as much meaning.

achiever

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?
thks,
achiever.

bastya_elvtars

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?
Everything could have been anything else and it would have just as much meaning.

achiever

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?
thks,
achiever.

bastya_elvtars

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.
Everything could have been anything else and it would have just as much meaning.

achiever

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?
thks,
achiever.

bastya_elvtars

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
Everything could have been anything else and it would have just as much meaning.

6Marilyn6Manson6

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  ???

Psycho_Chihuahua

you can also go active with 2 clients from the same IP if you use seperate ports (done that before)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

6Marilyn6Manson6

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

bastya_elvtars

#21
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.
Everything could have been anything else and it would have just as much meaning.

achiever

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?
thks,
achiever.

bastya_elvtars

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).
Everything could have been anything else and it would have just as much meaning.

achiever

thks,
achiever.

SMF spam blocked by CleanTalk