mIRC Home    About    Download    Register    News    Help

Print Thread
#190388 20/11/07 04:40 AM
Joined: Jul 2007
Posts: 19
O
Old Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Jul 2007
Posts: 19
Wow... it's definitely been a while since I've shown my face around here, I apologize.
I've had a little spare time to script the last couple days and, I came up with a little script to connect to a bot/computer remotely and securely via mIRC.

I know there's room for improvement so, feel free to offer your suggestions on changes and, take/edit the script to your liking to implement it yourself.

Code:
on *:notice:login *:?: {
  if (%login.counter <= 4) {
    if ($2 == Password) {
      unset %login.counter
      set %master.ident.ip.host $address($nick,5)
      notice $nick Password Accepted
    }
    else {
      set %login.counter $calc(%login.counter + 1)
      notice $nick Password Incorrect
      echo -a $nick %login.counter
    }
  }
  else {
    notice $nick You have failed 5 login attempts, please wait 5 minutes before trying again.
    .timer 300 1 set %login.counter 0
  }
}

on *:nick: {
  if (%master.ident.ip.host == $address($nick,5)) {
    unset %master.ident.ip.host
  }
}

on *:notice:*:?: {
  if ($address($nick,5) == %master.ident.ip.host) {
    echo -a Processing 
    $1-
  }
}

Ah yes, I couldn't come up with a location/way to initially set %login.counter 0 without it resetting every time the even was triggered. :\

Again, it was a quick mock-up and, I'm not professional in every aspect of mIRC scripting so, don't be too harsh. wink
Constructive criticism is greatly appreciated.


http://www.CloudyOneStudios.com
irc.CloudyOneStudios.com:#CloudyOne
Old #190395 20/11/07 06:39 AM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
$calc(%var +1) is same as inc %var

Here I wrote elseif and else statement and added something extra for you to the else statement that tells the user he/she has x amount of mins to wait till she/he can retry.

Code:
on *:notice:login *:?: {
  if (%login.counter <= 4) {
    if ($2 == Password) {
      unset %login.counter
      %master.ident.ip.host = $address($nick,5)
      notice $nick Password Accepted
    }
    else { inc %login.counter | notice $nick Password Incorrect | echo -a $nick %login.counter }
  }
  elseif (%login.counter == 5) {
    notice $nick You have failed 5 login attempts, please wait 5 minutes before trying again.
    .timera 1 300 set %login.counter 0 | inc %login.counter
  }
  else { notice $nick Sorry you still have to wait $duration($timer(a)) before trying again. }
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Lpfix5 #190396 20/11/07 07:15 AM
Joined: Jul 2007
Posts: 19
O
Old Offline OP
Pikka bird
OP Offline
Pikka bird
O
Joined: Jul 2007
Posts: 19
Quick reply, much appreciated. smile

After reading over some of the changes you've made, I noticed something:

In the elseif statement, you added | inc %login.counter which would put the counter to 1, decreasing the attempts possible down to 4.

The tip on inc %var is greatly appreciated, that should shorten up some of my other code nicely, thanks laugh

For my application, the message telling them time remaining isn't necessary, since it's allowing root access to the computer and, if they're messing up more than 5 times, it's because they're not supposed to be there. But, I'm sure it could come in handy if someone were to apply this elsewhere.

Edit:

I added an alias so the login function could be applied to various scripts in your remote by adding the line:

Code:
if ($ismaster($nick)) {


I also added a few more features like: automatic logout on certain events, a specific logout function, various changes to shorten up the code.

Code:
alias ismaster {
  if (%master.ident.ip.host == $address($1,5)) {
    return true
  }
  return false
}

on *:notice:login *:?: {
  if (%login.counter <= 4) {
    if ($2 == Password) {
      unset %login.counter
      set %master.ident.ip.host $address($nick,5)
      notice $nick Password Accepted
    }
    else {
      inc %login.counter
      notice $nick Password Incorrect
      echo -a $nick %login.counter
    }
  }
  else {
    notice $nick You have failed 5 login attempts, please wait 5 minutes before trying again.
    .timer 300 1 set %login.counter 0
  }
}

on *:nick: {
  if (%master.ident.ip.host == $address($nick,5)) {
    set %login.counter 0
    unset %master.ident.ip.host
    notice $newnick You have been logged out.
  }
}

on *:notice:logout:?: {
  if (%master.ident.ip.host == $address($nick,5)) {
    set %login.counter 0
    unset %master.ident.ip.host
    notice $nick You have been logged out.
  }
}

on *:notice:*:?: {
  if ($address($nick,5) == %master.ident.ip.host) {
    echo -a Processing 
    $1-
  }
}

Last edited by Old; 20/11/07 08:48 AM.

http://www.CloudyOneStudios.com
irc.CloudyOneStudios.com:#CloudyOne
Old #190407 20/11/07 02:40 PM
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
Indeed Inc(Increase by 1) or Dec(Decrease) by 1 but alternatively you can use inc %var amount like inc %var 2 this would increment by 2 instead of default 1


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }

Link Copied to Clipboard