Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

JDsVNC (SC over SSH tunnel)

SC <-> Proxy <-> Repeater <-> Proxy <-> Viewer
Post Reply
User avatar
JDaus
Friend of UVNC
Friend of UVNC
Posts: 537
Joined: 2007-03-17 11:00
Location: Sydney, Australia
Contact:

JDsVNC (SC over SSH tunnel)

Post by JDaus »

Hi all ...

I created a small AutoIT script/program that creates a SSH tunnel to my server.

I created the first few versions, then a friend (budg) joined in, and neatened up everything, and added many MANY more features.

Current program:
  • Creates a menu to select the viewer to create the SSH tunnel to. (dropdown list)
    IF none selection is chosen, IP and port can be entered manually.
    SSH is done using porta plink/putty (not portable putty - untested).
    plink window is started hidden. (autoit magic)
    VNC is not started till SSH tunnel established (port checking done)
    Automatically reconnects if connection dropped (can only cancel for 30 seconds after connection established)
to-do/wish list:
  • ping & Port checking on target machine, removing dead connections from the list.
    possible re-write in C++ to enable multiple platform use (to run on linux / MAC)
    Windows Vista support

Code: Select all

; ***************************************************************************
; *   JDs VNC GUI V1.0                                                      *
; *   Copyright (C) 2007 by Budgie & JD                                     *
; *   budgie05@gmail.com                                                    *
; *                                                                         *
; *   This program is free software; you can redistribute it and/or modify  *
; *   it under the terms of the GNU General Public License as published by  *
; *   the Free Software Foundation; either version 2 of the License, or     *
; *   (at your option) any later version.                                   *
; *                                                                         *
; *   This program is distributed in the hope that it will be useful,       *
; *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
; *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
; *   GNU General Public License for more details.                          * 
; *                                                                         *
; *   You should have received a copy of the GNU General Public License     *
; *   along with this program; if not, write to the                         *
; *   Free Software Foundation, Inc.,                                       *
; *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
;****************************************************************************

#include <GuiConstants.au3>
;Setup the EXE names and tunnel command lines globally for simplicity
Global $VNC = "jdswinvnc.exe"
Global $Plink = "jdsplink.exe"
Global $budg = $Plink & " -pw XXXXXXXX -batch -C -L 25501:127.0.0.1:5500 testuser@budg.nowhere -P 22"
Global $jd = $Plink & " -pw XXXXXX -batch -C -L 25501:127.0.0.1:5501 testuser@jd.nowhere -P 22"

Func JDsVNCGUI()

$looplock = 1

 GuiCreate("JDsVNC", 200, 150)

 GUISetIcon ("icon1.ico")
 
  $tcpipitem = GuiCtrlCreateInput( "127.0.0.1", 60, 10, 120, 20, $ES_READONLY )
  $portitem = GuiCtrlCreateInput("25501", 60, 30, 120, 20, $ES_READONLY )

  $comboitem = GuiCtrlCreatecombo("JD", 10, 80, 180, 90)
  $comboitem1 = GUICtrlSetData(-1,"Budg|None","")

  GuiCtrlCreateLabel("Select SSH Tunnel to Connect to:", 10, 55, 180, 20)
  GuiCtrlCreateLabel("TCP/IP", 10, 10, 40, 20)
  GuiCtrlCreateLabel("PORT", 10, 30, 40, 20)

  $subitem = GuiCtrlCreateButton("Connect", 10, 110, 80, 20)
  $canitem = GuiCtrlCreateButton("Cancel", 100, 110, 80, 20)

 GUISetState ()

 $msg = 0
 While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
  
  If GUICtrlRead($comboitem) = "jd" or GUICtrlRead($comboitem) = "budg" and $looplock = 0 Then
   GUICtrlDelete($tcpipitem)
   GUICtrlDelete($portitem)
   $tcpipitem = GuiCtrlCreateInput( "127.0.0.1", 60, 10, 120, 20, $ES_READONLY )
   $portitem = GuiCtrlCreateInput("25501", 60, 30, 120, 20, $ES_READONLY )
   GUISetState ()
   $looplock = 1
  EndIf
 
  If GUICtrlRead($comboitem) = "none" and $looplock = 1 Then
   GUICtrlDelete($tcpipitem)
   GUICtrlDelete($portitem)
   $tcpipitem = GuiCtrlCreateInput( "127.0.0.1", 60, 10, 120, 20)
   $portitem = GuiCtrlCreateInput("25501", 60, 30, 120, 20)
   GUISetState ()
   $looplock = 0
  EndIf
  
        Select
            Case $msg = $subitem
                exitloop
   EndSelect
   
  If $msg = $canitem Or $msg = -3 Or $msg = -1 Then Exit
 Wend

 Global $JDsVNCTunnel = GUICtrlRead($comboitem)
 Global $JDsVNCIP = GUICtrlRead($tcpipitem)
 Global $JDsVNCPort = GUICtrlRead($portitem)

 ProcessWaitClose($subitem)
 
 GUIDelete()

