GhostKill NickProtection

By FordLawnmower on Jul 20, 2009

ImageImage
Image
This Script will identify your nickname on request from nickserv and it will automatically kill ghosts if you disconnect/reconnect quickly.
This script will also automatically kill anyone who tries to use any of your protected nicknames.

To use just Right click and select nickprotection. Then add all the nicknames you want to protect.
Note that this is network specific so you will have to add nicknames for each network separately.
I did add an option for ALL networks for people who for some reason use a common password on all networks. I don't really like this option, but if it works for you, use it.

Once you have added all your nicks the script will take care of the rest and hash tables will remember all your information.

If you already have an identify script that you like, just uncheck identify in the add dialog.

Note That this script requires that you keep notify turned ON. /notify ON

Update
Added the option to regain your nick after it has been ghosted.
If you check the "Recover after Ghosting" box, Your nick will change to the ghosted nickname whenever the script is triggered.

Updated
*Added a feature to change your nick back in a case where, for whatever reason, your nick gets changed to Unidentified93845. I set this up for multi-network, so you can set a different prefix for each. Ex. Guest, Unknown etc.

To use this feature, just click setup unidentified protection, from the main dialog and add your networks/prefixes.
**Note that You must have nicknames added to your protection list for this to work.
The script will select one of the nicknames you have added at random.
I decided to use random in case there is a problem with one of your nick names.
This should prevent an endless cycle of nick changes if there is a problem with the identification of one of your nicks.

