Challenge auth

From Scriptwiki
Revision as of 20:41, 9 May 2008 by Daveoh (talk | contribs)

Jump to: navigation, search
; by doomie @ QuakeNet
; channel: #help.script
; written and tested on mIRC 6.31
;
; What does this script do?
;  
;   auths with Q using the 'CHALLENGEAUTH' command
;
; How to use this script?
;
;   if you want to auth, just type: /challengeauth
;   However, you need to have the SHA2.dll by slug, which can be downloaded here: 
;      http://www.quakenet.org/development/challengeauth/SHA2.dll
;   A general explanation can be found here: 
;      http://www.quakenet.org/development/challengeauth/


; CONFIGURE

; $1 = dll function
; $2 = parameter for the dll function
alias -l ChallengeAuth.PathToDll { return $mircdirSHA2.dll }




; DONT CHANGE ANYTHING UNDER THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING
alias -l ChallengeAuth.Q { return Q@CServe.quakenet.org }
alias -l ChallengeAuth.DLL { return $dll($ChallengeAuth.PathToDll,$1,$2) }

; $1 = string to lower
alias -l ChallengeAuth.IRCToLower {
 return $replacex($lower($1),$chr(91),$chr(123),$chr(93),$chr(125),$chr(92),$chr(124),$chr(94),$chr(126))
}

; $1 = Challenge
alias -l ChallengeAuth.Auth {
 var %ChallengeAuth.Username = $ChallengeAuth.IRCToLower($?="Username")
 if ($len(%ChallengeAuth.Username) == 0) {
   echo -s ChallengeAuth: No Username specified.
   return
 }

 var %ChallengeAuth.Password = $left($?*="Password",10)
 if ($len(%ChallengeAuth.Password) == 0) {
   echo -s ChallengeAuth: No Password specified.
   return
 } 

 var %ChallengeAuth.PasswordHash = $ChallengeAuth.DLL(sha256_hex, %ChallengeAuth.Password)
 var %ChallengeAuth.Key = $ChallengeAuth.DLL(sha256_hex, %ChallengeAuth.Username $+ : $+ %ChallengeAuth.PasswordHash)
 var %ChallengeAuth.Response = $ChallengeAuth.DLL(hmac_sha256, %ChallengeAuth.Key $1)
 !.msg $ChallengeAuth.Q CHALLENGEAUTH %ChallengeAuth.Username %ChallengeAuth.Response HMAC-SHA-256
}

alias ChallengeAuth {
 if (!$isfile($ChallengeAuth.PathToDll)) {
   echo -s ChallengeAuth: The path to your SHA2.dll is wrong. Please configure the challengeauth script correctly and/or download the dll from
   echo -s ChallengeAuth: http://www.quakenet.org/development/challengeauth/SHA2.dll
   return
 }
 set %ChallengeAuth.Active $true
 echo -s ChallengeAuth: ChallengeAuth is beginning.
 !.msg $ChallengeAuth.Q challenge
}

on ^*:NOTICE:*:*: {
 if ($fulladdress === Q!TheQBot@CServe.quakenet.org) && ($network === QuakeNet) && ($right($server, 13) === .quakenet.org) {
   if ($1 === CHALLENGE) && ($len($2) == 32) && (%ChallengeAuth.Active) {
     if ($istok($3-, HMAC-SHA-256, 32)) {
       .timer 1 0 ChallengeAuth.Auth $2
     }
     else {
       echo -s ChallengeAuth: HMAC-SHA-256 is not supported. ChallengeAuth is NOT continuing.
     } 
   }
   elseif ($1- == CHALLENGE is not available once you have authed.) && (%ChallengeAuth.Active) {
     echo -s ChallengeAuth: You are already authed!
     unset %ChallengeAuth.Active
   }
   elseif ($1-6 == You are now logged in as) && (%ChallengeAuth.Active) {
     echo -s ChallengeAuth: You are now authed!
     unset %ChallengeAuth.Active
   }
   elseif ($1- == Username or password incorrect.) && (%ChallengeAuth.Active) {
     echo -s ChallengeAuth: Username or password incorrect.
     unset %ChallengeAuth.Active
   }
 } 
}

raw 401:*: {
 if ($1- == $me $ChallengeAuth.Q No such nick) && (%ChallengeAuth.Active) {
   echo -s ChallengeAuth: Q is currently not reachable. Please try again later.
   unset %ChallengeAuth.Active
   haltdef
 }
}
Contributed by doomie