Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Reverse Screen Sharing Grabber' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Reverse Screen Sharing Grabber
Authored by: aechadwick on Dec 27, '10 09:00:49AM
Here is the most revised version of the Screen Sharing Grabber suite. For this setup, we will call the computers Sender1 (bonjour name sender1.local ) and Catcher (bonjour name catcher.local )

on (any) Catcher save this AppleScript as a compiled script " SceenSharingSwitch.scpt" (save in location /Library/Scripts/ScreenSharingSwitch.scpt, or edit the sender script, below, to call correctly!)

on run argv

set theHostname to item 1 of argv

tell application "Keychain Scripting"

tell keychain 1
unlock
set theKey to first key whose name is theHostname
set {theUsername, thePassword} to {((account of theKey) as string), ((password of theKey) as string)}
end tell

end tell

if application "Screen Sharing" is running then
do shell script "ps ax | grep " & (quoted form of "Screen Sharing") & " | grep -v grep | awk '{print $1}' | xargs kill -9"
else
tell application "Screen Sharing" to open location "vnc://" & theUsername & ":" & thePassword & "@" & theHostname
end if

end run
the argv passes the hostname from the sending computer, as provided by the next script. Thus, it can work from Sender2 , Sender3 , or any computer. (Of course, this assumes physical access to each computer, as well as the administrator ability to set up an RSA key and "always allow" the Keychain.)

on each sender, save this Applescript as "SendScreenTo catcher.app", replacing "catcher" with the localname of the host computer—this revised app will pull the localname from its own applet name—revise as required for any number of catchers.
tell application "Finder" to set catcherName to (last item of my text_to_list(first item of my text_to_list(name of (path to me) as Unicode text, "."), " ") & ".local")
--assumes name of Applet is "SendTo localname.app", will extract/concatenate "localname.local"

set theHostname to do shell script "hostname"

do shell script "ssh " & catcherName & " osascript /Library/Scripts/ScreenSharingSwitch.scpt " & theHostname

on text_to_list(txt, delim)
set saveD to AppleScript's text item delimiters
set AppleScript's text item delimiters to {delim}
set theList to every text item of txt
set AppleScript's text item delimiters to saveD
return (theList)
end text_to_list
Note, these scripts have no error trapping—they assume the existence of the appropriate Keychain, and an RSA key for SSH... basically, the scripts pretty much just assume everything will work.

thanks for reading!
Edited on Dec 27, '10 09:03:00AM by aechadwick


[ Reply to This | # ]