;Nick Protection Script by Ford_Lawnmower irc.mindforge.org #USA-Chat
menu channel,status { 
  Nick Protection:dialogopen Nickprotection Nickprotection 
}
dialog NickProtection {
  title "Nick Protection"
  size -1 -1 120 128
  option dbu
  text "Protection List:", 1, 8 6 105 8, center
  list 2, 7 16 106 74, sort size vsbar
  button "Add", 3, 8 96 29 12
  button "Edit", 4, 44 96 29 12
  button "Delete", 5, 81 96 29 12
  button "Set Up Unidentified Protection", 6, 8 112 101 12
}
On *:dialog:NickProtection:init:*:{
  var %records $hget(NickProtection,0).item
  while (%records)  {
    did -a $dname 2 $gettok($hget(NickProtection,%records).data,2,32) $gettok($hget(NickProtection,%records).data,1,32)
    dec %records
  }
}
On *:dialog:NickProtection:Sclick:3-6:{
  if ($did == 6) { DialogOpen UProtect UProtect | return }
  if ($did == 5) {
    if ($did($dname,2).seltext) {
      var %Pnetwork $gettok($v1,1,32), %Pnick $gettok($v1,2,32), %Pnetworks $notify(%Pnick).network
      hdel NickProtection $+(%Pnick,%Pnetwork)
      if ($gettok(%Pnetworks,2,44)) {
        %Pnetworks = $deltok(%Pnetworks,$findtok(%Pnetworks,%Pnetwork,1,44),44)
        .notify -r %Pnick
        .notify -n %Pnick %Pnetworks Added by NickProtection Script
      }
      else { .notify -r %Pnick }
      if ($dialog($dname)) { did -d $dname 2 $didwm($dname,2,%Pnetwork %Pnick) }
    }
    return
  }
  if ($did == 4) {
    if ($did($dname,2).seltext) {
      dialogopen NP_Add_Edit Np_Add_Edit
      tokenize 32 $hget(NickProtection,$+($gettok($did($dname,2).seltext,2,32),$gettok($did($dname,2).seltext,1,32)))
      dialog -x NickProtection
      did -c NP_Add_Edit 1 $didwm(NP_Add_Edit,1,$2)
      did -ra NP_Add_Edit 2 $1
      did -a NP_Add_Edit 3 $3
      if ($4) { did -c NP_Add_Edit 4 }
      if ($5) { did -c NP_Add_Edit 5 }
      if ($6) { did -c NP_Add_Edit 13 }
    }
    return
  }
  dialogopen NP_Add_Edit Np_Add_Edit
  dialog -x NickProtection
}
dialog NP_Add_Edit {
  title "Nick Protection Add/Edit"
  size -1 -1 120 128
  option dbu
  combo 1, 40 8 72 10, drop
  edit "", 2, 40 32 72 10, autohs
  edit "", 3, 40 48 72 10, pass autohs
  check "Protect this Nickname", 4, 40 64 66 10
  check "Identify this Nickname", 5, 40 80 66 10
  button "Apply", 6, 8 112 37 12
  button "Close", 7, 75 112 37 12, cancel
  text "Network:", 8, 8 9 26 8, right
  text "Nickname:", 9, 8 33 26 8, right
  text "Password:", 10, 8 49 26 8
  text "GhostKill:", 11, 8 65 26 8, right
  text "Identify:", 12, 8 80 26 8, right
  check "Recover after Ghosting", 13, 40 96 74 10
  text "Recover:", 14, 8 96 25 8, right
}
On *:dialog:Np_Add_Edit:Close:*:{ dialogopen NickProtection NickProtection }
On *:dialog:Np_Add_Edit:Sclick:6:{
  tokenize 32 $iif($did($dname,2).text,$v1,0) $iif($did($dname,1).seltext,$v1,0) $iif($did($dname,3).text,$v1,0) $did($dname,4).state $did($dname,5).state $did($dname,13).state
  if ($1) && ($2) && ($3) {
    dialog -x $dname
    hadd -m NickProtection $+($1,$2) $1-
    dialogopen NickProtection NickProtection
    var %message Added by NickProtection Script
    if ($2 == all) { 
      $iif($notify($1),.notify -r $1)
      notify $1 %message
      return 
    }
    if ($notify($1).network) { 
      var %networks $v1
      .notify -r $1
      .notify -n $1 $iif($istok(%networks,$2,44),%networks,$addtok(%networks,$2,44)) %message
      return
    }
    $iif($notify($1),.notify -r $1)
    .notify -n $1-2 %message
  }
}
On *:dialog:NP_Add_Edit:init:*:{
  var %nets $scon(0)
  while (%nets) && ($dialog($dname)) { 
    did -a $dname 1 $scon(%nets).network
    dec %nets 
  }
  did -a $dname 1 ALL
  did -c $dname 1 $didwm($dname,1,$network)
  did -a $dname 2 $me
  did -f $dname 3
  Tokenize 32 $did(NickProtection,2).seltext
  $iif($gettok($hget(NickProtection,$+($2,$1)),4,32),did -c $dname 4)
  $iif($gettok($hget(NickProtection,$+($2,$1)),5,32),did -c $dname 5)
  $iif($gettok($hget(NickProtection,$+($2,$1)),6,32),did -c $dname 13)
}
dialog UProtect {
  title "Unidentified Protection"
  size -1 -1 120 136
  option dbu
  combo 1, 32 8 84 10, drop
  edit "", 2, 32 24 82 10, autohs
  check "Protect for this Network", 3, 32 40 74 10
  button "Apply", 5, 45 123 32 12
  button "Exit", 6, 82 123 32 12, cancel
  text "Network:", 7, 0 8 31 8, right
  text "Nick Prefix:", 8, 0 24 31 8, right
  box "Current list of Unidentified Protections", 10, 6 56 110 66
  list 4, 10 64 102 54, size vsbar
}
On *:dialog:UProtect:init:*: {
  var %nets $scon(0)
  while (%nets) {
    did -a $dname 1 $scon(%nets).network
    dec %nets
  }
  did -c $dname 1 $didwm($dname,1,$network)
  UProList
  if ($hget(UProtect,$did($dname,1).seltext)) {
    did -ra $dname 2 $v1
    did -c $dname 3
  }
}
On *:dialog:UProtect:Sclick:1,3-5: {
  if ($did == 1) {
    if ($hget(UProtect,$did($dname,1).seltext)) {
      did -ra $dname 2 $v1
      did -c $dname 3
    }
    else { did -r $dname 2 | did -u $dname 3 }
  }
  if ($did == 3) && ($did($dname,2).text) {
    var %net $did($dname,1).seltext
    if ($did($dname,3).state) { 
      hadd -m UProtect %net $did($dname,2).text
    }
    else { $iif($hfind(UProtect,%net).item,hdel UProtect $v1) }
    UProList
  }
  if ($did == 4) {
    did -c $dname 1,3 $didwm($dname,1,$gettok($did($dname,4).seltext,1,32))
    did -ra $dname 2 $gettok($did($dname,4).seltext,2,32)
  }
}
alias -l UProList {
  did -r UProtect 4
  var %nets $hget(UProtect,0).item
  while (%nets) {
    did -a UProtect 4 $hget(Uprotect,%nets).item $hget(Uprotect,%nets).data
    dec %nets
  }
}
On *:Nick: {
  if ($regex($newnick,/\Q $+ $hget(UProtect,$network) $+ \E[0-9]{4}/i)) && ($nick == $me) && ($hfind(nickprotection,$+(*,$network),0,w).item) {
    nick $remove($hfind(nickprotection,$+(*,$network),$r(1,$v1),w).item,$network)
  }
}
On *:Notice:*NickServ IDENTIFY*:?: {
  if ($nick == Nickserv) {
    if ($gettok($hget(NickProtection,$+($me,$network)),5,32)) || ($gettok($hget(NickProtection,$+($me,ALL)),5,32)) {
      .msg nickserv identify $iif($gettok($hget(NickProtection,$+($me,$network)),3,32),$v1,$gettok($hget(NickProtection,$+($me,ALL)),3,32))
    } 
  } 
}
On $*:Notice:/\/ns recover\s(.*)\[password]/Si:?:{
  if ($nick == Nickserv) && ($gettok($server,-2-,46) == $gettok($wildsite,-2-,46)) {
    .msg nickserv recover $regml(1) $iif($gettok($hget(NickProtection,$+($nick,$network)),3,32),$v1,$gettok($hget(NickProtection,$+($nick,ALL)),3,32))
  }
}
On ^*:Notify:{
  if ($notify($nick).note == Added by NickProtection Script) { haltdef }
  if ($nick == $me) { return }
  if ($gettok($hget(NickProtection,$+($nick,$network)),4,32)) || ($gettok($hget(NickProtection,$+($nick,ALL)),4,32)) {
    echo -st 07NickProtection-GhostKill 04Killed $nick $notify($nick).addr 06@ $time On $adate 
    .msg nickserv ghost $nick $iif($gettok($hget(NickProtection,$+($nick,$network)),3,32),$v1,$gettok($hget(NickProtection,$+($nick,ALL)),3,32))
    if ($gettok($hget(NickProtection,$+($nick,$network)),6,32)) || ($gettok($hget(NickProtection,$+($nick,ALL)),6,32)) { .timer 1 4 nick $nick }
  }
}
;Raw 433:*: {
;  if ($gettok($hget(NickProtection,$+($2,$network)),5,32)) || ($gettok($hget(NickProtection,$+($2,ALL)),5,32)) {
;    .msg nickserv release $2 $iif($gettok($hget(NickProtection,$+($2,$network)),3,32),$v1,$gettok($hget(NickProtection,$+($2,ALL)),3,32))
;    .timer 1 4 nick $2
;  } 
;}
On *:Connect:{
  if ($gettok($hget(NickProtection,$+($me,$network)),5,32)) || ($gettok($hget(NickProtection,$+($me,ALL)),5,32)) {
    .msg nickserv identify $iif($gettok($hget(NickProtection,$+($me,$network)),3,32),$v1,$gettok($hget(NickProtection,$+($me,ALL)),3,32))
  } 
}
On *:Start:{ 
  if ($exists(NickProtection.hsh)) { hmake NickProtection 5 | hload NickProtection NickProtection.hsh  }
  if ($exists(Uprotect.hsh)) { hmake Uprotect 5 | hload Uprotect Uprotect.hsh  }  
}
On *:Disconnect:{ 
  if ($hget(NickProtection)) { hsave NickProtection NickProtection.hsh }
  if ($hget(Uprotect)) { hsave Uprotect Uprotect.hsh }
}
On *:Exit:{ 
  if ($hget(NickProtection)) {
    hsave NickProtection NickProtection.hsh
    hfree NickProtection 
  }
  if ($hget(Uprotect)) {
    hsave Uprotect Uprotect.hsh
    hfree Uprotect 
  }  
}
alias -l DialogOpen { dialog $iif($dialog($1),-v,-m) $1- }

