Advertisement
intangibles

Untitled

Sep 15th, 2016
1,229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.20 KB | None | 0 0
  1. #hide_me
  2.  
  3. =begin
  4.  
  5. This script checks for certain lines and alerts the person to their presence.  It uses the familiar window in game, and an email system.  You must have the mail gem installed.
  6. SMS is also enabled if your carrier has "email to text".
  7.  
  8. Note:  Any inattentive scripting is against Simutronics policy. This should NOT be used to script away from keyboard.  It is ONLY meant as a detection device
  9. so you can catch script checks through text scroll while at the keyboard. Simutronics has the power to issue script warnings
  10. even if you pass a script check. This is NOT designed to protect against AFK scripting.
  11.  
  12. There is no AS/DS checks here. This will not protect against those types of checks.
  13.  
  14. Since this is public as of 09/15/2016, expect many of the keywords below to not be used by GMs, and update accordingly.
  15.  
  16. v. 02 by Kalros/Haldrik
  17.    
  18. -- v.02 changelog
  19.  
  20. Added more variables.
  21.    
  22. ***************
  23. **What it does
  24. ***************
  25.  
  26. This script parses every game line and checks it against 3 patterns. Known script checks,
  27. danger script checks, and capital letters.
  28.  
  29. If any line is triggered, it passes through to the exceptions/exemptions.  If there is no exception,
  30. notification is sent. Script check patterns are ALWAYS sent.
  31.  
  32. This tests against XML lines.
  33.  
  34. ****************
  35. ** Instructions
  36. ****************
  37.  
  38. 1. You must install "mail gem".  This may or may not work out of the box.
  39. Go to cmd prompt and type "gem install mail".  If not, you may need to google how to install gems.
  40.  
  41. 2. You must enable outgoing SMTP in gmail settings.
  42.  
  43. 3. You must update @sendUserName and @sendPassword and @email1/@email2.  You do not need to update the others if you use gmail.
  44.  
  45. 4. Update exception patterns as needed if things are popping that should not be.
  46.  
  47. 5. Review line 352, it contains a break if !running certain scripts. Uncomment if you want.
  48.  
  49. =end
  50.  
  51. require 'mail'
  52.  
  53. $monitor_debug = true ## Debug option, turn off if you don't want to see patterns.  Recommened TRUE during initial runs.
  54. $monitor_send_email = true
  55.  
  56. ## Start variables
  57.  
  58. @sendAddress = "smtp.gmail.com"
  59. @sendPort = 587
  60. @sendDomain = "gmail.com"
  61. ## CHANGE THIS TO YOUR USER NAME
  62. @sendUserName = "gemstoneruby" # this is your username excluding @gmail.com
  63. @sendPassword = "plaintextpassword" # CHANGE
  64. @fromEmail = "full email" # ex, gemstoneruby@gmail.com
  65.  
  66. ## TO EMAILS - Max of 2 emails currently
  67. @email1 = "999-999-9999@txt.att.net"  # example of email to text for ATT
  68. @email2 = "youremail@gmail.com" # Email notification is sent here.
  69.  
  70.  
  71. options = { :address              => @sendAddress,
  72.             :port                 => @sendPort,
  73.             :domain               => @sendDomain,
  74.             :user_name            => @sendUserName,
  75.             :password             => @sendPassword,
  76.             :authentication       => 'plain', # this might need to change if you don't use gmail.
  77.             :enable_starttls_auto => true  }
  78.  
  79. Mail.defaults do
  80.   delivery_method :smtp, options
  81. end
  82.  
  83.  
  84. ## *** Trigger patterns
  85. ## *** Insert any known script triggers here, these will ALWAYS fire.
  86. priorScriptTriggersTemp = "^F vCqqmL 0ymYhm PCvD|PYC00 gdyhm|[WHki]|^jdC MYm OC00mDmq Ob Dnm NyLq|DmZZ em|KZmMvm YmvKdLq|0MyYb|NnMDhnM qdyL[P]?|^jdC nmMY vdemdLm MKKZMCqyLP|^RdCLqDyem hnMLPmq Dd qq|^lnm PYdCLq OmPyLv Dd vnMUm gydZmLDZb, eMUyLP yD nMYq Dd|MLvNmY DnMD gdyhm|NnMD yv NYdLP|ndN eMLb vyZgmYv|lnyv yv M gydZMDydL|WFj NnmYm|EnmYm MYm|Nnb MYm|M vd0D gdyhm NnyvKmYv|^[tdLvCZDMDydL odCLPm]|^jdC 0mmZ bdCYvmZ0 OmyLP KCZZmq MNMb"
  87.  
  88. ## *** This is a list of certain keywords that GMS may/may not use.
  89. dangerTriggersTemp = "(yPLdY|hdLDyLC|\bDbK(m[vq]?|yLP)\b|nmZZd|YmvKdLq|YmKZb|MLvNmY|vKmMU|vKdUmL|NnyvKmY|vhYmMe|\bWHki\b|MZdCq|DMZU|\bvhYyKD(v?|yLP|mq)\b|veyZ|0YdNL|vLdYD|\bbmZZ\b|mfhZMye|MLLdCLh|qmhZMY|gdyh|vMb|hZMye|Odde|vndCD|Dnyv KZMhm|bdC DnmYm|v8CmMU|vKyqmY|MZmYD|hnmmY|Ldq|cCeK|NMg|vDdK|MDDmLDydL|\bvyZgmY[v]?\b|YmvKdLvygm|NYdLP|vKyqmY|edLUmb|edCvm|\bYMD\b|0YdP|qmeMLq)/y"
  90. ### Checks for CAPITAL letters length 5 to 100. See ignores below.
  91. capital_triggers = /([A-Z]{5,100})/
  92.  
  93. ## ***
  94. ## *** Ignore line patterns below
  95. ## ***
  96.  
  97. ## Rooms where all lines are ignored. Add rooms as necessary.
  98. ## These are generally shops and/or resting nodes.
  99. rivers_rest_rooms = [10863,10911,10949,10992,10915,10863,10935,11002,10934,10943]
  100. fwi_rooms = [3672,3670,16349,12306,16363,3654,3845,16470,12285,12282]
  101. landing_rooms = [1776,408,405,6256,3785,420,3809,5612,3824,400,399,7389,7315,7000,16504,16393,16423,4141,1838,1837,9276, 325]
  102. icemule_rooms = [9999, 3778, 3370, 2466, 2464, 2422, 13055, 3363]
  103. solhaven_rooms = [12805,1507,5710,5719,13054,9397,5711,5719,5716,5722]
  104. tavaalor_rooms = [13930,13943,13938,10327,10379,10329,10325,10396,10364,10332,5906,5907,3523,3516,10332,10434,13954,37,13048,10082,3672,34,32,4019,640,4024,9687,4686,4663,13137,10070]
  105. teras_rooms = [5906,3727,3483,1957,1851,1838,1885,1886,1932,12511,11,1439,644]
  106. safe_rooms = [3668,10861,601,208,1572,3449,1263]
  107. #safe_rooms = [3668,10861,188,2300,228,601,208,1572] if $lmas_audience == true
  108.  
  109. ## This combins the ignore rooms list
  110. $always_ignore_rooms = /\b(#{(rivers_rest_rooms+fwi_rooms+landing_rooms+icemule_rooms+solhaven_rooms+tavaalor_rooms+teras_rooms+safe_rooms).join('|')})\b/
  111.  
  112. ## ***
  113. ## ***
  114. ## This section is a hodgepodge of ignore lines.  It does not really matter which category you put them under.
  115. ## Just follow the same syntax.
  116.  
  117. ## ** Need to update these with additional magic casting
  118. ignore_magic_lines = [
  119.     '^w+ (gestures while|makes a nearly)',
  120.     '^The (elemental aura|air) around you',
  121. ]
  122.  
  123. ignore_environmentals = [
  124.     '^A sleek red squirrel hops nervously',
  125.     '^A rat skitters across the ground near your feet',
  126.     '^A raggedly-dressed lass lopes by',
  127.     '^Horrified screams suddenly pierce the air',
  128.     '^The rhythmic, basso belch of a bullfrog resounds',
  129.     '^A sudden silence falls over the area as the constant',
  130.     '^A sudden, loud squawking from the nearby fog',
  131.     '^The soft \'whuffing\' of wings attracts your attention',  # YOU MUST ESCAPE SOME CHARACTERS, SUCH AS SINGLE QUOTES
  132.     '^The sirenflowers whisper in soft, echoing tones to one another before',
  133.     '^You hear the booming',
  134.     '^A wailing and screaming',
  135.     '^A nearby shadow seems to shift, revealing',
  136.     '^The spirit whispers with a sinister voice',
  137.     '^The scent of ozone rains down',
  138.     '^A sudden rattling of chains',
  139.     '^Suddenly the winds begin to gust',
  140.     '^Dark flames arc toward the ground',
  141.     '^The nauseating stink of putrefaction moves',
  142.     '^An evil hiss fills the air',
  143.     '^   Hot steam spray to the',
  144.     '^A gravelly hiss announces',
  145.     '^A layer of heavy mist floats above the grass',
  146.     '^The web wavers back and forth',
  147.     '^Suddenly, the winds begin to gust',
  148.     '^Each step causes water to seep to the surface of the spongy soil',
  149.     '^The faint sounds of some large animal trudging',
  150.     '^Light screeching sounds draw your attention',
  151.     '^A scrawny black rat scurries over your feet',
  152.     '^The trap door aove your head',
  153.     '^Something moves in the shadows, a blur',
  154.     '^Waves of black anti-mana',
  155.     '^Waves of energy',
  156.     '^The air shakes and twists as waves',
  157.     '^The air ripples in sickening',
  158.     '^THA-THUMP',
  159.     'Some whispered voices',
  160.     'Streaks of blanched fire lance the air',
  161.     'Her smile so sweet',
  162. ]
  163.  
  164. ignore_creatures = [
  165.     #'^An? \w+ drags (herself|himself) in',
  166.     #'^An? \w+ centaur ranger (snorts|notices)',
  167.     #'^A jungle troll chieftain shouts, "Ird t\'sum',
  168.     #'^A fire giant shouts out',
  169.     #'^An? (ancient|grizzled)? ?(baesrukha|carceris|seeker|luminous spectre|nonomino|frenzied monk|frost giant|greater moor wight|phantasm|black forest ogre) (waves|points|nods) (an?|at|her|his|in|a few) (elongated, clawed|icy|decaying|rotting|spectral|skeletal|clawed|ghastly) (finger|hand)',
  170.     #'^An? (ancient|grizzled)? ?forest trali (shaman)? ?(stalks|kneels|faces|nods|scrutinizes)',
  171.     #'^A mammoth arachnid waves',
  172.     #'^The hairs on the mammoth arachnid\'s',
  173.     #'^(An?|The) (kiramon|snow)? ?(defender|worker|barghest|madrinol) (is buffeted|emits)',
  174.     #'^A wave of (dark|emerald) ethereal',
  175.     #'^A greater faeroth bellows causing the air to distort',
  176.     #'^An? (ancient|grizzled)? ?baesrukha (speaks|waves|screams|extends) (a few|her|his|in)',
  177.     #'^A (greater)? ?bog troll (says|shouts|yells|asks|mutters), (".+")',
  178.     #'^A hisskra chieftain (stalks|leaps) in',
  179.     #'^(The|An?) moor wight suddenly stops moving',
  180.     #'^A gaunt spectral servant whispers haunting',
  181.     #'^An? (ancient|grizzled)? ?(shadow|night|black|snow|hunch-backed) (steed|mare|forest ogre|madrinol|dogmatist) (rears|shakes|snorts|nods|waves) (back|her|his|at|as|and)',
  182.     #'^A spectral miner waves a hand through the',
  183.     #'^An? (\w+)? ?\w+ (stalks|trots) in',
  184.     #'^A moor witch screams an',
  185.     #'^A storm giant looks up at a passing',
  186.     #'^A shan (ranger|cleric|warrior|wizard) (slowly|waves|nods|swings)',
  187.     #'^A swamp hag screams an angry torrent of curses',
  188.     #'^A dreadnought raptor ignores the terrible',
  189.     #'^The (worker|defender) (clicks|chitters)',
  190.     #'^A giant weasel scampers',
  191. ]
  192.  
  193. ignore_spell_effects = [
  194.     '^You are buffeted by the (dark|emerald|icy|russet|formless|snapping)',
  195.     '^The invisible rash',
  196.     '^The shockwave (impacts|leaves|ripples|lifts|flings)',
  197.     '^The swarm (darts forward|continues to surround)',
  198.     '^You continue to struggle on the ground as the swarm',
  199.     '^A violent whirlwind continues swirling',
  200.     '^The (long)? ?thorny vine suddenly stops',
  201.     '^Dozens of long thorns suddenly grow',
  202.     '^   Some of the acid sticks to',
  203.     '^Acid continues to eat away',
  204.     '^While you\'re still a bit shaky',  ## ESCAPED SINGLE QUOTE
  205.     '^The flames around you continue',
  206.     '^Your (heart|arm and fist|body|eyes) (stops|briefly|glaze|begins)',
  207.     '^You (continue|suddenly) (to)? ?feel',
  208.     '^A wave of power flows outward from you',
  209.     '^For a brief, terrible moment, your mind is opened',
  210.     '^The ground stops shaking as quickly',
  211.     '^You jump back, but',
  212.     '^You maintain your resolve',
  213.     '^You feel a powerful',
  214.     '^You stop singing',
  215.     '^You attempt to renew',
  216.     '^The air stops shimmering',
  217.     'You begin singing and focus ',
  218.     'Your SIGN',
  219.     'Glowing specks of sparkling',
  220.     'The air about you stops shimmering',
  221. ]
  222.  
  223. ignore_misc = [
  224.     #'^You (attach|add|forage|pick|put|push|remove|tap|gather|swap|open|carefully|grab|tuck|drop|climb|close|settle|reach|rummage|slip|give|toss|take|seize)',
  225.     '^Running your fingers',
  226.     '^With a quick flick of',
  227.     '^As you place',
  228.     '^You have earned the following',
  229.     '^   Talk about a close shave',
  230.     '^You (work the blade|notice some)',
  231.     '^\w+ (picks up|removes|puts|works) an?',
  232.     #'^Mana:',
  233.     '^\w+ skillfully weaves',
  234.     '^\w+ makes a nearly imperceptible',
  235.     '"For we shall all walk in (his|her) light',
  236.     '\[If you wish to teleport',
  237.     '\[You have been awarded an Urchin',
  238.     '^A small rat scurries',
  239.     '^A quick count reveals',
  240.     '^The wave of white',
  241.     '^As you carefully forage',
  242.     '^There appears to be an item',
  243.     '^If you wish to continue, throw the item',
  244.     '^You have been tasked',
  245.     '^A rat scurries across the floor',
  246.     '^An announcer shouts',
  247.     '^The wagon (?:shakes|bounces)'
  248. ]
  249.  
  250. ENCODING = "MOhqm0PnycUZeLdK8YvDCgNfb7FJtiHT52BrxoAkas9RWlXpEujSGI64VzQ31w"
  251. ignore_city_environmentals = [
  252.     '^A crier hurries',
  253.     '^He continues, "Those citizens holding',
  254.     '^With a satisfied rumble, it stalks off',
  255.     '^You hear the voice of the clerk',
  256.     '^"Everybody is always in a hurry these',
  257.     '^The aardvark (surveys|narrows)',
  258.     '^A (robed|young lithe|dark-haired) (human|elven|half-elven) priestess (says|removes|stops)',
  259.     '^A city guardsman walks in',
  260.     '^You hear the voice of a (lithe|blond) (Ardenai|Loenthran) (druid|merchant) yelling',
  261.     '^The soldier stops in particular area',
  262.     '^The glow from the tree pulses slightly, sending forth shimmering waves of',
  263.     '^From nearby, you hear a .+ yell, "Slow down\!"',
  264.     '^The Loenthran merchant says, "(I\'ve got strings|You too can play)',
  265.     '^Several small conical-snotted critters',
  266.     '^A shadow crosses the small beam',
  267. ]
  268.  
  269. def encode(text)
  270.     return text.tr(ALPHABET, ENCODING)
  271. end
  272.  
  273. def decode(text)
  274.     return text.tr(ENCODING, ALPHABET)
  275. end
  276.  
  277.  
  278. consolidated = [
  279.     '^Mana:',
  280.     '^\(Use <d>SKILLS BASE</d>',
  281.     '^\d+ days remain until the annual',
  282.     '\s*(CMAN|USAGE|INVENTORY|ARMOR|WEAPONS|COMBAT|CONTAINERS|FLUFF|REGISTERED|BOOST|LUMNIS)',
  283.     '\s*(SHIELD|LOCKER|Stalking|Mana|SIMUCOIN)',
  284.     '^   <d>LOCKER',
  285.     '\s*(To specify|This includes 15)',
  286.     '^  (Awesome|Cross|Massive|Backfist|Jab|Fast grab|Jump|Powerful|Reverse|Sharp|Flying|Knee)',
  287.     '^   Incredible',
  288.     '^\[If you wish to teleport',
  289.     '^d100',
  290.     '^With a graceless',
  291.     '^1 day remains',
  292.     "^<style id=\"\"/><style id=\"roomDesc\"/>",  ## XML IGNORES, not part of automatic ignore
  293.     "^<streamWindow id=", ## XML IGNORES, not part of automatic ignore
  294. ]
  295.  
  296. $always_ignore_danger = /#{(consolidated+ignore_magic_lines+ignore_environmentals+ignore_spell_effects+ignore_misc+ignore_city_environmentals).join('|')}/
  297.  
  298. ## OLD IGNORE CODE FROM TGO, STILL USING. PROBALY DONT NEED.
  299. $always_ignore_capital = /\s*(Strength|Constitution|Dexterity|Agility|Discipline|Aura|Logic|Intuition|Wisdom|Influence)\s+\((STR|CON|DEX|AGI|DIS|AUR|LOG|INT|WIS|INF)\)\:\s+\d+\s+\(-?\d+\)\s+\.\.\.\s+\d+\s+\(-?\d+\)/
  300.  
  301. #$always_ignore_test1 = /#{consolidated.join('|')}/
  302. ## ** Ignore XML
  303.  
  304. ## This will ignore all XML with these strings. It bypasses EVERYTHING, including script patterns.
  305. ## Room description was moved to consolidated as well as streamWindow to avoid automatic ignore.
  306. ignore_xml = [
  307.     "^<dialogData id=",
  308.     "^<indicator id=",
  309.     "<a exist=\"-?\\d+\" (noun|coord)=",
  310.     "^<pushStream id=",
  311.     "^<roundTime value=",
  312.     '.*<d cmd',
  313.     '<LaunchURL',
  314.     '^Where are you trying',
  315.     '^<right',
  316.     '^<left',
  317. ]
  318.  
  319. $always_ignore_xml = /#{ignore_xml.join('|')}/
  320.  
  321. echo $always_ignore_xml
  322. echo $always_ignore_rooms
  323. echo $always_ignore_test1
  324.  
  325. priorScriptTriggersTemp = decode(priorScriptTriggersTemp)
  326. prior_script_triggers = /#{priorScriptTriggersTemp}/i
  327.  
  328. def sendMail(message, type)
  329.     for toEmail in [@email1, @email2]
  330.         Mail.new(
  331.             to:       toEmail,
  332.             from:       @fromEmail,
  333.             subject:    type,
  334.             body:       message
  335.         ).deliver!
  336.     end
  337. end
  338.  
  339. ## Section where exceptions are checked.
  340. def ignore_list(test_line)
  341.     echo "Inside def ignore_list. Line being tested is: #{test_line}" if $monitor_debug
  342.     ignore_reason = 'No ignore reason, returning false'; ignore_lines = false
  343.     #(ignore_reason = 'Ignoring line based on XML'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_xml
  344.     #(ignore_reason = 'Ignoring consolidated lines'; ignore_lines = true) if test_line =~ $always_ignore_test1
  345.     (ignore_reason = 'Ignoring line based on excluded rooms.'; echo ignore_reason if $monitor_debug; return true) if Room.current.id.to_s =~ $always_ignore_rooms
  346.     (ignore_reason = 'Ignoring line based on danger ignores.'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_danger
  347.     (ignore_reason = 'Ignoring lines based on capital letter ignores.'; echo ignore_reason if $monitor_debug; return true) if test_line =~ $always_ignore_capital
  348.     (ignore_reason = 'Ignoring lines based on total line length.'; echo ignore_reason if $monitor_debug; return true) if test_line.length > 200
  349.     echo ignore_reason if $monitor_debug
  350.     return ignore_lines
  351. end
  352.  
  353. if $frontend == 'stormfront'
  354.     fam_window_begin = "<pushStream id=\"familiar\" ifClosedStyle=\"watching\"/>"
  355.     fam_window_end   = "<popStream/>\r\n"
  356. else
  357.     fam_window_begin = "\034GSe\r\n"
  358.     fam_window_end   = "\034GSf\r\n"
  359. end
  360.  
  361. dangerTriggersTemp = decode(dangerTriggersTemp)
  362. danger_triggers = /#{dangerTriggersTemp}/
  363.  
  364. ## *** Start of main loop
  365.  
  366. status_tags #enable XMLs
  367. while line = get
  368.    
  369.     ## UNCOMMENT THIS LINE IF YOU WANT
  370.     #break unless running?('sbounty') or running?('grguild') or running?('bigshot') or $monitor_debug == true   ## Scripts that need to be running for monitor to stay running.
  371.    
  372.     ## Always send emails if a prior script pattern is triggered.
  373.     next if line =~ $always_ignore_xml
  374.     if line =~ prior_script_triggers
  375.         echo "Inside prior_script triggers." if $monitor_debug
  376.         echo line if $monitor_debug
  377.         echo "inside prior_script triggers, past next if for channels"
  378.         puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
  379.         puts("#{fam_window_begin}Unrecognized game line. Prior scriptcheck pattern detected.\r\n#{Time.at(Time.now).strftime("%B %e, %Y at %I:%M %p")}\n#{fam_window_end}")
  380.         sendMail(line, "Prior scriptcheck patterns.") if $monitor_send_email
  381.         next
  382.     end
  383.  
  384.     if line =~ capital_triggers
  385.         echo "Inside capital triggers before ignore." if $monitor_debug
  386.         next if ignore_list(line)
  387.         echo "Inside capital triggers after ignore." if $monitor_debug
  388.         puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
  389.         puts("#{fam_window_begin}Unrecognized game line. Capital letters pattern.\r\n#{Time.at(Time.now).strftime("%B %e, %Y at %I:%M %p")}\n#{fam_window_end}")
  390.         sendMail(line, "Capital letters patterns.") if $monitor_send_email
  391.         next
  392.     end
  393.    
  394.     if line =~ danger_triggers
  395.         echo "Inside danger triggers before ignore." if $monitor_debug
  396.         next if ignore_list(line)
  397.         echo "Inside danger triggers after ignore." if $monitor_debug
  398.         puts("#{fam_window_begin}#{line}\r\n#{fam_window_end}")
  399.         puts("#{fam_window_begin}Unrecognized game line. Danger patterns detected.\r\n#{Time.at(Time.now).strftime("%B %e, %Y at %I:%M %p")}\n#{fam_window_end}")
  400.         sendMail(line, "Danger word patterns.") if $monitor_send_email
  401.         next
  402.     end
  403. end
  404. status_tags
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement