mIRC Home    About    Download    Register    News    Help

Print Thread
#46066 01/09/03 10:40 AM
Joined: Jan 2003
Posts: 28
H
Hendon Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Jan 2003
Posts: 28
alias password {
if (%password == on) { goto login }
if (%password == off) { halt }
:login
.showmirc -t
/set %times 1
;/set %passwordtry1 = $?*="What is your password?"
/set %passwordtry1 = $input($read($mircdirscript/insquotes.txt),pv,©º°¨¨°º© WELCOME HENDON ©º°¨¨°º©)
if (%passwordtry1 == %yourpass) { goto success }
if (%passwordtry1 != $1) { goto login2 }
:login2
/set %times 2
;/set %passwordtry2 = $?*="What is your password?"
/set %passwordtry2 = $input(______ O_O ______,pow,©º°¨¨°º© INTRUDER ALERT ©º°¨¨°º©))
if (%passwordtry2 == %yourpass) { goto success }
if (%passwordtry2 != $1) { goto login3 }
:login3
/set %times 3
;/set %passwordtry3 = $?*="What is your password?"
/set %passwordtry3 = $input(______* ^ *______,poh,©º°¨¨°º© CODE RED ©º°¨¨°º©))
if (%passwordtry3 == %yourpass) { goto success }
if (%passwordtry3 != $1) { goto sorry }
:sorry
if (%times == 3) { /showmirc -s | /echo 4 FAILED LOGIN }
:success
.showmirc -s
/unset %passwordtry1
/unset %passwordtry2
/unset %passwordtry3
/unset %times
}

menu status,menubar {
Password System ( $+ %password $+ )
.On:/set %password on | /techo Password is now ON
.-
.Off:/set %password off | /techo Password is now OFF
.-
.Change Password:/newpass
}

alias techo {
if (%scriptstamp == 1) { echo -at %s $1- }
else { echo -a %s $1- }
}

alias newpass {
/set %newpasstry $?*="Old password:"
if (%newpasstry == %yourpass) { goto change }
if (%newpasstry != $1) { goto sorry }
:change
/set %yourpass $?*="New password:" | halt
/unset %newpasstry
:sorry
/techo Wrong password
/unset %newpasstry
}

=================
I can't get my password to be correct, I'm sure %yourpass is password under my variables list and it's the only %yourpass there.


===================================
Live my life for a day.. I'll show you where I've been.
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
What is the exact part of the code you are having trouble with? The changing, the logging in?

If it is logging in, I'd prolly use something like this. I will not store passwords themselves, but I will store them encrypted.

Code:
alias newpass {
  [color:green]; $md5 - I work with encrypted passwords only[/color]
  [color:green]; $input - because it is more versatile than $?[/color]
  if ($md5($input(Input password:,p,input request)) == %mypassword) {
    [color:green]; user input his correct password[/color]
    [color:green]; input the pass twice to prevent typos![/color]
    var %pass1 = $md5($input(Enter new password:,p,input request))
    var %pass2 = $md5($input(Confirm new password:,p,input request))
    if (%pass1 == %pass2) {
      [color:green]; two entered passes are the same[/color]
      set %mypassword %pass1
      echo -a Your password has been changed.
    }
    else {
      [color:green]; two entered passes are different[/color]
      echo -a You entered two different passwords. Your password has not been changed.
    }
  }
  else {
    [color:green]; user input a wrong password[/color]
    echo -a You have entered the wrong password.
  }
}


You could of course make this nicer by adding popups boxes for the messages instead of using echo...

Then for the authentication (assuming one gets 3 tries...)

Code:
[color:green]; a group to enable/disable the login code[/color]
#login on
alias login {
  var %x = 1
  [color:green]; allow for 3 attempts[/color]
  while (%x <= 3) {
    if ($md5($input(Input password:,p,input request)) == %mypassword) {
      [color:green]; user has entered his password[/color]
      echo -a Password accepted!
      guser IDENTIFIED $nick 3
      [color:green]; stop processing or he will be asked again![/color]
      halt
    }
    else {
      [color:green]; user provided a wrong password[/color]
      echo -a You provided the wrong password. Please try again!
    }
  }
  else {
    [color:green]; Sorry, only 3 attempts allowed[/color]
    echo -a You have tried to identify 3 times and failed. Goodbye.
  }
}
#login end