Comments

Sign in to comment.
BigSteve   -  Sep 29, 2011

@heartbroken no need for a dialog for oper
try this as a nother script

 on *:CONNECT:{
if ($server == chat-name1) { oper your_nick pass }
} 

or if you know the network name change $server to $network and it will auto oper you on start up :)

 Respond  
Heartbroken   -  Sep 28, 2011

hi :)

can you add oper login dialog option into this if its possible.that will be great.. ..i use this code but not enuff alone .and i need another one for to send my oper pass so..if you cld add oper-admin login into this we can auto identify and login all in one code. thank you ...

 Respond  
FordLawnmower   -  Jun 22, 2011

No problem datahawkee :)
I'm glad you got it all working.

 Respond  
datahawkee   -  Jun 22, 2011

I can't thank you enough FordLawnmower ! problem solved, I made 4 mrc files for each snippet, save problem gone, I noticed that on ircqnet snippet didn't work ( Identify option didn't take action) once I connected, I opened protection snippet and found network name empty (although already saved), clicked on menu and found server of the network and I saved it instead of network name, I reconnected and I got identified by the snippet .

Thanks for your kind help and this great snippet !

 Respond  
FordLawnmower   -  Jun 22, 2011

@datahawkee All you need to do is:

  • Open remote editor Alt+R
  • Copy all of remote.ini to Notepad
  • Unload remote.ini (Alt f u)
  • Make a new remote (Alt f n)
  • Copy Alert $Tip Message Balloon's code to the new remote and save it with a unique name like AlertTip.mrc (Alt f a)
  • Make another new remote (Alt f n)
  • Copy AKA Nick Tracker's code to the new remote and save it with a unique name like AKA.mrc (Alt f a)
  • etc. etc.
  • Just repeat the process till you have all the scripts in separate remote files.
 Respond  
datahawkee   -  Jun 22, 2011

I have the following in this order in remote.ini ...
Alert $Tip Message Balloon
AKA Nick Tracker
clone scan
Nick Protection

Thanks for the modified snippet but I wil use it if all fail, it seems I am doing everything wrong , how can I put each snippet in a seperate remote, I would like to do it the proper way, can mirc read more than one remote at the same time ?

 Respond  
FordLawnmower   -  Jun 22, 2011

;/ So some other script must be halting On Start events or you do not have this in a file by it's self.
If this script has just been added to a large file with many other scripts this is probably conflicting with another script in the same file.
All scripts should be placed in a new remote and saved with a unique file name to avoid this issue.
If you already have already placed this in a remote all by its self, then something is causing the On start events not to trigger. This problem should be resolved to prevent the same problem in other scripts.
For the purpose of getting this script working correctly, you may try this edit that loads the hashtable when you connect to a server: http://pastebin.com/QmRXi3Mj

 Respond  
datahawkee   -  Jun 22, 2011

yes it did , * Loaded hash table 'NickProtection' from 'NickProtection.hsh' and I called the snippet and saw the protection entry loaded

why is this happening with me only and can we add these lines ?

 Respond  
FordLawnmower   -  Jun 22, 2011

Okay Try this command after mIRC is restarted to see if it will load the data:

//hmake NickProtection 5 | hload -s NickProtection NickProtection.hsh

Both slashes are needed: //

 Respond  
datahawkee   -  Jun 22, 2011

yes notepad opened and I saw my nick and pass in the followong format

NickNetwork
Nick Network password "1 1 1"

 Respond  
FordLawnmower   -  Jun 22, 2011

Check to see if the file is there:

/run notepad NickProtection.hsh
 Respond  
datahawkee   -  Jun 22, 2011

ok I got : * Saved hash table 'NickProtection' to 'NickProtection.hsh' , but after restart , nothing is saved ...

 Respond  
Jordyk19   -  Jun 22, 2011

Very nice script
/me likes it

 Respond  
FordLawnmower   -  Jun 22, 2011

Sorry datahawkee , should be :

/hsave -s NickProtection NickProtection.hsh
 Respond  
datahawkee   -  Jun 22, 2011

I typed this into status ? I got ... * You are not on a channel , was that correct ?

 Respond  
FordLawnmower   -  Jun 22, 2011

@datahawkee Hmm. Well maybe windows isn't allowing mIRC to write to the disk.
Try typing this command after you have added a nickname to the dialog.

hsave -s NickProtection NickProtection.hsh

Please post back the response and if the data remained saved after restart.

 Respond  
datahawkee   -  Jun 21, 2011

Hey FordLawnmower, I did like you said on the first time, see this video ...

http://tinypic.com/r/219s8xj/7 (14 Mb)

or download it for better view here

http://www.2shared.com/video/HM8WAQyM/20110621_2020_19.html (14 Mb)

 Respond  
FordLawnmower   -  Jun 21, 2011

@datahawkee This script saves all the data when you disconnect or close mIRC.
It will not, however, save the data if mIRC is closed abruptly or your system crashes and mIRC is not closed normally.
So... If you are clicking Shutdown or Restart on your computer while mIRC is still running, you are forcing mIRC closed and not allowing it to save the data. This is never a good idea and could cause more problems than just loss of data.
Just click the Red X and give mIRC time to run it's post scripts before you restart/shutdown and your data should still be there the next time you start mIRC :)

 Respond  
datahawkee   -  Jun 21, 2011

FordLawnmower Thanks for this snippet,

I tried it and saw it working and had some questions about some events but for some reason every time I restart mirc the protection list gets empty. is this by design ?

 Respond  
TomCoyote   -  Mar 25, 2011

Love this script, works perfectly ;-)

 Respond  
