aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OhSillyThreatDetector.lsl
diff options
context:
space:
mode:
authoronefang2019-07-04 02:02:34 +1000
committeronefang2019-07-04 02:02:34 +1000
commit740466e367af3afc39e9ca199207dc52c78f27cb (patch)
tree0fcdbe0092aef4b6d048e8e6cf95fa9d1a959a8d /OhSillyThreatDetector.lsl
parentBump version to 0.12 test (diff)
download1ring-740466e367af3afc39e9ca199207dc52c78f27cb.zip
1ring-740466e367af3afc39e9ca199207dc52c78f27cb.tar.gz
1ring-740466e367af3afc39e9ca199207dc52c78f27cb.tar.bz2
1ring-740466e367af3afc39e9ca199207dc52c78f27cb.tar.xz
New OhSilly Threat level detector, and actually use it.
Tries to work in all case.
Diffstat (limited to 'OhSillyThreatDetector.lsl')
-rw-r--r--OhSillyThreatDetector.lsl167
1 files changed, 157 insertions, 10 deletions
diff --git a/OhSillyThreatDetector.lsl b/OhSillyThreatDetector.lsl
index 4f17ed6..24b3e43 100644
--- a/OhSillyThreatDetector.lsl
+++ b/OhSillyThreatDetector.lsl
@@ -1,6 +1,6 @@
1 1
2// Detect when OpenSim reports a function was used that triggered a threat level warning. 2// Detect when OpenSim reports a function was used that triggered a threat level warning.
3// Coz their official method doesn't work, and often their threat levels are set way too high. 3// Coz their official method doesn't always work, and often their threat levels are set way too high.
4 4
5// This script will send a link message with number DEBUG_CHANNEL, message being the name of the naughty function, 5// This script will send a link message with number DEBUG_CHANNEL, message being the name of the naughty function,
6// and key of the prim containing the naughty script. It's up to the naughty script to catch this link message 6// 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 @@
9// Since it sniffs on DEBUG_CHANNEL messages, and a script can't hear any message sent by scripts in the same prim, 9// Since it sniffs on DEBUG_CHANNEL messages, and a script can't hear any message sent by scripts in the same prim,
10// you'll need to put this script in a prim without the naughty scripts you want to check. 10// you'll need to put this script in a prim without the naughty scripts you want to check.
11 11
12// Naturally it looks as if OpenSim has decided that scripts sniffing DEBUG_CHANNEL is a bad idee now.
13
14// Bits of this where taken from the script at the bottom of http://opensimulator.org/wiki/Threat_level
15
16
17// OSSL Function Availability Tester
18//
19// Demonstrates a method by which a script may determine whether or not it is permitted to call
20// various OSSL functions.
21
22integer WhichProbeFunction; // to tell us which function we're probing
23// OpenSim lies.
24list FunctionNames =
25[
26// "osAvatarName2Key", // low (it fails anyway)
27 "osAvatarPlayAnimation", // very high
28 "osAvatarStopAnimation", // very high
29 "osForceOtherSit", // very high
30// "osGetAgentIP", // severe
31// "osGetAgents", // none (it fails anyway)
32 "osGetAvatarList", // none (it fails anyway)
33 "osMakeNotecard", // high (describes what they where when making this decision)
34 "osGetNotecard", // very high (describes what they where when making this decision)
35 "osGetInventoryDesc", // -
36 "osGetNotecardLine", // very high (describes what they where when making this decision)
37 "osGetNumberOfNotecardLines", // very high
38 "osGetRegionSize", // - (it fails anyway)
39 "osGetRezzingObject", // none (it fails anyway)
40 "osIsNpc", // - (it fails anyway)
41 "osKey2Name", // low (it fails anyway)
42 "osMessageObject", // low (it fails anyway)
43 "osNpcSit", // high
44 "osSetSpeed", // moderate
45 "osTeleportAgent" // severe (it works anyway)
46];
47list FunctionPermitted = []; // 0 = not permitted, 1 = permitted
48
49startProbe()
50{
51// llSay(0, "Probing OhSilly threat system to see what OpenSim script functions we are allowed use -");
52 WhichProbeFunction = -1;
53 integer i = llGetListLength(FunctionNames);
54 FunctionPermitted = [];
55 while (i--)
56 FunctionPermitted += [-1];
57 llRemoveInventory("OhSillyThreatCard");
58 llSetTimerEvent(0.25); // check only four functions a second, just to be nice.
59}
60
61// The default state uses the timer to call all the OSSL functions we're interested in using, in turn.
62// If the function call fails, the timer event handler will abend, but the script doesn't crash. We can
63// use this fact to check all of our desired functions in turn, and then pass control to the Running
64// state once we've checked them all.
12default 65default
13{ 66{
14 state_entry() 67 state_entry()
15 { 68 {
16// llSay(DEBUG_CHANNEL, "G'day, I'm " + llGetKey() + " part of " + llGetLinkKey(LINK_ROOT));
17 llListen(DEBUG_CHANNEL, "", NULL_KEY, ""); 69 llListen(DEBUG_CHANNEL, "", NULL_KEY, "");
70//llSay(DEBUG_CHANNEL, "G'day, I'm " + llGetKey() + " part of " + llGetLinkKey(LINK_ROOT)
71// + "\nOpenSim sucks with their OhSilly threat system!");
18 } 72 }
19 73
20 listen(integer channel, string name, key id, string message) 74 listen(integer channel, string name, key id, string message)
@@ -28,7 +82,7 @@ default
28 /* Threat level errors look like this (at least in OpenSim 0.8.2) - 82 /* Threat level errors look like this (at least in OpenSim 0.8.2) -
29OSSL 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. 83OSSL 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.
30 84
31There is also (OpenSim 0.9 at least) - 85There is also (OpenSim 0.9.1 at least) -
32Max Zephyr script 86Max Zephyr script
33OSSL 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>) 87OSSL 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>)
34 88
@@ -42,18 +96,111 @@ From the source (NOTE: first version has no function name) -
42("{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 96("{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
43("{0} permission denied. Script permissions error.", function 97("{0} permission denied. Script permissions error.", function
44 98
45OpenSim 0.9.0.1 doesn't include the "OSSL Runtime Error: " bit at the beginning anymore. 99OpenSim 0.9.1 seems to not even send it to the DEBUG_CHANNEL for scripts anymore.
46OpenSim 0.9.2 seems to not even send it to the DEBUG_CHANNEL for scripts anymore.
47 */ 100 */
48 if ((llGetLinkKey(LINK_ROOT) == root) && ("OSSL Runtime Error: " == llGetSubString(message, 0, 19))) 101 if (llGetLinkKey(LINK_ROOT) == root)
49 { 102 {
50 list e = llParseStringKeepNulls(llGetSubString(message, 20, -1), [" "], []); 103 integer f = llSubStringIndex(message, "permission denied. ");
51//llOwnerSay(llList2String(e, 0)); 104 if (-1 != f)
52 if (("permission" == llList2String(e, 1)) && ("denied" == llList2String(e, 2)))
53 { 105 {
106 list e = llParseStringKeepNulls(llGetSubString(message, 0, -f), [" "], []);
54 string function = llList2String(e, 0); 107 string function = llList2String(e, 0);
55 llMessageLinked(LINK_SET, DEBUG_CHANNEL, function, id); 108 if (("OSSL" == llList2String(e, 0)) && ("Runtime" == llList2String(e, 1)) && ("Error:" == llList2String(e, 2)))
109 function = llList2String(e, 3);
110 llMessageLinked(LINK_SET, DEBUG_CHANNEL, function, "0");
111llOwnerSay("Found naughty function " + function);
112 llRegionSay(DEBUG_CHANNEL, "OPENSIM SUCKS!");
56 } 113 }
57 } 114 }
58 } 115 }
116
117 link_message(integer sender, integer num, string message, key id)
118 {
119 if ((DEBUG_CHANNEL == num) && ("OHSILLYPROBE" == message)) startProbe();
120 else
121 {
122 integer f = llListFindList(FunctionNames, [message]);
123 if (-1 != f)
124 {
125 FunctionPermitted = llListReplaceList(FunctionPermitted, [(integer) id], f, f);
126// llSay(0, "BROKEN " + message + " " + id);
127 }
128 }
129 }
130
131 // As noted above, this script wont hear itself when the below tests dump an error.
132 timer()
133 {
134 string name = llList2String(FunctionNames, ++WhichProbeFunction);
135 string BogusKey = "12345678-1234-1234-1234-123456789abc"; // it doesn't need to be valid
136 if ("" == name)
137 {
138 llSetTimerEvent(0.0); // stop the timer
139 llRemoveInventory("OhSillyThreatCard");
140 string s = "The OpenSim script functions we are allowed to use - ";
141 string t = "The Opensim script functions we are NOT ALLOWED to use - ";
142 integer i = llGetListLength(FunctionNames);
143 while (i--)
144 {
145 integer p = llList2Integer(FunctionPermitted, i);
146 if (-1 == p) p = 0;
147 llMessageLinked(LINK_SET, DEBUG_CHANNEL,
148 llList2String(FunctionNames, i), (string) p);
149 if (p)
150 s += llList2String(FunctionNames, i) + "() ";
151 else
152 t += llList2String(FunctionNames, i) + "() ";
153 }
154// llSay(0, s);
155 llSay(0, t);
156 return;
157 }
158// llOwnerSay("Checking OpenSim function " + name + "()"); // say status
159 if ("osAvatarName2Key" == name)
160 osAvatarName2Key("John", "Smith");
161 else if ("osAvatarPlayAnimation" == name)
162 osAvatarPlayAnimation(BogusKey, BogusKey);
163 else if ("osAvatarStopAnimation" == name)
164 osAvatarStopAnimation(BogusKey, BogusKey);
165 else if ("osForceOtherSit" == name)
166 osForceOtherSit(BogusKey, llGetKey());
167 else if ("osGetAgentIP" == name)
168 osGetAgentIP(BogusKey);
169 else if ("osGetAgents" == name)
170 osGetAgents();
171 else if ("osGetAvatarList" == name)
172 osGetAvatarList();
173 else if ("osMakeNotecard" == name) // Out of order, so the others have something to read.
174 osMakeNotecard("OhSillyThreatCard", [""]);
175 else if ("osGetNotecard" == name)
176 osGetNotecard("OhSillyThreatCard");
177 else if ("osGetInventoryDesc" == name)
178 osGetInventoryDesc("inventory");
179 else if ("osGetNotecardLine" == name)
180 osGetNotecardLine("OhSillyThreatCard", 0);
181 else if ("osGetNumberOfNotecardLines" == name)
182 osGetNumberOfNotecardLines("OhSillyThreatCard");
183 else if ("osGetRegionSize" == name)
184 osGetRegionSize();
185 else if ("osGetRezzingObject" == name)
186 osGetRezzingObject();
187 else if ("osIsNpc" == name)
188 osIsNpc(BogusKey);
189 else if ("osKey2Name" == name)
190 osKey2Name(BogusKey);
191 else if ("osMessageObject" == name)
192 osMessageObject(llGetKey(), "G'day.");
193 else if ("osNpcSit" == name)
194 osNpcSit(BogusKey, llGetKey(), 0);
195 else if ("osSetSpeed" == name)
196 osSetSpeed(BogusKey, 1.0);
197 else if ("osTeleportAgent" == name)
198 osTeleportAgent(BogusKey, ZERO_VECTOR, ZERO_VECTOR);
199
200 // If we got here, then the timer() handler didn't crash, which means the function it checked for
201 // was actually permitted. So we update the list to indicate that we can use that particular function.
202// llOwnerSay("Working " + name + "()");
203 if (-1 == llList2Integer(FunctionPermitted, WhichProbeFunction))
204 FunctionPermitted = llListReplaceList(FunctionPermitted, [1], WhichProbeFunction, WhichProbeFunction);
205 }
59} 206}