And of course the necessary popups to turn the group on and off:

Code:
menu status,menubar {
  $iif($group(#login) != on,Enable,Disable) Password System:$iif($group(#login) != on,.enable,.disable) #login
}


This is of course the very basics. I used the /guser to add the user to a userlist, then I would give access to people who have identified via the userlist (on LEVEL:EVENT.....)


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Corrected version of the login alias:

Code:
#login on
alias login {  
  var %x = 0 
  [color:green]; allow for 3 attempts[/color]
  while (%x < 3) {   
    inc %x
    if ($md5($input(Input password:,p,input request)) == %mypassword) {  
      [color:green]; user has entered his password [/color] 
      echo -a Password accepted!   
      guser IDENTIFIED $nick 3   
      [color:green]; stop processing or he will be asked again! [/color]    
      halt  
    }   
    elseif (%x != 3) {  
      [color:green]; user provided a wrong password [/color]
      echo -a You provided the wrong password. Please try again! 
    } 
    else {
      [color:green]; Sorry, only 3 attempts allowed  [/color]
      echo -a You have tried to identify 3 times and failed. Goodbye.  
    }
  } 
}
#login end


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Jan 2003
Posts: 28
H
Hendon Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Jan 2003
Posts: 28
The problem is with logging in. I can't seem to get the correct password. I tried your example as well and it's the same. I deleted away all variables and it's the same. Will it create it's own variable or do I have to do it?


===================================
Live my life for a day.. I'll show you where I've been.
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Weird - I tried my example (hence the correction) and it works for me. I get three chances to login, then it aborts. If I enter the wrong password it asks again, if I enter the right one it accepts.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Jan 2003
Posts: 28
H
Hendon Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Jan 2003
Posts: 28
Ok, let's say you delete all related variables and unload all password stuffs. Reload it. What's the default password then? What variables are created when it's loaded?

I can't even change the password because I don't know the default password!

Last edited by Hendon; 02/09/03 07:47 AM.

===================================
Live my life for a day.. I'll show you where I've been.
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Code:
[color:green]; to set a default password when you load the script[/color]
on *:LOAD: {
  [color:green]; probably obsolete, but check for an existing pass nonetheless[/color]
  if (!%mypassword) { 
    set %mypassword $md5(password) 
    echo -a Your default password is [color:red]password[/color]. Please change it with the popups!
  }
}
[color:green] [/color]
[color:green]; expanded popups: added one to change the pass and to login[/color]
menu status,menubar {  
Password system
  .$iif($group(#login) != on,Enable,Disable) Password System:$iif($group(#login) != on,.enable,.disable) #login
  .Change password:newpass
  .Login:login
}


Of course you might wanna expand by only displaying the last two popups when the system is active, but I can't get that to work out on this box.


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Jan 2003
Posts: 28
H
Hendon Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Jan 2003
Posts: 28
Wow this works. thanks a lot. you can actually type codes off the fly and you seem to like it.

oh by the way.. there seems to be something with /exit.. i tried doing an error and it did a /exit.. when i loaded it again another time all my remotes got unloaded.. is there a better way to /exit or something? Can i get back my remotes without doing it manually? ouch..


===================================
Live my life for a day.. I'll show you where I've been.
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Don't understand what you mean with "i tried doing an error and it did a /exit"


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Jan 2003
Posts: 28
H
Hendon Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Jan 2003
Posts: 28
Basically i edited the login code to this

else { ; Sorry, only 3 attempts allowed echo -a You have tried to identify 3 times and failed. Goodbye.
/exit
}
}

Is this a forced quit? Is there something more subtle?


===================================
Live my life for a day.. I'll show you where I've been.
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Password protecting mIRC from use? ewww...


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
Joined: Jan 2003
Posts: 28
H
Hendon Offline OP
Ameglian cow
OP Offline
Ameglian cow
H
Joined: Jan 2003
Posts: 28
Yes, my little sister wrecks havoc, and my less than IT literate friends wouldn't be able to mess around with my IRC. anything other than /exit that i could use?


===================================
Live my life for a day.. I'll show you where I've been.
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
how about using mirc lock feature? grin


-KingTomato

Link Copied to Clipboard