Searinox   -  Sep 01, 2010

Yes, it switched me to Searinox with the underscore and ghostkill did not switch it back. mIRC has Searinox set as a secondary nickname, when it is not possible to use the primary nickname it switches to it. GKNP didn't change it back to Searinox. The problem is actually reproduceable whenever I manually restart my network adapter in device manager. My guess is it has to do with mIRC not having any IP to bind to. True, adapter resets are not something that can accidentally happen like network dropouts, but still...

 Respond  
FordLawnmower   -  Aug 27, 2010

This doesn't really tell me anything Searinox. All I can do is guess what happened here.
To me it looks like You reconnected and the ghost Searinox caused mIRC to switch to your anick "Searinox".
By this output, it appears that "Searinox
" is not a registered nickname and the ghost "Searinox" pinged before you actually connected with "Searinox_".
This script will not react unless the server notifies you of a nickname on notify list that is protected by this script.
Please provide me some more detailed information and I will be happy to help you :)

 Respond  
Searinox   -  Aug 27, 2010

Not all cases seem to be handled properly. This is what happened after I reset my network adapter.

[17:46:13] * [10053] Software caused connection abort

[17:46:13] * Disconnected

[17:46:14] * Connect retry #1 xxx.xxx.org (+6697)

[17:46:40] * Unable to resolve server

