----------------------------------------------------------
Title: "Clone Scanning - Made Easy"
Author: Martyr2
Date: December 10, 2000
Written for [#clan-x-scripterz]
----------------------------------------------------------
clone noun - One or more clients connected to IRC from a single user, preferably with a matching hostname.

With the 32 bit issue of mIRC and on a multitasking system like windows 95/98/2000/NT you can open multiple copies of the same program and connect each copy to the same IRC network. While cloning is considered ok on some networks and some servers, it is generally discouraged because it uses a network/servers bandwidth that would normally be reserved for a real person. I say real because clones are nothing more than a vacant copy running on a computer that is either remotely controled by a real person or just responds to current channel/network conditions.

Cloning now, as in the past, has been generally used for malicious practices and thats why they have been discouraged by administration on several networks. But, like in life, there are people who don't head to the warnings and do it anyways. That is why many scripters would like to take action against these clones and help keep their channels safe from these abuse of resources.

Now to detect a clone, you can usually look at several users hostnames and find a match. Each user is given a unique address/ip/hostname and any clones running from their machine normally have a matching address (Not ident, each copy can have, and usually does, have a unique ident).

The IAL (Internal Address List)

The IAL is an internal list kept by mIRC of all the users it sees in channels or messages with it. When users trigger certain events like joining the channel you are in, speaking to you, or parting, the IAL is updated accordingly. This allows mIRC to keep a current list of what it comes in contact with and helps functions like bans effective.

A Blind Spot in the IAL

There is one small blind spot in the IAL that you should be aware of. Like in the section before, I mention that it is updated when a user triggers something. But what if you join a channel and a particular user doesn't say anything to you or join or part? The IAL never gets updated! Well to solve this, whenever you work with an addon or script that deals with the IAL it is recommended that you first update the IAL manually by using the /who #channel command. This queries the server for information on everyone on the channel and triggers a refresh in the IAL.

You must have it refresh the IAL every time you join a channel to make sure that no one is left out of the list and left out of our clone scan. Below is the event you will need and triggers when YOU first join a particular channel...


on me:*:JOIN:#:{ who $chan }

Every time you join a channel, you should see a list of names appear in your status screen. (Look up the /who response raw in Jeepsters Raw Numeric Guide if you wish to silence this listing).

The Clone Scanner

Now for the big hum dinger... the clone scanner code. What a clone scanner does is uses the IAL to run through everyone in the channel and looks for matches. If matches are found, you can kick the matches, tell the channel of the matches, or just ignore the nicks it finds to protect yourself.

To run through each choice looking for matches we will need a way to find their hostnames and a way to rotate through the people of the channel. You do this by using $ialchan and a while loop. (While loops were introduced in mIRC 5.7 and will not work for prior versions. It is recommended that you upgrade to 5.81+ or use a goto command combination for prior versions to 5.7).

$ialchan looks up IAL addresses for people who are on a channel with you and can be used for looking up matches, as well as provide nicknames for matches when used with the ".nick" property. Below is the whole scan code, followed by a brief explanation...


on !*:JOIN:#:{
    if ($ialchan($wildsite,$chan,0) > 1) {
       echo $chan *** Starting Clone Scan...
       var %i = 2
       while (%i <= $ialchan($wildsite,$chan,0)) {
          echo 15 $chan $ialchan($wildsite,$chan,1).nick - Clone Found: $ialchan($wildsite,$chan,%i).nick
          inc %i
       }
       echo $chan *** Clone Scan Complete
    }
}

Above we have a simple on join event, which does not trigger for when we ourselves join as marked by the exclamation point at the beginning. We then go into an if statement which checks the total number of matches in the IAL for the address of the person who joined. $wildsite gives us a wildcard match of the persons address which we then use to match in the IAL.

We then set a local variable to the value 2, since 1 is usually the owner of the clones. Using a while loop, we then use this variable to rotate through all the matches, listing them one by one till we reach the total number of matches we have. Our output is echoed to us in the following form...


*** Starting Clone Scan...
Martyr2 - Clone Found: Martyr3
Martyr2 - Clone Found: Martyr4
*** Clone Scan Complete

This is given in response to two of my clones joining the channel I am. Both Martyr3 and Martyr4 are clones of mine with the same matching address as me, Martyr2. I list the clones neatly one after the other till all matches are finished, then I conclude the scan.

Manual Scans

You can do a scan using a function key or alias by simply updating the IAL using the who command, and having it get the address of the user you want to scan for, and run through a while loop using $ialchan as well as the persons address rather than $wildsite like done above. This will allow you to display each match "on the fly."

If you wish to list the matching address, simply put the $wildsite or the address used to do the search into your echo statements. There is nothing to it. Here is the same example except with address listed as well...


on !*:JOIN:#:{
    if ($ialchan($wildsite,$chan,0) > 1) {
       echo $chan *** Starting Clone Scan...
       var %i = 2
       while (%i <= $ialchan($wildsite,$chan,0)) {
          echo 15 $chan $ialchan($wildsite,$chan,1).nick - Clone Found: $ialchan($wildsite,$chan,%i).nick ( $wildsite )
          inc %i
       }
       echo $chan *** Clone Scan Complete
    }
}

Conclusion:

First you must update your IAL (Internal Address List) with all the matches of people in the channel. Secondly, you must then get the address of the user to scan and rotate through the list of matches with a while loop, displaying each match separately. Use $ialchan to find the matches and either use $address in a manual scan or $wildsite in a on join clone scan. Stop the loop when it reaches the total number of matches available.

If you have problems with this or any of other article examples, please feel free to stop by and visit us on the DALnet IRC Network in the channel #Clan-X-Scripterz. Thank you for visiting!

.::(Martyr2)::. © 2000 Clan-X-Scripterz