请输入您要查询的百科知识:

 

词条 MIRC scripting language
释义

  1. Primary uses

  2. Script storage

  3. Language features

     File handling  Binary variables  Hash tables  Global variables  Local variables 

  4. Limitations

  5. Code examples

  6. See also

  7. References

  8. External links

{{multiple issues|{{no footnotes|date=August 2012}}{{prose|date=August 2012}}

}}

{{lowercase|title=mIRC Scripting Language}}{{Infobox programming language
| name = mIRC Scripting Language
| file_ext = .mrc, .ini
| paradigm = Event-driven programming, Procedural programming
| year = {{Start date|1995}}
| designer = Khaled Mardam-Bey
| developer = Khaled Mardam-Bey
| typing = Dynamic typing
| implementations = mIRC
| operating_system = Microsoft Windows
| license = Proprietary software
| website = http://mirc.com
}}

The mIRC scripting language, often unofficially abbreviated to "mSL"{{Citation needed|date=March 2011}}, is the scripting language embedded in mIRC, an IRC client for Windows.

Primary uses

  • Channel and personal protection against any types of attacks (flooding, spamming, CTCP floods, etc.).
  • Dialog windows can be created in mIRC to better serve user-compatibility.
    • Popular mIRC dialog extensions include MDX (mIRC Dialog Extension) and DCX (Dialog Control Extension). There are also a few versions of mdx.dll and dcx.dll modded by IRC hackers.
  • Bots that provide automated IRC channel management, trivia or other games, and other desired functions for chatters.
  • Commands that save typing or otherwise simplify life on IRC (such as automatically identifying as the owner of a nickname).

Script storage

Scripts are stored as either plain text files, usually with a .mrc file extension, or as INI files. They however can be stored with any extension. Multiple script files can be loaded at one time, although in some cases, one script will conflict with another and cause one or both of them to no longer work properly.

Language features

{{Technical|section|date=August 2012}}