[17:46:41] * Connect retry #2 xxx.xxx.org (+6697)

[17:47:08] * Unable to resolve server

[17:47:09] * Connect retry #3 xxx.xxx.org (+6697)

[17:47:38] * Unable to connect to server (Connection timed out)

[17:47:39] * Connect retry #4 XXX.XXX.org (+6697) (dns pool)

[17:47:50] -xxx.xxx.org- *** Looking up your hostname...

[17:47:50] -xxx.xxx.org- *** Checking ident...

[17:47:50] -xxx.xxx.org- *** Couldn't resolve your hostname; using your IP address instead

[17:47:59] -xxx.xxx.org- *** No ident response; username prefixed with ~

Searinox Nickname is already in use.

Welcome to the XXXXXX IRC Network Searinox_!~Searinox@XXXXXXXXX

End of /MOTD command.

[17:48:01] Local host: XXXXXXXXXXXXXXXXXXXXXX

[17:48:01] * Searinox_ sets mode: +iwxz

[17:48:01] -Global- [Logon News - Apr 23 2007] Have you read the Code of Conduct for Users? Go to XXXXXXXXXXXXXXXXXX - this applies to ALL users!

[17:48:01] -Global- [Random News - Oct 25 2004] Services Tip #2: Kill your ghost.. /msg nickserv GHOST

  • No one in your notify list is on IRC
 Respond  
Searinox   -  Aug 12, 2010

Yes I meant reading the servers.ini for the password. Your little identify on connect addition fixed the problem though. Now the password is being sent before attempting to autojoin and +r channels are opening. I was not using any autojoin script, just mIRC's builtin autojoin.

This is great, now I can keep all my passwords in just the .hsh file. Thanks for the quick fix!

 Respond  
FordLawnmower   -  Aug 11, 2010

Okay Cheiron :) I removed the 443 till I get a chance to test it. It looks like 443 is tripping at the same time as the notify is forcing the ghostkill. I'll have to take some time and try and figure out how to trap the instance when notify doesn't trip and the ghost is still stopping you from joining with the same nick.
Sorry for the crazy code, I just peeked in on my lunch break ;/

 Respond  
Cheiron   -  Aug 11, 2010

something went right tits up lol with the update code.. any ideas ? i had to manually change to my alt nick

-
Cheiron Nickname is already in use.

  • Your nick is now Sleeping_On_The_Job
  • -NickServ- This nickname is registered and protected. If it is your

  • -NickServ- nick, type /msg NickServ IDENTIFY password. Otherwise,

  • -> nickserv identify xxxxxxxxxxxxxxx

  • -NickServ- please choose a different nick.

  • -NickServ- If you do not change within one minute, I will change your nick.

  • CHEIRON Unknown command

  • -NickServ- Nick Cheiron isn't being held.

  • services.xxxxxx sets mode: +r
  • -NickServ- Password accepted - you are now recognized.

  • Cheiron [Looking@xxxxxxxx] has left IRC
  • -NickServ- Ghost with your nick has been killed.

  • -NickServ- You are already identified.

  • note i have an auto id on nickserv ask code running also on mirc.

 Respond  
Cheiron   -  Aug 11, 2010

i am yes Ford ..as the handshake with the server finishes i often get this

-
Cheiron Nickname is already in use.

and i have to manually change or wait for it to actively ping out.

 Respond  
FordLawnmower   -  Aug 11, 2010

@Searinox I'm a little lost here. It sounds like you want me to get the server password from servers.ini and use it for the nickname.
If this is what you are asking I don't think it will work because most people use a different password for their nick then they have for server login.
If you are referring to "perform", it's not a good idea to store passwords here because they are stored in plain text. In edition, you would have to parse the perform block and try to figure out which line is the identify line.

Please clear this up for me so I understand exactly what it is you are asking.

As for the autojoin issue, I think this should be addressed in a properly written autojoin script. If a channel is +R and doesn't let you join, the autojoin script should react by setting a timer and attempting to rejoin in 10 seconds or something.
I will add a on connect identify to this now. Let me know if that helps any.

@Cheiron are you getting a "nickname already in use error" in this case?
If so I'm adding a raw 443 check to address this. You'll have to let me know if it resolves this issue, as I have no way of simulating this situation. Normally the notify will kick in and ghostkill the nick.
I'll post an update now.

 Respond  
Cheiron   -  Aug 11, 2010

have had a few disconnects from peer and ping, when on reconnect it hasnt reclaimed nick and left me hanging till the nick drops or i manually change. thats the only other bug i can see. as for the kill and recover side. that i cannot fault. might be worth adding a check for nick on connect with auto recover/release etc if nick still online

 Respond  
Searinox   -  Aug 11, 2010

This addon is not the only one of its kind but after many searches it is the only one I've found that truly detects and corrects all possible scenarios of nick change, including internet dropout plus IP change. Awesome work you have there.

However I have a suggestion.

Think you can add a checkbox of sorts called "use password from mIRC settings" so that it uses the server password(s) stored in mIRC's settings? It's kind of redundant to have to input the password in both mIRC and NickProtection.

I would be using the password in NP alone but I can't because your script sometimes sends the password AFTER mIRC autojoins channels, so channels that require registration won't open, making me to still rely on mIRC's builtin password system.

Bottom line is a single password system is better. Either fix the script to register the nick BEFORE autojoin or add that checkbox I mentioned.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.