EndFunc

;=========================================================================================================================================================
 
Func JDsVNCReconnect()
 
 $loop = 1

 While $loop = 1
   $Exit = JDsVNCSSH()
  If $Exit = 2 Then
   $loop = 0
  EndIf
   If $loop = 0 Then
    MsgBox(64, "Finished:", $JDsVNCTunnel & " has finished." & @CRLF & @CRLF & "Your desktop is no longer remotely visible")
   EndIf
 WEnd

EndFunc

;=========================================================================================================================================================

Func JDsVNCSSH()

 CloseFunc($VNC)
 
 If $JDsVNCTunnel = "jd" or $JDsVNCTunnel = "budg" Then
   
  $port = CheckPort()
   
  if $port = -1 then
    
  CloseFunc($Plink)
 
   if $JDsVNCTunnel = "jd" Then
    RunDOSHide($jd)
;    Run($jd)
   elseif $JDsVNCTunnel = "budg" Then
    RunDOSHide($budg)
;    Run($budg)
   EndIf
  EndIf
 EndIf

 Sleep (5000)

 $port = CheckPort()

 if $port = -1 then
  MsgBox(64, "Error:","Could not connect to VNC Server or SSH Tunnel at " & $JDsVNCIP & ":"  & $JDsVNCPort & "")
  CloseFunc($VNC)
  CloseFunc($Plink)
  Return 2
 EndIf

 RunDOSHide ("jdswinvnc.exe -connect" & $JDsVNCIP & ":"  & $JDsVNCPort & " -noregistry")

 $JDsVNCStop = MsgBox(65,"JDsVNC Remote access", "You are now Connected to " & $JDsVNCTunnel &"'s Computer," & @CRLF & @CRLF & "Press Cancel now to exit", 30)

 If $JDsVNCStop = 2 Then
  WinClose ("jdsWinVNC")
  CloseFunc($Plink)
 EndIf
  
 ProcessWaitClose($VNC)

 Return $JDsVNCStop

EndFunc

;=========================================================================================================================================================

Func RunDOSHide($sCommand)
 
 Return Run(@ComSpec & " /C " & $sCommand, "", @SW_HIDE)
 
EndFunc

;=========================================================================================================================================================

Func CloseFunc($prog)
 
 $PID = ProcessExists($prog)
 If $PID Then ProcessClose($PID)

EndFunc

;=========================================================================================================================================================

Func CheckPort()
 
 TCPStartUp()
 $socket = TCPConnect( $JDsVNCIP, $JDsVNCPort )
 Return $socket
 TCPShutdown ()

EndFunc

;=========================================================================================================================================================

JDsVNCGUI()
JDsVNCReconnect()

Exit
Links
Porta Puttyhttp://socialistsushi.com/portaputty

Files
.putty/sshhostkeys - MUST hold the host key for all machines it is to connect to.
icon1.ico -
icon2.ico -
jdsplink.exe - porta plink (from above URL)
jdswinvnc.exe - UVNC SCII / SCIII
JDsVNC.exe - the compiled script (from above code).

Latest version can always be found at my SVN (http://svn.aus.st)

I will try to provide a tutorial on setting up the program in the near future, with links to setting up OpenSSH on windows.

One thing that you need to do, is make sure plink can connect to the host machine using the command lines at top of script - THIS IS ESSENTUAL

PS. POSITIVE feedback is always welcomed, or suggestions for fututre editions ....

JD
Last edited by JDaus on 2008-09-07 09:51, edited 2 times in total.
ask a silly question and remain a fool for 5 minutes...
don't ask, and remain a fool for life - JDaus 2003

without imperfections, neither you nor i would exist - Steven Hawkins
__
JD
SCPrompt - OpenSource Free Remote Screen\Desktop Sharing Solution
SecureTech.com.au
User avatar
JDaus
Friend of UVNC
Friend of UVNC
Posts: 537
Joined: 2007-03-17 11:00
Location: Sydney, Australia
Contact:

Re: JDsVNC (SC over SSH tunnel)

Post by JDaus »

This script has been outdated by vnc2me ... http://vnc2me.org[/i]
ask a silly question and remain a fool for 5 minutes...
don't ask, and remain a fool for life - JDaus 2003

without imperfections, neither you nor i would exist - Steven Hawkins
__
JD
SCPrompt - OpenSource Free Remote Screen\Desktop Sharing Solution
SecureTech.com.au
Post Reply