From 740466e367af3afc39e9ca199207dc52c78f27cb Mon Sep 17 00:00:00 2001 From: onefang Date: Thu, 4 Jul 2019 02:02:34 +1000 Subject: New OhSilly Threat level detector, and actually use it. Tries to work in all case. --- .1AOor2.settings.txt | 3 + .1AOor2.theme.txt | 3 + .1ring.theme.txt | 1 + 1AOor2.lsl | 62 ++++++++--------- 1chatter.lsl | 40 +++++------ 1ring.lsl | 42 ++++-------- OhSillyThreatDetector.lsl | 167 +++++++++++++++++++++++++++++++++++++++++++--- ~1AOor2.setting.data.txt | 16 +++++ ~1ring.command.data.txt | 5 +- 9 files changed, 244 insertions(+), 95 deletions(-) diff --git a/.1AOor2.settings.txt b/.1AOor2.settings.txt index 9ef4a07..1600f01 100644 --- a/.1AOor2.settings.txt +++ b/.1AOor2.settings.txt @@ -1,2 +1,5 @@ AO=1 SUPER=0 +OSANIM=1 +OSSIT=0 +OSSPEED=1 diff --git a/.1AOor2.theme.txt b/.1AOor2.theme.txt index e8627b5..6bba809 100644 --- a/.1AOor2.theme.txt +++ b/.1AOor2.theme.txt @@ -41,6 +41,9 @@ TOMENU sits | CHOOSE_STATE TOMENU stands | CHOOSE_STATE TOMENU swims | CHOOSE_STATE TOMENU walks | CHOOSE_STATE +TOGGLE osAnim +TOGGLE osSit +TOGGLE osSpeed MENU dances | Dance menu | ALL POSE cherished | cherished-m | cherished-f diff --git a/.1ring.theme.txt b/.1ring.theme.txt index 2807d7e..834a32d 100644 --- a/.1ring.theme.txt +++ b/.1ring.theme.txt @@ -55,6 +55,7 @@ TOMENU title TOMENU title colour TOGGLE record TOGGLE typing +BUTTON OhSilly probe | OHSILLYPROBE MENU mood | moods menu:\nLaugh\nCheeky\nHappy\nNone\nSad\nAngry\nCry\nTantrum | WEARER BUTTON △ better diff --git a/1AOor2.lsl b/1AOor2.lsl index 39b1184..96ef48b 100644 --- a/1AOor2.lsl +++ b/1AOor2.lsl @@ -56,20 +56,9 @@ integer lDYNAMIC = -20; integer lMENU = -21; // OhSillyThreat detector -list OhSillyThreats = []; -list OhSillyTreats = // OpenSim threat level. -[ -// "osKey2Name", // low -// "osGetAvatarList", // none - "osGetNotecard", // very high (describes what they where when making this decision) -// "osMakeNotecard", // high (describes what they where when making this decision) -// "osGetRezzingObject", // none - "osMessageObject", // low - "osAvatarPlayAnimation", // very high - "osAvatarStopAnimation", // very high - "osForceOtherSit", // very high - "osSetSpeed" // moderate -]; +integer doAnim = TRUE; +integer doSit = FALSE; +integer doSpeed = TRUE; d(string m) {if (DEBUG) llInstantMessage(Owner, llGetScriptName() + ": " + m);} D(string m) {llRegionSay(DEBUG_CHANNEL, llGetScriptName() + ": " + m);} @@ -102,6 +91,10 @@ string inKey2Name(key k) return k; } +animBegin(key u, string a){if (doAnim) osAvatarPlayAnimation(u, a); else llStartAnimation(a);} +animEnd(key u, string a){if (doAnim) osAvatarStopAnimation(u, a); else llStopAnimation(a);} +speed(key u, float s){if (doSpeed) osSetSpeed(u, s);} + integer listFindString(list lst, string name, integer stride) { integer f = llListFindList(lst, [name]); @@ -201,6 +194,13 @@ dynamicMenu(key id, string menu, string name, string title, string entries, stri integer Chosen; linky(integer num, string message, key id) { + if (DEBUG_CHANNEL == num) + { + if ("osAvatarPlayAnimation" == message) doAnim = (integer) id; + if ("osAvatarStopAnimation" == message) doAnim = (integer) id; + if ("osForceOtherSit" == message) doSit = (integer) id; + if ("osSetSpeed" == message) doSpeed = FALSE; + } if ((id != ScriptKey) && (id != NULL_KEY)) return; list input = llParseStringKeepNulls(message, [lSEP], []); key them = llList2Key(input, 0); @@ -234,16 +234,6 @@ d("linky RESET_DONE"); laterInit(); s(Owner, "Finished starting up " + getSetting("VERSION") + " in " + (string) (llGetTimeOfDay() - Start)); } - else if (DEBUG_CHANNEL == num) - { - key root = llList2Key(llGetObjectDetails(id, [OBJECT_ROOT]), 0); - integer f = llListFindList(OhSillyThreats, [message]); - if (-1 == f) OhSillyThreats += [message]; - else d("OhSillyThreats detected the function " + message + "() again!" ); - D("Oh Silly threat system prevented " + message + "()" - + "\n in " + id + " \t" + llKey2Name(id) - + "\n part of " + root + " \t" + llKey2Name(root)); - } } // END boilerplate, mostly. @@ -274,10 +264,10 @@ integer doThing(key id, string button, string fr, string cmd, string data, integ else if ("checkAO" == cmd) checkAO(); else if ("SMILE" == cmd) { // The built in express_* animations are too short, but live with it. - osAvatarStopAnimation(llGetOwner(), Smile); + animEnd(llGetOwner(), Smile); Smile = llList2String(Smiles, (integer) llFrand(2.5)); addEvent(3.0 + llFrand(5.0), cmd); - osAvatarPlayAnimation(llGetOwner(), Smile); + animBegin(llGetOwner(), Smile); } else if ("LESS_-" == cmd) { @@ -469,8 +459,10 @@ integer doThing(key id, string button, string fr, string cmd, string data, integ osNpcSit(Stalkee, llGetKey(), OS_NPC_SIT_NOW); else { - llInstantMessage(Stalkee, "Please sit on the big gold heart."); -// osForceOtherSit(Stalkee/*, llGetKey()*/); + if (doSit) + osForceOtherSit(Stalkee/*, llGetKey()*/); + else + llInstantMessage(Stalkee, "Please sit on the big gold heart."); } newPose(id, llList2Key(p, 1), llList2List(p, 2, -1)); } @@ -1450,7 +1442,7 @@ stopAnims(key avatar) for (i = 0; i < l; i++) { string anim = llList2String(anims, i); - if (anim != "") osAvatarStopAnimation(avatar, anim); + if (anim != "") animEnd(avatar, anim); } } } @@ -1550,6 +1542,8 @@ checkAO() integer fast; integer i; integer f; float dpth; if (NULL_KEY != TheirKey) return; +// doAnim = (integer) getSetting("osAnim"); +// doSpeed = (integer) getSetting("osSpeed"); if (Attached) { // if (llGetAgentInfo(Owner) & AGENT_ALWAYS_RUN) fast = 1; else fast = 0; @@ -1565,7 +1559,7 @@ checkAO() { stopAnims(Owner); AOspeed = 1.0; - osSetSpeed(Owner, 1.0); + speed(Owner, 1.0); return; } string oldAnim = newAnim; @@ -1635,7 +1629,7 @@ checkAO() else AOspeed = 4.0; } else AOspeed = 1.0; - if (0.0 < AOspeed) osSetSpeed(Owner, AOspeed + ((AOspeed / 2) * (fast + (2 * (integer) getSetting("super"))))); + if (0.0 < AOspeed) speed(Owner, AOspeed + ((AOspeed / 2) * (fast + (2 * (integer) getSetting("super"))))); else AOspeed = 1.0; for (f = 0; f < l; f += pSTRIDE) { @@ -1673,7 +1667,7 @@ checkAO() for (i = llGetListLength(anims) - 1; i >= 0; --i) { string a = llList2String(anims, i); - if (checkAnim(a)) osAvatarPlayAnimation(id, a); + if (checkAnim(a)) animBegin(id, a); } } } @@ -1691,7 +1685,7 @@ stopMe(key id, integer f) integer i; //d("stopMe " + llKey2Name(id) + " " + llList2String(Sitters, f + pANIMS)); for (i = llGetListLength(anims) - 1; i >= 0; --i) - osAvatarStopAnimation(id, llList2String(anims, i)); + animEnd(id, llList2String(anims, i)); } checkLag() @@ -1833,4 +1827,4 @@ d("\n\n1AOor2 sending RESET @ " + (string) Start + "\n"); } } } -} +} \ No newline at end of file diff --git a/1chatter.lsl b/1chatter.lsl index b3df84e..3ed1bac 100644 --- a/1chatter.lsl +++ b/1chatter.lsl @@ -1444,6 +1444,26 @@ d("lSCAN " + llDumpList2String(input, " ~ ")); listen(integer channel, string name, key id, string message) { //d("listen " + channel + ", " + llKey2Name(id) + "-> " + message + " " + llGetListLength(Musers)); + // Catch OhSillyThreatLevel messages, from the probe. + if (channel == DEBUG_CHANNEL) + { + key root = llList2Key(llGetObjectDetails(id, [OBJECT_ROOT]), 0); + if (llGetLinkKey(LINK_ROOT) == root) + { + integer f = llSubStringIndex(message, "permission denied. "); + if (-1 != f) + { + list e = llParseStringKeepNulls(llGetSubString(message, 0, -f), [" "], []); + string function = llList2String(e, 0); + if (("OSSL" == llList2String(e, 0)) && ("Runtime" == llList2String(e, 1)) && ("Error:" == llList2String(e, 2))) + function = llList2String(e, 3); + llMessageLinked(LINK_SET, DEBUG_CHANNEL, function, "0"); +llOwnerSay("Found naughty function " + function); + return; + } + } + } + // See if it's a prefix on the prefix channel, strip off the prefix and feed the remains to doThing(). if (channel == (integer) getSetting("1ring.CHANNEL")) { @@ -1472,26 +1492,6 @@ d("listen 1ring.CHANNEL " + message + " -> " + button + " " + cmd + " " + data); return; } } - - // Catch OhSillyThreatLevel messages. - if (channel == DEBUG_CHANNEL) - { - key root = llList2Key(llGetObjectDetails(id, [OBJECT_ROOT]), 0); - if ((llGetLinkKey(LINK_ROOT) == root) && ("OSSL Runtime Error: os" == llGetSubString(message, 0, 21))) - { - string function = llGetSubString(message, 20, -1); - integer f = llSubStringIndex(function, " "); - if (-1 != f) - { - if (" permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission." == llGetSubString(function, f, -1)) - { - llMessageLinked(LINK_SET, DEBUG_CHANNEL, llGetSubString(function, 0, f - 1), id); - llRegionSay(DEBUG_CHANNEL, "OPENSIM SUCKS!"); - return; - } - } - } - } } no_sensor() diff --git a/1ring.lsl b/1ring.lsl index 69dbc2e..9593321 100644 --- a/1ring.lsl +++ b/1ring.lsl @@ -56,20 +56,7 @@ integer lDYNAMIC = -20; integer lMENU = -21; // OhSillyThreat detector -list OhSillyThreats = []; -list OhSillyTreats = // OpenSim threat level. -[ - "osKey2Name", // low -// "osGetAvatarList", // none -// "osGetNotecard", // very high (describes what they where when making this decision) -// "osMakeNotecard", // high (describes what they where when making this decision) -// "osGetRezzingObject", // none - "osMessageObject", // low -// "osAvatarPlayAnimation", // very high -// "osAvatarStopAnimation", // very high -// "osForceOtherSit", // very high - "osSetSpeed" // moderate -]; +integer doSpeed = FALSE; d(string m) {if (DEBUG) llInstantMessage(Owner, llGetScriptName() + ": " + m);} D(string m) {llRegionSay(DEBUG_CHANNEL, llGetScriptName() + ": " + m);} @@ -103,6 +90,8 @@ string inKey2Name(key k) return k; } +speed(key u, float s){if (doSpeed) osSetSpeed(u, s);} + integer listFindString(list lst, string name, integer stride) { integer f = llListFindList(lst, [name]); @@ -215,6 +204,10 @@ dynamicMenu(key id, string menu, string name, string title, string entries, stri linky(integer num, string message, key id) { + if (DEBUG_CHANNEL == num) + { + if ("osSetSpeed" == message) doSpeed = (integer) id; + } if ((id != ScriptKey) && (id != NULL_KEY)) return; list input = llParseStringKeepNulls(message, [lSEP], []); key them = llList2Key(input, 0); @@ -266,19 +259,6 @@ d("linky RESET_DONE"); laterInit(); s("Finished starting up " + getSetting("VERSION") + " in " + (string) (llGetTimeOfDay() - Start)); } - else if (DEBUG_CHANNEL == num) - { - key root = llList2Key(llGetObjectDetails(id, [OBJECT_ROOT]), 0); - integer f = llListFindList(OhSillyThreats, [message]); - - if (-1 == f) - OhSillyThreats += [message]; - else - d("OhSillyThreats detected the function " + message + "() again!" ); - s("Oh Silly threat system prevented " + message + "()" - + "\n in " + id + " \t" + llKey2Name(id) - + "\n part of " + root + " \t" + llKey2Name(root)); - } } // END boilerplate, mostly. @@ -629,6 +609,8 @@ s("YAY! Freeeeeee at last!!!!!"); osMessageObject(LeashKey, "URL|" + data); d("New URL " + URL); } + else if ("OHSILLYPROBE" == cmd) + llMessageLinked(LINK_SET, DEBUG_CHANNEL, "OHSILLYPROBE", llGetKey()); else if ("▲" == cmd) ; else if (-1 == listFindString(Settings, fr + cmd, sSTRIDE)) @@ -853,9 +835,9 @@ goto(key this) if (dist > (RANGE + bb)) { if (dist > (2.0 * (RANGE + bb))) - osSetSpeed(Owner, 2.0); + speed(Owner, 2.0); else - osSetSpeed(Owner, 1.0); + speed(Owner, 1.0); llStopMoveToTarget(); if (0 != tid) @@ -899,7 +881,7 @@ stopGoto(integer all) llTargetRemove(tid); tid = 0; } - osSetSpeed(Owner, 1.0); + speed(Owner, 1.0); if (all) { Stalkee = NULL_KEY; diff --git a/OhSillyThreatDetector.lsl b/OhSillyThreatDetector.lsl index 4f17ed6..24b3e43 100644 --- a/OhSillyThreatDetector.lsl +++ b/OhSillyThreatDetector.lsl @@ -1,6 +1,6 @@ // Detect when OpenSim reports a function was used that triggered a threat level warning. -// Coz their official method doesn't work, and often their threat levels are set way too high. +// Coz their official method doesn't always work, and often their threat levels are set way too high. // This script will send a link message with number DEBUG_CHANNEL, message being the name of the naughty function, // and key of the prim containing the naughty script. It's up to the naughty script to catch this link message @@ -9,12 +9,66 @@ // Since it sniffs on DEBUG_CHANNEL messages, and a script can't hear any message sent by scripts in the same prim, // you'll need to put this script in a prim without the naughty scripts you want to check. +// Naturally it looks as if OpenSim has decided that scripts sniffing DEBUG_CHANNEL is a bad idee now. + +// Bits of this where taken from the script at the bottom of http://opensimulator.org/wiki/Threat_level + + +// OSSL Function Availability Tester +// +// Demonstrates a method by which a script may determine whether or not it is permitted to call +// various OSSL functions. + +integer WhichProbeFunction; // to tell us which function we're probing +// OpenSim lies. +list FunctionNames = +[ +// "osAvatarName2Key", // low (it fails anyway) + "osAvatarPlayAnimation", // very high + "osAvatarStopAnimation", // very high + "osForceOtherSit", // very high +// "osGetAgentIP", // severe +// "osGetAgents", // none (it fails anyway) + "osGetAvatarList", // none (it fails anyway) + "osMakeNotecard", // high (describes what they where when making this decision) + "osGetNotecard", // very high (describes what they where when making this decision) + "osGetInventoryDesc", // - + "osGetNotecardLine", // very high (describes what they where when making this decision) + "osGetNumberOfNotecardLines", // very high + "osGetRegionSize", // - (it fails anyway) + "osGetRezzingObject", // none (it fails anyway) + "osIsNpc", // - (it fails anyway) + "osKey2Name", // low (it fails anyway) + "osMessageObject", // low (it fails anyway) + "osNpcSit", // high + "osSetSpeed", // moderate + "osTeleportAgent" // severe (it works anyway) +]; +list FunctionPermitted = []; // 0 = not permitted, 1 = permitted + +startProbe() +{ +// llSay(0, "Probing OhSilly threat system to see what OpenSim script functions we are allowed use -"); + WhichProbeFunction = -1; + integer i = llGetListLength(FunctionNames); + FunctionPermitted = []; + while (i--) + FunctionPermitted += [-1]; + llRemoveInventory("OhSillyThreatCard"); + llSetTimerEvent(0.25); // check only four functions a second, just to be nice. +} + +// The default state uses the timer to call all the OSSL functions we're interested in using, in turn. +// If the function call fails, the timer event handler will abend, but the script doesn't crash. We can +// use this fact to check all of our desired functions in turn, and then pass control to the Running +// state once we've checked them all. default { state_entry() { -// llSay(DEBUG_CHANNEL, "G'day, I'm " + llGetKey() + " part of " + llGetLinkKey(LINK_ROOT)); llListen(DEBUG_CHANNEL, "", NULL_KEY, ""); +//llSay(DEBUG_CHANNEL, "G'day, I'm " + llGetKey() + " part of " + llGetLinkKey(LINK_ROOT) +// + "\nOpenSim sucks with their OhSilly threat system!"); } listen(integer channel, string name, key id, string message) @@ -28,7 +82,7 @@ default /* Threat level errors look like this (at least in OpenSim 0.8.2) - OSSL Runtime Error: osSetStateEvents permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission. -There is also (OpenSim 0.9 at least) - +There is also (OpenSim 0.9.1 at least) - Max Zephyr script OSSL Runtime Error: permission denied. All OS functions are disabled.(script: oc_settings event: changed primID:487baa88-d6e5-420c-b18c-f47f5bbd7de4 at <127.9408, 128.0009, 25.75689>) @@ -42,18 +96,111 @@ From the source (NOTE: first version has no function name) - ("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.", function ("{0} permission denied. Script permissions error.", function -OpenSim 0.9.0.1 doesn't include the "OSSL Runtime Error: " bit at the beginning anymore. -OpenSim 0.9.2 seems to not even send it to the DEBUG_CHANNEL for scripts anymore. +OpenSim 0.9.1 seems to not even send it to the DEBUG_CHANNEL for scripts anymore. */ - if ((llGetLinkKey(LINK_ROOT) == root) && ("OSSL Runtime Error: " == llGetSubString(message, 0, 19))) + if (llGetLinkKey(LINK_ROOT) == root) { - list e = llParseStringKeepNulls(llGetSubString(message, 20, -1), [" "], []); -//llOwnerSay(llList2String(e, 0)); - if (("permission" == llList2String(e, 1)) && ("denied" == llList2String(e, 2))) + integer f = llSubStringIndex(message, "permission denied. "); + if (-1 != f) { + list e = llParseStringKeepNulls(llGetSubString(message, 0, -f), [" "], []); string function = llList2String(e, 0); - llMessageLinked(LINK_SET, DEBUG_CHANNEL, function, id); + if (("OSSL" == llList2String(e, 0)) && ("Runtime" == llList2String(e, 1)) && ("Error:" == llList2String(e, 2))) + function = llList2String(e, 3); + llMessageLinked(LINK_SET, DEBUG_CHANNEL, function, "0"); +llOwnerSay("Found naughty function " + function); + llRegionSay(DEBUG_CHANNEL, "OPENSIM SUCKS!"); } } } + + link_message(integer sender, integer num, string message, key id) + { + if ((DEBUG_CHANNEL == num) && ("OHSILLYPROBE" == message)) startProbe(); + else + { + integer f = llListFindList(FunctionNames, [message]); + if (-1 != f) + { + FunctionPermitted = llListReplaceList(FunctionPermitted, [(integer) id], f, f); +// llSay(0, "BROKEN " + message + " " + id); + } + } + } + + // As noted above, this script wont hear itself when the below tests dump an error. + timer() + { + string name = llList2String(FunctionNames, ++WhichProbeFunction); + string BogusKey = "12345678-1234-1234-1234-123456789abc"; // it doesn't need to be valid + if ("" == name) + { + llSetTimerEvent(0.0); // stop the timer + llRemoveInventory("OhSillyThreatCard"); + string s = "The OpenSim script functions we are allowed to use - "; + string t = "The Opensim script functions we are NOT ALLOWED to use - "; + integer i = llGetListLength(FunctionNames); + while (i--) + { + integer p = llList2Integer(FunctionPermitted, i); + if (-1 == p) p = 0; + llMessageLinked(LINK_SET, DEBUG_CHANNEL, + llList2String(FunctionNames, i), (string) p); + if (p) + s += llList2String(FunctionNames, i) + "() "; + else + t += llList2String(FunctionNames, i) + "() "; + } +// llSay(0, s); + llSay(0, t); + return; + } +// llOwnerSay("Checking OpenSim function " + name + "()"); // say status + if ("osAvatarName2Key" == name) + osAvatarName2Key("John", "Smith"); + else if ("osAvatarPlayAnimation" == name) + osAvatarPlayAnimation(BogusKey, BogusKey); + else if ("osAvatarStopAnimation" == name) + osAvatarStopAnimation(BogusKey, BogusKey); + else if ("osForceOtherSit" == name) + osForceOtherSit(BogusKey, llGetKey()); + else if ("osGetAgentIP" == name) + osGetAgentIP(BogusKey); + else if ("osGetAgents" == name) + osGetAgents(); + else if ("osGetAvatarList" == name) + osGetAvatarList(); + else if ("osMakeNotecard" == name) // Out of order, so the others have something to read. + osMakeNotecard("OhSillyThreatCard", [""]); + else if ("osGetNotecard" == name) + osGetNotecard("OhSillyThreatCard"); + else if ("osGetInventoryDesc" == name) + osGetInventoryDesc("inventory"); + else if ("osGetNotecardLine" == name) + osGetNotecardLine("OhSillyThreatCard", 0); + else if ("osGetNumberOfNotecardLines" == name) + osGetNumberOfNotecardLines("OhSillyThreatCard"); + else if ("osGetRegionSize" == name) + osGetRegionSize(); + else if ("osGetRezzingObject" == name) + osGetRezzingObject(); + else if ("osIsNpc" == name) + osIsNpc(BogusKey); + else if ("osKey2Name" == name) + osKey2Name(BogusKey); + else if ("osMessageObject" == name) + osMessageObject(llGetKey(), "G'day."); + else if ("osNpcSit" == name) + osNpcSit(BogusKey, llGetKey(), 0); + else if ("osSetSpeed" == name) + osSetSpeed(BogusKey, 1.0); + else if ("osTeleportAgent" == name) + osTeleportAgent(BogusKey, ZERO_VECTOR, ZERO_VECTOR); + + // If we got here, then the timer() handler didn't crash, which means the function it checked for + // was actually permitted. So we update the list to indicate that we can use that particular function. +// llOwnerSay("Working " + name + "()"); + if (-1 == llList2Integer(FunctionPermitted, WhichProbeFunction)) + FunctionPermitted = llListReplaceList(FunctionPermitted, [1], WhichProbeFunction, WhichProbeFunction); + } } diff --git a/~1AOor2.setting.data.txt b/~1AOor2.setting.data.txt index 5a8c5c9..d2719a4 100644 --- a/~1AOor2.setting.data.txt +++ b/~1AOor2.setting.data.txt @@ -9,4 +9,20 @@ Y 1AOor2.AO LOCK Y 0 +9 +1AOor2.OSANIM +Y +1 +9 +1AOor2.OSSPEED +Y +1 +9 +1AOor2.OSSIT +Y +1 +9 +1AOor2.SUPER +Y +0 9 \ No newline at end of file diff --git a/~1ring.command.data.txt b/~1ring.command.data.txt index e49bb85..de8edd7 100644 --- a/~1ring.command.data.txt +++ b/~1ring.command.data.txt @@ -111,4 +111,7 @@ w 31 1ring.TESTS -8 \ No newline at end of file +8 +1ring.OHSILLYPROBE + +31 \ No newline at end of file -- cgit v1.1