mIRC scripting involves a peculiar nomenclature that is not entirely consistent with most of the rest of the programming world. (Most notably, the term identifier—which in most languages refers to the name of a variable or function (whether it returns a value or not)—in mIRC refers specifically to a value returning function.)

  • Built-in functions are termed commands or, if they return a value, identifiers.
  • Custom scripted functions are called aliases. Aliases that return a value are known as custom identifiers. Both are called from the command line or other parts of a script in the same ways as built-in commands and identifiers (and can even supersede them).
  • Popups are scripted context menu items. Popups are called when they are selected by the user. The term originally referred to the menus—which pop up upon a right click. It is still used this way in the manual. But the user community (who tend not to read scripting manuals) took to calling the individual items popups—perhaps thinking of the colourful novelty actions that are popular with many users as pages of a popup book.
  • Remotes are event-handling scripts. Remotes are called when the event they handle occurs.
  • All variables are dynamically typed.
  • mIRC scripts make use of sigils. Identifiers (whether custom or built-in) are preceded by $, binary variables are preceded by &, and other variables (whether local or global) are preceded by %. Commands and aliases are not preceded by any particular character (although when entered from a window's command line they must be preceded by the command prefix, usually /).

File handling

  • Scripts can read from and write to files [$read(file,[args]) | /write ]

The above is intended for singular access to the file. Because each time you issue $read or /write you open and close the file for access.

Multiple accesses, during a loop for instance, is best handled through /fopen, /fwrite and /fclose. Since this opens the file only once. In some cases /filter and /savebuf is an even more efficient (non scripted loop) method.

  • Scripts can also copy and delete files. [/copy | /remove]

Binary variables

  • Contain unlimited (8192 bytes prior to mIRC 6.1) raw data
  • Globally accessible via commands and identifiers
  • Automatically unset when script returns control to mIRC (and not to another part of a script)
  • Prefixed with & (e.g. &Variable)
  • Cannot be accessed other than by /bread and /bwrite, so these variables cannot be passed onto other parts of the script

Hash tables

  • May contain unlimited binary data or up to 4,150 (950 prior to mIRC 6.32) bytes of plain text. This limit is imposed by mIRC's scripting parser's own line length limitation (unless assigning a binary variable)
  • Globally accessible via commands and identifiers
  • Automatically unset when exiting mIRC as they are only stored in memory
  • Can be saved for later use
  • Not prefixed
  • Faster than accessing from a file, as hash tables are stored in memory rather than the hard disk
  • Size limited only by the computer's memory limits.
  • Allows any bucket size to be used

Global variables

  • May contain up to 4,150 (950 prior to mIRC 6.32) bytes of data including its name (however due to line-length limitations in mIRC's scripting parser, a maximum of 4,146 bytes can be assigned explicitly using /set or /var — this number decreasing as the variable's name grows longer)
  • Cannot store NUL (ASCII 0) or trailing spaces
  • Globally accessible
  • Do not automatically unset unless a switch is used (stored automatically in a mIRC initialization file)
  • Prefixed with % (e.g. %Variable)
  • Created using the set command or var -g or %Variable = value notation

Local variables

  • May contain up to 4,150 (950 prior to mIRC 6.32) bytes of data including the variable name (however due to line-length limitations in mIRC's scripting parser, a maximum of 4,146 bytes can be assigned explicitly using the /set or /var commands — this number decreasing as the variable's name grows longer)
  • Can store NUL (ASCII 0) or trailing spaces
  • Are destroyed when the triggered alias or event ends
  • Prefixed with % (e.g. %Variable)
  • Created using the var command. var is merely an internal alias for set -l but var poses the means to declare multiple local variables on a single line (e.g. var %a = 1, %b, %c = 2)

Limitations

  • Scripting parser supports a maximum of 8,292 (950 prior to mIRC 6.32) characters per line (not including newlines or indentation).
  • Strings are not syntactically enclosed, creating ambiguities in code where characters meant as literal strings are treated as part of the language's syntax.
  • Each line of code is broken down into a set of space-delimited tokens. As mIRC's parser does not support null tokens and the language doesn't provide a syntax to clearly differentiate literal strings from code; Prior to mIRC version 6.2 it was impossible to pass multiple consecutive spaces to any command or alias. However, this was fixed with the introduction of the returnex command which allows the preservation of spaces.

Code examples

The code below is in the remote scripts format. If placed into an alias file, the command names should not be preceded by the word "alias". Test Comments include the common /* comment */ and ;comment.

Here is an example of a Hello World alias:

;Defines the alias 'hello' in the remote script;Note: if this is placed in an alias script,;the 'alias' part must be removed (result: hello {);Usage: /helloalias hello {  ;Displays(/echo) 'Hello World!' into the active window(-a)  echo -a Hello World!}

A remote script to automatically respond to certain text

;Placed in a remote script;When a user types Hello! in a channel,;you answer back: Hello, [nickname]!on *:TEXT:Hello!:#:{ msg $chan Hello, $nick $+ ! };When a user types Hello! in a private message,;you answer back: Hello, [nickname]!on *:TEXT:Hello!:?: { msg $nick Hello, $nick $+ ! };Here is a script which automatically gives voice to a user;who joins a particular channel (The Bot or user should have HOP)on *:JOIN:#?: { mode $chan +v $nick };A bad word scripton *:Text:die*:#: { .mode $chan +b $nick | kick $chan $nick Dont say that again }

See also

  • Internet Relay Chat
  • mIRC

References

  • Smith, Chris. (2004). [https://books.google.com/books?id=MbHAnBh9AqQC&pg=PA71&lpg=PA71&dq=mIRC+scripting+language&source=bl&ots=c6vMlSuCHM&sig=0FN0NLYGLyKNc2yddeeS4j6ITFg&hl=en&sa=X&ei=nRowUNLtOs70igLLt4HIAw&ved=0CE4Q6AEwBg#v=onepage&q=mIRC%20scripting%20language&f=false "Hack #20 Automate IRC with Scripting" in IRC Hacks: 100 Industrial-Strength Tips & Tools]. Paul Mutton, ed. O'Reilly Media, Inc. pp. 71–74. (In-depth example of script features and usage)
  • Jose Nazario (2004)[https://books.google.com/books?id=swfZIwWZepYC&pg=PA53&lpg=PA53&dq=mIRC+scripting+language&source=bl&ots=YoLpSH3ZPg&sig=uZa1_pBdf7O59r7oeIOL0fiU3JU&hl=en&sa=X&ei=hiEwUPDPM6KuiQL2rIHoBg&ved=0CEwQ6AEwBTgK#v=onepage&q=mIRC%20scripting%20language&f=false Defense and Detection Strategies Against Internet Worms]. Artech House, 2004. p. 53, 55. (Discusses 1997 mIRC script attack.)
  • Ken Dunham, Jim Melnick (2008) [https://books.google.com/books?id=nmgK7KcibSUC&pg=PA9&lpg=PA9&dq=mIRC+scripting+language&source=bl&ots=xcpyDvnlSX&sig=DolGjRf-rch1WtSFUxj9HEEGaFg&hl=en&sa=X&ei=hiEwUPDPM6KuiQL2rIHoBg&ved=0CFEQ6AEwBjgK#v=onepage&q=mIRC%20scripting%20language&f=false Malicious Bots: An Inside Look into the Cyber-Criminal Underground of the Internet]. CRC Press. p. 7-31. (In-depth analysis/reverse engineering of mIRC-script-based malware bot)
  • Peter Szor (2005). [https://books.google.com/books?id=XE-ddYF6uhYC&pg=PT141&lpg=PT141&dq=mIRC+scripting+language&source=bl&ots=GfIPdo_XIY&sig=4SMQqjKAuJp2vCFRAh1e0nRVpRM&hl=en&sa=X&ei=nRowUNLtOs70igLLt4HIAw&ved=0CFQQ6AEwBw#v=onepage&q=mIRC%20scripting%20language&f=false The Art of Computer Virus Research and Defense]. Pearson Education. Ch. 3.7.7.
  • David Harley, Robert S. Vibert (2007). [https://books.google.com/books?id=LBzXf0A-jQwC&pg=PA147&lpg=PA147&dq=mIRC+scripting+language&source=bl&ots=B0LoItXxVC&sig=d6KWjWy_TAB7GcWN3_CSVTBfOfU&hl=en&sa=X&ei=hiEwUPDPM6KuiQL2rIHoBg&ved=0CC8Q6AEwADgK#v=onepage&q=mIRC%20scripting%20language&f=false AVIEN Malware Defense Guide for the Enterprise]. Elsevier. p. 147. (usage in script attacks)
  • Esharenana E. Adomi (2008). [https://books.google.com/books?id=jZwaZhCqbEAC&pg=PT195&lpg=PT195&dq=mIRC+scripting+language&source=bl&ots=QfDne0xOL5&sig=Uz6eoJa0ZrvOuTgJU8G99eSK4W0&hl=en&sa=X&ei=nRowUNLtOs70igLLt4HIAw&ved=0CD0Q6AEwAw#v=onepage&q=mIRC%20scripting%20language&f=false Security and Software for Cybercafés]. Idea Group Inc (IGI). p. 173.
  • Markus Jakobsson, Zulfikar Ramzan. (2008). [https://books.google.com/books?id=U8bh6a9Jvz0C&pg=PA194&lpg=PA194&dq=mIRC+scripting+language&source=bl&ots=W9NRyfnP65&sig=Wn-sngYCf-yFoowegQpv7pUaYDA&hl=en&sa=X&ei=nRowUNLtOs70igLLt4HIAw&ved=0CEIQ6AEwBA#v=onepage&q=mIRC%20scripting%20language&f=false Crimeware: Understanding New Attacks and Defenses]. Addison-Wesley Professional. p. 194.

External links

{{wikibooks|mIRC Scripting}}