02-18-2013, 03:44 AM
It will create a system where anyone chatting within range of it and will relay it to a connected box and show you whats being said. It encrypts the communication between the relays so no one else can just pick up on it and get what you are getting.
PHP Code:
//•/•/•/•/•/•/•/Ð/A/M/E/N/•/H/A/X/•/•/•/•/•/•/•/•/•//
// Do not sell this; Karma knowz where you live ☠
// Original found here: http://wiki.secondlife.com/wiki/User:Kireji_Haiku/SIMchat_headset
// Converted to use inscript config(removed need for notecard), removed extra states
// added link_message, changed to owner only usage/HUD/attachment
//
integer secret_channel = 10;
//
key owner;
string name;
string header;
string protocol_signature = "SPY";
string password = "P@ssw0rD";
string strHex = "0123456789ABCDEF";
float protocol_version = 0.3;
vector on_color = <0.468,1.000,0.683>;
vector off_color = <1.000,0.468,0.468>;
integer secret_listen;
integer active = 0;
init(){
owner = llGetOwner();
list versions = llParseString2List((string)protocol_version, ["."], []);
string minor = llList2String(versions, 1);
integer p = 0;
while(llGetSubString(minor, --p, p) == "0");
header = protocol_signature + hex(llList2Integer(versions, 0)) + hex((integer)llGetSubString(minor, 0xFF000000, p));
}
on(){
llListenRemove(secret_listen);
secret_listen = llListen(secret_channel, "", "", "");
llSetColor(on_color, ALL_SIDES);
llOwnerSay("/me ("+(string)secret_channel+") : ON :");
}
off(){
llListenRemove(secret_listen);
llSetColor(off_color, ALL_SIDES);
llOwnerSay("/me ("+(string)secret_channel+") : OFF :");
}
string hex(integer value){
integer digit = value & 0xF;
string text = llGetSubString(strHex, digit, digit);
value = (value >> 4) & 0xfffFFFF;
integer odd = TRUE;
while(value){
digit = value & 0xF;
text = llGetSubString(strHex, digit, digit) + text;
odd = !odd;
value = value >> 4;
}
if(odd)
text = "0" + text;
return text;
}
string encrypt(string password, string message){
integer nonce = (integer)llFrand(0x7FFFFFFF);
message = llMD5String(message, nonce) + message;
string oneTimePad = llMD5String(password, nonce);
integer count = (llStringLength(message) - 1) / 32;
if(count) do oneTimePad += llMD5String(oneTimePad, nonce);
while(--count);
return header + llGetSubString("00000000" + hex(nonce), -8, -1) + llXorBase64StringsCorrect(llStringToBase64(message), llStringToBase64(oneTimePad));
}
string decrypt(string password, string message){
integer signature_length = llStringLength(protocol_signature);
integer header_length = signature_length + 12;
if(llStringLength(message) < signature_length + 44)
llOwnerSay("/me • Bugger: Insufficient data.");
integer index = signature_length;
string major = "0x" + llGetSubString(message, index, ++index);
string minor = "0x" + llGetSubString(message, ++index, ++index);
integer nonce = (integer)("0x" + llGetSubString(message, ++index, index + 7));
message = llGetSubString(message, header_length, -1);
string otp = llMD5String(password, nonce);
while(llStringLength(otp) < (llStringLength(message) / 2 * 3))
otp += llMD5String(otp, nonce);
otp = llStringToBase64(otp);
message = llXorBase64StringsCorrect(message, otp);
message = llBase64ToString(message);
string digest = llGetSubString(message, 0, 31);
message = llGetSubString(message, 32, -1);
if(llMD5String(message, nonce) != digest)
llOwnerSay("/me • Bugger: Try again?...");
return message;
}
say(string who, string message){
llSetObjectName(who);
llSleep(llGetRegionTimeDilation()+0.04);
llSay(0,message);
llSetObjectName(" ");
}
default{
//
attach(key id){
if(id){//tests if it is a valid key and not NULL_KEY
llOwnerSay("/me • Channel for sim Talk /"+(string)secret_channel);
}else{
llOwnerSay("/me `0'");
}
}
//
state_entry(){
init();
}
//
touch_start(integer d){
active =! active;
if(active){
off();
}else{
on();
}
}
//
changed(integer c){
if(c & CHANGED_OWNER){
llResetScript();
}
}
//
link_message(integer sender, integer code, string str, key id){
if (str == "DCOMM"){//llMessageLinked(LINK_THIS, 0, "DCOMM","ON");
if(id == "ON") on();
else if(id == "OFF") off();
}
}
//
listen(integer channel, string name, key id, string message){
if (channel == secret_channel){
if (id == owner){
llRegionSay(secret_channel, encrypt(password, message));
say(name,message);
}
else if (llGetAgentSize(id) == ZERO_VECTOR){
say(llKey2Name(llGetOwnerKey(id)),decrypt(password, message));
}
}
}
//
}