Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Released under the GNU General Public License version 3 by J2897.
- set -e
- #################### README #################### > BEGIN
- # Filename: deploy-vnc.sh
- # Version: 1.4
- # SSH-PF: https://db.tt/82fJYgdS
- # Latest: https://pastebin.com/2WjW7jbc
- # Contact: https://pastebin.com/message_compose?to=J2897
- #
- # Before executing this, ensure the line endings (EOL) are in Unix format,
- # otherwise "set" is shown as an "invalid option" and the script will fail. To
- # convert the EOL to Unix format in Notepad++, simply select Edit from the File Menu.
- #
- # This script is meant to be run remotely after deploying Cygwin and OpenSSH.
- # After change the port, and/or both passwords, just upload it to the server
- # and then execute it from your SSH client, e.g. PuTTY.
- #
- # Instead of opening a port in the firewall, you should use SSH Port Forwarding
- # to connect locally. If you enable SERVER_ADD_FIREWALL_EXCEPTION, the port won't
- # be open until you launch the TightVNC program on the server, even though the
- # service is already up and running perfectly fine. I have included code below
- # which will open the port. But you should only connect directly via the LAN when
- # testing. After testing, remove the entire firewall section of this code and add
- # the SET_LOOPBACKONLY option to the install options section. You can then
- # connect to the port securely by bypassing the firewall completely using SSH Port
- # Forwarding.
- #
- # To silently install the DFMirage Driver...
- # wget http://www.demoforge.com/tightvnc/dfmirage-setup-2.0.301.exe
- # chmod u+x "dfmirage-setup-2.0.301.exe"
- # cygstart "dfmirage-setup-2.0.301.exe" /verysilent
- #
- # A good VNC Client for Android which supports SSH tunneling...
- # https://play.google.com/store/apps/details?id=com.iiordanov.freebVNC
- #################### README #################### > END
- PORT="5900"
- #--------------------------------------------------
- # Is wget installed?
- if !(cygcheck -cd wget | grep -q wget)
- then
- echo Please install the \'wget\' package for Cygwin.
- exit 1
- fi
- #--------------------------------------------------
- # Detect the Windows OS architecture.
- PF86=$(cygpath "$SYSTEMDRIVE\Program Files (x86)")
- if [ -d "$PF86" ]
- then
- ARCHITECTURE="64bit"
- else
- ARCHITECTURE="32bit"
- fi
- #--------------------------------------------------
- # Get the Site Version Numbers.
- SITE_VER_NUM="$(wget -q http://tightvnc.com/download.php -O - | grep -o '<h3>Download TightVNC for Windows.*</h3>' | awk '{print $2}' FS='(' | awk '{print $1}' FS=')' | awk '{print $2}')"
- #--------------------------------------------------
- # Select the appropriate Setup File.
- SETUP_FILE="tightvnc-$SITE_VER_NUM-gpl-setup-$ARCHITECTURE.msi"
- #--------------------------------------------------
- # Download the Setup File.
- echo Downloading...
- wget --output-document="$TMP/$SETUP_FILE" "http://www.tightvnc.com/download/$SITE_VER_NUM/$SETUP_FILE"
- #--------------------------------------------------
- # Set the TightVNC install options.
- OPTIONS="/quiet /norestart \
- ADDLOCAL=\"Server\" \
- SERVER_REGISTER_AS_SERVICE=1 \
- SET_RFBPORT=1 \
- VALUE_OF_RFBPORT=$PORT \
- SET_USEVNCAUTHENTICATION=1 \
- VALUE_OF_USEVNCAUTHENTICATION=1 \
- SET_PASSWORD=1 \
- VALUE_OF_PASSWORD=c0nn3cT \
- SET_USECONTROLAUTHENTICATION=1 \
- VALUE_OF_USECONTROLAUTHENTICATION=1 \
- SET_CONTROLPASSWORD=1 \
- VALUE_OF_CONTROLPASSWORD=C0nTr0l"
- # SET_ALLOWLOOPBACK=1
- # VALUE_OF_ALLOWLOOPBACK=1
- # SET_LOOPBACKONLY=1
- # VALUE_OF_LOOPBACKONLY=1
- #--------------------------------------------------
- # Install TightVNC.
- echo Deploying TightVNC...
- WIN_PATH_SF=$(cygpath --windows "$TMP/$SETUP_FILE")
- cygstart --wait msiexec.exe /i \"$WIN_PATH_SF\" $OPTIONS
- #--------------------------------------------------
- # Detect the Windows NT version.
- if (uname | grep -q "CYGWIN_NT-6.")
- then
- OS_VERSION="Windows 7"
- elif (uname | grep -q "CYGWIN_NT-5.")
- then
- OS_VERSION="Windows XP"
- fi
- #--------------------------------------------------
- # Punch a hole through Windows Firewall.
- # *** Don't use SERVER_ADD_FIREWALL_EXCEPTION because the port won't be open. ***
- # *** Close this port when you use SET_LOOPBACKONLY with SSH Port Forwarding. ***
- echo "Openning TCP port $PORT in Windows Firewall..."
- if [ "$OS_VERSION" = "Windows XP" ]
- then
- netsh firewall add portopening protocol=TCP port=$PORT name=TightVNC
- elif [ "$OS_VERSION" = "Windows 7" ]
- then
- netsh advfirewall firewall add rule name=TightVNC dir=in action=allow protocol=tcp localport=$PORT
- fi
- #--------------------------------------------------
- # Move the 'All Users' Start Menu entry to the 'User' Start Menu.
- ALLUSERS_7=$(cygpath "$ALLUSERSPROFILE\Microsoft\Windows\Start Menu\Programs\TightVNC")
- USER_7=$(cygpath "$APPDATA\Microsoft\Windows\Start Menu\Programs\TightVNC")
- ALLUSERS_XP=$(cygpath "$ALLUSERSPROFILE\Start Menu\Programs\TightVNC")
- USER_XP=$(cygpath "$USERPROFILE\Start Menu\Programs\TightVNC")
- if [ "$OS_VERSION" = "Windows 7" ]
- then
- mv -f "$ALLUSERS_7" "$USER_7"
- elif [ "$OS_VERSION" = "Windows XP" ]
- then
- mv -f "$ALLUSERS_XP" "$USER_XP"
- fi
- #--------------------------------------------------
- # Delete the Setup File.
- rm -f "$TMP/$SETUP_FILE"
- #--------------------------------------------------
- # End.
- echo Finished!
- exit 0
- #--------------------------------------------------
- # All available options...
- # http://www.tightvnc.com/doc/win/TightVNC_2.7_for_Windows_Installing_from_MSI_Packages.pdf
- # Install options:
- VIEWER_ASSOCIATE_VNC_EXTENSION
- SERVER_REGISTER_AS_SERVICE
- SERVER_ADD_FIREWALL_EXCEPTION
- VIEWER_ADD_FIREWALL_EXCEPTION
- SERVER_ALLOW_SAS
- # Server options:
- SET_ACCEPTHTTPCONNECTIONS
- VALUE_OF_ACCEPTHTTPCONNECTIONS
- SET_ACCEPTRFBCONNECTIONS
- VALUE_OF_ACCEPTRFBCONNECTIONS
- SET_ALLOWLOOPBACK
- VALUE_OF_ALLOWLOOPBACK
- SET_ALWAYSSHARED
- VALUE_OF_ALWAYSSHARED
- SET_BLOCKLOCALINPUT
- VALUE_OF_BLOCKLOCALINPUT
- SET_BLOCKREMOTEINPUT
- VALUE_OF_BLOCKREMOTEINPUT
- SET_DISCONNECTACTION
- VALUE_OF_DISCONNECTACTION
- SET_DISCONNECTCLIENTS
- VALUE_OF_DISCONNECTCLIENTS
- SET_EXTRAPORTS
- VALUE_OF_EXTRAPORTS
- SET_GRABTRANSPARENTWINDOWS
- VALUE_OF_GRABTRANSPARENTWINDOWS
- SET_HTTPPORT
- VALUE_OF_HTTPPORT
- SET_IPACCESSCONTROL
- VALUE_OF_IPACCESSCONTROL
- SET_LOCALINPUTPRIORITY
- VALUE_OF_LOCALINPUTPRIORITY
- SET_LOCALINPUTPRIORITYTIMEOUT
- VALUE_OF_LOCALINPUTPRIORITYTIMEOUT
- SET_LOGLEVEL
- VALUE_OF_LOGLEVEL
- SET_LOOPBACKONLY
- VALUE_OF_LOOPBACKONLY
- SET_NEVERSHARED
- VALUE_OF_NEVERSHARED
- SET_POLLINGINTERVAL
- VALUE_OF_POLLINGINTERVAL
- SET_QUERYACCEPTONTIMEOUT
- VALUE_OF_QUERYACCEPTONTIMEOUT
- SET_QUERYTIMEOUT
- VALUE_OF_QUERYTIMEOUT
- SET_REMOVEWALLPAPER
- VALUE_OF_REMOVEWALLPAPER
- SET_REPEATCONTROLAUTHENTICATION
- VALUE_OF_REPEATCONTROLAUTHENTICATION
- SET_RFBPORT
- VALUE_OF_RFBPORT
- SET_RUNCONTROLINTERFACE
- VALUE_OF_RUNCONTROLINTERFACE
- SET_SAVELOGTOALLUSERSPATH
- VALUE_OF_SAVELOGTOALLUSERSPATH
- SET_USEMIRRORDRIVER
- VALUE_OF_USEMIRRORDRIVER
- # Password options:
- SET_USECONTROLAUTHENTICATION
- VALUE_OF_USECONTROLAUTHENTICATION
- SET_USEVNCAUTHENTICATION
- VALUE_OF_USEVNCAUTHENTICATION
- SET_CONTROLPASSWORD
- VALUE_OF_CONTROLPASSWORD
- SET_PASSWORD
- VALUE_OF_PASSWORD
- SET_VIEWONLYPASSWORD
- VALUE_OF_VIEWONLYPASSWORD
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement