License Public Domain
Lines 40
Keywords
ARD (1) OS X (1) VNC (1)
Permissions
Owner: Stou S.
Viewable by Everyone
Editable by All Siafoo Users
Hide
Stay up to dateembedded code automagically updates, each snippet and article has a feed Join Siafoo Now or Learn More

Encode a password for VNC access to OS X Atom Feed 0

In Brief Usage:... more
# 's
 1#!/usr/bin/perl
2#
3# vncpasswd.pl
4#
5# Encode a password to enable access using with Apple Remote
6# Desktop's VNC service.
7#
8# License: I'm placing this script into the Public Domain. Use as
9# you wish, however you wish. You can even claim it to be your
10# own if you need.
11#
12# Usage: perl vncpasswd.pl [password]
13#
14
15# ----------------------------------------------------------------------------------
16# [Macoy] original script taken from:
17# [Macoy]http://www.macgeekery.com/user/unixgeek
18# [Macoy] this script revised by macoy [http://macoy.wordpress.com]
19# [Macoy] for easier usage & execution, follow these steps :
20# [Macoy]$ perl vncpass_macoy.pl [vnc_password] > startvnc.sh
21# [Macoy]$ sh startvnc.sh
22#----------------------------------------------------------------------------------
23
24# set plain text password to the first argument on the command
25# line. Note: VNC on Mac OS X only uses the first 8 characters.
26
27$plainTextPassword = $ARGV[0] ||
28 die "You must specify the password on the command line!";
29$plainTextPassword =~ s/^(.{8}).*/$1/;
30
31# convert the password to an array
32@passwordArray = unpack "C*", $plainTextPassword;
33
34# XOR key
35@vncXorKey = unpack "C*", pack "H*", "1734516E8BA8C5E2FF1C39567390ADCA";
36
37# print the kickstart command...
38# [Macoy] commented line is the original command from unixgeek but it
39# [Macoy] didn't work w/ my current xserve. thus the script modification.
40# print "sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -clientopts -setvnclegacy-vnclegacy yes -setvncpw -vncpw ";
41
42# [Macoy] this is the actual working command in my case:
43print "sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -activate -access -on -clientopts-setvnclegacy -vnclegacy yes -setvncpw -restart -agent -vncpw ";
44
45# print the password
46foreach $byteValue (@vncXorKey) {
47 printf("%02X",$byteValue ^ (shift @ passwordArray || 0));
48}

Usage:

$ perl vncpass_macoy.pl [vnc_password] > startvnc.sh
$ sh startvnc.sh